diff --git a/.dockerignore b/.dockerignore index cfbf1659f5..644ad99be7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,4 @@ target !target/release/aleph-node !target/production/aleph-node !bin/cliain/target/release/cliain + diff --git a/.github/actions/run-e2e-test/action.yml b/.github/actions/run-e2e-test/action.yml index 7151a6d29f..f157b1efb3 100644 --- a/.github/actions/run-e2e-test/action.yml +++ b/.github/actions/run-e2e-test/action.yml @@ -31,6 +31,10 @@ inputs: description: 'Whether to deploy the adder sample contract to the node.' required: false default: 'false' + deploy-button: + description: 'Whether to deploy the button game contracts to the node.' + required: false + default: 'false' image-path: description: 'Custom path to docker image for aleph-node' required: false @@ -116,6 +120,14 @@ runs: popd fi + DEPLOY_BUTTON="${{ inputs.deploy-button }}" + + if [[ "${DEPLOY_BUTTON}" = "true" ]]; then + source contracts/env/dev + contracts/scripts/deploy.sh + source contracts/scripts/test_env.sh + fi + ./.github/scripts/run_e2e_test.sh "${ARGS[@]}" - name: Run finalization e2e test diff --git a/.github/scripts/run_e2e_test.sh b/.github/scripts/run_e2e_test.sh index 1e23eb5c76..05538b5e68 100755 --- a/.github/scripts/run_e2e_test.sh +++ b/.github/scripts/run_e2e_test.sh @@ -113,7 +113,22 @@ fi if [[ -n "${ADDER:-}" ]]; then ARGS+=(-e "ADDER=${ADDER}") - ARGS+=(-e "ADDER_METADATA=/contracts/adder/target/ink/metadata.json") + ARGS+=(-e "ADDER_METADATA=/contracts/adder/target/ink/adder.json") +fi + +if [[ -n "${BUTTON_GAME_METADATA:-}" ]]; then + ARGS+=(-e "THE_PRESSIAH_COMETH=${THE_PRESSIAH_COMETH}") + ARGS+=(-e "EARLY_BIRD_SPECIAL=${EARLY_BIRD_SPECIAL}") + ARGS+=(-e "BACK_TO_THE_FUTURE=${BACK_TO_THE_FUTURE}") + ARGS+=(-e "SIMPLE_DEX=${SIMPLE_DEX}") + ARGS+=(-e "WRAPPED_AZERO=${WRAPPED_AZERO}") + ARGS+=(-e "RUST_LOG=${RUST_LOG}") + ARGS+=(-e "BUTTON_GAME_METADATA=/contracts/button/target/ink/button.json") + ARGS+=(-e "TICKET_TOKEN_METADATA=/contracts/ticket_token/target/ink/ticket_token.json") + ARGS+=(-e "REWARD_TOKEN_METADATA=/contracts/game_token/target/ink/game_token.json") + ARGS+=(-e "MARKETPLACE_METADATA=/contracts/marketplace/target/ink/marketplace.json") + ARGS+=(-e "SIMPLE_DEX_METADATA=/contracts/simple_dex/target/ink/simple_dex.json") + ARGS+=(-e "WRAPPED_AZERO_METADATA=/contracts/wrapped_azero/target/ink/wrapped_azero.json") fi if [[ -n "${OUT_LATENCY:-}" ]]; then diff --git a/.github/scripts/run_smartnet.sh b/.github/scripts/run_smartnet.sh new file mode 100755 index 0000000000..d838711704 --- /dev/null +++ b/.github/scripts/run_smartnet.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +export NODE_IMAGE=public.ecr.aws/p6e8q1z1/aleph-node:latest + +# key derived from "//0" +export NODE_ID=5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH +export ALICE=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY + +mkdir -p docker/data/ + +# generate chainspec +docker run --rm -v $(pwd)/docker/data:/data --entrypoint "/bin/sh" -e RUST_LOG=debug "${NODE_IMAGE}" -c \ + "aleph-node bootstrap-chain --base-path /data --account-ids $NODE_ID --faucet-account-id $ALICE --sudo-account-id $NODE_ID --chain-id a0smnet --token-symbol SZERO --chain-name 'Aleph Zero Smartnet' > /data/chainspec.smartnet.json" + +# Get bootnode peer id +export BOOTNODE_PEER_ID=$(docker run --rm -v $(pwd)/docker/data:/data --entrypoint "/bin/sh" -e RUST_LOG=info "${NODE_IMAGE}" -c "aleph-node key inspect-node-key --file /data/$NODE_ID/p2p_secret") + +docker network create node-network || true +docker-compose -f docker/smartnet-compose.yml up --remove-orphans +exit $? diff --git a/.github/workflows/check-excluded-packages.yml b/.github/workflows/check-excluded-packages.yml index 079aaa3acc..b2d1081918 100644 --- a/.github/workflows/check-excluded-packages.yml +++ b/.github/workflows/check-excluded-packages.yml @@ -23,6 +23,25 @@ jobs: build: name: Check excluded packages runs-on: self-hosted + strategy: + matrix: + package: [ + flooder, + e2e-tests, + aleph-client, + fork-off, + benches/payout-stakers, + bin/cliain, + contracts/access_control, + contracts/button, + contracts/game_token, + contracts/marketplace, + contracts/simple_dex, + contracts/ticket_token, + contracts/wrapped_azero, + contracts/adder, + scripts/synthetic-network/synthetic-link, + ] env: CARGO_INCREMENTAL: 0 RUSTC_WRAPPER: sccache diff --git a/.github/workflows/contracts-deploy.yml b/.github/workflows/contracts-deploy.yml new file mode 100644 index 0000000000..c7f87e6cb8 --- /dev/null +++ b/.github/workflows/contracts-deploy.yml @@ -0,0 +1,257 @@ +--- +name: contracts-e2e-tests-and-deploy + +on: + workflow_call: + +# DO NOT TOUCH THIS: +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +env: + CACHE_KEY: fe-benjamin-button + CONTRACTS_ENVFILE: fe-benjamin + NODE_VERSION: 16 + S3BUCKET_PATH: contracts/fe-benjamin-button + +jobs: + build_and_deploy_contracts: + name: Deploy contracts on feature environment + if: > + (github.event_name == 'push' && github.ref_name == 'benjamin') || + (github.event_name == 'pull_request' && + github.event.action == 'labeled' && + github.event.label.name == '[AZERO] DEPLOY-CONTRACTS') + runs-on: ubuntu-20.04 + steps: + - name: Checkout repo + uses: actions/checkout@v2.3.4 + + - name: Check if environment is reachable + shell: bash + run: | + source contracts/env/${{ env.CONTRACTS_ENVFILE }} && \ + HOSTPORT=${NODE/wss:\/\//} && nc -zvw5 ${HOSTPORT/:*/} ${HOSTPORT/*:/} + + - name: Get branch name and commit SHA + id: get_branch + uses: ./.github/actions/get-branch + + # Use of 'actions-rs/toolchain@v1' has been removed as it was causing some unknown problems + # Also, there is a ticket to replace it with custom solution anyway + + - name: Setup rust toolchain + run: | + . "$HOME/.cargo/env" + rustup target add wasm32-unknown-unknown + rustup toolchain install nightly-2022-08-12-x86_64-unknown-linux-gnu + rustup component add rust-src --toolchain nightly-2022-08-12-x86_64-unknown-linux-gnu + rustup default nightly-2022-08-12-x86_64-unknown-linux-gnu + + - name: Install jq + shell: bash + run: | + sudo apt-get install -y jq + + - name: Install binaryen + shell: bash + # yamllint disable rule:line-length + run: | + wget https://github.com/WebAssembly/binaryen/releases/download/version_110/binaryen-version_110-x86_64-linux.tar.gz \ + -O /tmp/binaryen-version_110-x86_64-linux.tar.gz + tar -zxvf /tmp/binaryen-version_110-x86_64-linux.tar.gz -C /tmp + sudo chmod +x /tmp/binaryen-version_110/bin/* + sudo cp -rf /tmp/binaryen-version_110/* /usr/ + # yamllint enable rule:line-length + + - name: Install node + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Restore cache + uses: ./.github/actions/restore-cache + with: + target-key: ${{ env.CACHE_KEY }} + cargo-key: ${{ env.CACHE_KEY }} + cache-version: v3 + cargo-targets: | + contracts/access_control/target/ + contracts/button/target/ + contracts/game_token/target/ + contracts/marketplace/target/ + contracts/simple_dex/target/ + contracts/ticket_token/target/ + contracts/wrapped_azero/target/ + + - name: Install cargo additional libs + run: | + . "$HOME/.cargo/env" + cargo install dylint-link cargo-dylint + + - name: Install cargo-contract + uses: baptiste0928/cargo-install@v1 + with: + crate: cargo-contract + version: "2.0.1" + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + env: + AWS_REGION: us-east-1 + with: + aws-access-key-id: ${{ secrets.AWS_DEVNET_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_DEVNET_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Copy addresses.json file from S3 bucket + shell: bash + # yamllint disable rule:line-length + run: | + aws s3 cp s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/addresses.json contracts/addresses.json + # yamllint enable rule:line-length + + - name: Copy metadata.json files from S3 bucket + shell: bash + env: + DOWNLOAD_TMP_DIR: downloaded_metadata + run: | + mkdir -p $DOWNLOAD_TMP_DIR + aws s3 sync --exclude '*' --include '*metadata.json' \ + s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/ ./$DOWNLOAD_TMP_DIR/ + for i in `find $DOWNLOAD_TMP_DIR -name "metadata.json" | awk -F/ '{print $2}'`; do \ + mkdir -p contracts/$i/target/ink; \ + cp $DOWNLOAD_TMP_DIR/$i/metadata.json contracts/$i/target/ink/metadata.json; \ + done + + - name: Run clean.sh script + shell: bash + run: | + . "$HOME/.cargo/env" + source contracts/env/${{ env.CONTRACTS_ENVFILE }} && ./contracts/scripts/clean.sh + + - name: Run deploy.sh script + shell: bash + run: | + . "$HOME/.cargo/env" + source contracts/env/${{ env.CONTRACTS_ENVFILE }} && ./contracts/scripts/deploy.sh + + - name: Copy metadata.json and addresses.json files onto S3 bucket + shell: bash + run: | + aws s3 cp contracts/addresses.json \ + s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/addresses.json + + for i in `find contracts -name "metadata.json" | awk -F/ '{print $2}'`; do \ + aws s3 cp contracts/"$i"/target/ink/metadata.json \ + s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/"$i"/metadata.json; \ + done + + echo -n "${{ steps.get_branch.outputs.sha_short }}" > commit_sha.txt + + aws s3 cp commit_sha.txt \ + s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/commit_sha.txt + + source contracts/env/${{ env.CONTRACTS_ENVFILE }} && echo -n "$NODE" > env_NODE.txt + aws s3 cp env_NODE.txt \ + s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/env_NODE.txt + + - name: Rename metadata and addresses JSON files to artifact upload + shell: bash + run: | + cp contracts/addresses.json addresses.${{ env.CONTRACTS_ENVFILE }}.json + for i in `find contracts -name "metadata.json" | awk -F/ '{print $2}'`; do \ + cp contracts/"$i"/target/ink/metadata.json \ + metadata_"$i".${{ env.CONTRACTS_ENVFILE }}.json; \ + done + + - name: Upload artifact with contract addresses + uses: actions/upload-artifact@v3 + with: + name: contracts-addresses + path: addresses.${{ env.CONTRACTS_ENVFILE }}.json + if-no-files-found: error + retention-days: 90 + + - name: Upload artifact with contract metadata + uses: actions/upload-artifact@v3 + with: + name: contracts-metadata + path: metadata_*.${{ env.CONTRACTS_ENVFILE }}.json + if-no-files-found: error + retention-days: 90 + + - name: Remove deploy label if present + uses: actions-ecosystem/action-remove-labels@v1.3.0 + if: > + github.event_name == 'pull_request' && + contains( github.event.pull_request.labels.*.name, '[AZERO] DEPLOY-CONTRACTS') + with: + labels: '[AZERO] DEPLOY-CONTRACTS' + github_token: ${{ secrets.CI_GH_TOKEN }} + + - name: Add label to mark that contracts have been deployed + if: github.event_name == 'pull_request' + uses: actions-ecosystem/action-add-labels@v1.1.0 + with: + labels: 'DEPLOYED-CONTRACTS' + github_token: ${{ secrets.CI_GH_TOKEN }} + + - name: Cleanup cache + uses: ./.github/actions/post-cache + + - name: GIT | Checkout aleph-apps repo + uses: actions/checkout@master + with: + repository: Cardinal-Cryptography/aleph-apps + token: ${{ secrets.CI_GH_TOKEN }} + path: "aleph-apps" + ref: main + + - name: KUSTOMIZE | Init kustomize + uses: imranismail/setup-kustomize@v1 + with: + kustomize-version: '3.8.6' + + - name: KUBECTL | Setup kubectl + uses: azure/setup-kubectl@v2.0 + with: + version: 'v1.23.6' + + - name: INDEXER | Destroy archive and squid apps + shell: bash + run: | + aws eks --region eu-central-1 update-kubeconfig --name alephzero-devnet-eu-central-1-eks + kubectl delete -n indexer-squid --ignore-not-found=true deploy squid-api + kubectl delete -n indexer-squid --ignore-not-found=true deploy squid-processor + kubectl delete -n indexer-archive --ignore-not-found=true deploy archive-gateway + kubectl delete -n indexer-archive --ignore-not-found=true deploy archive-ingest + + - name: INDEXER | Create archive db and archive apps + shell: bash + run: | + kubectl rollout restart statefulset archive-db -n indexer-archive + kubectl rollout status --watch --timeout=600s -n indexer-archive statefulset/archive-db + cd aleph-apps/indexer/archive/overlays/devnet/eu-central-1 + kustomize build . | kubectl apply -f - + sleep 3 + kubectl rollout status --watch --timeout=600s -n indexer-archive deploy/archive-ingest + kubectl rollout status --watch --timeout=600s -n indexer-archive deploy/archive-gateway + + - name: INDEXER | Create squid db and squid apps + shell: bash + run: | + kubectl rollout restart statefulset squid-db -n indexer-squid + kubectl rollout status --watch --timeout=600s -n indexer-squid statefulset/squid-db + cd aleph-apps/indexer/squid/overlays/devnet/eu-central-1 + kustomize build . | kubectl apply -f - + sleep 3 + kubectl rollout status --watch --timeout=600s -n indexer-squid deploy/squid-processor + kubectl rollout status --watch --timeout=600s -n indexer-squid deploy/squid-api + + - name: BUTTON | Restart the-button deployment + shell: bash + run: | + kubectl rollout restart deployment the-button -n the-button + kubectl rollout status --watch --timeout=600s -n the-button deploy/the-button diff --git a/.github/workflows/e2e-tests-main-devnet.yml b/.github/workflows/e2e-tests-main-devnet.yml index 144201d766..da4597729d 100644 --- a/.github/workflows/e2e-tests-main-devnet.yml +++ b/.github/workflows/e2e-tests-main-devnet.yml @@ -4,10 +4,12 @@ name: e2e-tests-main-devnet on: pull_request: branches: + - benjamin - main - 'release-*' push: branches: + - benjamin - main - 'release-*' workflow_dispatch: @@ -532,13 +534,6 @@ jobs: - name: Checkout source code uses: actions/checkout@v3 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - - - name: Install rust-src - working-directory: ./contracts - run: rustup component add rust-src - - name: Run e2e test uses: ./.github/actions/run-e2e-test with: @@ -546,6 +541,21 @@ jobs: test-case: adder timeout-minutes: 10 + run-e2e-button-contract-tests: + needs: [build-test-docker, build-test-client] + name: Run e2e button game contract tests + runs-on: self-hosted + steps: + - name: Checkout source code + uses: actions/checkout@v2 + + - name: Run e2e test + uses: ./.github/actions/run-e2e-test + with: + deploy-button: true + test-case: button + timeout-minutes: 60 + run-e2e-finality-version-change: needs: [build-test-docker, build-test-client] name: Run finality version change test @@ -561,7 +571,16 @@ jobs: follow-up-finalization-check: true timeout-minutes: 10 + # TODO: new dev env needed + # deploy-button: + # name: Deploy button contracts + # needs: run-e2e-button-contract-tests + # uses: ./.github/workflows/contracts-deploy.yml + # secrets: inherit + check-e2e-test-suite-completion: +# run-e2e-failing-version-upgrade, +# run-e2e-version-upgrade-catchup, needs: [ run-e2e-finalization-test, run-e2e-rewards-disable-node-test, @@ -587,8 +606,7 @@ jobs: run-e2e-version-upgrade, run-e2e-permissionless-ban, run-e2e-adder-contract-test, -# run-e2e-failing-version-upgrade, -# run-e2e-version-upgrade-catchup, + run-e2e-button-contract-tests, run-e2e-finality-version-change, ] name: Check e2e test suite completion @@ -597,7 +615,6 @@ jobs: - name: All e2e tests completed run: echo "All e2e tests completed." - push-image: needs: [check-e2e-test-suite-completion] name: Push node image to the ECR @@ -823,4 +840,3 @@ jobs: notify-on: "failure" env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - diff --git a/.gitignore b/.gitignore index dc9463fb6d..0faf9620f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # IDEs -/.idea +**/.idea /.vscode .projectile *.swp @@ -15,7 +15,7 @@ *.out # docker -docker/data/ +**/docker/data/ db/ keystore/ chainspec.json @@ -24,3 +24,6 @@ p2p_secret # Python __pycache__/ *.py[cod] + +# ink! +contracts/addresses.json diff --git a/Cargo.toml b/Cargo.toml index 1b43bc2772..356dfb293a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,8 +19,16 @@ exclude = [ "aleph-client", "benches/payout-stakers", "bin/cliain", + "contracts/access_control", "contracts/adder", + "contracts/adder", + "contracts/button", + "contracts/game_token", + "contracts/marketplace", "contracts/poseidon_host_bench", + "contracts/simple_dex", + "contracts/ticket_token", + "contracts/wrapped_azero", "e2e-tests", "flooder", "fork-off", diff --git a/aleph-client/Cargo.lock b/aleph-client/Cargo.lock index 9294833212..955778334c 100644 --- a/aleph-client/Cargo.lock +++ b/aleph-client/Cargo.lock @@ -18,7 +18,16 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" dependencies = [ - "gimli", + "gimli 0.26.2", +] + +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli 0.27.2", ] [[package]] @@ -391,19 +400,18 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "async-lock" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" +checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" dependencies = [ "event-listener", - "futures-lite", ] [[package]] name = "async-trait" -version = "0.1.59" +version = "0.1.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" +checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" dependencies = [ "proc-macro2", "quote", @@ -418,16 +426,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" dependencies = [ - "addr2line", + "addr2line 0.19.0", "cc", "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.30.3", "rustc-demangle", ] @@ -449,11 +457,17 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + [[package]] name = "base64ct" -version = "1.5.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "beef" @@ -504,9 +518,9 @@ dependencies = [ [[package]] name = "blake2" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b12e5fd123190ce1c2e559308a94c9bacad77907d4c6005d9e58fe1a0689e55e" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ "digest 0.10.6", ] @@ -534,9 +548,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array 0.14.6", ] @@ -561,9 +575,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.11.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "byte-slice-cast" @@ -585,15 +599,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cc" -version = "1.0.77" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cfg-expr" @@ -612,9 +626,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "num-integer", @@ -646,7 +660,7 @@ checksum = "38765f12af802e382a9d8075dac1c3d28f9fbd7b5ee2776740ee8c9a8dd4f8c9" dependencies = [ "anyhow", "impl-serde", - "semver 1.0.16", + "semver 1.0.17", "serde", "serde_json", "url", @@ -660,7 +674,7 @@ checksum = "73db6f39c07b43a0fb49410a2a4d8dbf6eaf1d8a646cb7430003e56e5b3522ed" dependencies = [ "anyhow", "base58", - "blake2 0.10.5", + "blake2 0.10.6", "contract-metadata", "escape8259", "hex", @@ -807,9 +821,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.83" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf" +checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72" dependencies = [ "cc", "cxxbridge-flags", @@ -819,9 +833,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.83" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39" +checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613" dependencies = [ "cc", "codespan-reporting", @@ -834,15 +848,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.83" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12" +checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97" [[package]] name = "cxxbridge-macro" -version = "1.0.83" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6" +checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" dependencies = [ "proc-macro2", "quote", @@ -851,9 +865,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.14.2" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ "darling_core", "darling_macro", @@ -861,9 +875,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.2" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", @@ -875,9 +889,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.14.2" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core", "quote", @@ -951,7 +965,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "crypto-common", "subtle", ] @@ -985,9 +999,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecdsa" @@ -1038,9 +1052,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" @@ -1115,15 +1129,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" -[[package]] -name = "fastrand" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", -] - [[package]] name = "ff" version = "0.12.1" @@ -1293,9 +1298,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.25" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" dependencies = [ "futures-channel", "futures-core", @@ -1308,9 +1313,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" dependencies = [ "futures-core", "futures-sink", @@ -1318,15 +1323,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" [[package]] name = "futures-executor" -version = "0.3.25" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" dependencies = [ "futures-core", "futures-task", @@ -1336,30 +1341,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" - -[[package]] -name = "futures-lite" -version = "1.12.0" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] +checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" dependencies = [ "proc-macro2", "quote", @@ -1368,15 +1358,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" [[package]] name = "futures-timer" @@ -1386,9 +1376,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" dependencies = [ "futures-channel", "futures-core", @@ -1457,6 +1447,12 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" + [[package]] name = "group" version = "0.12.1" @@ -1470,9 +1466,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" dependencies = [ "bytes", "fnv", @@ -1528,15 +1524,15 @@ checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.1.19" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" dependencies = [ "libc", ] @@ -1589,9 +1585,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", @@ -1623,9 +1619,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.23" +version = "0.14.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" dependencies = [ "bytes", "futures-channel", @@ -1762,7 +1758,7 @@ version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daed9b710cba6f50f1fa0372a7e8a47a35624d84af4ef2c3a8d34d4e96202d1c" dependencies = [ - "blake2 0.10.5", + "blake2 0.10.6", "derive_more", "ink_primitives", "parity-scale-codec", @@ -1778,7 +1774,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41c6a3f4e740e27449f805ed47f536a35fb254ebcd03d2480014589331cda3e" dependencies = [ "arrayref", - "blake2 0.10.5", + "blake2 0.10.6", "cfg-if", "derive_more", "ink_allocator", @@ -1848,15 +1844,6 @@ dependencies = [ "syn", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "integer-sqrt" version = "0.1.5" @@ -1883,9 +1870,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "joinery" @@ -1895,9 +1882,9 @@ checksum = "72167d68f5fce3b8655487b8038691a3c9984ee769590f93f2a631f4ad64e4f5" [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" dependencies = [ "wasm-bindgen", ] @@ -2020,9 +2007,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.138" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "libm" @@ -2037,7 +2024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" dependencies = [ "arrayref", - "base64", + "base64 0.13.1", "digest 0.9.0", "hmac-drbg", "libsecp256k1-core", @@ -2080,9 +2067,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" dependencies = [ "cc", ] @@ -2220,23 +2207,23 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.5.4" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -2310,9 +2297,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" dependencies = [ "num-traits", ] @@ -2361,9 +2348,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ "hermit-abi", "libc", @@ -2381,11 +2368,20 @@ dependencies = [ "memchr", ] +[[package]] +name = "object" +version = "0.30.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" -version = "1.16.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "opaque-debug" @@ -2507,12 +2503,6 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" -[[package]] -name = "parking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" - [[package]] name = "parking_lot" version = "0.12.1" @@ -2525,22 +2515,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.5" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "paste" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "pbkdf2" @@ -2577,9 +2567,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.5.1" +version = "2.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc8bed3549e0f9b0a2a78bf7c0018237a2cdf085eecbbc048e52612438e4e9d0" +checksum = "8cbd939b234e95d72bc393d51788aec68aeeb5d51e748ca08ff3aad58cb722f7" dependencies = [ "thiserror", "ucd-trie", @@ -2663,13 +2653,12 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.2.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "thiserror", - "toml", + "toml_edit", ] [[package]] @@ -2698,9 +2687,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" dependencies = [ "unicode-ident", ] @@ -2716,9 +2705,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.21" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -2837,18 +2826,18 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b15debb4f9d60d767cd8ca9ef7abb2452922f3214671ff052defc7f3502c44" +checksum = "a9af2cf09ef80e610097515e80095b7f76660a92743c4185aff5406cd5ce3dd5" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abfa8511e9e94fd3de6585a3d3cd00e01ed556dc9814829280af0e8dc72a8f36" +checksum = "9c501201393982e275433bc55de7d6ae6f00e7699cd5572c5b57581cd69c881b" dependencies = [ "proc-macro2", "quote", @@ -2857,9 +2846,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ "aho-corasick", "memchr", @@ -2956,9 +2945,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.7" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "539a2bfe908f471bfa933876bd1eb6a19cf2176d375f82ef7f99530a40e48c2c" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", "ring", @@ -2980,24 +2969,24 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64", + "base64 0.21.0", ] [[package]] name = "rustversion" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "scale-bits" @@ -3067,12 +3056,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" dependencies = [ - "lazy_static", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] @@ -3112,9 +3100,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sct" @@ -3142,9 +3130,9 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9512ffd81e3a3503ed401f79c33168b9148c75038956039166cd750eaa037c3" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" dependencies = [ "secp256k1-sys 0.6.1", ] @@ -3187,9 +3175,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.7.0" +version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" dependencies = [ "bitflags", "core-foundation", @@ -3200,9 +3188,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.6.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" dependencies = [ "core-foundation-sys", "libc", @@ -3219,9 +3207,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" dependencies = [ "serde", ] @@ -3237,18 +3225,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.155" +version = "1.0.156" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8" +checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.155" +version = "1.0.156" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" +checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" dependencies = [ "proc-macro2", "quote", @@ -3358,9 +3346,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -3373,9 +3361,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -3387,7 +3375,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ - "base64", + "base64 0.13.1", "bytes", "futures", "httparse", @@ -3419,7 +3407,7 @@ name = "sp-api-proc-macro" version = "4.0.0-dev" source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ - "blake2 0.10.5", + "blake2 0.10.6", "proc-macro-crate", "proc-macro2", "quote", @@ -3492,7 +3480,7 @@ dependencies = [ "array-bytes", "base58", "bitflags", - "blake2 0.10.5", + "blake2 0.10.6", "byteorder", "dyn-clonable", "ed25519-zebra", @@ -3512,7 +3500,7 @@ dependencies = [ "regex", "scale-info", "schnorrkel", - "secp256k1 0.24.2", + "secp256k1 0.24.3", "secrecy", "serde", "sp-core-hashing 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3537,7 +3525,7 @@ dependencies = [ "array-bytes", "base58", "bitflags", - "blake2 0.10.5", + "blake2 0.10.6", "dyn-clonable", "ed25519-zebra", "futures", @@ -3555,7 +3543,7 @@ dependencies = [ "regex", "scale-info", "schnorrkel", - "secp256k1 0.24.2", + "secp256k1 0.24.3", "secrecy", "serde", "sp-core-hashing 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", @@ -3577,7 +3565,7 @@ version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49b9d1daa6aebfc144729b630885e91df92ff00560490ec065a56cb538e8895a" dependencies = [ - "blake2 0.10.5", + "blake2 0.10.6", "byteorder", "digest 0.10.6", "sha2 0.10.6", @@ -3591,7 +3579,7 @@ name = "sp-core-hashing" version = "5.0.0" source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ - "blake2 0.10.5", + "blake2 0.10.6", "byteorder", "digest 0.10.6", "sha2 0.10.6", @@ -3682,7 +3670,7 @@ dependencies = [ "log", "parity-scale-codec", "parking_lot", - "secp256k1 0.24.2", + "secp256k1 0.24.3", "sp-core 7.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-externalities 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-keystore 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3708,7 +3696,7 @@ dependencies = [ "libsecp256k1", "log", "parity-scale-codec", - "secp256k1 0.24.2", + "secp256k1 0.24.3", "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-externalities 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-keystore 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", @@ -4152,9 +4140,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.36.0" +version = "1.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d92659e7d18d82b803824a9ba5a6022cff101c3491d027c1c1d8d30e749284" +checksum = "ecf0bd63593ef78eca595a7fc25e9a443ca46fe69fd472f8f09f5245cdcd769d" dependencies = [ "Inflector", "num-format", @@ -4290,9 +4278,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.105" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -4325,9 +4313,9 @@ checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" [[package]] name = "termcolor" -version = "1.1.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] @@ -4354,10 +4342,11 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ + "cfg-if", "once_cell", ] @@ -4410,15 +4399,15 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.23.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" dependencies = [ "autocfg", "bytes", @@ -4429,7 +4418,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -4456,9 +4445,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" dependencies = [ "bytes", "futures-core", @@ -4470,12 +4459,20 @@ dependencies = [ ] [[package]] -name = "toml" -version = "0.5.9" +name = "toml_datetime" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" + +[[package]] +name = "toml_edit" +version = "0.19.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc18466501acd8ac6a3f615dd29a3438f8ca6bb3b19537138b3106e575621274" dependencies = [ - "serde", + "indexmap", + "toml_datetime", + "winnow", ] [[package]] @@ -4584,15 +4581,15 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "tt-call" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" +checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" [[package]] name = "twox-hash" @@ -4632,15 +4629,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -4693,12 +4690,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "want" version = "0.3.0" @@ -4723,9 +4714,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -4733,9 +4724,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", "log", @@ -4748,9 +4739,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4758,9 +4749,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", @@ -4771,9 +4762,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "wasmi" @@ -4829,7 +4820,7 @@ dependencies = [ "indexmap", "libc", "log", - "object", + "object 0.29.0", "once_cell", "paste", "psm", @@ -4859,10 +4850,10 @@ checksum = "ebb881c61f4f627b5d45c54e629724974f8a8890d455bcbe634330cc27309644" dependencies = [ "anyhow", "cranelift-entity", - "gimli", + "gimli 0.26.2", "indexmap", "log", - "object", + "object 0.29.0", "serde", "target-lexicon", "thiserror", @@ -4876,14 +4867,14 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1985c628011fe26adf5e23a5301bdc79b245e0e338f14bb58b39e4e25e4d8681" dependencies = [ - "addr2line", + "addr2line 0.17.0", "anyhow", "bincode", "cfg-if", "cpp_demangle", - "gimli", + "gimli 0.26.2", "log", - "object", + "object 0.29.0", "rustc-demangle", "rustix", "serde", @@ -4941,9 +4932,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" dependencies = [ "js-sys", "wasm-bindgen", @@ -4961,9 +4952,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368bfe657969fb01238bb756d351dcade285e0f6fcbd36dcb23359a5169975be" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ "webpki", ] @@ -5019,19 +5010,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.2", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_msvc" @@ -5041,9 +5056,9 @@ checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_aarch64_msvc" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" @@ -5053,9 +5068,9 @@ checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" @@ -5065,9 +5080,9 @@ checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_i686_msvc" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" @@ -5077,15 +5092,15 @@ checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" @@ -5095,9 +5110,18 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "winnow" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "23d020b441f92996c80d94ae9166e8501e59c7bb56121189dc9eab3bd8216966" +dependencies = [ + "memchr", +] [[package]] name = "wyz" diff --git a/aleph-client/Cargo.toml b/aleph-client/Cargo.toml index 4909dbf998..025f95d223 100644 --- a/aleph-client/Cargo.toml +++ b/aleph-client/Cargo.toml @@ -10,8 +10,9 @@ anyhow = "1.0" codec = { package = 'parity-scale-codec', version = "3.0.0", features = ['derive'] } hex = { version = "0.4.3", features = ["alloc"] } log = "0.4" -serde_json = { version = "1.0" } +serde_json = { version = "1.0.94" } thiserror = "1.0" + contract-transcode = "2.1.0" ink_metadata = "4.0.0-beta" subxt = "0.25.0" diff --git a/aleph-client/src/contract/convertible_value.rs b/aleph-client/src/contract/convertible_value.rs index f92809bcdc..b7e16e651b 100644 --- a/aleph-client/src/contract/convertible_value.rs +++ b/aleph-client/src/contract/convertible_value.rs @@ -66,6 +66,19 @@ try_from_flat_value!(i32, Int, "signed integer"); try_from_flat_value!(i64, Int, "signed integer"); try_from_flat_value!(i128, Int, "signed integer"); +impl TryFrom for () { + type Error = anyhow::Error; + + fn try_from(value: ConvertibleValue) -> Result { + match value.0 { + Value::Tuple(tuple) if tuple.ident().is_none() && tuple.values().next().is_none() => { + Ok(()) + } + _ => bail!("Expected {:?} to be a unit", value.0), + } + } +} + impl TryFrom for AccountId { type Error = anyhow::Error; diff --git a/aleph-client/src/contract/mod.rs b/aleph-client/src/contract/mod.rs index 242f49f7db..e9e9466641 100644 --- a/aleph-client/src/contract/mod.rs +++ b/aleph-client/src/contract/mod.rs @@ -50,6 +50,8 @@ use std::fmt::{Debug, Formatter}; use anyhow::{anyhow, Context, Result}; use contract_transcode::ContractMessageTranscoder; pub use convertible_value::ConvertibleValue; +use log::{error, info}; +use pallet_contracts_primitives::ContractExecResult; use crate::{ connections::TxInfo, @@ -124,22 +126,28 @@ impl ContractInstance { message: &str, args: &[S], ) -> Result { - let payload = self.encode(message, args)?; - let args = ContractCallArgs { - origin: self.address.clone(), - dest: self.address.clone(), - value: 0, - gas_limit: None, - input_data: payload, - storage_deposit_limit: None, - }; - - let result = conn - .call_and_get(args) + self.contract_read_as(conn, message, args, self.address.clone()) .await - .context("RPC request error - there may be more info in node logs.")? + } + + /// Reads the value of a contract call via RPC as if it was executed by `sender`. + pub async fn contract_read_as< + S: AsRef + Debug, + T: TryFrom, + C: ConnectionApi, + >( + &self, + conn: &C, + message: &str, + args: &[S], + sender: AccountId, + ) -> Result { + let result = self + .dry_run(conn, message, args, sender) + .await? .result .map_err(|e| anyhow!("Contract exec failed {:?}", e))?; + let decoded = self.decode(message, result.data)?; ConvertibleValue(decoded).try_into()? } @@ -183,19 +191,21 @@ impl ContractInstance { args: &[S], value: Balance, ) -> Result { + let dry_run_result = self + .dry_run(conn, message, args, conn.account_id().clone()) + .await?; + let data = self.encode(message, args)?; conn.call( self.address.clone(), value, Weight { - ref_time: self.max_gas_override.unwrap_or(DEFAULT_MAX_GAS), - proof_size: self - .max_proof_size_override - .unwrap_or(DEFAULT_MAX_PROOF_SIZE), + ref_time: dry_run_result.gas_required.ref_time(), + proof_size: dry_run_result.gas_required.proof_size(), }, None, data, - TxStatus::InBlock, + TxStatus::Finalized, ) .await } @@ -207,6 +217,51 @@ impl ContractInstance { fn decode(&self, message: &str, data: Vec) -> Result { self.transcoder.decode_return(message, &mut data.as_slice()) } + + async fn dry_run + Debug, C: ConnectionApi>( + &self, + conn: &C, + message: &str, + args: &[S], + sender: AccountId, + ) -> Result> { + let payload = self.encode(message, args)?; + let args = ContractCallArgs { + origin: sender, + dest: self.address.clone(), + value: 0, + gas_limit: None, + input_data: payload, + storage_deposit_limit: None, + }; + + let contract_read_result = conn + .call_and_get(args) + .await + .context("RPC request error - there may be more info in node logs.")?; + + if !contract_read_result.debug_message.is_empty() { + info!( + target: "aleph_client::contract", + "Dry-run debug messages: {:?}", + core::str::from_utf8(&contract_read_result.debug_message) + .unwrap_or("") + .split('\n') + .filter(|m| !m.is_empty()) + .collect::>() + ); + } + + if let Ok(res) = &contract_read_result.result { + if res.did_revert() { + // For dry run, failed transactions don't return `Err` but `Ok(_)` + // and we have to inspect flags manually. + error!("Dry-run call reverted"); + } + } + + Ok(contract_read_result) + } } impl Debug for ContractInstance { diff --git a/aleph-client/src/contract/util.rs b/aleph-client/src/contract/util.rs deleted file mode 100644 index d2732fb533..0000000000 --- a/aleph-client/src/contract/util.rs +++ /dev/null @@ -1,48 +0,0 @@ -//! Utilities for writing contract wrappers. - -use anyhow::{anyhow, Result}; -use contract_transcode::Value; -use subxt::ext::sp_core::crypto::Ss58Codec; - -use crate::AccountId; - -/// Returns `Ok(u128)` if the given `Value` represents one, or `Err(_)` otherwise. -/// -/// ``` -/// # #![feature(assert_matches)] -/// # use std::assert_matches::assert_matches; -/// # use anyhow::anyhow; -/// # use aleph_client::contract::util::to_u128; -/// use contract_transcode::Value; -/// -/// assert_matches!(to_u128(Value::UInt(42)), Ok(42)); -/// assert_matches!(to_u128(Value::String("not a number".to_string())), Err(_)); -/// ``` -pub fn to_u128(value: Value) -> Result { - match value { - Value::UInt(value) => Ok(value), - _ => Err(anyhow!("Expected {:?} to be an integer", value)), - } -} - -/// Returns `Ok(AccountId)` if the given `Value` represents one, or `Err(_)` otherwise. -/// -/// ``` -/// # #![feature(assert_matches)] -/// # use std::assert_matches::assert_matches; -/// # use anyhow::anyhow; -/// # use aleph_client::contract::util::to_account_id; -/// use contract_transcode::Value; -/// -/// assert_matches!( -/// to_account_id(Value::Literal("5H8cjBBzCJrAvDn9LHZpzzJi2UKvEGC9VeVYzWX5TrwRyVCA".to_string())), -/// Ok(_) -/// ); -/// assert_matches!(to_account_id(Value::UInt(42)), Err(_)); -/// ``` -pub fn to_account_id(value: Value) -> Result { - match value { - Value::Literal(value) => Ok(AccountId::from_ss58check(&value)?), - _ => Err(anyhow!("Expected {:?} to be a string", value)), - } -} diff --git a/aleph-client/src/lib.rs b/aleph-client/src/lib.rs index fb87dedfde..d71638a38b 100644 --- a/aleph-client/src/lib.rs +++ b/aleph-client/src/lib.rs @@ -5,7 +5,6 @@ //! Most of the [pallets](https://docs.substrate.io/reference/frame-pallets/) are common to any //! [Substrate](https://github.com/paritytech/substrate) chain, but there are some unique to `aleph-node`, //! e.g. [`pallets::elections::ElectionsApi`]. -//! #![feature(auto_traits)] #![feature(negative_impls)] diff --git a/bin/cliain/.dockerignore b/bin/cliain/.dockerignore new file mode 100644 index 0000000000..acc89da10f --- /dev/null +++ b/bin/cliain/.dockerignore @@ -0,0 +1,4 @@ +**/target +target +docker/data +!target/release/cliain \ No newline at end of file diff --git a/bin/cliain/Cargo.lock b/bin/cliain/Cargo.lock index 003489d13b..42dd031436 100644 --- a/bin/cliain/Cargo.lock +++ b/bin/cliain/Cargo.lock @@ -442,9 +442,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.64" +version = "0.1.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" +checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" dependencies = [ "proc-macro2", "quote", @@ -592,9 +592,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array 0.14.6", ] @@ -670,9 +670,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "num-integer", @@ -726,7 +726,7 @@ dependencies = [ "aleph_client", "anyhow", "clap", - "contract-metadata 0.6.0", + "contract-metadata", "contract-transcode", "dialoguer", "env_logger", @@ -773,18 +773,6 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" -[[package]] -name = "contract-metadata" -version = "0.6.0" -source = "git+https://github.com/paritytech/cargo-contract.git?tag=v1.4.0#4e3a1981012999d310bd6e171aba4c5ffc7beaca" -dependencies = [ - "impl-serde 0.3.2", - "semver 1.0.16", - "serde", - "serde_json", - "url", -] - [[package]] name = "contract-metadata" version = "2.1.0" @@ -792,8 +780,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38765f12af802e382a9d8075dac1c3d28f9fbd7b5ee2776740ee8c9a8dd4f8c9" dependencies = [ "anyhow", - "impl-serde 0.4.0", - "semver 1.0.16", + "impl-serde", + "semver 1.0.17", "serde", "serde_json", "url", @@ -808,7 +796,7 @@ dependencies = [ "anyhow", "base58", "blake2 0.10.6", - "contract-metadata 2.1.0", + "contract-metadata", "escape8259", "hex", "indexmap", @@ -954,9 +942,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" +checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72" dependencies = [ "cc", "cxxbridge-flags", @@ -966,9 +954,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" +checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613" dependencies = [ "cc", "codespan-reporting", @@ -981,15 +969,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" +checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97" [[package]] name = "cxxbridge-macro" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" +checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" dependencies = [ "proc-macro2", "quote", @@ -998,9 +986,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ "darling_core", "darling_macro", @@ -1008,9 +996,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", @@ -1022,9 +1010,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core", "quote", @@ -1110,7 +1098,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "crypto-common", "subtle", ] @@ -1499,9 +1487,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" +checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" dependencies = [ "futures-channel", "futures-core", @@ -1514,9 +1502,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" +checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" dependencies = [ "futures-core", "futures-sink", @@ -1524,15 +1512,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" [[package]] name = "futures-executor" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" +checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" dependencies = [ "futures-core", "futures-task", @@ -1542,15 +1530,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" +checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" [[package]] name = "futures-macro" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" +checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" dependencies = [ "proc-macro2", "quote", @@ -1559,15 +1547,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" +checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" [[package]] name = "futures-task" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" +checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" [[package]] name = "futures-timer" @@ -1577,9 +1565,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" dependencies = [ "futures-channel", "futures-core", @@ -1835,9 +1823,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.24" +version = "0.14.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" +checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" dependencies = [ "bytes", "futures-channel", @@ -1922,15 +1910,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-serde" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" -dependencies = [ - "serde", -] - [[package]] name = "impl-serde" version = "0.4.0" @@ -2026,7 +2005,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfcfa666ada5729c7e4d3d986cd196365a2c469459fced4fa31dc6ad87c4d8f" dependencies = [ "derive_more", - "impl-serde 0.4.0", + "impl-serde", "ink_prelude", "ink_primitives", "scale-info", @@ -2095,9 +2074,9 @@ checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" [[package]] name = "io-lifetimes" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" +checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" dependencies = [ "libc", "windows-sys 0.45.0", @@ -2114,9 +2093,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "joinery" @@ -2251,9 +2230,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "libm" @@ -2910,9 +2889,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "pbkdf2" @@ -2949,9 +2928,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.5.5" +version = "2.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "028accff104c4e513bad663bbcd2ad7cfd5304144404c31ed0a77ac103d00660" +checksum = "8cbd939b234e95d72bc393d51788aec68aeeb5d51e748ca08ff3aad58cb722f7" dependencies = [ "thiserror", "ucd-trie", @@ -3033,7 +3012,7 @@ checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ "fixed-hash", "impl-codec", - "impl-serde 0.4.0", + "impl-serde", "scale-info", "uint", ] @@ -3089,9 +3068,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" dependencies = [ "unicode-ident", ] @@ -3107,9 +3086,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -3228,18 +3207,18 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c78fb8c9293bcd48ef6fce7b4ca950ceaf21210de6e105a883ee280c0f7b9ed" +checksum = "a9af2cf09ef80e610097515e80095b7f76660a92743c4185aff5406cd5ce3dd5" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f9c0c92af03644e4806106281fe2e068ac5bc0ae74a707266d06ea27bccee5f" +checksum = "9c501201393982e275433bc55de7d6ae6f00e7699cd5572c5b57581cd69c881b" dependencies = [ "proc-macro2", "quote", @@ -3347,13 +3326,13 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.8" +version = "0.36.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" dependencies = [ "bitflags", "errno", - "io-lifetimes 1.0.5", + "io-lifetimes 1.0.6", "libc", "linux-raw-sys 0.1.4", "windows-sys 0.45.0", @@ -3394,15 +3373,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "scale-bits" @@ -3516,9 +3495,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sct" @@ -3623,9 +3602,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" dependencies = [ "serde", ] @@ -3641,18 +3620,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.155" +version = "1.0.156" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8" +checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.155" +version = "1.0.156" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" +checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" dependencies = [ "proc-macro2", "quote", @@ -3792,9 +3771,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -3918,7 +3897,7 @@ dependencies = [ "futures", "hash-db", "hash256-std-hasher", - "impl-serde 0.4.0", + "impl-serde", "lazy_static", "libsecp256k1", "log", @@ -3962,7 +3941,7 @@ dependencies = [ "futures", "hash-db", "hash256-std-hasher", - "impl-serde 0.4.0", + "impl-serde", "lazy_static", "libsecp256k1", "log", @@ -4402,7 +4381,7 @@ version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb987ed2e4d7d870170a225083ea962f2a359d75cdf76935d5ed8d91bee912d9" dependencies = [ - "impl-serde 0.4.0", + "impl-serde", "parity-scale-codec", "ref-cast", "serde", @@ -4415,7 +4394,7 @@ name = "sp-storage" version = "7.0.0" source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ - "impl-serde 0.4.0", + "impl-serde", "parity-scale-codec", "ref-cast", "serde", @@ -4515,7 +4494,7 @@ name = "sp-version" version = "5.0.0" source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ - "impl-serde 0.4.0", + "impl-serde", "parity-scale-codec", "parity-wasm", "scale-info", @@ -4794,7 +4773,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall", - "rustix 0.36.8", + "rustix 0.36.9", "windows-sys 0.42.0", ] @@ -4961,9 +4940,9 @@ checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" [[package]] name = "toml_edit" -version = "0.19.4" +version = "0.19.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1eb0622d28f4b9c90adc4ea4b2b46b47663fde9ac5fafcb14a1369d5508825" +checksum = "dc18466501acd8ac6a3f615dd29a3438f8ca6bb3b19537138b3106e575621274" dependencies = [ "indexmap", "toml_datetime", @@ -5124,15 +5103,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -5505,12 +5484,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.1", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -5524,24 +5503,24 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.1", + "windows_x86_64_msvc 0.42.2", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_msvc" @@ -5551,9 +5530,9 @@ checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" @@ -5563,9 +5542,9 @@ checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" @@ -5575,9 +5554,9 @@ checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" @@ -5587,15 +5566,15 @@ checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" @@ -5605,15 +5584,15 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "winnow" -version = "0.3.3" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf09497b8f8b5ac5d3bb4d05c0a99be20f26fd3d5f2db7b0716e946d5103658" +checksum = "23d020b441f92996c80d94ae9166e8501e59c7bb56121189dc9eab3bd8216966" dependencies = [ "memchr", ] diff --git a/bin/cliain/Cargo.toml b/bin/cliain/Cargo.toml index d16edf909b..c81340a114 100644 --- a/bin/cliain/Cargo.toml +++ b/bin/cliain/Cargo.toml @@ -8,18 +8,18 @@ license = "GPL-3.0-or-later" anyhow = "1.0" clap = { version = "3.0", features = ["derive"] } codec = { package = 'parity-scale-codec', version = "3.0.0", features = ['derive'] } +contract-metadata = "2.0.2" contract-transcode = "2.1.0" dialoguer = "0.10.0" env_logger = "0.8" hex = "0.4.3" -ink_metadata = { version = "4.0.0-beta", features = ["derive"] } +ink_metadata = { version = "=4.0.1", features = ["derive"] } log = "0.4" serde = { version = "1.0.137", features = ["derive"] } serde_json = "1.0.81" -tokio = { version = "1.21.2", features = ["full"] } subxt = "0.25.0" +tokio = { version = "1.21.2", features = ["full"] } -contract-metadata = { git = "https://github.com/paritytech/cargo-contract.git", tag = "v1.4.0"} pallet-staking = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.38" } sp-core = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.38", features = ["full_crypto"] } @@ -34,4 +34,3 @@ liminal = [ "aleph_client/liminal", "liminal-ark-relations", ] - diff --git a/bin/cliain/src/contracts.rs b/bin/cliain/src/contracts.rs index 3b5599aa46..456f65a087 100644 --- a/bin/cliain/src/contracts.rs +++ b/bin/cliain/src/contracts.rs @@ -5,6 +5,7 @@ use std::{ use aleph_client::{ api::contracts::events::{CodeRemoved, CodeStored, Instantiated}, + contract_transcode, pallet_contracts::wasm::OwnerInfo, pallets::contract::{ContractsApi, ContractsUserApi}, sp_weights::weight_v2::Weight, @@ -13,13 +14,15 @@ use aleph_client::{ }; use codec::{Compact, Decode}; use contract_metadata::ContractMetadata; -use contract_transcode::ContractMessageTranscoder; use log::{debug, info}; use serde::{Deserialize, Serialize}; -use crate::commands::{ - ContractCall, ContractInstantiate, ContractInstantiateWithCode, ContractOptions, - ContractOwnerInfo, ContractRemoveCode, ContractUploadCode, +use crate::{ + commands::{ + ContractCall, ContractInstantiate, ContractInstantiateWithCode, ContractOptions, + ContractOwnerInfo, ContractRemoveCode, ContractUploadCode, + }, + contracts::contract_transcode::ContractMessageTranscoder, }; #[derive(Debug, Decode, Clone, Serialize, Deserialize)] diff --git a/contracts/README.md b/contracts/README.md new file mode 100644 index 0000000000..6648605ee8 --- /dev/null +++ b/contracts/README.md @@ -0,0 +1,88 @@ +# TheButton + +Series of smart contract based games, with varying tokenomics. +TheButton is loosely based on the famous [game](https://en.wikipedia.org/wiki/The_Button_(Reddit)) on reddit. + +- Button lives for a set time. +- Pressing the button extends its life. +- Users are rewarded for playing the game. +- Everybody can play only once. + +``` + |______|_______| + | | | +start now deadline +``` + +## EarlyBirdSpecial + +There is a pre-minted amount of tokens (a classic ERC20 standard). +Users are rewarded for pressing as early on as possible: + +``` +score = deadline - now +``` + +There are two built-in incentives: +* playing for the score: If you clicked in the 10th second of TheButton's life, which is set for example to 900 blocks, you get rewarded based on the score of 900-10=890 (and the button's life now will end at block 910). +* playing to be ThePressiah: the last player to click gets 20% of the total reward pool (1/4 of the sum of all the rewards paid for pressing the button) + +## BackToTheFuture + +In this scenario the rewards are reversed - players get rewarded for extending the button's life further into the future, i.e.: + +``` +score = now - start +``` + +The Pressiah gets 20% of the total reward pool. + +## ThePressiahCometh + +Game continues in perpetuity (but in practice as long as there are accounts that can still play it) + +- In each iteration of the game TheButton lives for a number of blocks +- Clicking TheButton resets its countdown timer (extending the button's life further into the future) +- Tokens are continuously minted at the end of each iteration +- Players are rewarded for playing, with the ultimate goal of being the Pressiah (the last person to click the button) +- Reward rules: + - If you're not ThePressiah, you get _k_ tokens if you pressed the button as the _k-th_ person in a row. + - ThePressiah gets 20% of the total reward pool. + +# Development + +## Prerequisites + +- Rust nightly +- cargo-contract compatible with current node: `cargo install cargo-contract --version 2.0.1` + +## Instructions + +Firstly bootstrap a one-node `smartnet` chain: + +```bash + ./.github/scripts/run_smartnet.sh +``` + +Secondly `deploy` script takes care of compiling and deploying the contracts. + +```bash +source contracts/env/dev && ./contracts/scripts/deploy.sh +``` + +Specifically it will: + +- Deploy the contracts. +- Set access control on them. +- Make necessary token transfers. + +Third `test.sh` script plays the game from two well-known dev addresses. + +```bash +./contracts/scripts/test.sh +``` + +It will: + +- Interact with the games from known accounts. +- Wait past the game deadline, trigger the game end and reward distribution. diff --git a/contracts/access_control/Cargo.lock b/contracts/access_control/Cargo.lock new file mode 100644 index 0000000000..0724e871e0 --- /dev/null +++ b/contracts/access_control/Cargo.lock @@ -0,0 +1,916 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "access_control" +version = "0.2.0" +dependencies = [ + "ink", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "array-init" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfb6d71005dc22a708c7496eee5c8dc0300ee47355de6256c3b35b12b5fef596" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +dependencies = [ + "digest", +] + +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byte-slice-cast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cpufeatures" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "either" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76b4fc39f3bcab7e042becf5c9dbbebc179fff64924025753a5fafa016e8576d" +dependencies = [ + "derive_more", + "ink_env", + "ink_macro", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage", + "parity-scale-codec", +] + +[[package]] +name = "ink_allocator" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a54dbbaffb0f97bcae062e628dcdc9da4d3c9044f5a53fb2715a328b07221631" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_codegen" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "283b022679ef75898db5c28b89388412d93f91cea4f0b1443426901cb391b079" +dependencies = [ + "blake2", + "derive_more", + "either", + "env_logger", + "heck", + "impl-serde", + "ink_ir", + "ink_primitives", + "itertools", + "log", + "parity-scale-codec", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", +] + +[[package]] +name = "ink_engine" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daed9b710cba6f50f1fa0372a7e8a47a35624d84af4ef2c3a8d34d4e96202d1c" +dependencies = [ + "blake2", + "derive_more", + "ink_primitives", + "parity-scale-codec", + "secp256k1", + "sha2", + "sha3", +] + +[[package]] +name = "ink_env" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41c6a3f4e740e27449f805ed47f536a35fb254ebcd03d2480014589331cda3e" +dependencies = [ + "arrayref", + "blake2", + "cfg-if", + "derive_more", + "ink_allocator", + "ink_engine", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "num-traits", + "parity-scale-codec", + "paste", + "rlibc", + "scale-info", + "secp256k1", + "sha2", + "sha3", + "static_assertions", +] + +[[package]] +name = "ink_ir" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "946b940d26e69ded558daafead0979f25f2e9d7e2cf86027f250c3942aa4d0f1" +dependencies = [ + "blake2", + "either", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink_macro" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6642450e6169cfaf81717b1d62b2abae48a6b41d3f70f885b6aeff7bb14ea96b" +dependencies = [ + "ink_codegen", + "ink_ir", + "ink_primitives", + "parity-scale-codec", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "ink_metadata" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfcfa666ada5729c7e4d3d986cd196365a2c469459fced4fa31dc6ad87c4d8f" +dependencies = [ + "derive_more", + "impl-serde", + "ink_prelude", + "ink_primitives", + "scale-info", + "serde", +] + +[[package]] +name = "ink_prelude" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8080235e5ae921975c2c7772fe9959e1b3c92b4d5a1afcfe104f93fb79aa268" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_primitives" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b3f711d857d2de7c08158369cc32a762833ac211a00aac7931992094e25741" +dependencies = [ + "derive_more", + "ink_prelude", + "parity-scale-codec", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "ink_storage" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2872a5ea4559433381b2d82b08b6acd33ce934b07a22ce951c6f00483680c950" +dependencies = [ + "array-init", + "cfg-if", + "derive_more", + "ink_env", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ink_storage_traits" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c90e11b60233ae5ab877854739da2c380a337cb31b3900cb50328821c0381b6" +dependencies = [ + "ink_metadata", + "ink_prelude", + "ink_primitives", + "parity-scale-codec", + "scale-info", + "syn", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "keccak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "parity-scale-codec" +version = "3.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9182e4a71cae089267ab03e67c99368db7cd877baf50f931e5d6d4b71e195ac0" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "paste" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "rlibc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" + +[[package]] +name = "rustix" +version = "0.36.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" + +[[package]] +name = "scale-info" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "secp256k1" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642a62736682fdd8c71da0eb273e453c8ac74e33b9fb310e22ba5b03ec7651ff" +dependencies = [ + "cc", +] + +[[package]] +name = "serde" +version = "1.0.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha3" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881bf8156c87b6301fc5ca6b27f11eeb2761224c7081e69b409d5a1951a70c86" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "unicode-ident" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" + +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "wyz" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +dependencies = [ + "tap", +] + +[[package]] +name = "xxhash-rust" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735a71d46c4d68d71d4b24d03fdc2b98e38cea81730595801db779c04fe80d70" diff --git a/contracts/access_control/Cargo.toml b/contracts/access_control/Cargo.toml new file mode 100644 index 0000000000..e359c41fc4 --- /dev/null +++ b/contracts/access_control/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "access_control" +version = "0.2.0" +authors = ["Cardinal Cryptography"] +edition = "2021" +publish = false +license = "Apache 2.0" + +[dependencies] +ink = { version = "=4.0.1", default-features = false } + +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } + +[lib] +name = "access_control" +path = "lib.rs" +crate-type = [ + # Used for normal contract Wasm blobs. + "cdylib", + # Used for ABI generation. + "rlib", +] + +[features] +default = ["std"] +std = [ + "ink/std", + "scale/std", + "scale-info/std", +] +ink-as-dependency = [] diff --git a/contracts/access_control/LICENSE b/contracts/access_control/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/contracts/access_control/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/contracts/access_control/lib.rs b/contracts/access_control/lib.rs new file mode 100644 index 0000000000..47f0219538 --- /dev/null +++ b/contracts/access_control/lib.rs @@ -0,0 +1,237 @@ +#![cfg_attr(not(feature = "std"), no_std)] +#![allow(clippy::let_unit_value)] + +pub use crate::access_control::{ + AccessControl, AccessControlError, AccessControlRef, ACCESS_CONTROL_PUBKEY, + CHECK_ROLE_SELECTOR, HAS_ROLE_SELECTOR, +}; +pub mod roles; + +use ink::env::{DefaultEnvironment, Environment}; + +type AccountId = ::AccountId; +type Hash = ::Hash; + +#[ink::contract] +mod access_control { + use ink::{codegen::EmitEvent, reflect::ContractEventBase, storage::Mapping}; + use scale::{Decode, Encode}; + + use crate::roles::Role; + + // address placeholder, to be set in the bytecode + // 4465614444656144446561444465614444656144446561444465614444656144 => 5DcPEG9AQ4Y9Lo9C5WXuKJDDawens77jWxZ6zGChnm8y8FUX + pub const ACCESS_CONTROL_PUBKEY: [u8; 32] = *b"DeaDDeaDDeaDDeaDDeaDDeaDDeaDDeaD"; + pub const HAS_ROLE_SELECTOR: [u8; 4] = [0, 0, 0, 3]; + pub const CHECK_ROLE_SELECTOR: [u8; 4] = [0, 0, 0, 5]; + + #[ink(storage)] + pub struct AccessControl { + /// Stores a de-facto hashset of user accounts and their roles + pub privileges: Mapping<(AccountId, Role), ()>, + } + + #[ink(event)] + #[derive(Debug)] + pub struct RoleGranted { + #[ink(topic)] + by: AccountId, + #[ink(topic)] + to: AccountId, + #[ink(topic)] + role: Role, + } + + #[ink(event)] + #[derive(Debug)] + pub struct RoleRevoked { + #[ink(topic)] + by: AccountId, + #[ink(topic)] + from: AccountId, + #[ink(topic)] + role: Role, + } + + #[derive(Debug, PartialEq, Eq, Encode, Decode)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + pub enum AccessControlError { + MissingRole(Role), + } + + /// Result type + pub type Result = core::result::Result; + /// Event type + pub type Event = ::Type; + + impl AccessControl { + /// Creates a new contract. + #[ink(constructor)] + pub fn new() -> Self { + let mut privileges = Mapping::default(); + let caller = Self::env().caller(); + let this = Self::env().account_id(); + privileges.insert((caller, Role::Admin(this)), &()); + privileges.insert((caller, Role::Owner(this)), &()); + + Self { privileges } + } + + /// Gives a role to an account + /// + /// Can only be called by an account with an admin role on this contract + #[ink(message, selector = 1)] + pub fn grant_role(&mut self, account: AccountId, role: Role) -> Result<()> { + let key = (account, role); + if !self.privileges.contains(key) { + let caller = self.env().caller(); + let this = self.env().account_id(); + self.check_role(caller, Role::Admin(this))?; + self.privileges.insert(key, &()); + + let event = Event::RoleGranted(RoleGranted { + by: caller, + to: account, + role, + }); + Self::emit_event(self.env(), event); + } + + Ok(()) + } + + /// Revokes a role from an account + /// + /// Can only be called by an admin role on this contract + #[ink(message, selector = 2)] + pub fn revoke_role(&mut self, account: AccountId, role: Role) -> Result<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + self.check_role(caller, Role::Admin(this))?; + self.privileges.remove((account, role)); + + let event = Event::RoleRevoked(RoleRevoked { + by: caller, + from: account, + role, + }); + Self::emit_event(self.env(), event); + + Ok(()) + } + + /// Returns true if account has a role + #[ink(message, selector = 3)] + pub fn has_role(&self, account: AccountId, role: Role) -> bool { + self.privileges.contains((account, role)) + } + + /// Terminates the contract. + /// + /// can only be called by the contract owner + #[ink(message, selector = 4)] + pub fn terminate(&mut self) -> Result<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + self.check_role(caller, Role::Owner(this))?; + self.env().terminate_contract(caller) + } + + /// Result wrapped version of `has_role` + /// + /// Returns Error variant MissingRole(Role) if the account does not carry a role + #[ink(message, selector = 5)] + pub fn check_role(&self, account: AccountId, role: Role) -> Result<()> { + if !self.has_role(account, role) { + return Err(AccessControlError::MissingRole(role)); + } + Ok(()) + } + + fn emit_event>(emitter: EE, event: Event) { + emitter.emit_event(event); + } + } + + impl Default for AccessControl { + fn default() -> Self { + Self::new() + } + } + + #[cfg(test)] + mod tests { + use super::*; + + #[ink::test] + fn access_control() { + let accounts = ink::env::test::default_accounts::(); + + let alice = accounts.alice; + let bob = accounts.bob; + let charlie = accounts.charlie; + let contract_address = accounts.django; + + // alice deploys the access control contract + ink::env::test::set_caller::(alice); + ink::env::test::set_callee::(contract_address); + ink::env::test::set_account_balance::( + contract_address, + 100, + ); + let mut access_control = AccessControl::new(); + + // alice should be admin + assert!( + access_control.has_role(alice, Role::Admin(contract_address)), + "deployer is not admin" + ); + + // alice should be owner + assert!( + access_control.has_role(alice, Role::Owner(contract_address)), + "deployer is not owner" + ); + + // alice grants admin rights to bob + assert!( + access_control + .grant_role(bob, Role::Admin(contract_address)) + .is_ok(), + "Alice's grant_role call failed" + ); + + assert!( + access_control.has_role(bob, Role::Admin(contract_address)), + "Bob is not admin" + ); + + ink::env::test::set_caller::(charlie); + ink::env::test::set_callee::(contract_address); + + // charlie tries granting admin rights to himself + assert!( + access_control + .grant_role(charlie, Role::Admin(contract_address)) + .is_err(), + "grant_role should fail" + ); + + // test terminating + ink::env::test::set_caller::(alice); + ink::env::test::set_callee::(contract_address); + + let should_terminate = move || { + access_control + .terminate() + .expect("Calling terminate failed") + }; + + ink::env::test::assert_contract_termination::( + should_terminate, + alice, + 100, + ); + } + } +} diff --git a/contracts/access_control/roles.rs b/contracts/access_control/roles.rs new file mode 100644 index 0000000000..13ee5586e1 --- /dev/null +++ b/contracts/access_control/roles.rs @@ -0,0 +1,20 @@ +use scale::{Decode, Encode}; + +use crate::{AccountId, Hash}; + +#[derive(Debug, Encode, Decode, Clone, Copy, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] +pub enum Role { + /// Indicates a superuser. + Admin(AccountId), + /// Indicates account that can terminate a contract. + Owner(AccountId), + /// Indicates account that can initialize a contract from a given code hash. + Initializer(Hash), + /// Indicates account that can add liquidity to a DEX contract (call certain functions) + LiquidityProvider(AccountId), + /// Indicates account that can mint tokens of a given token contract, + Minter(AccountId), + /// Indicates account that can burn tokens of a given token contract, + Burner(AccountId), +} diff --git a/contracts/adder/Cargo.toml b/contracts/adder/Cargo.toml index b55dd2fac2..eb3db347ed 100644 --- a/contracts/adder/Cargo.toml +++ b/contracts/adder/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] anyhow = "*" -ink = { version = "4.0.0-beta", default-features = false } +ink = { version = "=4.0.1", default-features = false } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/contracts/adder/deploy.sh b/contracts/adder/deploy.sh index 37f8d10747..477935cc56 100755 --- a/contracts/adder/deploy.sh +++ b/contracts/adder/deploy.sh @@ -1,22 +1,37 @@ #!/bin/bash +set -euox pipefail + NODE_URL="${NODE_URL:-ws://localhost:9944}" AUTHORITY="${AUTHORITY:-//Alice}" -function ink-build() { - docker run \ +function run_ink_builder() { + docker start ink_builder 1>&2 || docker run \ --network host \ - -v ${PWD}:/code \ + -v "${PWD}/../..:/code" \ + -u "$(id -u):$(id -g)" \ + --name ink_builder \ --platform linux/amd64 \ - --rm public.ecr.aws/p6e8q1z1/ink-dev:0.1.0 "$@" + --detach \ + --rm public.ecr.aws/p6e8q1z1/ink-dev:1.0.0 sleep 1d 1>&2 +} + +function ink_build() { + docker exec \ + -u "$(id -u):$(id -g)" \ + -w "/code/contracts/adder" \ + ink_builder "$@" } -ink-build cargo contract build --release --quiet 1>&2 +run_ink_builder +ink_build rustup target add wasm32-unknown-unknown +ink_build rustup component add rust-src +ink_build cargo contract build --release --quiet 1>&2 export ADDER ADDER=$( - ink-build cargo contract instantiate --url "$NODE_URL" --suri "$AUTHORITY" --skip-confirm --output-json \ + ink_build cargo contract instantiate --url "$NODE_URL" --suri "$AUTHORITY" --skip-confirm --output-json \ | jq -r ".contract" ) echo "$ADDER" diff --git a/contracts/button/Cargo.lock b/contracts/button/Cargo.lock new file mode 100644 index 0000000000..e625dcf207 --- /dev/null +++ b/contracts/button/Cargo.lock @@ -0,0 +1,1251 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "access_control" +version = "0.2.0" +dependencies = [ + "ink", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "array-init" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfb6d71005dc22a708c7496eee5c8dc0300ee47355de6256c3b35b12b5fef596" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +dependencies = [ + "crypto-mac", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "blake2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +dependencies = [ + "digest 0.10.3", +] + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "button" +version = "0.1.0" +dependencies = [ + "access_control", + "game_token", + "ink", + "marketplace", + "openbrush", + "parity-scale-codec", + "scale-info", + "ticket_token", +] + +[[package]] +name = "byte-slice-cast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" + +[[package]] +name = "camino" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "081e3f0755c1f380c2d010481b6fa2e02973586d5f2b24eebb7a2a1d98b143d8" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "semver-parser", + "serde", + "serde_json", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const_format" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "game_token" +version = "2.1.0" +dependencies = [ + "access_control", + "ink", + "openbrush", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76b4fc39f3bcab7e042becf5c9dbbebc179fff64924025753a5fafa016e8576d" +dependencies = [ + "derive_more", + "ink_env", + "ink_macro", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage", + "parity-scale-codec", +] + +[[package]] +name = "ink_allocator" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a54dbbaffb0f97bcae062e628dcdc9da4d3c9044f5a53fb2715a328b07221631" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_codegen" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "283b022679ef75898db5c28b89388412d93f91cea4f0b1443426901cb391b079" +dependencies = [ + "blake2 0.10.4", + "derive_more", + "either", + "env_logger", + "heck 0.4.0", + "impl-serde", + "ink_ir", + "ink_primitives", + "itertools", + "log", + "parity-scale-codec", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", +] + +[[package]] +name = "ink_engine" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daed9b710cba6f50f1fa0372a7e8a47a35624d84af4ef2c3a8d34d4e96202d1c" +dependencies = [ + "blake2 0.10.4", + "derive_more", + "ink_primitives", + "parity-scale-codec", + "secp256k1", + "sha2", + "sha3", +] + +[[package]] +name = "ink_env" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41c6a3f4e740e27449f805ed47f536a35fb254ebcd03d2480014589331cda3e" +dependencies = [ + "arrayref", + "blake2 0.10.4", + "cfg-if", + "derive_more", + "ink_allocator", + "ink_engine", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "num-traits", + "parity-scale-codec", + "paste", + "rlibc", + "scale-info", + "secp256k1", + "sha2", + "sha3", + "static_assertions", +] + +[[package]] +name = "ink_ir" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "946b940d26e69ded558daafead0979f25f2e9d7e2cf86027f250c3942aa4d0f1" +dependencies = [ + "blake2 0.10.4", + "either", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink_macro" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6642450e6169cfaf81717b1d62b2abae48a6b41d3f70f885b6aeff7bb14ea96b" +dependencies = [ + "ink_codegen", + "ink_ir", + "ink_primitives", + "parity-scale-codec", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "ink_metadata" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfcfa666ada5729c7e4d3d986cd196365a2c469459fced4fa31dc6ad87c4d8f" +dependencies = [ + "derive_more", + "impl-serde", + "ink_prelude", + "ink_primitives", + "scale-info", + "serde", +] + +[[package]] +name = "ink_prelude" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8080235e5ae921975c2c7772fe9959e1b3c92b4d5a1afcfe104f93fb79aa268" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_primitives" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b3f711d857d2de7c08158369cc32a762833ac211a00aac7931992094e25741" +dependencies = [ + "derive_more", + "ink_prelude", + "parity-scale-codec", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "ink_storage" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2872a5ea4559433381b2d82b08b6acd33ce934b07a22ce951c6f00483680c950" +dependencies = [ + "array-init", + "cfg-if", + "derive_more", + "ink_env", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ink_storage_traits" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c90e11b60233ae5ab877854739da2c380a337cb31b3900cb50328821c0381b6" +dependencies = [ + "ink_metadata", + "ink_prelude", + "ink_primitives", + "parity-scale-codec", + "scale-info", + "syn", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8bf247779e67a9082a4790b45e71ac7cfd1321331a5c856a74a9faebdab78d0" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" + +[[package]] +name = "keccak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "marketplace" +version = "0.1.0" +dependencies = [ + "access_control", + "game_token", + "ink", + "openbrush", + "parity-scale-codec", + "scale-info", + "ticket_token", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "obce" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "ink", + "ink_engine", + "obce-macro", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "obce-codegen" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "blake2 0.10.4", + "itertools", + "proc-macro2", + "quote", + "syn", + "tuple", +] + +[[package]] +name = "obce-macro" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "obce-codegen", + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "once_cell" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openbrush" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "ink", + "openbrush_contracts", + "openbrush_lang", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "openbrush_contracts" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "ink", + "openbrush_lang", + "pallet-assets-chain-extension", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "openbrush_lang" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "const_format", + "ink", + "openbrush_lang_macro", + "parity-scale-codec", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "openbrush_lang_codegen" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "blake2 0.9.2", + "cargo_metadata", + "fs2", + "heck 0.3.3", + "ink_ir", + "ink_primitives", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", + "synstructure", + "unwrap", +] + +[[package]] +name = "openbrush_lang_macro" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "openbrush_lang_codegen", + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "pallet-assets-chain-extension" +version = "0.1.1" +source = "git+https://github.com/727-ventures/pallet-assets-chain-extension?branch=polkadot-v0.9.37#f8ea374186df2a3fc139c8d585719e58d83df582" +dependencies = [ + "ink", + "obce", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "parity-scale-codec" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "paste" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" + +[[package]] +name = "pest" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb779fcf4bb850fbbb0edc96ff6cf34fd90c4b1a112ce042653280d9a7364048" +dependencies = [ + "thiserror", + "ucd-trie", +] + +[[package]] +name = "proc-macro-crate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +dependencies = [ + "once_cell", + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "rlibc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" + +[[package]] +name = "rustix" +version = "0.36.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "scale-info" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "secp256k1" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642a62736682fdd8c71da0eb273e453c8ac74e33b9fb310e22ba5b03ec7651ff" +dependencies = [ + "cc", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9db03534dff993187064c4e0c05a5708d2a9728ace9a8959b77bedf415dac5" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + +[[package]] +name = "sha3" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaedf34ed289ea47c2b741bb72e5357a209512d67bcd4bda44359e5bf0470f56" +dependencies = [ + "digest 0.10.3", + "keccak", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ticket_token" +version = "2.1.0" +dependencies = [ + "access_control", + "ink", + "openbrush", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "tuple" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39a40ba241047e1174c927dc5f61c141a166b938d61a2ff61838441368cc7d0e" +dependencies = [ + "num-traits", + "serde", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "ucd-trie" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" + +[[package]] +name = "unicode-ident" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" + +[[package]] +name = "unicode-segmentation" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" + +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + +[[package]] +name = "unwrap" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e33648dd74328e622c7be51f3b40a303c63f93e6fa5f08778b6203a4c25c20f" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "wyz" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +dependencies = [ + "tap", +] + +[[package]] +name = "xxhash-rust" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735a71d46c4d68d71d4b24d03fdc2b98e38cea81730595801db779c04fe80d70" diff --git a/contracts/button/Cargo.toml b/contracts/button/Cargo.toml new file mode 100644 index 0000000000..eb32109a27 --- /dev/null +++ b/contracts/button/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "button" +version = "0.1.0" +authors = ["Cardinal Cryptography"] +edition = "2021" + +[dependencies] +ink = { version = "=4.0.1", default-features = false } +openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts/", tag = "3.0.0", default-features = false, features = ["psp22"] } + +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } + +access_control = { path = "../access_control", default-features = false, features = ["ink-as-dependency"] } +game_token = { path = "../game_token", default-features = false, features = ["ink-as-dependency"] } +ticket_token = { path = "../ticket_token", default-features = false, features = ["ink-as-dependency"] } +marketplace = { path = "../marketplace", default-features = false, features = ["ink-as-dependency"] } + +[lib] +name = "button" +path = "lib.rs" +crate-type = [ + "cdylib", + "rlib", +] + +[features] +default = ["std"] +std = [ + "ink/std", + "scale-info/std", + "scale/std", + "access_control/std", + "game_token/std", + "ticket_token/std", + "marketplace/std", + "openbrush/std", +] +ink-as-dependency = [] diff --git a/contracts/button/errors.rs b/contracts/button/errors.rs new file mode 100644 index 0000000000..c2799aeadf --- /dev/null +++ b/contracts/button/errors.rs @@ -0,0 +1,56 @@ +use access_control::roles::Role; +use ink::{ + env::Error as InkEnvError, + prelude::{format, string::String}, + LangError, +}; +use marketplace::marketplace::Error as MarketplaceError; +use openbrush::contracts::psp22::PSP22Error; + +/// GameError types +#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)] +#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] +pub enum GameError { + /// Reset has been called before the deadline + BeforeDeadline, + /// Button has been pressed after the deadline + AfterDeadline, + /// Call has been made from an account with missing access control privileges + MissingRole(Role), + /// A call to a PSP22 contract has failed + PSP22Error(PSP22Error), + /// An interaction with ink! environment has failed + InkEnvError(String), + /// Couldn't have retrieved own code hash + CantRetrieveOwnCodeHash, + /// Overflow error + Arithmethic, + /// Error from the marketplace contract + MarketplaceError(MarketplaceError), + /// Error while calling another contract + ContractCall(LangError), +} + +impl From for GameError { + fn from(e: PSP22Error) -> Self { + GameError::PSP22Error(e) + } +} + +impl From for GameError { + fn from(e: InkEnvError) -> Self { + GameError::InkEnvError(format!("{:?}", e)) + } +} + +impl From for GameError { + fn from(e: MarketplaceError) -> Self { + GameError::MarketplaceError(e) + } +} + +impl From for GameError { + fn from(e: LangError) -> Self { + GameError::ContractCall(e) + } +} diff --git a/contracts/button/lib.rs b/contracts/button/lib.rs new file mode 100644 index 0000000000..95f93a6750 --- /dev/null +++ b/contracts/button/lib.rs @@ -0,0 +1,411 @@ +#![cfg_attr(not(feature = "std"), no_std)] +#![allow(clippy::let_unit_value)] + +mod errors; + +#[ink::contract] +pub mod button_game { + use access_control::{roles::Role, AccessControlRef, ACCESS_CONTROL_PUBKEY}; + #[cfg(feature = "std")] + use ink::storage::traits::StorageLayout; + use ink::{ + codegen::EmitEvent, + env::{call::FromAccountId, CallFlags}, + prelude::vec, + reflect::ContractEventBase, + ToAccountId, + }; + use marketplace::marketplace::MarketplaceRef; + use openbrush::contracts::psp22::{extensions::mintable::PSP22MintableRef, PSP22Ref}; + use scale::{Decode, Encode}; + + use crate::errors::GameError; + + /// Result type + type ButtonResult = core::result::Result; + + /// Event type + type Event = ::Type; + + /// Event emitted when TheButton is created + #[ink(event)] + #[derive(Debug)] + pub struct ButtonCreated { + #[ink(topic)] + reward_token: AccountId, + #[ink(topic)] + ticket_token: AccountId, + start: BlockNumber, + deadline: BlockNumber, + } + + /// Event emitted when TheButton is pressed + #[ink(event)] + #[derive(Debug)] + pub struct ButtonPressed { + #[ink(topic)] + by: AccountId, + when: BlockNumber, + score: Balance, + } + + /// Event emitted when the finished game is reset and pressiah is rewarded + #[ink(event)] + #[derive(Debug)] + pub struct GameReset { + when: BlockNumber, + } + + /// Scoring strategy indicating what kind of reward users get for pressing the button + #[derive(Debug, Encode, Decode, Clone, Copy, PartialEq, Eq)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] + pub enum Scoring { + /// Pressing the button as soon as possible gives the highest reward + EarlyBirdSpecial, + /// Pressing the button as late as possible gives the highest reward + BackToTheFuture, + /// The reward increases linearly with the number of participants + ThePressiahCometh, + } + + /// Game contracts storage + #[ink(storage)] + pub struct ButtonGame { + /// How long does TheButton live for? + pub button_lifetime: BlockNumber, + /// stores the last account that pressed The Button + pub last_presser: Option, + /// block number of the last press, set to current block number at button start/reset + pub last_press: BlockNumber, + /// sum of rewards paid to players in the current iteration + pub total_rewards: u128, + /// counter for the number of presses + pub presses: u128, + /// AccountId of the PSP22 ButtonToken instance on-chain + pub reward_token: AccountId, + /// Account ID of the ticket token + pub ticket_token: AccountId, + /// access control contract + pub access_control: AccessControlRef, + /// ticket marketplace contract + pub marketplace: MarketplaceRef, + /// scoring strategy + pub scoring: Scoring, + /// current round number + pub round: u64, + } + + impl ButtonGame { + #[ink(constructor)] + pub fn new( + ticket_token: AccountId, + reward_token: AccountId, + marketplace: AccountId, + button_lifetime: BlockNumber, + scoring: Scoring, + ) -> Self { + let caller = Self::env().caller(); + let code_hash = Self::env() + .own_code_hash() + .expect("Called new on a contract with no code hash"); + let required_role = Role::Initializer(code_hash); + let access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); + let access_control = AccessControlRef::from_account_id(access_control); + + match ButtonGame::check_role(&access_control, caller, required_role) { + Ok(_) => Self::init( + access_control, + ticket_token, + reward_token, + marketplace, + button_lifetime, + scoring, + ), + Err(why) => panic!("Could not initialize the contract {:?}", why), + } + } + + /// Returns the current deadline + /// + /// Deadline is the block number at which the game will end if there are no more participants + #[ink(message)] + pub fn deadline(&self) -> BlockNumber { + self.last_press + self.button_lifetime + } + + /// Returns the curent round number + #[ink(message)] + pub fn round(&self) -> u64 { + self.round + } + + /// Returns the buttons status + #[ink(message)] + pub fn is_dead(&self) -> bool { + self.env().block_number() > self.deadline() + } + + /// Returns the last player who pressed the button. + /// If button is dead, this is The Pressiah. + #[ink(message)] + pub fn last_presser(&self) -> Option { + self.last_presser + } + + /// Returns the current access control contract address + #[ink(message)] + pub fn access_control(&self) -> AccountId { + self.access_control.to_account_id() + } + + /// Returns address of the game's reward token + #[ink(message)] + pub fn reward_token(&self) -> AccountId { + self.reward_token + } + + /// Returns address of the game's ticket token + #[ink(message)] + pub fn ticket_token(&self) -> AccountId { + self.ticket_token + } + + /// Returns the address of the marketplace for exchanging this game's rewards for tickets. + #[ink(message)] + pub fn marketplace(&self) -> AccountId { + self.marketplace.to_account_id() + } + + /// Returns own code hash + #[ink(message)] + pub fn code_hash(&self) -> ButtonResult { + self.env() + .own_code_hash() + .map_err(|_| GameError::CantRetrieveOwnCodeHash) + } + + /// Presses the button + /// + /// If called on alive button, instantaneously mints reward tokens to the caller + #[ink(message)] + pub fn press(&mut self) -> ButtonResult<()> { + if self.is_dead() { + return Err(GameError::AfterDeadline); + } + + let caller = self.env().caller(); + let now = Self::env().block_number(); + let this = self.env().account_id(); + + // transfers 1 ticket token from the caller to self + // tx will fail if user did not give allowance to the game contract + // or does not have enough balance + self.transfer_ticket(caller, this, 1u128)?; + + let score = self.score(now); + + // mints reward tokens to pay out the reward + // contract needs to have a Minter role on the reward token contract + self.mint_reward(caller, score)?; + + self.presses += 1; + self.last_presser = Some(caller); + self.last_press = now; + self.total_rewards += score; + + Self::emit_event( + self.env(), + Event::ButtonPressed(ButtonPressed { + by: caller, + when: now, + score, + }), + ); + + Ok(()) + } + + /// Resets the game + /// + /// Erases the storage and pays award to the Pressiah + /// Can be called by any account on behalf of a player + /// Can only be called after button's deadline + #[ink(message)] + pub fn reset(&mut self) -> ButtonResult<()> { + self.ensure_dead()?; + self.reward_pressiah()?; + self.reset_state()?; + self.transfer_tickets_to_marketplace()?; + self.reset_marketplace() + } + + /// Sets new access control contract address + /// + /// Should only be called by the contract owner + /// Implementing contract is responsible for setting up proper AccessControl + #[ink(message)] + pub fn set_access_control(&mut self, new_access_control: AccountId) -> ButtonResult<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + let required_role = Role::Owner(this); + ButtonGame::check_role(&self.access_control, caller, required_role)?; + self.access_control = AccessControlRef::from_account_id(new_access_control); + Ok(()) + } + + /// Terminates the contract + /// + /// Should only be called by the contract Owner + #[ink(message)] + pub fn terminate(&mut self) -> ButtonResult<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + let required_role = Role::Owner(this); + ButtonGame::check_role(&self.access_control, caller, required_role)?; + self.env().terminate_contract(caller) + } + + //=================================================================================================== + + fn init( + access_control: AccessControlRef, + ticket_token: AccountId, + reward_token: AccountId, + marketplace: AccountId, + button_lifetime: BlockNumber, + scoring: Scoring, + ) -> Self { + let now = Self::env().block_number(); + let deadline = now + button_lifetime; + + let contract = Self { + access_control, + button_lifetime, + reward_token, + ticket_token, + marketplace: MarketplaceRef::from_account_id(marketplace), + last_press: now, + scoring, + last_presser: None, + presses: 0, + total_rewards: 0, + round: 0, + }; + + Self::emit_event( + Self::env(), + Event::ButtonCreated(ButtonCreated { + start: now, + deadline, + ticket_token, + reward_token, + }), + ); + + contract + } + + fn reset_state(&mut self) -> ButtonResult<()> { + let now = self.env().block_number(); + + self.presses = 0; + self.last_presser = None; + self.last_press = now; + self.total_rewards = 0; + self.round.checked_add(1).ok_or(GameError::Arithmethic)?; + + Self::emit_event(self.env(), Event::GameReset(GameReset { when: now })); + Ok(()) + } + + fn reward_pressiah(&self) -> ButtonResult<()> { + if let Some(pressiah) = self.last_presser { + let reward = self.pressiah_score(); + self.mint_reward(pressiah, reward)?; + }; + + Ok(()) + } + + fn ensure_dead(&self) -> ButtonResult<()> { + if !self.is_dead() { + Err(GameError::BeforeDeadline) + } else { + Ok(()) + } + } + + fn transfer_tickets_to_marketplace(&self) -> ButtonResult<()> { + PSP22Ref::transfer_builder( + &self.ticket_token, + self.marketplace.to_account_id(), + self.held_tickets(), + vec![], + ) + .call_flags(CallFlags::default().set_allow_reentry(true)) + .invoke()?; + + Ok(()) + } + + fn held_tickets(&self) -> Balance { + PSP22Ref::balance_of(&self.ticket_token, self.env().account_id()) + } + + fn reset_marketplace(&mut self) -> ButtonResult<()> { + self.marketplace.reset()?; + + Ok(()) + } + + fn check_role( + access_control: &AccessControlRef, + account: AccountId, + role: Role, + ) -> ButtonResult<()> { + if access_control.has_role(account, role) { + Ok(()) + } else { + Err(GameError::MissingRole(role)) + } + } + + fn score(&self, now: BlockNumber) -> Balance { + match self.scoring { + Scoring::EarlyBirdSpecial => self.deadline().saturating_sub(now) as Balance, + Scoring::BackToTheFuture => now.saturating_sub(self.last_press) as Balance, + Scoring::ThePressiahCometh => (self.presses + 1) as Balance, + } + } + + fn pressiah_score(&self) -> Balance { + (self.total_rewards / 4) as Balance + } + + fn transfer_ticket( + &self, + from: AccountId, + to: AccountId, + value: Balance, + ) -> ButtonResult<()> { + PSP22Ref::transfer_from_builder(&self.ticket_token, from, to, value, vec![]) + .call_flags(CallFlags::default().set_allow_reentry(true)) + .invoke()?; + + Ok(()) + } + + fn mint_reward(&self, to: AccountId, amount: Balance) -> ButtonResult<()> { + PSP22MintableRef::mint(&self.reward_token, to, amount)?; + + Ok(()) + } + + fn emit_event(emitter: EE, event: Event) + where + EE: EmitEvent, + { + emitter.emit_event(event); + } + } +} diff --git a/contracts/env/dev b/contracts/env/dev new file mode 100644 index 0000000000..6c3f7f3bd7 --- /dev/null +++ b/contracts/env/dev @@ -0,0 +1,17 @@ +export NODE=ws://127.0.0.1:9944 + +# authority is a joint name for the account that is an INITIALIZER, OWNER and ADMIN of the game contracts for the purposes of the deployment +export AUTHORITY=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY +export AUTHORITY_SEED=//Alice + +# how long do the games live for (in blocks) +export LIFETIME=20 + +# mint this many ticket tokens +export TICKET_BALANCE=100000000 + +# initial price of ticket on the marketplace +export INITIAL_PRICE=69 + +# use dev-only hacks, like allowing the authority to mint game tokens on demand +export ENV_NAME=dev diff --git a/contracts/env/fe-benjamin b/contracts/env/fe-benjamin new file mode 100644 index 0000000000..2e168f67bc --- /dev/null +++ b/contracts/env/fe-benjamin @@ -0,0 +1,17 @@ +export NODE=wss://ws-fe-benjamin.dev.azero.dev:443 + +# authority is a joint name for the account that is an INITIALIZER, OWNER and ADMIN of the game contracts for the purposes of the deployment +export AUTHORITY=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY +export AUTHORITY_SEED=//Alice + +# how long do the games live for (in blocks) +export LIFETIME=604800 # 1 week + +# mint this many ticket tokens +export TICKET_BALANCE=100 + +# initial price of ticket on the marketplace +export INITIAL_PRICE=69 + +# semi-serious environment with no hacks +export ENV_NAME=feature-env diff --git a/contracts/game_token/Cargo.lock b/contracts/game_token/Cargo.lock new file mode 100644 index 0000000000..d0c0bf243b --- /dev/null +++ b/contracts/game_token/Cargo.lock @@ -0,0 +1,1205 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "access_control" +version = "0.2.0" +dependencies = [ + "ink", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "array-init" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfb6d71005dc22a708c7496eee5c8dc0300ee47355de6256c3b35b12b5fef596" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +dependencies = [ + "crypto-mac", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "blake2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +dependencies = [ + "digest 0.10.3", +] + +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byte-slice-cast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" + +[[package]] +name = "camino" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "081e3f0755c1f380c2d010481b6fa2e02973586d5f2b24eebb7a2a1d98b143d8" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "semver-parser", + "serde", + "serde_json", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const_format" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "cpufeatures" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "either" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "game_token" +version = "2.1.0" +dependencies = [ + "access_control", + "ink", + "openbrush", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76b4fc39f3bcab7e042becf5c9dbbebc179fff64924025753a5fafa016e8576d" +dependencies = [ + "derive_more", + "ink_env", + "ink_macro", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage", + "parity-scale-codec", +] + +[[package]] +name = "ink_allocator" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a54dbbaffb0f97bcae062e628dcdc9da4d3c9044f5a53fb2715a328b07221631" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_codegen" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "283b022679ef75898db5c28b89388412d93f91cea4f0b1443426901cb391b079" +dependencies = [ + "blake2 0.10.4", + "derive_more", + "either", + "env_logger", + "heck 0.4.0", + "impl-serde", + "ink_ir", + "ink_primitives", + "itertools", + "log", + "parity-scale-codec", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", +] + +[[package]] +name = "ink_engine" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daed9b710cba6f50f1fa0372a7e8a47a35624d84af4ef2c3a8d34d4e96202d1c" +dependencies = [ + "blake2 0.10.4", + "derive_more", + "ink_primitives", + "parity-scale-codec", + "secp256k1", + "sha2", + "sha3", +] + +[[package]] +name = "ink_env" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41c6a3f4e740e27449f805ed47f536a35fb254ebcd03d2480014589331cda3e" +dependencies = [ + "arrayref", + "blake2 0.10.4", + "cfg-if", + "derive_more", + "ink_allocator", + "ink_engine", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "num-traits", + "parity-scale-codec", + "paste", + "rlibc", + "scale-info", + "secp256k1", + "sha2", + "sha3", + "static_assertions", +] + +[[package]] +name = "ink_ir" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "946b940d26e69ded558daafead0979f25f2e9d7e2cf86027f250c3942aa4d0f1" +dependencies = [ + "blake2 0.10.4", + "either", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink_macro" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6642450e6169cfaf81717b1d62b2abae48a6b41d3f70f885b6aeff7bb14ea96b" +dependencies = [ + "ink_codegen", + "ink_ir", + "ink_primitives", + "parity-scale-codec", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "ink_metadata" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfcfa666ada5729c7e4d3d986cd196365a2c469459fced4fa31dc6ad87c4d8f" +dependencies = [ + "derive_more", + "impl-serde", + "ink_prelude", + "ink_primitives", + "scale-info", + "serde", +] + +[[package]] +name = "ink_prelude" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8080235e5ae921975c2c7772fe9959e1b3c92b4d5a1afcfe104f93fb79aa268" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_primitives" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b3f711d857d2de7c08158369cc32a762833ac211a00aac7931992094e25741" +dependencies = [ + "derive_more", + "ink_prelude", + "parity-scale-codec", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "ink_storage" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2872a5ea4559433381b2d82b08b6acd33ce934b07a22ce951c6f00483680c950" +dependencies = [ + "array-init", + "cfg-if", + "derive_more", + "ink_env", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ink_storage_traits" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c90e11b60233ae5ab877854739da2c380a337cb31b3900cb50328821c0381b6" +dependencies = [ + "ink_metadata", + "ink_prelude", + "ink_primitives", + "parity-scale-codec", + "scale-info", + "syn", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" + +[[package]] +name = "keccak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "obce" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "ink", + "ink_engine", + "obce-macro", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "obce-codegen" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "blake2 0.10.4", + "itertools", + "proc-macro2", + "quote", + "syn", + "tuple", +] + +[[package]] +name = "obce-macro" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "obce-codegen", + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openbrush" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "ink", + "openbrush_contracts", + "openbrush_lang", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "openbrush_contracts" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "ink", + "openbrush_lang", + "pallet-assets-chain-extension", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "openbrush_lang" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "const_format", + "ink", + "openbrush_lang_macro", + "parity-scale-codec", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "openbrush_lang_codegen" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "blake2 0.9.2", + "cargo_metadata", + "fs2", + "heck 0.3.3", + "ink_ir", + "ink_primitives", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", + "synstructure", + "unwrap", +] + +[[package]] +name = "openbrush_lang_macro" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "openbrush_lang_codegen", + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "pallet-assets-chain-extension" +version = "0.1.1" +source = "git+https://github.com/727-ventures/pallet-assets-chain-extension?branch=polkadot-v0.9.37#f8ea374186df2a3fc139c8d585719e58d83df582" +dependencies = [ + "ink", + "obce", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "parity-scale-codec" +version = "3.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9182e4a71cae089267ab03e67c99368db7cd877baf50f931e5d6d4b71e195ac0" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "paste" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "rlibc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" + +[[package]] +name = "rustix" +version = "0.36.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" + +[[package]] +name = "scale-info" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "secp256k1" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642a62736682fdd8c71da0eb273e453c8ac74e33b9fb310e22ba5b03ec7651ff" +dependencies = [ + "cc", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + +[[package]] +name = "sha3" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881bf8156c87b6301fc5ca6b27f11eeb2761224c7081e69b409d5a1951a70c86" +dependencies = [ + "digest 0.10.3", + "keccak", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "tuple" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39a40ba241047e1174c927dc5f61c141a166b938d61a2ff61838441368cc7d0e" +dependencies = [ + "num-traits", + "serde", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "ucd-trie" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" + +[[package]] +name = "unicode-ident" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" + +[[package]] +name = "unicode-segmentation" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" + +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + +[[package]] +name = "unwrap" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e33648dd74328e622c7be51f3b40a303c63f93e6fa5f08778b6203a4c25c20f" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "wyz" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +dependencies = [ + "tap", +] + +[[package]] +name = "xxhash-rust" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735a71d46c4d68d71d4b24d03fdc2b98e38cea81730595801db779c04fe80d70" diff --git a/contracts/game_token/Cargo.toml b/contracts/game_token/Cargo.toml new file mode 100644 index 0000000000..fcf55a775e --- /dev/null +++ b/contracts/game_token/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "game_token" +version = "2.1.0" +authors = ["Cardinal Cryptography"] +edition = "2021" +license = "Apache 2.0" + +[dependencies] +ink = { version = "=4.0.1", default-features = false } +openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts/", tag = "3.0.0", default-features = false, features = ["psp22"] } + +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } + +access_control = { path = "../access_control", default-features = false, features = ["ink-as-dependency"] } + +[lib] +name = "game_token" +path = "lib.rs" +crate-type = [ + # Used for normal contract Wasm blobs. + "cdylib", + # Used for ABI generation. + "rlib", +] + +[features] +default = ["std"] +std = [ + "ink/std", + "openbrush/std", + "scale-info", + "scale-info/std", + "scale/std", + "access_control/std" +] +ink-as-dependency = [] + +[profile.dev] +codegen-units = 16 diff --git a/contracts/game_token/lib.rs b/contracts/game_token/lib.rs new file mode 100644 index 0000000000..57827b3080 --- /dev/null +++ b/contracts/game_token/lib.rs @@ -0,0 +1,221 @@ +#![cfg_attr(not(feature = "std"), no_std)] +#![feature(min_specialization)] +#![allow(clippy::let_unit_value)] + +pub use crate::game_token::{ + ALLOWANCE_SELECTOR, BALANCE_OF_SELECTOR, BURN_SELECTOR, MINT_SELECTOR, TRANSFER_FROM_SELECTOR, + TRANSFER_SELECTOR, +}; + +#[openbrush::contract] +pub mod game_token { + use access_control::{roles::Role, AccessControlRef, ACCESS_CONTROL_PUBKEY}; + use ink::{ + codegen::{EmitEvent, Env}, + env::call::FromAccountId, + prelude::{format, string::String}, + reflect::ContractEventBase, + ToAccountId, + }; + use openbrush::{ + contracts::psp22::{ + extensions::{burnable::*, metadata::*, mintable::*}, + Internal, + }, + traits::Storage, + }; + + pub const BALANCE_OF_SELECTOR: [u8; 4] = [0x65, 0x68, 0x38, 0x2f]; + pub const TRANSFER_SELECTOR: [u8; 4] = [0xdb, 0x20, 0xf9, 0xf5]; + pub const TRANSFER_FROM_SELECTOR: [u8; 4] = [0x54, 0xb3, 0xc7, 0x6e]; + pub const ALLOWANCE_SELECTOR: [u8; 4] = [0x4d, 0x47, 0xd9, 0x21]; + pub const MINT_SELECTOR: [u8; 4] = [0xfc, 0x3c, 0x75, 0xd4]; + pub const BURN_SELECTOR: [u8; 4] = [0x7a, 0x9d, 0xa5, 0x10]; + + #[ink(storage)] + #[derive(Storage)] + pub struct GameToken { + #[storage_field] + psp22: psp22::Data, + #[storage_field] + metadata: metadata::Data, + access_control: AccessControlRef, + } + + impl PSP22 for GameToken {} + + impl PSP22Metadata for GameToken {} + + impl PSP22Mintable for GameToken { + #[ink(message)] + fn mint(&mut self, account: AccountId, amount: Balance) -> Result<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + let required_role = Role::Minter(this); + + self.check_role(caller, required_role)?; + self._mint_to(account, amount) + } + } + + impl PSP22Burnable for GameToken { + #[ink(message)] + fn burn(&mut self, account: AccountId, amount: Balance) -> Result<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + let required_role = Role::Burner(this); + + self.check_role(caller, required_role)?; + self._burn_from(account, amount) + } + } + + // emit events + // https://github.com/w3f/PSPs/blob/master/PSPs/psp-22.md + impl Internal for GameToken { + fn _emit_transfer_event( + &self, + _from: Option, + _to: Option, + _amount: Balance, + ) { + GameToken::emit_event( + self.env(), + Event::Transfer(Transfer { + from: _from, + to: _to, + value: _amount, + }), + ); + } + + fn _emit_approval_event(&self, _owner: AccountId, _spender: AccountId, _amount: Balance) { + GameToken::emit_event( + self.env(), + Event::Approval(Approval { + owner: _owner, + spender: _spender, + value: _amount, + }), + ); + } + } + + /// Result type + pub type Result = core::result::Result; + /// Event type + pub type Event = ::Type; + + /// Event emitted when a token transfer occurs. + #[ink(event)] + #[derive(Debug)] + pub struct Transfer { + #[ink(topic)] + pub from: Option, + #[ink(topic)] + pub to: Option, + pub value: Balance, + } + + /// Event emitted when an approval occurs that `spender` is allowed to withdraw + /// up to the amount of `value` tokens from `owner`. + #[ink(event)] + #[derive(Debug)] + pub struct Approval { + #[ink(topic)] + owner: AccountId, + #[ink(topic)] + spender: AccountId, + value: Balance, + } + + impl GameToken { + /// Creates a new game token with the specified initial supply. + /// + /// The token will have its name and symbol set in metadata to the specified values. + /// Decimals are fixed at 18. + /// + /// Will revert if called from an account without a proper role + #[ink(constructor)] + pub fn new(name: String, symbol: String) -> Self { + let caller = Self::env().caller(); + let code_hash = Self::env() + .own_code_hash() + .expect("Called new on a contract with no code hash"); + + let required_role = Role::Initializer(code_hash); + let access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); + let access_control = AccessControlRef::from_account_id(access_control); + + if access_control.has_role(caller, required_role) { + let metadata = metadata::Data { + name: Some(name.into()), + symbol: Some(symbol.into()), + decimals: 12, + ..Default::default() + }; + + Self { + metadata, + access_control, + psp22: psp22::Data::default(), + } + } else { + panic!("Caller is not allowed to initialize this contract"); + } + } + + pub fn emit_event>(emitter: EE, event: Event) { + emitter.emit_event(event); + } + + /// Terminates the contract. + /// + /// can only be called by the contract's Owner + #[ink(message, selector = 7)] + pub fn terminate(&mut self) -> Result<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + let required_role = Role::Owner(this); + + self.check_role(caller, required_role)?; + self.env().terminate_contract(caller) + } + + /// Returns the contract's access control contract address + #[ink(message, selector = 8)] + pub fn access_control(&self) -> AccountId { + self.access_control.to_account_id() + } + + fn check_role(&self, account: AccountId, role: Role) -> Result<()> { + if self.access_control.has_role(account, role) { + Ok(()) + } else { + Err(PSP22Error::Custom(format!("MissingRole:{:?}", role).into())) + } + } + + /// Sets new access control contract address + /// + /// Can only be called by the contract's Owner + #[ink(message, selector = 9)] + pub fn set_access_control(&mut self, access_control: AccountId) -> Result<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + let required_role = Role::Owner(this); + + self.check_role(caller, required_role)?; + self.access_control = AccessControlRef::from_account_id(access_control); + Ok(()) + } + + /// Returns own code hash + #[ink(message, selector = 10)] + pub fn code_hash(&self) -> Result { + Self::env().own_code_hash().map_err(|why| { + PSP22Error::Custom(format!("Can't retrieve own code hash: {:?}", why).into()) + }) + } + } +} diff --git a/contracts/marketplace/Cargo.lock b/contracts/marketplace/Cargo.lock new file mode 100644 index 0000000000..cf734c565d --- /dev/null +++ b/contracts/marketplace/Cargo.lock @@ -0,0 +1,1229 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "access_control" +version = "0.2.0" +dependencies = [ + "ink", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "array-init" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfb6d71005dc22a708c7496eee5c8dc0300ee47355de6256c3b35b12b5fef596" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +dependencies = [ + "crypto-mac", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "blake2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +dependencies = [ + "digest 0.10.3", +] + +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byte-slice-cast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" + +[[package]] +name = "camino" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "081e3f0755c1f380c2d010481b6fa2e02973586d5f2b24eebb7a2a1d98b143d8" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "semver-parser", + "serde", + "serde_json", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const_format" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "cpufeatures" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "either" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "game_token" +version = "2.1.0" +dependencies = [ + "access_control", + "ink", + "openbrush", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76b4fc39f3bcab7e042becf5c9dbbebc179fff64924025753a5fafa016e8576d" +dependencies = [ + "derive_more", + "ink_env", + "ink_macro", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage", + "parity-scale-codec", +] + +[[package]] +name = "ink_allocator" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a54dbbaffb0f97bcae062e628dcdc9da4d3c9044f5a53fb2715a328b07221631" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_codegen" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "283b022679ef75898db5c28b89388412d93f91cea4f0b1443426901cb391b079" +dependencies = [ + "blake2 0.10.4", + "derive_more", + "either", + "env_logger", + "heck 0.4.0", + "impl-serde", + "ink_ir", + "ink_primitives", + "itertools", + "log", + "parity-scale-codec", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", +] + +[[package]] +name = "ink_engine" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daed9b710cba6f50f1fa0372a7e8a47a35624d84af4ef2c3a8d34d4e96202d1c" +dependencies = [ + "blake2 0.10.4", + "derive_more", + "ink_primitives", + "parity-scale-codec", + "secp256k1", + "sha2", + "sha3", +] + +[[package]] +name = "ink_env" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41c6a3f4e740e27449f805ed47f536a35fb254ebcd03d2480014589331cda3e" +dependencies = [ + "arrayref", + "blake2 0.10.4", + "cfg-if", + "derive_more", + "ink_allocator", + "ink_engine", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "num-traits", + "parity-scale-codec", + "paste", + "rlibc", + "scale-info", + "secp256k1", + "sha2", + "sha3", + "static_assertions", +] + +[[package]] +name = "ink_ir" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "946b940d26e69ded558daafead0979f25f2e9d7e2cf86027f250c3942aa4d0f1" +dependencies = [ + "blake2 0.10.4", + "either", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink_macro" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6642450e6169cfaf81717b1d62b2abae48a6b41d3f70f885b6aeff7bb14ea96b" +dependencies = [ + "ink_codegen", + "ink_ir", + "ink_primitives", + "parity-scale-codec", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "ink_metadata" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfcfa666ada5729c7e4d3d986cd196365a2c469459fced4fa31dc6ad87c4d8f" +dependencies = [ + "derive_more", + "impl-serde", + "ink_prelude", + "ink_primitives", + "scale-info", + "serde", +] + +[[package]] +name = "ink_prelude" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8080235e5ae921975c2c7772fe9959e1b3c92b4d5a1afcfe104f93fb79aa268" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_primitives" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b3f711d857d2de7c08158369cc32a762833ac211a00aac7931992094e25741" +dependencies = [ + "derive_more", + "ink_prelude", + "parity-scale-codec", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "ink_storage" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2872a5ea4559433381b2d82b08b6acd33ce934b07a22ce951c6f00483680c950" +dependencies = [ + "array-init", + "cfg-if", + "derive_more", + "ink_env", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ink_storage_traits" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c90e11b60233ae5ab877854739da2c380a337cb31b3900cb50328821c0381b6" +dependencies = [ + "ink_metadata", + "ink_prelude", + "ink_primitives", + "parity-scale-codec", + "scale-info", + "syn", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" + +[[package]] +name = "keccak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "marketplace" +version = "0.1.0" +dependencies = [ + "access_control", + "game_token", + "ink", + "openbrush", + "parity-scale-codec", + "scale-info", + "ticket_token", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "obce" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "ink", + "ink_engine", + "obce-macro", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "obce-codegen" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "blake2 0.10.4", + "itertools", + "proc-macro2", + "quote", + "syn", + "tuple", +] + +[[package]] +name = "obce-macro" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "obce-codegen", + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openbrush" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "ink", + "openbrush_contracts", + "openbrush_lang", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "openbrush_contracts" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "ink", + "openbrush_lang", + "pallet-assets-chain-extension", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "openbrush_lang" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "const_format", + "ink", + "openbrush_lang_macro", + "parity-scale-codec", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "openbrush_lang_codegen" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "blake2 0.9.2", + "cargo_metadata", + "fs2", + "heck 0.3.3", + "ink_ir", + "ink_primitives", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", + "synstructure", + "unwrap", +] + +[[package]] +name = "openbrush_lang_macro" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "openbrush_lang_codegen", + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "pallet-assets-chain-extension" +version = "0.1.1" +source = "git+https://github.com/727-ventures/pallet-assets-chain-extension?branch=polkadot-v0.9.37#f8ea374186df2a3fc139c8d585719e58d83df582" +dependencies = [ + "ink", + "obce", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "parity-scale-codec" +version = "3.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9182e4a71cae089267ab03e67c99368db7cd877baf50f931e5d6d4b71e195ac0" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "paste" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "rlibc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" + +[[package]] +name = "rustix" +version = "0.36.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" + +[[package]] +name = "scale-info" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "secp256k1" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642a62736682fdd8c71da0eb273e453c8ac74e33b9fb310e22ba5b03ec7651ff" +dependencies = [ + "cc", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + +[[package]] +name = "sha3" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881bf8156c87b6301fc5ca6b27f11eeb2761224c7081e69b409d5a1951a70c86" +dependencies = [ + "digest 0.10.3", + "keccak", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ticket_token" +version = "2.1.0" +dependencies = [ + "access_control", + "ink", + "openbrush", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "tuple" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39a40ba241047e1174c927dc5f61c141a166b938d61a2ff61838441368cc7d0e" +dependencies = [ + "num-traits", + "serde", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "ucd-trie" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" + +[[package]] +name = "unicode-ident" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" + +[[package]] +name = "unicode-segmentation" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" + +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + +[[package]] +name = "unwrap" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e33648dd74328e622c7be51f3b40a303c63f93e6fa5f08778b6203a4c25c20f" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "wyz" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +dependencies = [ + "tap", +] + +[[package]] +name = "xxhash-rust" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735a71d46c4d68d71d4b24d03fdc2b98e38cea81730595801db779c04fe80d70" diff --git a/contracts/marketplace/Cargo.toml b/contracts/marketplace/Cargo.toml new file mode 100644 index 0000000000..d399997380 --- /dev/null +++ b/contracts/marketplace/Cargo.toml @@ -0,0 +1,43 @@ +[package] +name = "marketplace" +version = "0.1.0" +authors = ["Cardinal Cryptography"] +edition = "2021" +license = "Apache 2.0" + +[dependencies] +ink = { version = "=4.0.1", default-features = false } +openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts/", tag = "3.0.0", default-features = false, features = ["psp22"] } + +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } + +access_control = { path = "../access_control", default-features = false, features = ["ink-as-dependency"] } +game_token = { path = "../game_token", default-features = false, features = ["ink-as-dependency"] } +ticket_token = { path = "../ticket_token", default-features = false, features = ["ink-as-dependency"] } + +[lib] +name = "marketplace" +path = "lib.rs" +crate-type = [ + "cdylib", + "rlib", +] + +[features] +default = ["std"] +std = [ + "ink/std", + "openbrush/std", + "scale-info", + "scale-info/std", + "scale/std", + "openbrush/std", + "access_control/std", + "game_token/std", + "ticket_token/std" +] +ink-as-dependency = [] + +[profile.dev] +codegen-units = 16 diff --git a/contracts/marketplace/lib.rs b/contracts/marketplace/lib.rs new file mode 100644 index 0000000000..c71483b0bd --- /dev/null +++ b/contracts/marketplace/lib.rs @@ -0,0 +1,309 @@ +//! Implements a Dutch auction of one token for another. +//! +//! This contract will auction off units of one token (referred to as `tickets`), accepting payment +//! in another token (`reward token`). The auction keeps track of the average price over all sales +//! made (before the first auction, this number is set on contract initialization) and starts off +//! the auction at `average_price() * sale_multiplier()`. Afterwards the price decreases linearly +//! with each block until reaching `min_price()` after `auction_length()` blocks, at which point +//! the price stays at that level indefinitely. +//! +//! A user can use the `buy(max_price)` call (after issuing a `psp22::approve` for the appropriate +//! amount to the reward token contract) to accept the current price and buy one ticket. This +//! transaction will fail if the price increased to above `max_price`, for example, due to a ticket +//! getting sold. +//! +//! The admin of the contract is expected to transfer a number of reward tokens for sale +//! into this contract and then call `reset()` in the same transaction to begin the auction. Calling +//! `reset()` if an auction is already in progress. + +#![cfg_attr(not(feature = "std"), no_std)] +#![feature(min_specialization)] +#![allow(clippy::let_unit_value)] + +pub const RESET_SELECTOR: [u8; 4] = [0x00, 0x00, 0x00, 0x01]; + +#[ink::contract] +pub mod marketplace { + use access_control::{roles::Role, AccessControlRef, ACCESS_CONTROL_PUBKEY}; + use ink::{ + codegen::EmitEvent, + env::call::FromAccountId, + prelude::{format, string::String, vec}, + reflect::ContractEventBase, + LangError, + }; + use openbrush::contracts::psp22::{ + extensions::burnable::PSP22BurnableRef, PSP22Error, PSP22Ref, + }; + + type Event = ::Type; + + #[ink(storage)] + pub struct Marketplace { + total_proceeds: Balance, + tickets_sold: Balance, + min_price: Balance, + current_start_block: BlockNumber, + auction_length: BlockNumber, + sale_multiplier: Balance, + ticket_token: AccountId, + reward_token: AccountId, + access_control: AccessControlRef, + } + + #[derive(Eq, PartialEq, Debug, scale::Encode, scale::Decode)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + pub enum Error { + MissingRole(Role), + ContractCall(String), + PSP22TokenCall(PSP22Error), + MaxPriceExceeded, + MarketplaceEmpty, + } + + #[ink(event)] + #[derive(Clone, Eq, PartialEq, Debug)] + pub struct Bought { + #[ink(topic)] + pub account_id: AccountId, + pub price: Balance, + } + + #[ink(event)] + #[derive(Clone, Eq, PartialEq, Debug)] + pub struct Reset; + + impl From for Error { + fn from(inner: ink::env::Error) -> Self { + Error::ContractCall(format!("{:?}", inner)) + } + } + + impl From for Error { + fn from(inner: PSP22Error) -> Self { + Error::PSP22TokenCall(inner) + } + } + + impl From for Error { + fn from(inner: LangError) -> Self { + Error::ContractCall(format!("{:?}", inner)) + } + } + + impl Marketplace { + #[ink(constructor)] + pub fn new( + ticket_token: AccountId, + reward_token: AccountId, + starting_price: Balance, + min_price: Balance, + sale_multiplier: Balance, + auction_length: BlockNumber, + ) -> Self { + let access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); + let access_control = AccessControlRef::from_account_id(access_control); + if access_control.has_role(Self::env().caller(), Self::initializer()) { + Marketplace { + ticket_token, + reward_token, + min_price, + sale_multiplier, + auction_length, + current_start_block: Self::env().block_number(), + total_proceeds: starting_price.saturating_div(sale_multiplier), + tickets_sold: 1, + access_control, + } + } else { + panic!("Caller is not allowed to initialize this contract"); + } + } + + /// The length of each auction of a single ticket in blocks. + /// + /// The contract will decrease the price linearly from `average_price() * sale_multiplier()` + /// to `min_price()` over this period. The auction doesn't end after the period elapses - + /// the ticket remains available for purchase at `min_price()`. + #[ink(message)] + pub fn auction_length(&self) -> BlockNumber { + self.auction_length + } + + /// The block at which the auction of the current ticket started. + #[ink(message)] + pub fn current_start_block(&self) -> BlockNumber { + self.current_start_block + } + + /// The price the contract would charge when buying at the current block. + #[ink(message)] + pub fn price(&self) -> Balance { + self.current_price() + } + + /// The average price over all sales the contract made. + #[ink(message)] + pub fn average_price(&self) -> Balance { + self.total_proceeds.saturating_div(self.tickets_sold) + } + + /// The multiplier applied to the average price after each sale. + /// + /// The contract tracks the average price of all sold tickets and starts off each new + /// auction at `price() = average_price() * sale_multiplier()`. + #[ink(message)] + pub fn sale_multiplier(&self) -> Balance { + self.sale_multiplier + } + + /// Number of tickets available for sale. + /// + /// The tickets will be auctioned off one by one. + #[ink(message)] + pub fn available_tickets(&self) -> Balance { + self.ticket_balance() + } + + /// The minimal price the contract allows. + #[ink(message)] + pub fn min_price(&self) -> Balance { + self.min_price + } + + /// Update the minimal price. + #[ink(message)] + pub fn set_min_price(&mut self, value: Balance) -> Result<(), Error> { + self.ensure_role(self.admin())?; + + self.min_price = value; + + Ok(()) + } + + /// Address of the reward token contract this contract will accept as payment. + #[ink(message)] + pub fn reward_token(&self) -> AccountId { + self.reward_token + } + + /// Address of the ticket token contract this contract will auction off. + #[ink(message)] + pub fn ticket_token(&self) -> AccountId { + self.ticket_token + } + + /// Buy one ticket at the current_price. + /// + /// The caller should make an approval for at least `price()` reward tokens to make sure the + /// call will succeed. The caller can specify a `max_price` - the call will fail if the + /// current price is greater than that. + #[ink(message)] + pub fn buy(&mut self, max_price: Option) -> Result<(), Error> { + if self.ticket_balance() == 0 { + return Err(Error::MarketplaceEmpty); + } + + let price = self.current_price(); + if let Some(max_price) = max_price { + if price > max_price { + return Err(Error::MaxPriceExceeded); + } + } + + let account_id = self.env().caller(); + + self.take_payment(account_id, price)?; + self.give_ticket(account_id)?; + + self.total_proceeds = self.total_proceeds.saturating_add(price); + self.tickets_sold = self.tickets_sold.saturating_add(1); + self.current_start_block = self.env().block_number(); + Self::emit_event(self.env(), Event::Bought(Bought { price, account_id })); + + Ok(()) + } + + /// Re-start the auction from the current block. + /// + /// Note that this will keep the average estimate from previous auctions. + /// + /// Requires `Role::Admin`. + #[ink(message, selector = 0x00000001)] + pub fn reset(&mut self) -> Result<(), Error> { + self.ensure_role(self.admin())?; + + self.current_start_block = self.env().block_number(); + Self::emit_event(self.env(), Event::Reset(Reset {})); + + Ok(()) + } + + /// Terminates the contract + /// + /// Should only be called by the contract Owner + #[ink(message)] + pub fn terminate(&mut self) -> Result<(), Error> { + let caller = self.env().caller(); + let this = self.env().account_id(); + self.ensure_role(Role::Owner(this))?; + self.env().terminate_contract(caller) + } + + fn current_price(&self) -> Balance { + let block = self.env().block_number(); + let elapsed = block.saturating_sub(self.current_start_block); + self.average_price() + .saturating_mul(self.sale_multiplier) + .saturating_sub(self.per_block_reduction().saturating_mul(elapsed.into())) + .max(self.min_price) + } + + fn per_block_reduction(&self) -> Balance { + self.average_price() + .saturating_div(self.auction_length.into()) + .max(1u128) + } + + fn take_payment(&self, from: AccountId, amount: Balance) -> Result<(), Error> { + PSP22BurnableRef::burn_builder(&self.reward_token, from, amount) + .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) + .invoke()?; + + Ok(()) + } + + fn give_ticket(&self, to: AccountId) -> Result<(), Error> { + PSP22Ref::transfer(&self.ticket_token, to, 1, vec![])?; + + Ok(()) + } + + fn ticket_balance(&self) -> Balance { + PSP22Ref::balance_of(&self.ticket_token, self.env().account_id()) + } + + fn ensure_role(&self, role: Role) -> Result<(), Error> { + if self.access_control.has_role(self.env().caller(), role) { + Ok(()) + } else { + Err(Error::MissingRole(role)) + } + } + + fn initializer() -> Role { + let code_hash = Self::env() + .own_code_hash() + .expect("Failure to retrieve code hash."); + Role::Initializer(code_hash) + } + + fn admin(&self) -> Role { + Role::Admin(self.env().account_id()) + } + + fn emit_event>(emitter: EE, event: Event) { + emitter.emit_event(event) + } + } +} diff --git a/contracts/rust-toolchain b/contracts/rust-toolchain deleted file mode 100644 index 6680fdbf12..0000000000 --- a/contracts/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.65.0 \ No newline at end of file diff --git a/contracts/scripts/LICENSE b/contracts/scripts/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/contracts/scripts/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/contracts/scripts/clean.sh b/contracts/scripts/clean.sh new file mode 100755 index 0000000000..5253f0f390 --- /dev/null +++ b/contracts/scripts/clean.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +set -euo pipefail + +# --- FUNCTIONS + +function terminate_contract { + local contract_name=$1 + local contract_dir=$2 + local contract_address=$(get_address $contract_name) + local tmp_output_file="tmp_terminate_contract_output" + + cd "$CONTRACTS_PATH"/"$contract_dir" + # When 'ContractNotFound' occurs, ignore it and continue + set +e + cargo contract call --url "$NODE" --contract $contract_address --message terminate --suri "$AUTHORITY_SEED" --skip-confirm 2>&1 | tee $tmp_output_file + if [ $? -ne 0 ]; then + grep -q "ContractNotFound" $tmp_output_file + if [ $? -ne 0 ]; then + echo "** Exiting with error code 1. Error is different than 'ContractNotFound'" + exit 1 + else + echo "** Ignoring 'ContractNotFound' error." + fi + fi + rm -f $tmp_output_file + set -e +} + +function get_address { + local contract_name=$1 + cat "$CONTRACTS_PATH"/addresses.json | jq --raw-output ".$contract_name" +} + +function remove_contract_code { + local code_hash=$(cat "$CONTRACTS_PATH"/addresses.json | jq --raw-output ".$1") + + if [ "None" == "$(docker run --network host -e RUST_LOG=info "$CLIAIN_IMAGE" --seed "$AUTHORITY_SEED" --node "$NODE" contract-owner-info --code-hash "$code_hash")" ]; then + echo "Contract code does not exist on chain." + else + echo "Contract code exists, removing" + + local tmp_output_file="tmp_remove_contract_code" + set +e + docker rm -f remove_contract_code + timeout -k 1m 1m bash -c "docker run --network host -e RUST_LOG=info \"${CLIAIN_IMAGE}\" --seed \"$AUTHORITY_SEED\" --node \"$NODE\" contract-remove-code --code-hash $code_hash 2>&1 | tee $tmp_output_file" + grep -q "CodeNotFound\|Received ContractCodeRemoved" $tmp_output_file + if [ $? -ne 0 ]; then + echo "** Exiting with error code 1. Process has been killed after 1m and 'CodeNotFound' error has not been found in the output" + exit 1 + else + echo "** Ignoring 'CodeNotFound' error or 'Received ContractCodeRemoved' message" + fi + rm -f $tmp_output_file + set -e + + fi +} + +# --- GLOBAL CONSTANTS + +CONTRACTS_PATH=$(pwd)/contracts +CLIAIN_IMAGE=public.ecr.aws/p6e8q1z1/cliain:latest + +# --- CLEAN BUTTON CONTRACT + +terminate_contract early_bird_special button +terminate_contract early_bird_special_marketplace marketplace +terminate_contract early_bird_special_ticket ticket_token +terminate_contract early_bird_special_token game_token +echo "succesfully terminated early_bird_special" + +terminate_contract back_to_the_future button +terminate_contract back_to_the_future_ticket ticket_token +terminate_contract back_to_the_future_token game_token +terminate_contract back_to_the_future_marketplace marketplace +echo "succesfully terminated back_to_the_future" + +terminate_contract the_pressiah_cometh button +terminate_contract the_pressiah_cometh_ticket ticket_token +terminate_contract the_pressiah_cometh_token game_token +terminate_contract the_pressiah_cometh_marketplace marketplace +echo "succesfully terminated the_pressiah_cometh" + +remove_contract_code button_code_hash +remove_contract_code ticket_token_code_hash +remove_contract_code game_token_code_hash +remove_contract_code marketplace_code_hash +echo "succesfully removed code hashes" + +terminate_contract simple_dex simple_dex +remove_contract_code simple_dex_code_hash +echo "succesfully terminated and removed simple_dex" + +terminate_contract wrapped_azero wrapped_azero +remove_contract_code wrapped_azero_code_hash +echo "succesfully terminated and removed wrapped_azero" + +# remove access control as last +terminate_contract access_control access_control +remove_contract_code access_control_code_hash +echo "succesfully terminated and removed AccessControl" + +exit $? diff --git a/contracts/scripts/deploy.sh b/contracts/scripts/deploy.sh new file mode 100755 index 0000000000..2f4bed7d99 --- /dev/null +++ b/contracts/scripts/deploy.sh @@ -0,0 +1,411 @@ +#!/bin/bash + +set -euox pipefail + +# --- FUNCTIONS + +function run_ink_builder() { + docker start ink_builder || docker run \ + --network host \ + -v "${PWD}:/code" \ + -u "$(id -u):$(id -g)" \ + --name ink_builder \ + --platform linux/amd64 \ + --detach \ + --rm public.ecr.aws/p6e8q1z1/ink-dev:1.0.0 sleep 1d +} + +function ink_build() { + contract_dir=$(basename "${PWD}") + + docker exec \ + -u "$(id -u):$(id -g)" \ + -w "/code/contracts/$contract_dir" \ + ink_builder "$@" +} + +function cargo_contract() { + ink_build cargo contract "$@" +} + +function upload_contract { + + local __resultvar=$1 + local contract_name=$2 + + cd "$CONTRACTS_PATH"/$contract_name + + # --- REPLACE THE ADDRESS OF ACCESS CONTROL CONTRACT + + # replace address placeholder with the on-chain address of the AccessControl contract + link_bytecode $contract_name 4465614444656144446561444465614444656144446561444465614444656144 $ACCESS_CONTROL_PUBKEY + # remove just in case + rm target/ink/$contract_name.wasm + # NOTE : here we go from hex to binary using a nodejs cli tool + # availiable from https://github.com/fbielejec/polkadot-cljs + node ../scripts/hex-to-wasm.js target/ink/$contract_name.contract target/ink/$contract_name.wasm + + # --- UPLOAD CONTRACT CODE + + code_hash=$(cargo_contract upload --url "$NODE" --suri "$AUTHORITY_SEED" --output-json | jq -r '.code_hash') + + echo "$contract_name code hash: $code_hash" + + cd "$CONTRACTS_PATH"/access_control + + # Set the initializer of the contract + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Initializer('$code_hash')' --suri "$AUTHORITY_SEED" --skip-confirm + + eval $__resultvar="'$code_hash'" +} + +function deploy_ticket_token { + + local __resultvar=$1 + local token_name=$2 + local token_symbol=$3 + local salt=$4 + + # --- CREATE AN INSTANCE OF THE TICKET CONTRACT + + cd "$CONTRACTS_PATH"/ticket_token + + local contract_address=$(cargo_contract instantiate --url "$NODE" --constructor new --args \"$token_name\" \"$token_symbol\" "$TICKET_BALANCE" --suri "$AUTHORITY_SEED" --salt "$salt" --skip-confirm --output-json) + local contract_address=$(echo "$contract_address" | jq -r '.contract') + + echo "$token_symbol ticket contract instance address: $contract_address" + + # --- GRANT PRIVILEGES ON THE TICKET CONTRACT + + cd "$CONTRACTS_PATH"/access_control + + # set the admin and the owner of the contract instance + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Owner('"$contract_address"')' --suri "$AUTHORITY_SEED" --skip-confirm + + eval $__resultvar="'$contract_address'" +} + +function deploy_game_token { + + local __resultvar=$1 + local token_name=$2 + local token_symbol=$3 + local salt=$4 + + # --- CREATE AN INSTANCE OF THE TOKEN CONTRACT + + cd "$CONTRACTS_PATH"/game_token + + local contract_address=$(cargo_contract instantiate --url "$NODE" --constructor new --args \"$token_name\" \"$token_symbol\" --suri "$AUTHORITY_SEED" --salt "$salt" --skip-confirm --output-json) + local contract_address=$(echo "$contract_address" | jq -r '.contract') + + echo "$token_symbol token contract instance address: $contract_address" + + # --- GRANT PRIVILEGES ON THE TOKEN CONTRACT + + cd "$CONTRACTS_PATH"/access_control + + # set the owner of the contract instance + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Owner('"$contract_address"')' --suri "$AUTHORITY_SEED" --skip-confirm + + eval "$__resultvar='$contract_address'" +} + +function deploy_button_game { + + local __resultvar=$1 + local game_type=$2 + local ticket_token=$3 + local game_token=$4 + local marketplace=$5 + local salt=$6 + + # --- CREATE AN INSTANCE OF THE CONTRACT + + cd "$CONTRACTS_PATH"/button + + local contract_address=$(cargo_contract instantiate --url "$NODE" --constructor new --args "$ticket_token" "$game_token" "$marketplace" "$LIFETIME" "$game_type" --suri "$AUTHORITY_SEED" --salt "$salt" --skip-confirm --output-json) + local contract_address=$(echo "$contract_address" | jq -r '.contract') + echo "$game_type contract instance address: $contract_address" + + # --- GRANT PRIVILEGES ON THE CONTRACT + + cd "$CONTRACTS_PATH"/access_control + + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Owner('"$contract_address"')' --suri "$AUTHORITY_SEED" --skip-confirm + if [ "$ENV_NAME" = "dev" ]; then + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Minter('"$game_token"')' --suri "$AUTHORITY_SEED" --skip-confirm + fi + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$contract_address" 'Admin('"$marketplace"')' --suri "$AUTHORITY_SEED" --skip-confirm + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$contract_address" 'Minter('"$game_token"')' --suri "$AUTHORITY_SEED" --skip-confirm + + eval "$__resultvar='$contract_address'" +} + +function deploy_marketplace { + local __resultvar=$1 + local code_hash=$2 + local contract_name=$3 + local salt=$4 + local ticket_token=$5 + local game_token=$6 + + # --- CREATE AN INSTANCE OF THE CONTRACT + + cd "$CONTRACTS_PATH"/marketplace + + local blocks_per_hour=3600 + local initial_price="$INITIAL_PRICE" + local min_price=1 + local sale_price_multiplier=2 + + local contract_address + contract_address=$(cargo_contract instantiate --url "$NODE" --constructor new \ + --args "$ticket_token" "$game_token" "$initial_price" "$min_price" "$sale_price_multiplier" "$blocks_per_hour" \ + --suri "$AUTHORITY_SEED" --salt "$salt" --skip-confirm --output-json) + contract_address=$(echo "$contract_address" | jq -r '.contract') + + echo "Marketplace for $contract_name instance address: $contract_address" + + # --- GRANT PRIVILEGES ON THE CONTRACT + + cd "$CONTRACTS_PATH"/access_control + + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Owner('"$contract_address"')' --suri "$AUTHORITY_SEED" --skip-confirm + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Admin('"$contract_address"')' --suri "$AUTHORITY_SEED" --skip-confirm + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$contract_address" 'Burner('"$game_token"')' --suri "$AUTHORITY_SEED" --skip-confirm + + eval "$__resultvar='$contract_address'" +} + +function deploy_simple_dex { + local __resultvar=$1 + + # --- CREATE AN INSTANCE OF THE CONTRACT + + cd "$CONTRACTS_PATH"/simple_dex + + local contract_address + contract_address=$(cargo_contract instantiate --url "$NODE" --constructor new --suri "$AUTHORITY_SEED" --skip-confirm --output-json) + contract_address=$(echo "$contract_address" | jq -r '.contract') + + echo "Simple dex contract instance address: $contract_address" + + # --- GRANT PRIVILEGES ON THE CONTRACT + + cd "$CONTRACTS_PATH"/access_control + + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Owner('"$contract_address"')' --suri "$AUTHORITY_SEED" --skip-confirm + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Admin('"$contract_address"')' --suri "$AUTHORITY_SEED" --skip-confirm + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'LiquidityProvider('"$contract_address"')' --suri "$AUTHORITY_SEED" --skip-confirm + + eval "$__resultvar='$contract_address'" +} + +function whitelist_swap_pair() { + local from_address=$1 + local to_address=$2 + + cd "$CONTRACTS_PATH"/simple_dex + + cargo_contract call --url "$NODE" --contract "$SIMPLE_DEX" --message add_swap_pair --args "$from_address" "$to_address" --suri "$AUTHORITY_SEED" --skip-confirm +} + +function deploy_wrapped_azero { + local __resultvar=$1 + + # --- CREATE AN INSTANCE OF THE CONTRACT + + cd "$CONTRACTS_PATH"/wrapped_azero + + local contract_address + contract_address=$(cargo_contract instantiate --url "$NODE" --constructor new --suri "$AUTHORITY_SEED" --skip-confirm --output-json) + contract_address=$(echo "$contract_address" | jq -r '.contract') + + echo "wrapped Azero contract instance address: $contract_address" + + # --- GRANT PRIVILEGES ON THE CONTRACT + + cd "$CONTRACTS_PATH"/access_control + + cargo_contract call --url "$NODE" --contract "$ACCESS_CONTROL" --message grant_role --args "$AUTHORITY" 'Owner('"$contract_address"')' --suri "$AUTHORITY_SEED" --skip-confirm + + eval "$__resultvar='$contract_address'" +} + +function link_bytecode() { + local contract=$1 + local placeholder=$2 + local replacement=$3 + + sed -i 's/'"$placeholder"'/'"$replacement"'/' "target/ink/$contract.contract" +} + +# --- GLOBAL CONSTANTS + +NODE_IMAGE=public.ecr.aws/p6e8q1z1/aleph-node:latest + +CONTRACTS_PATH=$(pwd)/contracts + +# --- COMPILE CONTRACTS + +run_ink_builder + +cd "$CONTRACTS_PATH"/access_control +ink_build rustup target add wasm32-unknown-unknown +ink_build rustup component add rust-src +cargo_contract build --release + +cd "$CONTRACTS_PATH"/ticket_token +cargo_contract build --release + +cd "$CONTRACTS_PATH"/game_token +cargo_contract build --release + +cd "$CONTRACTS_PATH"/button +cargo_contract build --release + +cd "$CONTRACTS_PATH"/marketplace +cargo_contract build --release + +cd "$CONTRACTS_PATH"/simple_dex +cargo_contract build --release + +cd "$CONTRACTS_PATH"/wrapped_azero +cargo_contract build --release + +# # --- DEPLOY ACCESS CONTROL CONTRACT + +cd "$CONTRACTS_PATH"/access_control + +ACCESS_CONTROL_CODE_HASH=$(cargo_contract upload --url "$NODE" --suri "$AUTHORITY_SEED") +ACCESS_CONTROL_CODE_HASH=$(echo "$ACCESS_CONTROL_CODE_HASH" | grep hash | tail -1 | cut -c 14-) +ACCESS_CONTROL=$(cargo_contract instantiate --url "$NODE" --constructor new --suri "$AUTHORITY_SEED" --skip-confirm --output-json) +ACCESS_CONTROL=$(echo "$ACCESS_CONTROL" | jq -r '.contract') +ACCESS_CONTROL_PUBKEY=$(docker run --rm --entrypoint "/bin/sh" "${NODE_IMAGE}" -c "aleph-node key inspect $ACCESS_CONTROL" | grep hex | cut -c 23- | cut -c 3-) + +echo "access control contract address: $ACCESS_CONTROL" +echo "access control contract public key \(hex\): $ACCESS_CONTROL_PUBKEY" + +# --- UPLOAD CONTRACTS CODES + +upload_contract TICKET_TOKEN_CODE_HASH ticket_token +upload_contract GAME_TOKEN_CODE_HASH game_token +upload_contract BUTTON_CODE_HASH button +upload_contract MARKETPLACE_CODE_HASH marketplace +upload_contract SIMPLE_DEX_CODE_HASH simple_dex +upload_contract WRAPPED_AZERO_CODE_HASH wrapped_azero + +start=$(date +%s.%N) + +# +# --- EARLY_BIRD_SPECIAL GAME +# +echo "Early Bird Special" + +salt="0x4561726C79426972645370656369616C" +deploy_ticket_token EARLY_BIRD_SPECIAL_TICKET early_bird_special_ticket EBST $salt +deploy_game_token EARLY_BIRD_SPECIAL_TOKEN Ubik UBI $salt +deploy_marketplace EARLY_BIRD_SPECIAL_MARKETPLACE "$MARKETPLACE_CODE_HASH" early_bird_special "$salt" "$EARLY_BIRD_SPECIAL_TICKET" "$EARLY_BIRD_SPECIAL_TOKEN" +deploy_button_game EARLY_BIRD_SPECIAL EarlyBirdSpecial "$EARLY_BIRD_SPECIAL_TICKET" "$EARLY_BIRD_SPECIAL_TOKEN" "$EARLY_BIRD_SPECIAL_MARKETPLACE" "$salt" + +# +# --- BACK_TO_THE_FUTURE GAME +# +echo "Back To The Future" + +salt="0x4261636B546F546865467574757265" +deploy_ticket_token BACK_TO_THE_FUTURE_TICKET back_to_the_future_ticket BTFT $salt +deploy_game_token BACK_TO_THE_FUTURE_TOKEN Cyberiad CYB $salt +deploy_marketplace BACK_TO_THE_FUTURE_MARKETPLACE "$MARKETPLACE_CODE_HASH" back_to_the_future "$salt" "$BACK_TO_THE_FUTURE_TICKET" "$BACK_TO_THE_FUTURE_TOKEN" +deploy_button_game BACK_TO_THE_FUTURE BackToTheFuture "$BACK_TO_THE_FUTURE_TICKET" "$BACK_TO_THE_FUTURE_TOKEN" "$BACK_TO_THE_FUTURE_MARKETPLACE" "$salt" + +# +# --- THE_PRESSIAH_COMETH GAME +# +echo "The Pressiah Cometh" + +salt="0x7468655F70726573736961685F636F6D657468" +deploy_ticket_token THE_PRESSIAH_COMETH_TICKET the_pressiah_cometh_ticket TPCT $salt +deploy_game_token THE_PRESSIAH_COMETH_TOKEN Lono LON $salt +deploy_marketplace THE_PRESSIAH_COMETH_MARKETPLACE "$MARKETPLACE_CODE_HASH" the_pressiah_cometh "$salt" "$THE_PRESSIAH_COMETH_TICKET" "$THE_PRESSIAH_COMETH_TOKEN" +deploy_button_game THE_PRESSIAH_COMETH ThePressiahCometh "$THE_PRESSIAH_COMETH_TICKET" "$THE_PRESSIAH_COMETH_TOKEN" "$THE_PRESSIAH_COMETH_MARKETPLACE" "$salt" + +# --- DEPLOY WRAPPED AZERO CONTRACT + +echo "Wrapped Azero" +deploy_wrapped_azero WRAPPED_AZERO + +# --- DEPLOY DEX CONTRACT + +echo "Simple Dex" +deploy_simple_dex SIMPLE_DEX + +echo "Whitelisting swap token pairs" +whitelist_swap_pair $EARLY_BIRD_SPECIAL_TOKEN $BACK_TO_THE_FUTURE_TOKEN +whitelist_swap_pair $EARLY_BIRD_SPECIAL_TOKEN $THE_PRESSIAH_COMETH_TOKEN +whitelist_swap_pair $EARLY_BIRD_SPECIAL_TOKEN $WRAPPED_AZERO + +whitelist_swap_pair $BACK_TO_THE_FUTURE_TOKEN $EARLY_BIRD_SPECIAL_TOKEN +whitelist_swap_pair $BACK_TO_THE_FUTURE_TOKEN $THE_PRESSIAH_COMETH_TOKEN +whitelist_swap_pair $BACK_TO_THE_FUTURE_TOKEN $WRAPPED_AZERO + +whitelist_swap_pair $THE_PRESSIAH_COMETH_TOKEN $EARLY_BIRD_SPECIAL_TOKEN +whitelist_swap_pair $THE_PRESSIAH_COMETH_TOKEN $BACK_TO_THE_FUTURE_TOKEN +whitelist_swap_pair $THE_PRESSIAH_COMETH_TOKEN $WRAPPED_AZERO + +# spit adresses to a JSON file +cd "$CONTRACTS_PATH" + +jq -n --arg early_bird_special "$EARLY_BIRD_SPECIAL" \ + --arg early_bird_special_marketplace "$EARLY_BIRD_SPECIAL_MARKETPLACE" \ + --arg early_bird_special_ticket "$EARLY_BIRD_SPECIAL_TICKET" \ + --arg early_bird_special_token "$EARLY_BIRD_SPECIAL_TOKEN" \ + --arg back_to_the_future "$BACK_TO_THE_FUTURE" \ + --arg back_to_the_future_ticket "$BACK_TO_THE_FUTURE_TICKET" \ + --arg back_to_the_future_token "$BACK_TO_THE_FUTURE_TOKEN" \ + --arg back_to_the_future_marketplace "$BACK_TO_THE_FUTURE_MARKETPLACE" \ + --arg the_pressiah_cometh "$THE_PRESSIAH_COMETH" \ + --arg the_pressiah_cometh_ticket "$THE_PRESSIAH_COMETH_TICKET" \ + --arg the_pressiah_cometh_token "$THE_PRESSIAH_COMETH_TOKEN" \ + --arg the_pressiah_cometh_marketplace "$THE_PRESSIAH_COMETH_MARKETPLACE" \ + --arg button_code_hash "$BUTTON_CODE_HASH" \ + --arg ticket_token_code_hash "$TICKET_TOKEN_CODE_HASH" \ + --arg game_token_code_hash "$GAME_TOKEN_CODE_HASH" \ + --arg marketplace_code_hash "$MARKETPLACE_CODE_HASH" \ + --arg access_control "$ACCESS_CONTROL" \ + --arg access_control_code_hash "$ACCESS_CONTROL_CODE_HASH" \ + --arg simple_dex "$SIMPLE_DEX" \ + --arg simple_dex_code_hash "$SIMPLE_DEX_CODE_HASH" \ + --arg wrapped_azero "$WRAPPED_AZERO" \ + --arg wrapped_azero_code_hash "$WRAPPED_AZERO_CODE_HASH" \ + '{ + early_bird_special: $early_bird_special, + early_bird_special_marketplace: $early_bird_special_marketplace, + early_bird_special_ticket: $early_bird_special_ticket, + early_bird_special_token: $early_bird_special_token, + back_to_the_future: $back_to_the_future, + back_to_the_future_ticket: $back_to_the_future_ticket, + back_to_the_future_token: $back_to_the_future_token, + back_to_the_future_marketplace: $back_to_the_future_marketplace, + the_pressiah_cometh: $the_pressiah_cometh, + the_pressiah_cometh_ticket: $the_pressiah_cometh_ticket, + the_pressiah_cometh_token: $the_pressiah_cometh_token, + the_pressiah_cometh_marketplace: $the_pressiah_cometh_marketplace, + access_control: $access_control, + simple_dex: $simple_dex, + wrapped_azero: $wrapped_azero, + button_code_hash: $button_code_hash, + ticket_token_code_hash: $ticket_token_code_hash, + game_token_code_hash: $game_token_code_hash, + marketplace_code_hash: $marketplace_code_hash, + access_control_code_hash: $access_control_code_hash, + simple_dex_code_hash: $simple_dex_code_hash, + wrapped_azero_code_hash: $wrapped_azero_code_hash + }' > addresses.json + +end=`date +%s.%N` +echo "Time elapsed: $( echo "$end - $start" | bc -l )" +cat addresses.json + +exit $? diff --git a/contracts/scripts/hex-to-wasm.js b/contracts/scripts/hex-to-wasm.js new file mode 100644 index 0000000000..9f472726f4 --- /dev/null +++ b/contracts/scripts/hex-to-wasm.js @@ -0,0 +1 @@ +!function(root,factory){if("object"==typeof exports&&"object"==typeof module)module.exports=factory();else if("function"==typeof define&&define.amd)define([],factory);else{var a=factory();for(var i in a)("object"==typeof exports?exports:root)[i]=a[i]}}(global,(()=>(()=>{var __webpack_modules__={5318:module=>{module.exports=function(obj){return obj&&obj.__esModule?obj:{default:obj}},module.exports.__esModule=!0,module.exports.default=module.exports},2207:function(module,__unused_webpack_exports,__webpack_require__){!function(module,exports){"use strict";function assert(val,msg){if(!val)throw new Error(msg||"Assertion failed")}function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}function BN(number,base,endian){if(BN.isBN(number))return number;this.negative=0,this.words=null,this.length=0,this.red=null,null!==number&&("le"!==base&&"be"!==base||(endian=base,base=10),this._init(number||0,base||10,endian||"be"))}var Buffer;"object"==typeof module?module.exports=BN:exports.BN=BN,BN.BN=BN,BN.wordSize=26;try{Buffer="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:__webpack_require__(4300).Buffer}catch(e){}function parseHex4Bits(string,index){var c=string.charCodeAt(index);return c>=48&&c<=57?c-48:c>=65&&c<=70?c-55:c>=97&&c<=102?c-87:void assert(!1,"Invalid character in "+string)}function parseHexByte(string,lowerBound,index){var r=parseHex4Bits(string,index);return index-1>=lowerBound&&(r|=parseHex4Bits(string,index-1)<<4),r}function parseBase(str,start,end,mul){for(var r=0,b=0,len=Math.min(str.length,end),i=start;i=49?c-49+10:c>=17?c-17+10:c,assert(c>=0&&b0?left:right},BN.min=function(left,right){return left.cmp(right)<0?left:right},BN.prototype._init=function(number,base,endian){if("number"==typeof number)return this._initNumber(number,base,endian);if("object"==typeof number)return this._initArray(number,base,endian);"hex"===base&&(base=16),assert(base===(0|base)&&base>=2&&base<=36);var start=0;"-"===(number=number.toString().replace(/\s+/g,""))[0]&&(start++,this.negative=1),start=0;i-=3)w=number[i]|number[i-1]<<8|number[i-2]<<16,this.words[j]|=w<>>26-off&67108863,(off+=24)>=26&&(off-=26,j++);else if("le"===endian)for(i=0,j=0;i>>26-off&67108863,(off+=24)>=26&&(off-=26,j++);return this._strip()},BN.prototype._parseHex=function(number,start,endian){this.length=Math.ceil((number.length-start)/6),this.words=new Array(this.length);for(var i=0;i=start;i-=2)w=parseHexByte(number,start,i)<=18?(off-=18,j+=1,this.words[j]|=w>>>26):off+=8;else for(i=(number.length-start)%2==0?start+1:start;i=18?(off-=18,j+=1,this.words[j]|=w>>>26):off+=8;this._strip()},BN.prototype._parseBase=function(number,base,start){this.words=[0],this.length=1;for(var limbLen=0,limbPow=1;limbPow<=67108863;limbPow*=base)limbLen++;limbLen--,limbPow=limbPow/base|0;for(var total=number.length-start,mod=total%limbLen,end=Math.min(total,total-mod)+start,word=0,i=start;i1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{BN.prototype[Symbol.for("nodejs.util.inspect.custom")]=inspect}catch(e){BN.prototype.inspect=inspect}else BN.prototype.inspect=inspect;function inspect(){return(this.red?""}var zeros=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],groupSizes=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],groupBases=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];BN.prototype.toString=function(base,padding){var out;if(padding=0|padding||1,16===(base=base||10)||"hex"===base){out="";for(var off=0,carry=0,i=0;i>>24-off&16777215,(off+=2)>=26&&(off-=26,i--),out=0!==carry||i!==this.length-1?zeros[6-word.length]+word+out:word+out}for(0!==carry&&(out=carry.toString(16)+out);out.length%padding!=0;)out="0"+out;return 0!==this.negative&&(out="-"+out),out}if(base===(0|base)&&base>=2&&base<=36){var groupSize=groupSizes[base],groupBase=groupBases[base];out="";var c=this.clone();for(c.negative=0;!c.isZero();){var r=c.modrn(groupBase).toString(base);out=(c=c.idivn(groupBase)).isZero()?r+out:zeros[groupSize-r.length]+r+out}for(this.isZero()&&(out="0"+out);out.length%padding!=0;)out="0"+out;return 0!==this.negative&&(out="-"+out),out}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function(){var ret=this.words[0];return 2===this.length?ret+=67108864*this.words[1]:3===this.length&&1===this.words[2]?ret+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-ret:ret},BN.prototype.toJSON=function(){return this.toString(16,2)},Buffer&&(BN.prototype.toBuffer=function(endian,length){return this.toArrayLike(Buffer,endian,length)}),BN.prototype.toArray=function(endian,length){return this.toArrayLike(Array,endian,length)};function smallMulTo(self,num,out){out.negative=num.negative^self.negative;var len=self.length+num.length|0;out.length=len,len=len-1|0;var a=0|self.words[0],b=0|num.words[0],r=a*b,lo=67108863&r,carry=r/67108864|0;out.words[0]=lo;for(var k=1;k>>26,rword=67108863&carry,maxJ=Math.min(k,num.length-1),j=Math.max(0,k-self.length+1);j<=maxJ;j++){var i=k-j|0;ncarry+=(r=(a=0|self.words[i])*(b=0|num.words[j])+rword)/67108864|0,rword=67108863&r}out.words[k]=0|rword,carry=0|ncarry}return 0!==carry?out.words[k]=0|carry:out.length--,out._strip()}BN.prototype.toArrayLike=function(ArrayType,endian,length){this._strip();var byteLength=this.byteLength(),reqLength=length||Math.max(1,byteLength);assert(byteLength<=reqLength,"byte array longer than desired length"),assert(reqLength>0,"Requested array length <= 0");var res=function(ArrayType,size){return ArrayType.allocUnsafe?ArrayType.allocUnsafe(size):new ArrayType(size)}(ArrayType,reqLength);return this["_toArrayLike"+("le"===endian?"LE":"BE")](res,byteLength),res},BN.prototype._toArrayLikeLE=function(res,byteLength){for(var position=0,carry=0,i=0,shift=0;i>8&255),position>16&255),6===shift?(position>24&255),carry=0,shift=0):(carry=word>>>24,shift+=2)}if(position=0&&(res[position--]=word>>8&255),position>=0&&(res[position--]=word>>16&255),6===shift?(position>=0&&(res[position--]=word>>24&255),carry=0,shift=0):(carry=word>>>24,shift+=2)}if(position>=0)for(res[position--]=carry;position>=0;)res[position--]=0},Math.clz32?BN.prototype._countBits=function(w){return 32-Math.clz32(w)}:BN.prototype._countBits=function(w){var t=w,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},BN.prototype._zeroBits=function(w){if(0===w)return 26;var t=w,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},BN.prototype.bitLength=function(){var w=this.words[this.length-1],hi=this._countBits(w);return 26*(this.length-1)+hi},BN.prototype.zeroBits=function(){if(this.isZero())return 0;for(var r=0,i=0;inum.length?this.clone().ior(num):num.clone().ior(this)},BN.prototype.uor=function(num){return this.length>num.length?this.clone().iuor(num):num.clone().iuor(this)},BN.prototype.iuand=function(num){var b;b=this.length>num.length?num:this;for(var i=0;inum.length?this.clone().iand(num):num.clone().iand(this)},BN.prototype.uand=function(num){return this.length>num.length?this.clone().iuand(num):num.clone().iuand(this)},BN.prototype.iuxor=function(num){var a,b;this.length>num.length?(a=this,b=num):(a=num,b=this);for(var i=0;inum.length?this.clone().ixor(num):num.clone().ixor(this)},BN.prototype.uxor=function(num){return this.length>num.length?this.clone().iuxor(num):num.clone().iuxor(this)},BN.prototype.inotn=function(width){assert("number"==typeof width&&width>=0);var bytesNeeded=0|Math.ceil(width/26),bitsLeft=width%26;this._expand(bytesNeeded),bitsLeft>0&&bytesNeeded--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-bitsLeft),this._strip()},BN.prototype.notn=function(width){return this.clone().inotn(width)},BN.prototype.setn=function(bit,val){assert("number"==typeof bit&&bit>=0);var off=bit/26|0,wbit=bit%26;return this._expand(off+1),this.words[off]=val?this.words[off]|1<num.length?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>>26;for(;0!==carry&&i>>26;if(this.length=a.length,0!==carry)this.words[this.length]=carry,this.length++;else if(a!==this)for(;inum.length?this.clone().iadd(num):num.clone().iadd(this)},BN.prototype.isub=function(num){if(0!==num.negative){num.negative=0;var r=this.iadd(num);return num.negative=1,r._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(num),this.negative=1,this._normSign();var a,b,cmp=this.cmp(num);if(0===cmp)return this.negative=0,this.length=1,this.words[0]=0,this;cmp>0?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>26,this.words[i]=67108863&r;for(;0!==carry&&i>26,this.words[i]=67108863&r;if(0===carry&&i>>13,a1=0|a[1],al1=8191&a1,ah1=a1>>>13,a2=0|a[2],al2=8191&a2,ah2=a2>>>13,a3=0|a[3],al3=8191&a3,ah3=a3>>>13,a4=0|a[4],al4=8191&a4,ah4=a4>>>13,a5=0|a[5],al5=8191&a5,ah5=a5>>>13,a6=0|a[6],al6=8191&a6,ah6=a6>>>13,a7=0|a[7],al7=8191&a7,ah7=a7>>>13,a8=0|a[8],al8=8191&a8,ah8=a8>>>13,a9=0|a[9],al9=8191&a9,ah9=a9>>>13,b0=0|b[0],bl0=8191&b0,bh0=b0>>>13,b1=0|b[1],bl1=8191&b1,bh1=b1>>>13,b2=0|b[2],bl2=8191&b2,bh2=b2>>>13,b3=0|b[3],bl3=8191&b3,bh3=b3>>>13,b4=0|b[4],bl4=8191&b4,bh4=b4>>>13,b5=0|b[5],bl5=8191&b5,bh5=b5>>>13,b6=0|b[6],bl6=8191&b6,bh6=b6>>>13,b7=0|b[7],bl7=8191&b7,bh7=b7>>>13,b8=0|b[8],bl8=8191&b8,bh8=b8>>>13,b9=0|b[9],bl9=8191&b9,bh9=b9>>>13;out.negative=self.negative^num.negative,out.length=19;var w0=(c+(lo=Math.imul(al0,bl0))|0)+((8191&(mid=(mid=Math.imul(al0,bh0))+Math.imul(ah0,bl0)|0))<<13)|0;c=((hi=Math.imul(ah0,bh0))+(mid>>>13)|0)+(w0>>>26)|0,w0&=67108863,lo=Math.imul(al1,bl0),mid=(mid=Math.imul(al1,bh0))+Math.imul(ah1,bl0)|0,hi=Math.imul(ah1,bh0);var w1=(c+(lo=lo+Math.imul(al0,bl1)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh1)|0)+Math.imul(ah0,bl1)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh1)|0)+(mid>>>13)|0)+(w1>>>26)|0,w1&=67108863,lo=Math.imul(al2,bl0),mid=(mid=Math.imul(al2,bh0))+Math.imul(ah2,bl0)|0,hi=Math.imul(ah2,bh0),lo=lo+Math.imul(al1,bl1)|0,mid=(mid=mid+Math.imul(al1,bh1)|0)+Math.imul(ah1,bl1)|0,hi=hi+Math.imul(ah1,bh1)|0;var w2=(c+(lo=lo+Math.imul(al0,bl2)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh2)|0)+Math.imul(ah0,bl2)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh2)|0)+(mid>>>13)|0)+(w2>>>26)|0,w2&=67108863,lo=Math.imul(al3,bl0),mid=(mid=Math.imul(al3,bh0))+Math.imul(ah3,bl0)|0,hi=Math.imul(ah3,bh0),lo=lo+Math.imul(al2,bl1)|0,mid=(mid=mid+Math.imul(al2,bh1)|0)+Math.imul(ah2,bl1)|0,hi=hi+Math.imul(ah2,bh1)|0,lo=lo+Math.imul(al1,bl2)|0,mid=(mid=mid+Math.imul(al1,bh2)|0)+Math.imul(ah1,bl2)|0,hi=hi+Math.imul(ah1,bh2)|0;var w3=(c+(lo=lo+Math.imul(al0,bl3)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh3)|0)+Math.imul(ah0,bl3)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh3)|0)+(mid>>>13)|0)+(w3>>>26)|0,w3&=67108863,lo=Math.imul(al4,bl0),mid=(mid=Math.imul(al4,bh0))+Math.imul(ah4,bl0)|0,hi=Math.imul(ah4,bh0),lo=lo+Math.imul(al3,bl1)|0,mid=(mid=mid+Math.imul(al3,bh1)|0)+Math.imul(ah3,bl1)|0,hi=hi+Math.imul(ah3,bh1)|0,lo=lo+Math.imul(al2,bl2)|0,mid=(mid=mid+Math.imul(al2,bh2)|0)+Math.imul(ah2,bl2)|0,hi=hi+Math.imul(ah2,bh2)|0,lo=lo+Math.imul(al1,bl3)|0,mid=(mid=mid+Math.imul(al1,bh3)|0)+Math.imul(ah1,bl3)|0,hi=hi+Math.imul(ah1,bh3)|0;var w4=(c+(lo=lo+Math.imul(al0,bl4)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh4)|0)+Math.imul(ah0,bl4)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh4)|0)+(mid>>>13)|0)+(w4>>>26)|0,w4&=67108863,lo=Math.imul(al5,bl0),mid=(mid=Math.imul(al5,bh0))+Math.imul(ah5,bl0)|0,hi=Math.imul(ah5,bh0),lo=lo+Math.imul(al4,bl1)|0,mid=(mid=mid+Math.imul(al4,bh1)|0)+Math.imul(ah4,bl1)|0,hi=hi+Math.imul(ah4,bh1)|0,lo=lo+Math.imul(al3,bl2)|0,mid=(mid=mid+Math.imul(al3,bh2)|0)+Math.imul(ah3,bl2)|0,hi=hi+Math.imul(ah3,bh2)|0,lo=lo+Math.imul(al2,bl3)|0,mid=(mid=mid+Math.imul(al2,bh3)|0)+Math.imul(ah2,bl3)|0,hi=hi+Math.imul(ah2,bh3)|0,lo=lo+Math.imul(al1,bl4)|0,mid=(mid=mid+Math.imul(al1,bh4)|0)+Math.imul(ah1,bl4)|0,hi=hi+Math.imul(ah1,bh4)|0;var w5=(c+(lo=lo+Math.imul(al0,bl5)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh5)|0)+Math.imul(ah0,bl5)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh5)|0)+(mid>>>13)|0)+(w5>>>26)|0,w5&=67108863,lo=Math.imul(al6,bl0),mid=(mid=Math.imul(al6,bh0))+Math.imul(ah6,bl0)|0,hi=Math.imul(ah6,bh0),lo=lo+Math.imul(al5,bl1)|0,mid=(mid=mid+Math.imul(al5,bh1)|0)+Math.imul(ah5,bl1)|0,hi=hi+Math.imul(ah5,bh1)|0,lo=lo+Math.imul(al4,bl2)|0,mid=(mid=mid+Math.imul(al4,bh2)|0)+Math.imul(ah4,bl2)|0,hi=hi+Math.imul(ah4,bh2)|0,lo=lo+Math.imul(al3,bl3)|0,mid=(mid=mid+Math.imul(al3,bh3)|0)+Math.imul(ah3,bl3)|0,hi=hi+Math.imul(ah3,bh3)|0,lo=lo+Math.imul(al2,bl4)|0,mid=(mid=mid+Math.imul(al2,bh4)|0)+Math.imul(ah2,bl4)|0,hi=hi+Math.imul(ah2,bh4)|0,lo=lo+Math.imul(al1,bl5)|0,mid=(mid=mid+Math.imul(al1,bh5)|0)+Math.imul(ah1,bl5)|0,hi=hi+Math.imul(ah1,bh5)|0;var w6=(c+(lo=lo+Math.imul(al0,bl6)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh6)|0)+Math.imul(ah0,bl6)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh6)|0)+(mid>>>13)|0)+(w6>>>26)|0,w6&=67108863,lo=Math.imul(al7,bl0),mid=(mid=Math.imul(al7,bh0))+Math.imul(ah7,bl0)|0,hi=Math.imul(ah7,bh0),lo=lo+Math.imul(al6,bl1)|0,mid=(mid=mid+Math.imul(al6,bh1)|0)+Math.imul(ah6,bl1)|0,hi=hi+Math.imul(ah6,bh1)|0,lo=lo+Math.imul(al5,bl2)|0,mid=(mid=mid+Math.imul(al5,bh2)|0)+Math.imul(ah5,bl2)|0,hi=hi+Math.imul(ah5,bh2)|0,lo=lo+Math.imul(al4,bl3)|0,mid=(mid=mid+Math.imul(al4,bh3)|0)+Math.imul(ah4,bl3)|0,hi=hi+Math.imul(ah4,bh3)|0,lo=lo+Math.imul(al3,bl4)|0,mid=(mid=mid+Math.imul(al3,bh4)|0)+Math.imul(ah3,bl4)|0,hi=hi+Math.imul(ah3,bh4)|0,lo=lo+Math.imul(al2,bl5)|0,mid=(mid=mid+Math.imul(al2,bh5)|0)+Math.imul(ah2,bl5)|0,hi=hi+Math.imul(ah2,bh5)|0,lo=lo+Math.imul(al1,bl6)|0,mid=(mid=mid+Math.imul(al1,bh6)|0)+Math.imul(ah1,bl6)|0,hi=hi+Math.imul(ah1,bh6)|0;var w7=(c+(lo=lo+Math.imul(al0,bl7)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh7)|0)+Math.imul(ah0,bl7)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh7)|0)+(mid>>>13)|0)+(w7>>>26)|0,w7&=67108863,lo=Math.imul(al8,bl0),mid=(mid=Math.imul(al8,bh0))+Math.imul(ah8,bl0)|0,hi=Math.imul(ah8,bh0),lo=lo+Math.imul(al7,bl1)|0,mid=(mid=mid+Math.imul(al7,bh1)|0)+Math.imul(ah7,bl1)|0,hi=hi+Math.imul(ah7,bh1)|0,lo=lo+Math.imul(al6,bl2)|0,mid=(mid=mid+Math.imul(al6,bh2)|0)+Math.imul(ah6,bl2)|0,hi=hi+Math.imul(ah6,bh2)|0,lo=lo+Math.imul(al5,bl3)|0,mid=(mid=mid+Math.imul(al5,bh3)|0)+Math.imul(ah5,bl3)|0,hi=hi+Math.imul(ah5,bh3)|0,lo=lo+Math.imul(al4,bl4)|0,mid=(mid=mid+Math.imul(al4,bh4)|0)+Math.imul(ah4,bl4)|0,hi=hi+Math.imul(ah4,bh4)|0,lo=lo+Math.imul(al3,bl5)|0,mid=(mid=mid+Math.imul(al3,bh5)|0)+Math.imul(ah3,bl5)|0,hi=hi+Math.imul(ah3,bh5)|0,lo=lo+Math.imul(al2,bl6)|0,mid=(mid=mid+Math.imul(al2,bh6)|0)+Math.imul(ah2,bl6)|0,hi=hi+Math.imul(ah2,bh6)|0,lo=lo+Math.imul(al1,bl7)|0,mid=(mid=mid+Math.imul(al1,bh7)|0)+Math.imul(ah1,bl7)|0,hi=hi+Math.imul(ah1,bh7)|0;var w8=(c+(lo=lo+Math.imul(al0,bl8)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh8)|0)+Math.imul(ah0,bl8)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh8)|0)+(mid>>>13)|0)+(w8>>>26)|0,w8&=67108863,lo=Math.imul(al9,bl0),mid=(mid=Math.imul(al9,bh0))+Math.imul(ah9,bl0)|0,hi=Math.imul(ah9,bh0),lo=lo+Math.imul(al8,bl1)|0,mid=(mid=mid+Math.imul(al8,bh1)|0)+Math.imul(ah8,bl1)|0,hi=hi+Math.imul(ah8,bh1)|0,lo=lo+Math.imul(al7,bl2)|0,mid=(mid=mid+Math.imul(al7,bh2)|0)+Math.imul(ah7,bl2)|0,hi=hi+Math.imul(ah7,bh2)|0,lo=lo+Math.imul(al6,bl3)|0,mid=(mid=mid+Math.imul(al6,bh3)|0)+Math.imul(ah6,bl3)|0,hi=hi+Math.imul(ah6,bh3)|0,lo=lo+Math.imul(al5,bl4)|0,mid=(mid=mid+Math.imul(al5,bh4)|0)+Math.imul(ah5,bl4)|0,hi=hi+Math.imul(ah5,bh4)|0,lo=lo+Math.imul(al4,bl5)|0,mid=(mid=mid+Math.imul(al4,bh5)|0)+Math.imul(ah4,bl5)|0,hi=hi+Math.imul(ah4,bh5)|0,lo=lo+Math.imul(al3,bl6)|0,mid=(mid=mid+Math.imul(al3,bh6)|0)+Math.imul(ah3,bl6)|0,hi=hi+Math.imul(ah3,bh6)|0,lo=lo+Math.imul(al2,bl7)|0,mid=(mid=mid+Math.imul(al2,bh7)|0)+Math.imul(ah2,bl7)|0,hi=hi+Math.imul(ah2,bh7)|0,lo=lo+Math.imul(al1,bl8)|0,mid=(mid=mid+Math.imul(al1,bh8)|0)+Math.imul(ah1,bl8)|0,hi=hi+Math.imul(ah1,bh8)|0;var w9=(c+(lo=lo+Math.imul(al0,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al0,bh9)|0)+Math.imul(ah0,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah0,bh9)|0)+(mid>>>13)|0)+(w9>>>26)|0,w9&=67108863,lo=Math.imul(al9,bl1),mid=(mid=Math.imul(al9,bh1))+Math.imul(ah9,bl1)|0,hi=Math.imul(ah9,bh1),lo=lo+Math.imul(al8,bl2)|0,mid=(mid=mid+Math.imul(al8,bh2)|0)+Math.imul(ah8,bl2)|0,hi=hi+Math.imul(ah8,bh2)|0,lo=lo+Math.imul(al7,bl3)|0,mid=(mid=mid+Math.imul(al7,bh3)|0)+Math.imul(ah7,bl3)|0,hi=hi+Math.imul(ah7,bh3)|0,lo=lo+Math.imul(al6,bl4)|0,mid=(mid=mid+Math.imul(al6,bh4)|0)+Math.imul(ah6,bl4)|0,hi=hi+Math.imul(ah6,bh4)|0,lo=lo+Math.imul(al5,bl5)|0,mid=(mid=mid+Math.imul(al5,bh5)|0)+Math.imul(ah5,bl5)|0,hi=hi+Math.imul(ah5,bh5)|0,lo=lo+Math.imul(al4,bl6)|0,mid=(mid=mid+Math.imul(al4,bh6)|0)+Math.imul(ah4,bl6)|0,hi=hi+Math.imul(ah4,bh6)|0,lo=lo+Math.imul(al3,bl7)|0,mid=(mid=mid+Math.imul(al3,bh7)|0)+Math.imul(ah3,bl7)|0,hi=hi+Math.imul(ah3,bh7)|0,lo=lo+Math.imul(al2,bl8)|0,mid=(mid=mid+Math.imul(al2,bh8)|0)+Math.imul(ah2,bl8)|0,hi=hi+Math.imul(ah2,bh8)|0;var w10=(c+(lo=lo+Math.imul(al1,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al1,bh9)|0)+Math.imul(ah1,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah1,bh9)|0)+(mid>>>13)|0)+(w10>>>26)|0,w10&=67108863,lo=Math.imul(al9,bl2),mid=(mid=Math.imul(al9,bh2))+Math.imul(ah9,bl2)|0,hi=Math.imul(ah9,bh2),lo=lo+Math.imul(al8,bl3)|0,mid=(mid=mid+Math.imul(al8,bh3)|0)+Math.imul(ah8,bl3)|0,hi=hi+Math.imul(ah8,bh3)|0,lo=lo+Math.imul(al7,bl4)|0,mid=(mid=mid+Math.imul(al7,bh4)|0)+Math.imul(ah7,bl4)|0,hi=hi+Math.imul(ah7,bh4)|0,lo=lo+Math.imul(al6,bl5)|0,mid=(mid=mid+Math.imul(al6,bh5)|0)+Math.imul(ah6,bl5)|0,hi=hi+Math.imul(ah6,bh5)|0,lo=lo+Math.imul(al5,bl6)|0,mid=(mid=mid+Math.imul(al5,bh6)|0)+Math.imul(ah5,bl6)|0,hi=hi+Math.imul(ah5,bh6)|0,lo=lo+Math.imul(al4,bl7)|0,mid=(mid=mid+Math.imul(al4,bh7)|0)+Math.imul(ah4,bl7)|0,hi=hi+Math.imul(ah4,bh7)|0,lo=lo+Math.imul(al3,bl8)|0,mid=(mid=mid+Math.imul(al3,bh8)|0)+Math.imul(ah3,bl8)|0,hi=hi+Math.imul(ah3,bh8)|0;var w11=(c+(lo=lo+Math.imul(al2,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al2,bh9)|0)+Math.imul(ah2,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah2,bh9)|0)+(mid>>>13)|0)+(w11>>>26)|0,w11&=67108863,lo=Math.imul(al9,bl3),mid=(mid=Math.imul(al9,bh3))+Math.imul(ah9,bl3)|0,hi=Math.imul(ah9,bh3),lo=lo+Math.imul(al8,bl4)|0,mid=(mid=mid+Math.imul(al8,bh4)|0)+Math.imul(ah8,bl4)|0,hi=hi+Math.imul(ah8,bh4)|0,lo=lo+Math.imul(al7,bl5)|0,mid=(mid=mid+Math.imul(al7,bh5)|0)+Math.imul(ah7,bl5)|0,hi=hi+Math.imul(ah7,bh5)|0,lo=lo+Math.imul(al6,bl6)|0,mid=(mid=mid+Math.imul(al6,bh6)|0)+Math.imul(ah6,bl6)|0,hi=hi+Math.imul(ah6,bh6)|0,lo=lo+Math.imul(al5,bl7)|0,mid=(mid=mid+Math.imul(al5,bh7)|0)+Math.imul(ah5,bl7)|0,hi=hi+Math.imul(ah5,bh7)|0,lo=lo+Math.imul(al4,bl8)|0,mid=(mid=mid+Math.imul(al4,bh8)|0)+Math.imul(ah4,bl8)|0,hi=hi+Math.imul(ah4,bh8)|0;var w12=(c+(lo=lo+Math.imul(al3,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al3,bh9)|0)+Math.imul(ah3,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah3,bh9)|0)+(mid>>>13)|0)+(w12>>>26)|0,w12&=67108863,lo=Math.imul(al9,bl4),mid=(mid=Math.imul(al9,bh4))+Math.imul(ah9,bl4)|0,hi=Math.imul(ah9,bh4),lo=lo+Math.imul(al8,bl5)|0,mid=(mid=mid+Math.imul(al8,bh5)|0)+Math.imul(ah8,bl5)|0,hi=hi+Math.imul(ah8,bh5)|0,lo=lo+Math.imul(al7,bl6)|0,mid=(mid=mid+Math.imul(al7,bh6)|0)+Math.imul(ah7,bl6)|0,hi=hi+Math.imul(ah7,bh6)|0,lo=lo+Math.imul(al6,bl7)|0,mid=(mid=mid+Math.imul(al6,bh7)|0)+Math.imul(ah6,bl7)|0,hi=hi+Math.imul(ah6,bh7)|0,lo=lo+Math.imul(al5,bl8)|0,mid=(mid=mid+Math.imul(al5,bh8)|0)+Math.imul(ah5,bl8)|0,hi=hi+Math.imul(ah5,bh8)|0;var w13=(c+(lo=lo+Math.imul(al4,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al4,bh9)|0)+Math.imul(ah4,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah4,bh9)|0)+(mid>>>13)|0)+(w13>>>26)|0,w13&=67108863,lo=Math.imul(al9,bl5),mid=(mid=Math.imul(al9,bh5))+Math.imul(ah9,bl5)|0,hi=Math.imul(ah9,bh5),lo=lo+Math.imul(al8,bl6)|0,mid=(mid=mid+Math.imul(al8,bh6)|0)+Math.imul(ah8,bl6)|0,hi=hi+Math.imul(ah8,bh6)|0,lo=lo+Math.imul(al7,bl7)|0,mid=(mid=mid+Math.imul(al7,bh7)|0)+Math.imul(ah7,bl7)|0,hi=hi+Math.imul(ah7,bh7)|0,lo=lo+Math.imul(al6,bl8)|0,mid=(mid=mid+Math.imul(al6,bh8)|0)+Math.imul(ah6,bl8)|0,hi=hi+Math.imul(ah6,bh8)|0;var w14=(c+(lo=lo+Math.imul(al5,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al5,bh9)|0)+Math.imul(ah5,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah5,bh9)|0)+(mid>>>13)|0)+(w14>>>26)|0,w14&=67108863,lo=Math.imul(al9,bl6),mid=(mid=Math.imul(al9,bh6))+Math.imul(ah9,bl6)|0,hi=Math.imul(ah9,bh6),lo=lo+Math.imul(al8,bl7)|0,mid=(mid=mid+Math.imul(al8,bh7)|0)+Math.imul(ah8,bl7)|0,hi=hi+Math.imul(ah8,bh7)|0,lo=lo+Math.imul(al7,bl8)|0,mid=(mid=mid+Math.imul(al7,bh8)|0)+Math.imul(ah7,bl8)|0,hi=hi+Math.imul(ah7,bh8)|0;var w15=(c+(lo=lo+Math.imul(al6,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al6,bh9)|0)+Math.imul(ah6,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah6,bh9)|0)+(mid>>>13)|0)+(w15>>>26)|0,w15&=67108863,lo=Math.imul(al9,bl7),mid=(mid=Math.imul(al9,bh7))+Math.imul(ah9,bl7)|0,hi=Math.imul(ah9,bh7),lo=lo+Math.imul(al8,bl8)|0,mid=(mid=mid+Math.imul(al8,bh8)|0)+Math.imul(ah8,bl8)|0,hi=hi+Math.imul(ah8,bh8)|0;var w16=(c+(lo=lo+Math.imul(al7,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al7,bh9)|0)+Math.imul(ah7,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah7,bh9)|0)+(mid>>>13)|0)+(w16>>>26)|0,w16&=67108863,lo=Math.imul(al9,bl8),mid=(mid=Math.imul(al9,bh8))+Math.imul(ah9,bl8)|0,hi=Math.imul(ah9,bh8);var w17=(c+(lo=lo+Math.imul(al8,bl9)|0)|0)+((8191&(mid=(mid=mid+Math.imul(al8,bh9)|0)+Math.imul(ah8,bl9)|0))<<13)|0;c=((hi=hi+Math.imul(ah8,bh9)|0)+(mid>>>13)|0)+(w17>>>26)|0,w17&=67108863;var w18=(c+(lo=Math.imul(al9,bl9))|0)+((8191&(mid=(mid=Math.imul(al9,bh9))+Math.imul(ah9,bl9)|0))<<13)|0;return c=((hi=Math.imul(ah9,bh9))+(mid>>>13)|0)+(w18>>>26)|0,w18&=67108863,o[0]=w0,o[1]=w1,o[2]=w2,o[3]=w3,o[4]=w4,o[5]=w5,o[6]=w6,o[7]=w7,o[8]=w8,o[9]=w9,o[10]=w10,o[11]=w11,o[12]=w12,o[13]=w13,o[14]=w14,o[15]=w15,o[16]=w16,o[17]=w17,o[18]=w18,0!==c&&(o[19]=c,out.length++),out};function bigMulTo(self,num,out){out.negative=num.negative^self.negative,out.length=self.length+num.length;for(var carry=0,hncarry=0,k=0;k>>26)|0)>>>26,ncarry&=67108863}out.words[k]=rword,carry=ncarry,ncarry=hncarry}return 0!==carry?out.words[k]=carry:out.length--,out._strip()}function jumboMulTo(self,num,out){return bigMulTo(self,num,out)}function FFTM(x,y){this.x=x,this.y=y}Math.imul||(comb10MulTo=smallMulTo),BN.prototype.mulTo=function(num,out){var len=this.length+num.length;return 10===this.length&&10===num.length?comb10MulTo(this,num,out):len<63?smallMulTo(this,num,out):len<1024?bigMulTo(this,num,out):jumboMulTo(this,num,out)},FFTM.prototype.makeRBT=function(N){for(var t=new Array(N),l=BN.prototype._countBits(N)-1,i=0;i>=1;return rb},FFTM.prototype.permute=function(rbt,rws,iws,rtws,itws,N){for(var i=0;i>>=1)i++;return 1<>>=13,rws[2*i+1]=8191&carry,carry>>>=13;for(i=2*len;i>=26,carry+=w/67108864|0,carry+=lo>>>26,this.words[i]=67108863&lo}return 0!==carry&&(this.words[i]=carry,this.length++),isNegNum?this.ineg():this},BN.prototype.muln=function(num){return this.clone().imuln(num)},BN.prototype.sqr=function(){return this.mul(this)},BN.prototype.isqr=function(){return this.imul(this.clone())},BN.prototype.pow=function(num){var w=function(num){for(var w=new Array(num.bitLength()),bit=0;bit>>wbit&1}return w}(num);if(0===w.length)return new BN(1);for(var res=this,i=0;i=0);var i,r=bits%26,s=(bits-r)/26,carryMask=67108863>>>26-r<<26-r;if(0!==r){var carry=0;for(i=0;i>>26-r}carry&&(this.words[i]=carry,this.length++)}if(0!==s){for(i=this.length-1;i>=0;i--)this.words[i+s]=this.words[i];for(i=0;i=0),h=hint?(hint-hint%26)/26:0;var r=bits%26,s=Math.min((bits-r)/26,this.length),mask=67108863^67108863>>>r<s)for(this.length-=s,i=0;i=0&&(0!==carry||i>=h);i--){var word=0|this.words[i];this.words[i]=carry<<26-r|word>>>r,carry=word&mask}return maskedWords&&0!==carry&&(maskedWords.words[maskedWords.length++]=carry),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},BN.prototype.ishrn=function(bits,hint,extended){return assert(0===this.negative),this.iushrn(bits,hint,extended)},BN.prototype.shln=function(bits){return this.clone().ishln(bits)},BN.prototype.ushln=function(bits){return this.clone().iushln(bits)},BN.prototype.shrn=function(bits){return this.clone().ishrn(bits)},BN.prototype.ushrn=function(bits){return this.clone().iushrn(bits)},BN.prototype.testn=function(bit){assert("number"==typeof bit&&bit>=0);var r=bit%26,s=(bit-r)/26,q=1<=0);var r=bits%26,s=(bits-r)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=s)return this;if(0!==r&&s++,this.length=Math.min(s,this.length),0!==r){var mask=67108863^67108863>>>r<=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},BN.prototype.isubn=function(num){if(assert("number"==typeof num),assert(num<67108864),num<0)return this.iaddn(-num);if(0!==this.negative)return this.negative=0,this.iaddn(num),this.negative=1,this;if(this.words[0]-=num,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(right/67108864|0),this.words[i+shift]=67108863&w}for(;i>26,this.words[i+shift]=67108863&w;if(0===carry)return this._strip();for(assert(-1===carry),carry=0,i=0;i>26,this.words[i]=67108863&w;return this.negative=1,this._strip()},BN.prototype._wordDiv=function(num,mode){var shift=(this.length,num.length),a=this.clone(),b=num,bhi=0|b.words[b.length-1];0!==(shift=26-this._countBits(bhi))&&(b=b.ushln(shift),a.iushln(shift),bhi=0|b.words[b.length-1]);var q,m=a.length-b.length;if("mod"!==mode){(q=new BN(null)).length=m+1,q.words=new Array(q.length);for(var i=0;i=0;j--){var qj=67108864*(0|a.words[b.length+j])+(0|a.words[b.length+j-1]);for(qj=Math.min(qj/bhi|0,67108863),a._ishlnsubmul(b,qj,j);0!==a.negative;)qj--,a.negative=0,a._ishlnsubmul(b,1,j),a.isZero()||(a.negative^=1);q&&(q.words[j]=qj)}return q&&q._strip(),a._strip(),"div"!==mode&&0!==shift&&a.iushrn(shift),{div:q||null,mod:a}},BN.prototype.divmod=function(num,mode,positive){return assert(!num.isZero()),this.isZero()?{div:new BN(0),mod:new BN(0)}:0!==this.negative&&0===num.negative?(res=this.neg().divmod(num,mode),"mod"!==mode&&(div=res.div.neg()),"div"!==mode&&(mod=res.mod.neg(),positive&&0!==mod.negative&&mod.iadd(num)),{div,mod}):0===this.negative&&0!==num.negative?(res=this.divmod(num.neg(),mode),"mod"!==mode&&(div=res.div.neg()),{div,mod:res.mod}):0!=(this.negative&num.negative)?(res=this.neg().divmod(num.neg(),mode),"div"!==mode&&(mod=res.mod.neg(),positive&&0!==mod.negative&&mod.isub(num)),{div:res.div,mod}):num.length>this.length||this.cmp(num)<0?{div:new BN(0),mod:this}:1===num.length?"div"===mode?{div:this.divn(num.words[0]),mod:null}:"mod"===mode?{div:null,mod:new BN(this.modrn(num.words[0]))}:{div:this.divn(num.words[0]),mod:new BN(this.modrn(num.words[0]))}:this._wordDiv(num,mode);var div,mod,res},BN.prototype.div=function(num){return this.divmod(num,"div",!1).div},BN.prototype.mod=function(num){return this.divmod(num,"mod",!1).mod},BN.prototype.umod=function(num){return this.divmod(num,"mod",!0).mod},BN.prototype.divRound=function(num){var dm=this.divmod(num);if(dm.mod.isZero())return dm.div;var mod=0!==dm.div.negative?dm.mod.isub(num):dm.mod,half=num.ushrn(1),r2=num.andln(1),cmp=mod.cmp(half);return cmp<0||1===r2&&0===cmp?dm.div:0!==dm.div.negative?dm.div.isubn(1):dm.div.iaddn(1)},BN.prototype.modrn=function(num){var isNegNum=num<0;isNegNum&&(num=-num),assert(num<=67108863);for(var p=(1<<26)%num,acc=0,i=this.length-1;i>=0;i--)acc=(p*acc+(0|this.words[i]))%num;return isNegNum?-acc:acc},BN.prototype.modn=function(num){return this.modrn(num)},BN.prototype.idivn=function(num){var isNegNum=num<0;isNegNum&&(num=-num),assert(num<=67108863);for(var carry=0,i=this.length-1;i>=0;i--){var w=(0|this.words[i])+67108864*carry;this.words[i]=w/num|0,carry=w%num}return this._strip(),isNegNum?this.ineg():this},BN.prototype.divn=function(num){return this.clone().idivn(num)},BN.prototype.egcd=function(p){assert(0===p.negative),assert(!p.isZero());var x=this,y=p.clone();x=0!==x.negative?x.umod(p):x.clone();for(var A=new BN(1),B=new BN(0),C=new BN(0),D=new BN(1),g=0;x.isEven()&&y.isEven();)x.iushrn(1),y.iushrn(1),++g;for(var yp=y.clone(),xp=x.clone();!x.isZero();){for(var i=0,im=1;0==(x.words[0]&im)&&i<26;++i,im<<=1);if(i>0)for(x.iushrn(i);i-- >0;)(A.isOdd()||B.isOdd())&&(A.iadd(yp),B.isub(xp)),A.iushrn(1),B.iushrn(1);for(var j=0,jm=1;0==(y.words[0]&jm)&&j<26;++j,jm<<=1);if(j>0)for(y.iushrn(j);j-- >0;)(C.isOdd()||D.isOdd())&&(C.iadd(yp),D.isub(xp)),C.iushrn(1),D.iushrn(1);x.cmp(y)>=0?(x.isub(y),A.isub(C),B.isub(D)):(y.isub(x),C.isub(A),D.isub(B))}return{a:C,b:D,gcd:y.iushln(g)}},BN.prototype._invmp=function(p){assert(0===p.negative),assert(!p.isZero());var a=this,b=p.clone();a=0!==a.negative?a.umod(p):a.clone();for(var res,x1=new BN(1),x2=new BN(0),delta=b.clone();a.cmpn(1)>0&&b.cmpn(1)>0;){for(var i=0,im=1;0==(a.words[0]&im)&&i<26;++i,im<<=1);if(i>0)for(a.iushrn(i);i-- >0;)x1.isOdd()&&x1.iadd(delta),x1.iushrn(1);for(var j=0,jm=1;0==(b.words[0]&jm)&&j<26;++j,jm<<=1);if(j>0)for(b.iushrn(j);j-- >0;)x2.isOdd()&&x2.iadd(delta),x2.iushrn(1);a.cmp(b)>=0?(a.isub(b),x1.isub(x2)):(b.isub(a),x2.isub(x1))}return(res=0===a.cmpn(1)?x1:x2).cmpn(0)<0&&res.iadd(p),res},BN.prototype.gcd=function(num){if(this.isZero())return num.abs();if(num.isZero())return this.abs();var a=this.clone(),b=num.clone();a.negative=0,b.negative=0;for(var shift=0;a.isEven()&&b.isEven();shift++)a.iushrn(1),b.iushrn(1);for(;;){for(;a.isEven();)a.iushrn(1);for(;b.isEven();)b.iushrn(1);var r=a.cmp(b);if(r<0){var t=a;a=b,b=t}else if(0===r||0===b.cmpn(1))break;a.isub(b)}return b.iushln(shift)},BN.prototype.invm=function(num){return this.egcd(num).a.umod(num)},BN.prototype.isEven=function(){return 0==(1&this.words[0])},BN.prototype.isOdd=function(){return 1==(1&this.words[0])},BN.prototype.andln=function(num){return this.words[0]&num},BN.prototype.bincn=function(bit){assert("number"==typeof bit);var r=bit%26,s=(bit-r)/26,q=1<>>26,w&=67108863,this.words[i]=w}return 0!==carry&&(this.words[i]=carry,this.length++),this},BN.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},BN.prototype.cmpn=function(num){var res,negative=num<0;if(0!==this.negative&&!negative)return-1;if(0===this.negative&&negative)return 1;if(this._strip(),this.length>1)res=1;else{negative&&(num=-num),assert(num<=67108863,"Number is too big");var w=0|this.words[0];res=w===num?0:wnum.length)return 1;if(this.length=0;i--){var a=0|this.words[i],b=0|num.words[i];if(a!==b){ab&&(res=1);break}}return res},BN.prototype.gtn=function(num){return 1===this.cmpn(num)},BN.prototype.gt=function(num){return 1===this.cmp(num)},BN.prototype.gten=function(num){return this.cmpn(num)>=0},BN.prototype.gte=function(num){return this.cmp(num)>=0},BN.prototype.ltn=function(num){return-1===this.cmpn(num)},BN.prototype.lt=function(num){return-1===this.cmp(num)},BN.prototype.lten=function(num){return this.cmpn(num)<=0},BN.prototype.lte=function(num){return this.cmp(num)<=0},BN.prototype.eqn=function(num){return 0===this.cmpn(num)},BN.prototype.eq=function(num){return 0===this.cmp(num)},BN.red=function(num){return new Red(num)},BN.prototype.toRed=function(ctx){return assert(!this.red,"Already a number in reduction context"),assert(0===this.negative,"red works only with positives"),ctx.convertTo(this)._forceRed(ctx)},BN.prototype.fromRed=function(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function(ctx){return this.red=ctx,this},BN.prototype.forceRed=function(ctx){return assert(!this.red,"Already a number in reduction context"),this._forceRed(ctx)},BN.prototype.redAdd=function(num){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,num)},BN.prototype.redIAdd=function(num){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,num)},BN.prototype.redSub=function(num){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,num)},BN.prototype.redISub=function(num){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,num)},BN.prototype.redShl=function(num){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,num)},BN.prototype.redMul=function(num){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,num),this.red.mul(this,num)},BN.prototype.redIMul=function(num){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,num),this.red.imul(this,num)},BN.prototype.redSqr=function(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function(num){return assert(this.red&&!num.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,num)};var primes={k256:null,p224:null,p192:null,p25519:null};function MPrime(name,p){this.name=name,this.p=new BN(p,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P224(){MPrime.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P192(){MPrime.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P25519(){MPrime.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function Red(m){if("string"==typeof m){var prime=BN._prime(m);this.m=prime.p,this.prime=prime}else assert(m.gtn(1),"modulus must be greater than 1"),this.m=m,this.prime=null}function Mont(m){Red.call(this,m),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new BN(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}MPrime.prototype._tmp=function(){var tmp=new BN(null);return tmp.words=new Array(Math.ceil(this.n/13)),tmp},MPrime.prototype.ireduce=function(num){var rlen,r=num;do{this.split(r,this.tmp),rlen=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(rlen>this.n);var cmp=rlen0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},MPrime.prototype.split=function(input,out){input.iushrn(this.n,0,out)},MPrime.prototype.imulK=function(num){return num.imul(this.k)},inherits(K256,MPrime),K256.prototype.split=function(input,output){for(var outLen=Math.min(input.length,9),i=0;i>>22,prev=next}prev>>>=22,input.words[i-10]=prev,0===prev&&input.length>10?input.length-=10:input.length-=9},K256.prototype.imulK=function(num){num.words[num.length]=0,num.words[num.length+1]=0,num.length+=2;for(var lo=0,i=0;i>>=26,num.words[i]=lo,carry=hi}return 0!==carry&&(num.words[num.length++]=carry),num},BN._prime=function(name){if(primes[name])return primes[name];var prime;if("k256"===name)prime=new K256;else if("p224"===name)prime=new P224;else if("p192"===name)prime=new P192;else{if("p25519"!==name)throw new Error("Unknown prime "+name);prime=new P25519}return primes[name]=prime,prime},Red.prototype._verify1=function(a){assert(0===a.negative,"red works only with positives"),assert(a.red,"red works only with red numbers")},Red.prototype._verify2=function(a,b){assert(0==(a.negative|b.negative),"red works only with positives"),assert(a.red&&a.red===b.red,"red works only with red numbers")},Red.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(move(a,a.umod(this.m)._forceRed(this)),a)},Red.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},Red.prototype.add=function(a,b){this._verify2(a,b);var res=a.add(b);return res.cmp(this.m)>=0&&res.isub(this.m),res._forceRed(this)},Red.prototype.iadd=function(a,b){this._verify2(a,b);var res=a.iadd(b);return res.cmp(this.m)>=0&&res.isub(this.m),res},Red.prototype.sub=function(a,b){this._verify2(a,b);var res=a.sub(b);return res.cmpn(0)<0&&res.iadd(this.m),res._forceRed(this)},Red.prototype.isub=function(a,b){this._verify2(a,b);var res=a.isub(b);return res.cmpn(0)<0&&res.iadd(this.m),res},Red.prototype.shl=function(a,num){return this._verify1(a),this.imod(a.ushln(num))},Red.prototype.imul=function(a,b){return this._verify2(a,b),this.imod(a.imul(b))},Red.prototype.mul=function(a,b){return this._verify2(a,b),this.imod(a.mul(b))},Red.prototype.isqr=function(a){return this.imul(a,a.clone())},Red.prototype.sqr=function(a){return this.mul(a,a)},Red.prototype.sqrt=function(a){if(a.isZero())return a.clone();var mod3=this.m.andln(3);if(assert(mod3%2==1),3===mod3){var pow=this.m.add(new BN(1)).iushrn(2);return this.pow(a,pow)}for(var q=this.m.subn(1),s=0;!q.isZero()&&0===q.andln(1);)s++,q.iushrn(1);assert(!q.isZero());var one=new BN(1).toRed(this),nOne=one.redNeg(),lpow=this.m.subn(1).iushrn(1),z=this.m.bitLength();for(z=new BN(2*z*z).toRed(this);0!==this.pow(z,lpow).cmp(nOne);)z.redIAdd(nOne);for(var c=this.pow(z,q),r=this.pow(a,q.addn(1).iushrn(1)),t=this.pow(a,q),m=s;0!==t.cmp(one);){for(var tmp=t,i=0;0!==tmp.cmp(one);i++)tmp=tmp.redSqr();assert(i=0;i--){for(var word=num.words[i],j=start-1;j>=0;j--){var bit=word>>j&1;res!==wnd[0]&&(res=this.sqr(res)),0!==bit||0!==current?(current<<=1,current|=bit,(4===++currentLen||0===i&&0===j)&&(res=this.mul(res,wnd[current]),currentLen=0,current=0)):currentLen=0}start=26}return res},Red.prototype.convertTo=function(num){var r=num.umod(this.m);return r===num?r.clone():r},Red.prototype.convertFrom=function(num){var res=num.clone();return res.red=null,res},BN.mont=function(num){return new Mont(num)},inherits(Mont,Red),Mont.prototype.convertTo=function(num){return this.imod(num.ushln(this.shift))},Mont.prototype.convertFrom=function(num){var r=this.imod(num.mul(this.rinv));return r.red=null,r},Mont.prototype.imul=function(a,b){if(a.isZero()||b.isZero())return a.words[0]=0,a.length=1,a;var t=a.imul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.mul=function(a,b){if(a.isZero()||b.isZero())return new BN(0)._forceRed(this);var t=a.mul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.invm=function(a){return this.imod(a._invmp(this.m).mul(this.r2))._forceRed(this)}}(module=__webpack_require__.nmd(module),this)},1476:module=>{"use strict";const b=options=>options&&options.includeBoundaries?"(?:(?<=\\s|^)(?=[a-fA-F\\d:])|(?<=[a-fA-F\\d:])(?=\\s|$))":"",v4="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",v6seg="[a-fA-F\\d]{1,4}",v6=`\n(?:\n(?:${v6seg}:){7}(?:${v6seg}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${v6seg}:){6}(?:${v4}|:${v6seg}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${v6seg}:){5}(?::${v4}|(?::${v6seg}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${v6seg}:){4}(?:(?::${v6seg}){0,1}:${v4}|(?::${v6seg}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${v6seg}:){3}(?:(?::${v6seg}){0,2}:${v4}|(?::${v6seg}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${v6seg}:){2}(?:(?::${v6seg}){0,3}:${v4}|(?::${v6seg}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${v6seg}:){1}(?:(?::${v6seg}){0,4}:${v4}|(?::${v6seg}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${v6seg}){0,5}:${v4}|(?::${v6seg}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),v46Exact=new RegExp(`(?:^${v4}$)|(?:^${v6}$)`),v4exact=new RegExp(`^${v4}$`),v6exact=new RegExp(`^${v6}$`),ip=options=>options&&options.exact?v46Exact:new RegExp(`(?:${b(options)}${v4}${b(options)})|(?:${b(options)}${v6}${b(options)})`,"g");ip.v4=options=>options&&options.exact?v4exact:new RegExp(`${b(options)}${v4}${b(options)}`,"g"),ip.v6=options=>options&&options.exact?v6exact:new RegExp(`${b(options)}${v6}${b(options)}`,"g"),module.exports=ip},4300:module=>{"use strict";module.exports=require("buffer")},7147:module=>{"use strict";module.exports=require("fs")},3837:module=>{"use strict";module.exports=require("util")},2626:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.arrayChunk=function(array,chunkSize){const outputSize=Math.ceil(array.length/chunkSize),output=Array(outputSize);for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.arrayFilter=function(array){let allowNulls=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return array.filter((v=>!(0,_undefined.isUndefined)(v)&&(allowNulls||!(0,_null.isNull)(v))))};var _null=__webpack_require__(9111),_undefined=__webpack_require__(4617)},1800:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.arrayFlatten=function(arrays){let size=0;for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"arrayChunk",{enumerable:!0,get:function(){return _chunk.arrayChunk}}),Object.defineProperty(exports,"arrayFilter",{enumerable:!0,get:function(){return _filter.arrayFilter}}),Object.defineProperty(exports,"arrayFlatten",{enumerable:!0,get:function(){return _flatten.arrayFlatten}}),Object.defineProperty(exports,"arrayRange",{enumerable:!0,get:function(){return _range.arrayRange}}),Object.defineProperty(exports,"arrayShuffle",{enumerable:!0,get:function(){return _shuffle.arrayShuffle}}),Object.defineProperty(exports,"arrayZip",{enumerable:!0,get:function(){return _zip.arrayZip}});var _chunk=__webpack_require__(2626),_filter=__webpack_require__(3546),_flatten=__webpack_require__(1800),_range=__webpack_require__(3476),_shuffle=__webpack_require__(5218),_zip=__webpack_require__(3091)},3476:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.arrayRange=function(size){let startAt=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;(0,_assert.assert)(size>0,"Expected non-zero, positive number as a range size");const result=new Array(size);for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.arrayShuffle=function(input){const result=input.slice();let curr=result.length;if(1===curr)return result;for(;0!==curr;){const rand=Math.floor(Math.random()*curr);curr--,[result[curr],result[rand]]=[result[rand],result[curr]]}return result}},3091:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.arrayZip=function(keys,values){const result=new Array(keys.length);for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.assert=assert,exports.assertReturn=function(value,message){return assert(!(0,_undefined.isUndefined)(value)&&!(0,_null.isNull)(value),message),value},exports.assertUnreachable=function(x){throw new Error(`This codepath should be unreachable. Unhandled input: ${x}`)};var _function=__webpack_require__(2404),_null=__webpack_require__(9111),_undefined=__webpack_require__(4617);function assert(condition,message){if(!condition)throw new Error((0,_function.isFunction)(message)?message():message)}},1405:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports._2pow53n=exports._1n=exports._1Qn=exports._1Mn=exports._1Bn=exports._0n=void 0;var _xBigint=__webpack_require__(3059);const _0n=(0,_xBigint.BigInt)(0);exports._0n=_0n;const _1n=(0,_xBigint.BigInt)(1);exports._1n=_1n;const _1Mn=(0,_xBigint.BigInt)(1e6);exports._1Mn=_1Mn;const _1Bn=(0,_xBigint.BigInt)(1e9);exports._1Bn=_1Bn;const _1Qn=_1Bn*_1Bn;exports._1Qn=_1Qn;const _2pow53n=(0,_xBigint.BigInt)(Number.MAX_SAFE_INTEGER);exports._2pow53n=_2pow53n},9822:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _exportNames={nSqrt:!0,nToBigInt:!0,nMax:!0,nMin:!0,nToHex:!0,nToU8a:!0};Object.defineProperty(exports,"nMax",{enumerable:!0,get:function(){return _min.nMax}}),Object.defineProperty(exports,"nMin",{enumerable:!0,get:function(){return _min.nMin}}),Object.defineProperty(exports,"nSqrt",{enumerable:!0,get:function(){return _sqrt.nSqrt}}),Object.defineProperty(exports,"nToBigInt",{enumerable:!0,get:function(){return _toBigInt.nToBigInt}}),Object.defineProperty(exports,"nToHex",{enumerable:!0,get:function(){return _toHex.nToHex}}),Object.defineProperty(exports,"nToU8a",{enumerable:!0,get:function(){return _toU8a.nToU8a}});var _consts=__webpack_require__(1405);Object.keys(_consts).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_consts[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _consts[key]}}))}));var _sqrt=__webpack_require__(8766),_toBigInt=__webpack_require__(5023),_min=__webpack_require__(8716),_toHex=__webpack_require__(9074),_toU8a=__webpack_require__(7846)},8716:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.nMax=function(){for(var _len=arguments.length,items=new Array(_len),_key=0;_key<_len;_key++)items[_key]=arguments[_key];return find(items,gt)},exports.nMin=function(){for(var _len2=arguments.length,items=new Array(_len2),_key2=0;_key2<_len2;_key2++)items[_key2]=arguments[_key2];return find(items,lt)};var _assert=__webpack_require__(2944);function gt(a,b){return a>b}function lt(a,b){return a=1,"Must provide one or more bigint arguments");let result=items[0];for(let i=1;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.nSqrt=function(value){const n=(0,_toBigInt.nToBigInt)(value);if((0,_assert.assert)(n>=_consts._0n,"square root of negative numbers is not supported"),n<=_consts._2pow53n)return(0,_xBigint.BigInt)(Math.floor(Math.sqrt(Number(n))));let x0=_sqrt2pow53n;for(;;){const x1=n/x0+x0>>_consts._1n;if(x0===x1||x0===x1-_consts._1n)return x0;x0=x1}};var _xBigint=__webpack_require__(3059),_assert=__webpack_require__(2944),_consts=__webpack_require__(1405),_toBigInt=__webpack_require__(5023);const _sqrt2pow53n=(0,_xBigint.BigInt)(94906265)},5023:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.nToBigInt=function(value){return"bigint"==typeof value?value:value?(0,_hex.isHex)(value)?(0,_toBigInt.hexToBigInt)(value.toString()):(0,_bn.isBn)(value)?(0,_xBigint.BigInt)(value.toString()):(0,_toBigInt2.isToBigInt)(value)?value.toBigInt():(0,_toBn.isToBn)(value)?(0,_xBigint.BigInt)(value.toBn().toString()):(0,_xBigint.BigInt)(value):(0,_xBigint.BigInt)(0)};var _xBigint=__webpack_require__(3059),_toBigInt=__webpack_require__(8325),_bn=__webpack_require__(5767),_hex=__webpack_require__(1580),_toBigInt2=__webpack_require__(4455),_toBn=__webpack_require__(789)},9074:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.nToHex=function(value,options){return value?(0,_u8a.u8aToHex)((0,_toU8a.nToU8a)(value,(0,_spread.objectSpread)({isLe:!1,isNegative:!1},options))):"0x00"};var _spread=__webpack_require__(9704),_u8a=__webpack_require__(7736),_toU8a=__webpack_require__(7846)},7846:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.nToU8a=function(value,options){const opts=(0,_spread.objectSpread)({bitLength:-1,isLe:!0,isNegative:!1},options),valueBi=(0,_toBigInt.nToBigInt)(value);if(valueBi===_consts._0n)return-1===opts.bitLength?new Uint8Array:new Uint8Array(Math.ceil((opts.bitLength||0)/8));const u8a=function(value,_ref){let{isLe,isNegative}=_ref;const arr=[];isNegative&&(value=(value+_consts._1n)*-_consts._1n);for(;value!==_consts._0n;){const mod=value%DIV,val=Number(isNegative?mod^NEG_MASK:mod);isLe?arr.push(val):arr.unshift(val),value=(value-mod)/DIV}return Uint8Array.from(arr)}(valueBi,opts);if(-1===opts.bitLength)return u8a;const byteLength=Math.ceil((opts.bitLength||0)/8),output=new Uint8Array(byteLength);opts.isNegative&&output.fill(255);return output.set(u8a,opts.isLe?0:byteLength-u8a.length),output};var _xBigint=__webpack_require__(3059),_spread=__webpack_require__(9704),_consts=__webpack_require__(1405),_toBigInt=__webpack_require__(5023);const DIV=(0,_xBigint.BigInt)(256),NEG_MASK=(0,_xBigint.BigInt)(255)},3672:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";var _interopRequireDefault=__webpack_require__(5318);Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"BN",{enumerable:!0,get:function(){return _bn.default}});var _bn=_interopRequireDefault(__webpack_require__(2207))},6212:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BN_ZERO=exports.BN_TWO=exports.BN_THREE=exports.BN_THOUSAND=exports.BN_TEN=exports.BN_SIX=exports.BN_SEVEN=exports.BN_QUINTILL=exports.BN_ONE=exports.BN_NINE=exports.BN_MILLION=exports.BN_MAX_INTEGER=exports.BN_HUNDRED=exports.BN_FOUR=exports.BN_FIVE=exports.BN_EIGHT=exports.BN_BILLION=void 0;var _bn=__webpack_require__(3672);const BN_ZERO=new _bn.BN(0);exports.BN_ZERO=BN_ZERO;const BN_ONE=new _bn.BN(1);exports.BN_ONE=BN_ONE;const BN_TWO=new _bn.BN(2);exports.BN_TWO=BN_TWO;const BN_THREE=new _bn.BN(3);exports.BN_THREE=BN_THREE;const BN_FOUR=new _bn.BN(4);exports.BN_FOUR=BN_FOUR;const BN_FIVE=new _bn.BN(5);exports.BN_FIVE=BN_FIVE;const BN_SIX=new _bn.BN(6);exports.BN_SIX=BN_SIX;const BN_SEVEN=new _bn.BN(7);exports.BN_SEVEN=BN_SEVEN;const BN_EIGHT=new _bn.BN(8);exports.BN_EIGHT=BN_EIGHT;const BN_NINE=new _bn.BN(9);exports.BN_NINE=BN_NINE;const BN_TEN=new _bn.BN(10);exports.BN_TEN=BN_TEN;const BN_HUNDRED=new _bn.BN(100);exports.BN_HUNDRED=BN_HUNDRED;const BN_THOUSAND=new _bn.BN(1e3);exports.BN_THOUSAND=BN_THOUSAND;const BN_MILLION=new _bn.BN(1e6);exports.BN_MILLION=BN_MILLION;const BN_BILLION=new _bn.BN(1e9);exports.BN_BILLION=BN_BILLION;const BN_QUINTILL=BN_BILLION.mul(BN_BILLION);exports.BN_QUINTILL=BN_QUINTILL;const BN_MAX_INTEGER=new _bn.BN(Number.MAX_SAFE_INTEGER);exports.BN_MAX_INTEGER=BN_MAX_INTEGER},35:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"bnFromHex",{enumerable:!0,get:function(){return _toBn.hexToBn}});var _toBn=__webpack_require__(4958)},2442:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _exportNames={BN:!0,bnFromHex:!0,bnMax:!0,bnMin:!0,bnSqrt:!0,bnToBn:!0,bnToHex:!0,bnToU8a:!0};Object.defineProperty(exports,"BN",{enumerable:!0,get:function(){return _bn.BN}}),Object.defineProperty(exports,"bnFromHex",{enumerable:!0,get:function(){return _fromHex.bnFromHex}}),Object.defineProperty(exports,"bnMax",{enumerable:!0,get:function(){return _min.bnMax}}),Object.defineProperty(exports,"bnMin",{enumerable:!0,get:function(){return _min.bnMin}}),Object.defineProperty(exports,"bnSqrt",{enumerable:!0,get:function(){return _sqrt.bnSqrt}}),Object.defineProperty(exports,"bnToBn",{enumerable:!0,get:function(){return _toBn.bnToBn}}),Object.defineProperty(exports,"bnToHex",{enumerable:!0,get:function(){return _toHex.bnToHex}}),Object.defineProperty(exports,"bnToU8a",{enumerable:!0,get:function(){return _toU8a.bnToU8a}});var _consts=__webpack_require__(6212);Object.keys(_consts).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_consts[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _consts[key]}}))}));var _bn=__webpack_require__(3672),_fromHex=__webpack_require__(35),_min=__webpack_require__(2891),_sqrt=__webpack_require__(4620),_toBn=__webpack_require__(7569),_toHex=__webpack_require__(2004),_toU8a=__webpack_require__(7899)},2891:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.bnMax=function(){for(var _len=arguments.length,items=new Array(_len),_key=0;_key<_len;_key++)items[_key]=arguments[_key];return find(items,_bn.BN.max)},exports.bnMin=function(){for(var _len2=arguments.length,items=new Array(_len2),_key2=0;_key2<_len2;_key2++)items[_key2]=arguments[_key2];return find(items,_bn.BN.min)},exports.find=find;var _assert=__webpack_require__(2944),_bn=__webpack_require__(3672);function find(items,cmp){(0,_assert.assert)(items.length>=1,"Must provide one or more BN arguments");let result=items[0];for(let i=1;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.bnSqrt=function(value){const n=(0,_toBn.bnToBn)(value);if((0,_assert.assert)(n.gte(_consts.BN_ZERO),"square root of negative numbers is not supported"),n.lte(_consts.BN_MAX_INTEGER))return new _bn.BN(Math.floor(Math.sqrt(n.toNumber())));let x0=SQRT_MAX_SAFE_INTEGER.clone();for(;;){const x1=n.div(x0).iadd(x0).ishrn(1);if(x0.eq(x1)||x0.eq(x1.sub(_consts.BN_ONE)))return x0;x0=x1}};var _assert=__webpack_require__(2944),_bn=__webpack_require__(3672),_consts=__webpack_require__(6212),_toBn=__webpack_require__(7569);const SQRT_MAX_SAFE_INTEGER=new _bn.BN(94906265)},7569:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.bnToBn=function(value){return value?_bn.BN.isBN(value)?value:(0,_hex.isHex)(value)?(0,_toBn.hexToBn)(value.toString()):(0,_bigInt.isBigInt)(value)?new _bn.BN(value.toString()):(0,_toBn2.isToBn)(value)?value.toBn():(0,_toBigInt.isToBigInt)(value)?new _bn.BN(value.toBigInt().toString()):new _bn.BN(value):new _bn.BN(0)};var _toBn=__webpack_require__(4958),_bigInt=__webpack_require__(175),_hex=__webpack_require__(1580),_toBigInt=__webpack_require__(4455),_toBn2=__webpack_require__(789),_bn=__webpack_require__(3672)},2004:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.bnToHex=function(value){let arg1=arguments.length>1&&void 0!==arguments[1]?arguments[1]:DEFAULT_OPTS,arg2=arguments.length>2?arguments[2]:void 0;return value?(0,_u8a.u8aToHex)((0,_toU8a.bnToU8a)(value,(0,_spread.objectSpread)({isLe:!1,isNegative:!1},(0,_number.isNumber)(arg1)?{bitLength:arg1,isLe:arg2}:arg1))):"0x00"};var _number=__webpack_require__(2425),_spread=__webpack_require__(9704),_u8a=__webpack_require__(7736),_toU8a=__webpack_require__(7899);const DEFAULT_OPTS={bitLength:-1,isLe:!1,isNegative:!1}},7899:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.bnToU8a=function(value){let arg1=arguments.length>1&&void 0!==arguments[1]?arguments[1]:DEFAULT_OPTS,arg2=arguments.length>2?arguments[2]:void 0;const{bitLength,isLe,isNegative}=(0,_spread.objectSpread)({bitLength:-1,isLe:!0,isNegative:!1},(0,_number.isNumber)(arg1)?{bitLength:arg1,isLe:arg2}:arg1),valueBn=(0,_toBn.bnToBn)(value),byteLength=-1===bitLength?Math.ceil(valueBn.bitLength()/8):Math.ceil((bitLength||0)/8);if(!value)return-1===bitLength?new Uint8Array:new Uint8Array(byteLength);const output=new Uint8Array(byteLength),bn=isNegative?valueBn.toTwos(8*byteLength):valueBn;return output.set(bn.toArray(isLe?"le":"be",byteLength),0),output};var _number=__webpack_require__(2425),_spread=__webpack_require__(9704),_toBn=__webpack_require__(7569);const DEFAULT_OPTS={bitLength:-1,isLe:!0,isNegative:!1}},3226:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"bufferToU8a",{enumerable:!0,get:function(){return _toU8a.bufferToU8a}});var _toU8a=__webpack_require__(6880)},6880:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.bufferToU8a=function(buffer){return new Uint8Array(buffer||[])}},643:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _exportNames={packageInfo:!0};Object.defineProperty(exports,"packageInfo",{enumerable:!0,get:function(){return _packageInfo.packageInfo}});var _packageInfo=__webpack_require__(321),_array=__webpack_require__(3488);Object.keys(_array).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_array[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _array[key]}}))}));var _assert=__webpack_require__(2944);Object.keys(_assert).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_assert[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _assert[key]}}))}));var _bi=__webpack_require__(9822);Object.keys(_bi).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_bi[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _bi[key]}}))}));var _bn=__webpack_require__(2442);Object.keys(_bn).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_bn[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _bn[key]}}))}));var _buffer=__webpack_require__(3226);Object.keys(_buffer).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_buffer[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _buffer[key]}}))}));var _compact=__webpack_require__(6344);Object.keys(_compact).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_compact[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _compact[key]}}))}));var _extractTime=__webpack_require__(7246);Object.keys(_extractTime).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_extractTime[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _extractTime[key]}}))}));var _format=__webpack_require__(7169);Object.keys(_format).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_format[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _format[key]}}))}));var _has=__webpack_require__(6140);Object.keys(_has).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_has[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _has[key]}}))}));var _hex=__webpack_require__(8614);Object.keys(_hex).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_hex[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _hex[key]}}))}));var _is=__webpack_require__(6959);Object.keys(_is).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_is[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _is[key]}}))}));var _lazy=__webpack_require__(4521);Object.keys(_lazy).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_lazy[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _lazy[key]}}))}));var _logger=__webpack_require__(9924);Object.keys(_logger).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_logger[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _logger[key]}}))}));var _memoize=__webpack_require__(4456);Object.keys(_memoize).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_memoize[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _memoize[key]}}))}));var _nextTick=__webpack_require__(5501);Object.keys(_nextTick).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_nextTick[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _nextTick[key]}}))}));var _number=__webpack_require__(8510);Object.keys(_number).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_number[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _number[key]}}))}));var _object=__webpack_require__(2200);Object.keys(_object).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_object[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _object[key]}}))}));var _promisify=__webpack_require__(4404);Object.keys(_promisify).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_promisify[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _promisify[key]}}))}));var _string=__webpack_require__(7556);Object.keys(_string).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_string[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _string[key]}}))}));var _stringify=__webpack_require__(5329);Object.keys(_stringify).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_stringify[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _stringify[key]}}))}));var _u8a=__webpack_require__(7736);Object.keys(_u8a).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_u8a[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _u8a[key]}}))}));var _versionDetect=__webpack_require__(9454);Object.keys(_versionDetect).forEach((function(key){"default"!==key&&"__esModule"!==key&&(Object.prototype.hasOwnProperty.call(_exportNames,key)||key in exports&&exports[key]===_versionDetect[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _versionDetect[key]}}))}))},4448:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compactAddLength=function(input){return(0,_u8a.u8aConcatStrict)([(0,_toU8a.compactToU8a)(input.length),input])};var _u8a=__webpack_require__(7736),_toU8a=__webpack_require__(5189)},7922:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compactFromU8a=function(input){const u8a=(0,_u8a.u8aToU8a)(input);switch(3&u8a[0]){case 0:return[1,new _bn.BN(u8a[0]>>>2)];case 1:return[2,new _bn.BN(u8a[0]+256*u8a[1]>>>2)];case 2:return[4,new _bn.BN(u8a[0]+256*u8a[1]+65536*u8a[2]+16777216*u8a[3]>>>2)]}const offset=5+(u8a[0]>>>2);switch(offset){case 5:return[5,new _bn.BN(u8a[1]+256*u8a[2]+65536*u8a[3]+16777216*u8a[4])];case 6:return[6,new _bn.BN(u8a[1]+256*u8a[2]+65536*u8a[3]+16777216*u8a[4]+4294967296*u8a[5])];case 7:return[7,new _bn.BN(u8a[1]+256*u8a[2]+65536*u8a[3]+16777216*u8a[4]+4294967296*u8a[5]+1099511627776*u8a[6])];default:return[offset,(0,_u8a.u8aToBn)(u8a.subarray(1,offset))]}},exports.compactFromU8aLim=function(u8a){switch(3&u8a[0]){case 0:return[1,u8a[0]>>>2];case 1:return[2,u8a[0]+256*u8a[1]>>>2];case 2:return[4,u8a[0]+256*u8a[1]+65536*u8a[2]+16777216*u8a[3]>>>2]}switch(5+(u8a[0]>>>2)){case 5:return[5,u8a[1]+256*u8a[2]+65536*u8a[3]+16777216*u8a[4]];case 6:return[6,u8a[1]+256*u8a[2]+65536*u8a[3]+16777216*u8a[4]+4294967296*u8a[5]];case 7:return[7,u8a[1]+256*u8a[2]+65536*u8a[3]+16777216*u8a[4]+4294967296*u8a[5]+1099511627776*u8a[6]];default:throw new Error("Compact input is > Number.MAX_SAFE_INTEGER")}};var _bn=__webpack_require__(2442),_u8a=__webpack_require__(7736)},6344:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"compactAddLength",{enumerable:!0,get:function(){return _addLength.compactAddLength}}),Object.defineProperty(exports,"compactFromU8a",{enumerable:!0,get:function(){return _fromU8a.compactFromU8a}}),Object.defineProperty(exports,"compactFromU8aLim",{enumerable:!0,get:function(){return _fromU8a.compactFromU8aLim}}),Object.defineProperty(exports,"compactStripLength",{enumerable:!0,get:function(){return _stripLength.compactStripLength}}),Object.defineProperty(exports,"compactToU8a",{enumerable:!0,get:function(){return _toU8a.compactToU8a}});var _addLength=__webpack_require__(4448),_stripLength=__webpack_require__(606),_fromU8a=__webpack_require__(7922),_toU8a=__webpack_require__(5189)},606:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compactStripLength=function(input){const[offset,length]=(0,_fromU8a.compactFromU8a)(input),total=offset+length.toNumber();return[total,input.subarray(offset,total)]};var _fromU8a=__webpack_require__(7922)},5189:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compactToU8a=function(value){const bn=(0,_bn.bnToBn)(value);if(bn.lte(MAX_U8))return new Uint8Array([bn.toNumber()<<2]);if(bn.lte(MAX_U16))return(0,_bn.bnToU8a)(bn.shln(2).iadd(_bn.BN_ONE),BL_16);if(bn.lte(MAX_U32))return(0,_bn.bnToU8a)(bn.shln(2).iadd(_bn.BN_TWO),BL_32);const u8a=(0,_bn.bnToU8a)(bn);let length=u8a.length;for(;0===u8a[length-1];)length--;return(0,_assert.assert)(length>=4,"Invalid length, previous checks match anything less than 2^30"),(0,_u8a.u8aConcatStrict)([new Uint8Array([3+(length-4<<2)]),u8a.subarray(0,length)])};var _assert=__webpack_require__(2944),_bn=__webpack_require__(2442),_u8a=__webpack_require__(7736);const MAX_U8=_bn.BN_TWO.pow(new _bn.BN(6)).isub(_bn.BN_ONE),MAX_U16=_bn.BN_TWO.pow(new _bn.BN(14)).isub(_bn.BN_ONE),MAX_U32=_bn.BN_TWO.pow(new _bn.BN(30)).isub(_bn.BN_ONE),BL_16={bitLength:16},BL_32={bitLength:32}},4116:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _xTextdecoder=__webpack_require__(7653),_xTextencoder=__webpack_require__(2012),_default=[_xTextdecoder.packageInfo,_xTextencoder.packageInfo];exports.default=_default},6503:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{"use strict";var _detectOther=__webpack_require__(5318)(__webpack_require__(4116)),_packageInfo=__webpack_require__(321);(0,__webpack_require__(9454).detectPackage)(_packageInfo.packageInfo,null,_detectOther.default)},7246:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.extractTime=extractTime;var _spread=__webpack_require__(9704);const ZERO={days:0,hours:0,milliseconds:0,minutes:0,seconds:0};function addTime(a,b){return{days:a.days+b.days,hours:a.hours+b.hours,milliseconds:a.milliseconds+b.milliseconds,minutes:a.minutes+b.minutes,seconds:a.seconds+b.seconds}}function extractHrs(milliseconds,mins){const hrs=mins/60;if(hrs<24){const hours=Math.floor(hrs);return addTime((0,_spread.objectSpread)({},ZERO,{hours}),extractTime(milliseconds-3600*hours*1e3))}return function(milliseconds,hrs){const days=Math.floor(hrs/24);return addTime((0,_spread.objectSpread)({},ZERO,{days}),extractTime(milliseconds-86400*days*1e3))}(milliseconds,hrs)}function extractSecs(milliseconds){const secs=milliseconds/1e3;if(secs<60){const seconds=Math.floor(secs);return addTime((0,_spread.objectSpread)({},ZERO,{seconds}),extractTime(milliseconds-1e3*seconds))}return function(milliseconds,secs){const mins=secs/60;if(mins<60){const minutes=Math.floor(mins);return addTime((0,_spread.objectSpread)({},ZERO,{minutes}),extractTime(milliseconds-60*minutes*1e3))}return extractHrs(milliseconds,mins)}(milliseconds,secs)}function extractTime(milliseconds){return milliseconds?milliseconds<1e3?(0,_spread.objectSpread)({},ZERO,{milliseconds}):extractSecs(milliseconds):ZERO}},9307:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatBalance=void 0;var _toBn=__webpack_require__(7569),_boolean=__webpack_require__(7186),_undefined=__webpack_require__(4617),_formatDecimal=__webpack_require__(2079),_si=__webpack_require__(1335);const DEFAULT_UNIT=_si.SI[_si.SI_MID].text;let defaultDecimals=0,defaultUnit=DEFAULT_UNIT;function getUnits(si,withSi,withSiFull,withUnit){const unit=(0,_boolean.isBoolean)(withUnit)?_si.SI[_si.SI_MID].text:withUnit;return withSi||withSiFull?"-"===si.value?withUnit?` ${unit}`:"":` ${withSiFull?`${si.text}${withUnit?" ":""}`:si.value}${withUnit?unit:""}`:""}function getPrePost(text,decimals,forceUnit){const si=(0,_si.calcSi)(text,decimals,forceUnit),mid=text.length-(decimals+si.power);return[si,text.substring(0,mid)||"0",`${`${new Array((mid<0?0-mid:0)+1).join("0")}${text}`.substring(mid<0?0:mid)}0000`.substring(0,4)]}const formatBalance=function(input){let options=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],optDecimals=arguments.length>2&&void 0!==arguments[2]?arguments[2]:defaultDecimals,text=(0,_toBn.bnToBn)(input).toString();if(0===text.length||"0"===text)return"0";const{decimals=optDecimals,forceUnit,withSi=!0,withSiFull=!1,withUnit=!0}=(0,_boolean.isBoolean)(options)?{withSi:options}:options;let sign="";text[0].startsWith("-")&&(sign="-",text=text.substring(1));const[si,prefix,postfix]=getPrePost(text,decimals,forceUnit),units=getUnits(si,withSi,withSiFull,withUnit);return`${sign}${(0,_formatDecimal.formatDecimal)(prefix)}.${postfix}${units}`};exports.formatBalance=formatBalance,formatBalance.calcSi=function(text){let decimals=arguments.length>1&&void 0!==arguments[1]?arguments[1]:defaultDecimals;return(0,_si.calcSi)(text,decimals)},formatBalance.findSi=_si.findSi,formatBalance.getDefaults=()=>({decimals:defaultDecimals,unit:defaultUnit}),formatBalance.getOptions=function(){let decimals=arguments.length>0&&void 0!==arguments[0]?arguments[0]:defaultDecimals;return _si.SI.filter((_ref=>{let{power}=_ref;return!(power<0)||decimals+power>=0}))},formatBalance.setDefaults=_ref2=>{let{decimals,unit}=_ref2;defaultDecimals=(0,_undefined.isUndefined)(decimals)?defaultDecimals:Array.isArray(decimals)?decimals[0]:decimals,defaultUnit=(0,_undefined.isUndefined)(unit)?defaultUnit:Array.isArray(unit)?unit[0]:unit,_si.SI[_si.SI_MID].text=defaultUnit}},7041:(__unused_webpack_module,exports)=>{"use strict";function zeroPad(value){return value.toString().padStart(2,"0")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatDate=function(date){const year=date.getFullYear().toString(),month=zeroPad(date.getMonth()+1),day=zeroPad(date.getDate()),hour=zeroPad(date.getHours()),minute=zeroPad(date.getMinutes()),second=zeroPad(date.getSeconds());return`${year}-${month}-${day} ${hour}:${minute}:${second}`}},2079:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatDecimal=function(value){const isNegative=value[0].startsWith("-"),matched=isNegative?value.substring(1).match(NUMBER_REGEX):value.match(NUMBER_REGEX);return matched?`${isNegative?"-":""}${matched.join(",")}`:value};const NUMBER_REGEX=new RegExp("(\\d+?)(?=(\\d{3})+(?!\\d)|$)","g")},4513:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatElapsed=function(now,value){const tsNow=now&&now.getTime()||0,tsValue=value instanceof Date?value.getTime():(0,_toBn.bnToBn)(value).toNumber();return tsNow&&tsValue?function(elapsed){if(elapsed<15)return`${elapsed.toFixed(1)}s`;if(elapsed<60)return(0|elapsed)+"s";if(elapsed<3600)return(elapsed/60|0)+"m";return(elapsed/3600|0)+"h"}(Math.max(Math.abs(tsNow-tsValue),0)/1e3):"0.0s"};var _toBn=__webpack_require__(7569)},1855:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatNumber=function(value){return(0,_formatDecimal.formatDecimal)((0,_toBn.bnToBn)(value).toString())};var _toBn=__webpack_require__(7569),_formatDecimal=__webpack_require__(2079)},7169:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"calcSi",{enumerable:!0,get:function(){return _si.calcSi}}),Object.defineProperty(exports,"findSi",{enumerable:!0,get:function(){return _si.findSi}}),Object.defineProperty(exports,"formatBalance",{enumerable:!0,get:function(){return _formatBalance.formatBalance}}),Object.defineProperty(exports,"formatDate",{enumerable:!0,get:function(){return _formatDate.formatDate}}),Object.defineProperty(exports,"formatDecimal",{enumerable:!0,get:function(){return _formatDecimal.formatDecimal}}),Object.defineProperty(exports,"formatElapsed",{enumerable:!0,get:function(){return _formatElapsed.formatElapsed}}),Object.defineProperty(exports,"formatNumber",{enumerable:!0,get:function(){return _formatNumber.formatNumber}});var _formatBalance=__webpack_require__(9307),_formatDate=__webpack_require__(7041),_formatDecimal=__webpack_require__(2079),_formatElapsed=__webpack_require__(4513),_formatNumber=__webpack_require__(1855),_si=__webpack_require__(1335)},1335:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SI_MID=exports.SI=void 0,exports.calcSi=function(text,decimals,forceUnit){if(forceUnit)return findSi(forceUnit);const siDefIndex=7+Math.ceil((text.length-decimals)/3);return SI[siDefIndex]||SI[siDefIndex<0?0:SI.length-1]},exports.findSi=findSi;exports.SI_MID=8;const SI=[{power:-24,text:"yocto",value:"y"},{power:-21,text:"zepto",value:"z"},{power:-18,text:"atto",value:"a"},{power:-15,text:"femto",value:"f"},{power:-12,text:"pico",value:"p"},{power:-9,text:"nano",value:"n"},{power:-6,text:"micro",value:"µ"},{power:-3,text:"milli",value:"m"},{power:0,text:"Unit",value:"-"},{power:3,text:"Kilo",value:"k"},{power:6,text:"Mill",value:"M"},{power:9,text:"Bill",value:"B"},{power:12,text:"Tril",value:"T"},{power:15,text:"Peta",value:"P"},{power:18,text:"Exa",value:"E"},{power:21,text:"Zeta",value:"Z"},{power:24,text:"Yotta",value:"Y"}];function findSi(type){for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hasWasm=exports.hasProcess=exports.hasEsm=exports.hasDirname=exports.hasCjs=exports.hasBuffer=exports.hasBigInt=void 0;var _xBigint=__webpack_require__(3059);const hasBigInt="function"==typeof _xBigint.BigInt&&"function"==typeof _xBigint.BigInt.asIntN;exports.hasBigInt=hasBigInt;const hasBuffer="undefined"!=typeof Buffer;exports.hasBuffer=hasBuffer;exports.hasCjs=true;const hasDirname="undefined"!=typeof __dirname;exports.hasDirname=hasDirname;exports.hasEsm=false;const hasProcess="object"==typeof process;exports.hasProcess=hasProcess;const hasWasm="undefined"!=typeof WebAssembly;exports.hasWasm=hasWasm},8899:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hexAddPrefix=function(value){return value&&(0,_hasPrefix.hexHasPrefix)(value)?value:`0x${value&&value.length%2==1?"0":""}${value||""}`};var _hasPrefix=__webpack_require__(5717)},9674:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.U8_TO_HEX=exports.U16_TO_HEX=exports.HEX_TO_U8=exports.HEX_TO_U16=void 0;const U8_TO_HEX=new Array(256);exports.U8_TO_HEX=U8_TO_HEX;const U16_TO_HEX=new Array(65536);exports.U16_TO_HEX=U16_TO_HEX;const HEX_TO_U8={};exports.HEX_TO_U8=HEX_TO_U8;const HEX_TO_U16={};exports.HEX_TO_U16=HEX_TO_U16;for(let n=0;n<256;n++){const hex=n.toString(16).padStart(2,"0");U8_TO_HEX[n]=hex,HEX_TO_U8[hex]=n}for(let i=0;i<256;i++)for(let j=0;j<256;j++){const hex=U8_TO_HEX[i]+U8_TO_HEX[j],n=i<<8|j;U16_TO_HEX[n]=hex,HEX_TO_U16[hex]=n}},4805:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hexFixLength=function(value){let bitLength=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,withPadding=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const strLength=Math.ceil(bitLength/4),hexLength=strLength+2;return(0,_addPrefix.hexAddPrefix)(-1===bitLength||value.length===hexLength||!withPadding&&value.lengthhexLength?(0,_stripPrefix.hexStripPrefix)(value).slice(-1*strLength):`${"0".repeat(strLength)}${(0,_stripPrefix.hexStripPrefix)(value)}`.slice(-1*strLength))};var _addPrefix=__webpack_require__(8899),_stripPrefix=__webpack_require__(8338)},5717:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hexHasPrefix=function(value){return!!value&&(0,_hex.isHex)(value,-1)};var _hex=__webpack_require__(1580)},8614:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"hexAddPrefix",{enumerable:!0,get:function(){return _addPrefix.hexAddPrefix}}),Object.defineProperty(exports,"hexFixLength",{enumerable:!0,get:function(){return _fixLength.hexFixLength}}),Object.defineProperty(exports,"hexHasPrefix",{enumerable:!0,get:function(){return _hasPrefix.hexHasPrefix}}),Object.defineProperty(exports,"hexStripPrefix",{enumerable:!0,get:function(){return _stripPrefix.hexStripPrefix}}),Object.defineProperty(exports,"hexToBigInt",{enumerable:!0,get:function(){return _toBigInt.hexToBigInt}}),Object.defineProperty(exports,"hexToBn",{enumerable:!0,get:function(){return _toBn.hexToBn}}),Object.defineProperty(exports,"hexToNumber",{enumerable:!0,get:function(){return _toNumber.hexToNumber}}),Object.defineProperty(exports,"hexToString",{enumerable:!0,get:function(){return _toString.hexToString}}),Object.defineProperty(exports,"hexToU8a",{enumerable:!0,get:function(){return _toU8a.hexToU8a}});var _addPrefix=__webpack_require__(8899),_fixLength=__webpack_require__(4805),_hasPrefix=__webpack_require__(5717),_stripPrefix=__webpack_require__(8338),_toBigInt=__webpack_require__(8325),_toBn=__webpack_require__(4958),_toNumber=__webpack_require__(577),_toString=__webpack_require__(5269),_toU8a=__webpack_require__(2166)},8338:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hexStripPrefix=function(value){if(!value||"0x"===value)return"";if(_hex.REGEX_HEX_PREFIXED.test(value))return value.substring(2);if(_hex.REGEX_HEX_NOPREFIX.test(value))return value;throw new Error(`Expected hex value to convert, found '${value}'`)};var _hex=__webpack_require__(1580)},8325:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hexToBigInt=function(value){let options=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return value&&"0x"!==value?(0,_toBigInt.u8aToBigInt)((0,_toU8a.hexToU8a)(value),(0,_spread.objectSpread)({isLe:!1,isNegative:!1},options)):(0,_xBigint.BigInt)(0)};var _xBigint=__webpack_require__(3059),_spread=__webpack_require__(9704),_toBigInt=__webpack_require__(6755),_toU8a=__webpack_require__(2166)},4958:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hexToBn=function(value){let options=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!value||"0x"===value)return new _bn.BN(0);const{isLe,isNegative}=(0,_spread.objectSpread)({isLe:!1,isNegative:!1},(0,_boolean.isBoolean)(options)?{isLe:options}:options),stripped=(0,_stripPrefix.hexStripPrefix)(value),bn=new _bn.BN(stripped,16,isLe?"le":"be");return isNegative?bn.fromTwos(4*stripped.length):bn};var _bn=__webpack_require__(3672),_boolean=__webpack_require__(7186),_spread=__webpack_require__(9704),_stripPrefix=__webpack_require__(8338)},577:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hexToNumber=function(value){return value?(0,_toBn.hexToBn)(value).toNumber():NaN};var _toBn=__webpack_require__(4958)},5269:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hexToString=function(_value){return(0,_toString.u8aToString)((0,_toU8a.hexToU8a)(_value))};var _toString=__webpack_require__(2913),_toU8a=__webpack_require__(2166)},2166:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hexToU8a=function(_value){let bitLength=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;if(!_value)return new Uint8Array;const value=(0,_stripPrefix.hexStripPrefix)(_value).toLowerCase(),valLength=value.length/2,endLength=Math.ceil(-1===bitLength?valLength:bitLength/8),result=new Uint8Array(endLength),offset=endLength>valLength?endLength-valLength:0,dv=new DataView(result.buffer,offset),mod=(endLength-offset)%2,length=endLength-offset-mod;for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),__webpack_require__(6503);var _bundle=__webpack_require__(643);Object.keys(_bundle).forEach((function(key){"default"!==key&&"__esModule"!==key&&(key in exports&&exports[key]===_bundle[key]||Object.defineProperty(exports,key,{enumerable:!0,get:function(){return _bundle[key]}}))}))},7594:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isArray=function(value){return Array.isArray(value)}},7919:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isAscii=function(value){const isStringIn=(0,_string.isString)(value);if(value)return isStringIn&&!(0,_hex.isHex)(value)?value.toString().split("").every(isAsciiChar):(0,_toU8a.u8aToU8a)(value).every(isAsciiByte);return isStringIn};var _toU8a=__webpack_require__(3365),_hex=__webpack_require__(1580),_string=__webpack_require__(3300);const FORMAT=[9,10,13];function isAsciiByte(b){return b<127&&(b>=32||FORMAT.includes(b))}function isAsciiChar(s){return isAsciiByte(s.charCodeAt(0))}},175:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isBigInt=function(value){return"bigint"==typeof value}},5767:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isBn=function(value){return _bn.BN.isBN(value)};var _bn=__webpack_require__(3672)},7186:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isBoolean=function(value){return"boolean"==typeof value}},5109:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isBuffer=function(value){return _has.hasBuffer&&(0,_function.isFunction)(value&&value.readDoubleLE)&&Buffer.isBuffer(value)};var _has=__webpack_require__(6140),_function=__webpack_require__(2404)},804:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isChildClass=function(Parent,Child){return!!Child&&(Parent===Child||Parent.isPrototypeOf(Child))}},2139:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isCodec=function(value){return checkCodec(value)&&checkRegistry(value.registry)};var _helpers=__webpack_require__(3179);const checkCodec=(0,_helpers.isOnObject)("toHex","toU8a"),checkRegistry=(0,_helpers.isOnObject)("get")},5511:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isCompact=void 0;const isCompact=(0,__webpack_require__(3179).isOnObject)("toBigInt","toBn","toNumber","unwrap");exports.isCompact=isCompact},4880:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isError=function(value){return(value&&value.constructor)===Error||value instanceof Error}},2404:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isFunction=function(value){return"function"==typeof value}},3179:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isOn=function(){for(var _len=arguments.length,fns=new Array(_len),_key=0;_key<_len;_key++)fns[_key]=arguments[_key];return value=>((0,_object.isObject)(value)||(0,_function.isFunction)(value))&&fns.every((f=>(0,_function.isFunction)(value[f])))},exports.isOnObject=function(){for(var _len2=arguments.length,fns=new Array(_len2),_key2=0;_key2<_len2;_key2++)fns[_key2]=arguments[_key2];return value=>(0,_object.isObject)(value)&&fns.every((f=>(0,_function.isFunction)(value[f])))};var _function=__webpack_require__(2404),_object=__webpack_require__(7509)},1580:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.REGEX_HEX_PREFIXED=exports.REGEX_HEX_NOPREFIX=void 0,exports.isHex=function(value){let bitLength=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,ignoreLength=arguments.length>2?arguments[2]:void 0;return"string"==typeof value&&("0x"===value||REGEX_HEX_PREFIXED.test(value))&&(-1===bitLength?ignoreLength||value.length%2==0:value.length===2+Math.ceil(bitLength/4))};const REGEX_HEX_PREFIXED=/^0x[\da-fA-F]+$/;exports.REGEX_HEX_PREFIXED=REGEX_HEX_PREFIXED;exports.REGEX_HEX_NOPREFIX=/^[\da-fA-F]+$/},6959:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"isArray",{enumerable:!0,get:function(){return _array.isArray}}),Object.defineProperty(exports,"isAscii",{enumerable:!0,get:function(){return _ascii.isAscii}}),Object.defineProperty(exports,"isBigInt",{enumerable:!0,get:function(){return _bigInt.isBigInt}}),Object.defineProperty(exports,"isBn",{enumerable:!0,get:function(){return _bn.isBn}}),Object.defineProperty(exports,"isBoolean",{enumerable:!0,get:function(){return _boolean.isBoolean}}),Object.defineProperty(exports,"isBuffer",{enumerable:!0,get:function(){return _buffer.isBuffer}}),Object.defineProperty(exports,"isChildClass",{enumerable:!0,get:function(){return _childClass.isChildClass}}),Object.defineProperty(exports,"isCodec",{enumerable:!0,get:function(){return _codec.isCodec}}),Object.defineProperty(exports,"isCompact",{enumerable:!0,get:function(){return _compact.isCompact}}),Object.defineProperty(exports,"isError",{enumerable:!0,get:function(){return _error.isError}}),Object.defineProperty(exports,"isFunction",{enumerable:!0,get:function(){return _function.isFunction}}),Object.defineProperty(exports,"isHex",{enumerable:!0,get:function(){return _hex.isHex}}),Object.defineProperty(exports,"isInstanceOf",{enumerable:!0,get:function(){return _instanceOf.isInstanceOf}}),Object.defineProperty(exports,"isIp",{enumerable:!0,get:function(){return _ip.isIp}}),Object.defineProperty(exports,"isJsonObject",{enumerable:!0,get:function(){return _jsonObject.isJsonObject}}),Object.defineProperty(exports,"isNull",{enumerable:!0,get:function(){return _null.isNull}}),Object.defineProperty(exports,"isNumber",{enumerable:!0,get:function(){return _number.isNumber}}),Object.defineProperty(exports,"isObject",{enumerable:!0,get:function(){return _object.isObject}}),Object.defineProperty(exports,"isObservable",{enumerable:!0,get:function(){return _observable.isObservable}}),Object.defineProperty(exports,"isPromise",{enumerable:!0,get:function(){return _promise.isPromise}}),Object.defineProperty(exports,"isString",{enumerable:!0,get:function(){return _string.isString}}),Object.defineProperty(exports,"isTestChain",{enumerable:!0,get:function(){return _testChain.isTestChain}}),Object.defineProperty(exports,"isToBigInt",{enumerable:!0,get:function(){return _toBigInt.isToBigInt}}),Object.defineProperty(exports,"isToBn",{enumerable:!0,get:function(){return _toBn.isToBn}}),Object.defineProperty(exports,"isU8a",{enumerable:!0,get:function(){return _u8a.isU8a}}),Object.defineProperty(exports,"isUndefined",{enumerable:!0,get:function(){return _undefined.isUndefined}}),Object.defineProperty(exports,"isUtf8",{enumerable:!0,get:function(){return _utf.isUtf8}}),Object.defineProperty(exports,"isWasm",{enumerable:!0,get:function(){return _wasm.isWasm}});var _array=__webpack_require__(7594),_ascii=__webpack_require__(7919),_bigInt=__webpack_require__(175),_bn=__webpack_require__(5767),_buffer=__webpack_require__(5109),_boolean=__webpack_require__(7186),_childClass=__webpack_require__(804),_codec=__webpack_require__(2139),_compact=__webpack_require__(5511),_error=__webpack_require__(4880),_function=__webpack_require__(2404),_hex=__webpack_require__(1580),_instanceOf=__webpack_require__(4705),_ip=__webpack_require__(745),_jsonObject=__webpack_require__(6e3),_null=__webpack_require__(9111),_number=__webpack_require__(2425),_object=__webpack_require__(7509),_observable=__webpack_require__(6913),_promise=__webpack_require__(4711),_string=__webpack_require__(3300),_testChain=__webpack_require__(4673),_toBigInt=__webpack_require__(4455),_toBn=__webpack_require__(789),_u8a=__webpack_require__(9727),_undefined=__webpack_require__(4617),_utf=__webpack_require__(8157),_wasm=__webpack_require__(2993)},4705:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isInstanceOf=function(value,Clazz){return(value&&value.constructor)===Clazz||value instanceof Clazz}},745:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";var _interopRequireDefault=__webpack_require__(5318);Object.defineProperty(exports,"__esModule",{value:!0}),exports.isIp=function(value,type){if("v4"===type)return _ipRegex.default.v4({exact:!0}).test(value);if("v6"===type)return _ipRegex.default.v6({exact:!0}).test(value);return(0,_ipRegex.default)({exact:!0}).test(value)};var _ipRegex=_interopRequireDefault(__webpack_require__(1476))},6e3:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isJsonObject=function(value){const str="string"!=typeof value?(0,_stringify.stringify)(value):value;try{const obj=JSON.parse(str);return"object"==typeof obj&&null!==obj}catch(e){return!1}};var _stringify=__webpack_require__(5329)},9111:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isNull=function(value){return null===value}},2425:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isNumber=function(value){return"number"==typeof value}},7509:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isObject=function(value){return!!value&&"object"==typeof value}},6913:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isObservable=void 0;const isObservable=(0,__webpack_require__(3179).isOn)("next");exports.isObservable=isObservable},4711:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isPromise=void 0;const isPromise=(0,__webpack_require__(3179).isOnObject)("catch","then");exports.isPromise=isPromise},3300:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isString=function(value){return"string"==typeof value||value instanceof String}},4673:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isTestChain=function(chain){if(!chain)return!1;return!!REGEX_DEV.test(chain.toString())};const REGEX_DEV=/(Development|Local Testnet)$/},4455:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isToBigInt=void 0;const isToBigInt=(0,__webpack_require__(3179).isOn)("toBigInt");exports.isToBigInt=isToBigInt},789:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isToBn=void 0;const isToBn=(0,__webpack_require__(3179).isOn)("toBn");exports.isToBn=isToBn},9727:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isU8a=function(value){return(value&&value.constructor)===Uint8Array||value instanceof Uint8Array}},4617:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isUndefined=function(value){return void 0===value}},8157:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isUtf8=function(value){if(!value)return(0,_string.isString)(value);const u8a=(0,_toU8a.u8aToU8a)(value),len=u8a.length;let i=0;for(;i=194&&u8a[i]<=223){if(!(i+1191)return!1;i+=2}else if(224===u8a[i]){if(!(i+2191)return!1;if(u8a[i+2]<128||u8a[i+2]>191)return!1;i+=3}else if(u8a[i]>=225&&u8a[i]<=236){if(!(i+2191)return!1;if(u8a[i+2]<128||u8a[i+2]>191)return!1;i+=3}else if(237===u8a[i]){if(!(i+2159)return!1;if(u8a[i+2]<128||u8a[i+2]>191)return!1;i+=3}else if(u8a[i]>=238&&u8a[i]<=239){if(!(i+2191)return!1;if(u8a[i+2]<128||u8a[i+2]>191)return!1;i+=3}else if(240===u8a[i]){if(!(i+3191)return!1;if(u8a[i+2]<128||u8a[i+2]>191)return!1;if(u8a[i+3]<128||u8a[i+3]>191)return!1;i+=4}else if(u8a[i]>=241&&u8a[i]<=243){if(!(i+3191)return!1;if(u8a[i+2]<128||u8a[i+2]>191)return!1;if(u8a[i+3]<128||u8a[i+3]>191)return!1;i+=4}else{if(244!==u8a[i])return!1;if(!(i+3143)return!1;if(u8a[i+2]<128||u8a[i+2]>191)return!1;if(u8a[i+3]<128||u8a[i+3]>191)return!1;i+=4}return!0};var _toU8a=__webpack_require__(3365),_string=__webpack_require__(3300)},2993:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isWasm=function(value){return(0,_u8a.isU8a)(value)&&(0,_eq.u8aEq)(value.subarray(0,4),WASM_MAGIC)};var _eq=__webpack_require__(6594),_u8a=__webpack_require__(9727);const WASM_MAGIC=new Uint8Array([0,97,115,109])},4521:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.lazyMethod=lazyMethod,exports.lazyMethods=function(result,items,creator,getName){for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.logger=function(_type){const type=`${_type.toUpperCase()}:`.padStart(16),[isDebug,maxSize]=function(type){const env=(_has.hasProcess?process:{}).env||{},maxSize=parseInt(env.DEBUG_MAX||"-1",10);return[getDebugFlag((env.DEBUG||"").toLowerCase().split(","),type),isNaN(maxSize)?-1:maxSize]}(_type.toLowerCase());return{debug:isDebug?function(){for(var _len=arguments.length,values=new Array(_len),_key=0;_key<_len;_key++)values[_key]=arguments[_key];return apply("debug",type,values,maxSize)}:noop,error:function(){for(var _len2=arguments.length,values=new Array(_len2),_key2=0;_key2<_len2;_key2++)values[_key2]=arguments[_key2];return apply("error",type,values)},log:function(){for(var _len3=arguments.length,values=new Array(_len3),_key3=0;_key3<_len3;_key3++)values[_key3]=arguments[_key3];return apply("log",type,values)},noop,warn:function(){for(var _len4=arguments.length,values=new Array(_len4),_key4=0;_key4<_len4;_key4++)values[_key4]=arguments[_key4];return apply("warn",type,values)}}},exports.loggerFormat=loggerFormat;var _formatDate=__webpack_require__(7041),_bn=__webpack_require__(5767),_buffer=__webpack_require__(5109),_function=__webpack_require__(2404),_object=__webpack_require__(7509),_u8a=__webpack_require__(9727),_toHex=__webpack_require__(9481),_toU8a=__webpack_require__(3365),_has=__webpack_require__(6140);const logTo={debug:"log",error:"error",log:"log",warn:"warn"};function loggerFormat(value){return Array.isArray(value)?value.map(loggerFormat):(0,_bn.isBn)(value)?value.toString():(0,_u8a.isU8a)(value)||(0,_buffer.isBuffer)(value)?(0,_toHex.u8aToHex)((0,_toU8a.u8aToU8a)(value)):function(value){if(value&&(0,_object.isObject)(value)&&value.constructor===Object){const result={};for(const k of Object.keys(value))result[k]=loggerFormat(value[k]);return result}return value}(value)}function formatWithLength(maxLength){return v=>{if(maxLength<=0)return v;const r=`${v}`;return r.length3&&void 0!==arguments[3]?arguments[3]:-1;if(1===values.length&&(0,_function.isFunction)(values[0])){const fnResult=values[0]();return apply(log,type,Array.isArray(fnResult)?fnResult:[fnResult],maxSize)}console[logTo[log]]((0,_formatDate.formatDate)(new Date),type,...values.map(loggerFormat).map(formatWithLength(maxSize)))}function noop(){}function isDebugOn(e,type){return!!e&&("*"===e||type===e||e.endsWith("*")&&type.startsWith(e.slice(0,-1)))}function isDebugOff(e,type){return!!e&&e.startsWith("-")&&(type===e.slice(1)||e.endsWith("*")&&type.startsWith(e.slice(1,-1)))}function getDebugFlag(env,type){let flag=!1;for(const e of env)isDebugOn(e,type)?flag=!0:isDebugOff(e,type)&&(flag=!1);return flag}},4456:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.memoize=function(fn){let{getInstanceId=defaultGetId}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const cache={},memoized=function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];const stringParams=(0,_stringify.stringify)(args),instanceId=getInstanceId();return cache[instanceId]||(cache[instanceId]={}),(0,_undefined.isUndefined)(cache[instanceId][stringParams])&&(cache[instanceId][stringParams]=fn(...args)),cache[instanceId][stringParams]};return memoized.unmemoize=function(){for(var _len2=arguments.length,args=new Array(_len2),_key2=0;_key2<_len2;_key2++)args[_key2]=arguments[_key2];const stringParams=(0,_stringify.stringify)(args),instanceId=getInstanceId();cache[instanceId]&&!(0,_undefined.isUndefined)(cache[instanceId][stringParams])&&delete cache[instanceId][stringParams]},memoized};var _undefined=__webpack_require__(4617),_stringify=__webpack_require__(5329);function defaultGetId(){return"none"}},5501:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.nextTick=function(onExec,onError){Promise.resolve().then((()=>{onExec()})).catch((error=>{onError?onError(error):console.error(error)}))}},8510:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"numberToHex",{enumerable:!0,get:function(){return _toHex.numberToHex}}),Object.defineProperty(exports,"numberToU8a",{enumerable:!0,get:function(){return _toU8a.numberToU8a}});var _toHex=__webpack_require__(8441),_toU8a=__webpack_require__(3143)},8441:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.numberToHex=function(value){let bitLength=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;if((0,_undefined.isUndefined)(value)||(0,_null.isNull)(value)||isNaN(value))return"0x";const hex=value.toString(16);return(0,_fixLength.hexFixLength)(hex.length%2?`0${hex}`:hex,bitLength,!0)};var _fixLength=__webpack_require__(4805),_null=__webpack_require__(9111),_undefined=__webpack_require__(4617)},3143:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.numberToU8a=function(value){let bitLength=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return(0,_undefined.isUndefined)(value)||(0,_null.isNull)(value)||isNaN(value)?new Uint8Array:(0,_toU8a.hexToU8a)((0,_toHex.numberToHex)(value,bitLength))};var _toU8a=__webpack_require__(2166),_null=__webpack_require__(9111),_undefined=__webpack_require__(4617),_toHex=__webpack_require__(8441)},7437:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectClear=function(value){const keys=Object.keys(value);for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectCopy=function(source){return(0,_spread.objectSpread)({},source)};var _spread=__webpack_require__(9704)},4185:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectEntries=function(obj){return Object.entries(obj)}},2200:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"objectClear",{enumerable:!0,get:function(){return _clear.objectClear}}),Object.defineProperty(exports,"objectCopy",{enumerable:!0,get:function(){return _copy.objectCopy}}),Object.defineProperty(exports,"objectEntries",{enumerable:!0,get:function(){return _entries.objectEntries}}),Object.defineProperty(exports,"objectKeys",{enumerable:!0,get:function(){return _keys.objectKeys}}),Object.defineProperty(exports,"objectProperties",{enumerable:!0,get:function(){return _property.objectProperties}}),Object.defineProperty(exports,"objectProperty",{enumerable:!0,get:function(){return _property.objectProperty}}),Object.defineProperty(exports,"objectSpread",{enumerable:!0,get:function(){return _spread.objectSpread}}),Object.defineProperty(exports,"objectValues",{enumerable:!0,get:function(){return _values.objectValues}});var _clear=__webpack_require__(7437),_copy=__webpack_require__(1174),_entries=__webpack_require__(4185),_keys=__webpack_require__(6032),_property=__webpack_require__(1015),_spread=__webpack_require__(9704),_values=__webpack_require__(2499)},6032:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectKeys=function(value){return Object.keys(value)}},1015:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectProperties=function(that,keys,getter){for(let i=0;igetter(k,i)))},exports.objectProperty=objectProperty;var _undefined=__webpack_require__(4617);function objectProperty(that,key,getter){!Object.prototype.hasOwnProperty.call(that,key)&&(0,_undefined.isUndefined)(that[key])&&Object.defineProperty(that,key,{enumerable:!0,get:()=>getter(key)})}},9704:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectSpread=function(dest){for(let i=0;i<(arguments.length<=1?0:arguments.length-1);i++){const src=i+1<1||arguments.length<=i+1?void 0:arguments[i+1];if(src){const keys=(0,_keys.objectKeys)(src);for(let j=0;j{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectValues=function(obj){return Object.values(obj)}},321:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packageInfo=void 0;const packageInfo={name:"@polkadot/util",path:__dirname,type:"cjs",version:"9.4.1"};exports.packageInfo=packageInfo},4404:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.promisify=function(self,fn){for(var _len=arguments.length,params=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++)params[_key-2]=arguments[_key];return new Promise(((resolve,reject)=>{fn.apply(self,params.concat(((error,result)=>{error?reject(error):resolve(result)})))}))}},2772:(__unused_webpack_module,exports)=>{"use strict";function converter(format){const formatRuns=w=>w.slice(0,w.length-1).toLowerCase()+w.slice(-1).toUpperCase();return value=>{const parts=value.toString().replace(/[-_., ]+/g," ").trim().split(" ");let result="";for(let i=0;i(i?w[0].toUpperCase():w[0].toLowerCase())+w.slice(1)));exports.stringCamelCase=stringCamelCase;const stringPascalCase=converter((w=>w[0].toUpperCase()+w.slice(1)));exports.stringPascalCase=stringPascalCase},7556:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"stringCamelCase",{enumerable:!0,get:function(){return _camelCase.stringCamelCase}}),Object.defineProperty(exports,"stringLowerFirst",{enumerable:!0,get:function(){return _lowerFirst.stringLowerFirst}}),Object.defineProperty(exports,"stringPascalCase",{enumerable:!0,get:function(){return _camelCase.stringPascalCase}}),Object.defineProperty(exports,"stringShorten",{enumerable:!0,get:function(){return _shorten.stringShorten}}),Object.defineProperty(exports,"stringToHex",{enumerable:!0,get:function(){return _toHex.stringToHex}}),Object.defineProperty(exports,"stringToU8a",{enumerable:!0,get:function(){return _toU8a.stringToU8a}}),Object.defineProperty(exports,"stringUpperFirst",{enumerable:!0,get:function(){return _lowerFirst.stringUpperFirst}});var _camelCase=__webpack_require__(2772),_lowerFirst=__webpack_require__(6092),_shorten=__webpack_require__(8149),_toHex=__webpack_require__(1734),_toU8a=__webpack_require__(1593)},6092:(__unused_webpack_module,exports)=>{"use strict";function converter(fn){return value=>value?fn(value[0])+value.slice(1):""}Object.defineProperty(exports,"__esModule",{value:!0}),exports.stringUpperFirst=exports.stringLowerFirst=void 0;const stringLowerFirst=converter((s=>s.toLowerCase()));exports.stringLowerFirst=stringLowerFirst;const stringUpperFirst=converter((s=>s.toUpperCase()));exports.stringUpperFirst=stringUpperFirst},8149:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.stringShorten=function(value){let prefixLength=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6;return value.length<=2+2*prefixLength?value.toString():`${value.substring(0,prefixLength)}…${value.slice(-prefixLength)}`}},1734:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.stringToHex=function(value){return(0,_toHex.u8aToHex)((0,_toU8a.stringToU8a)(value))};var _toHex=__webpack_require__(9481),_toU8a=__webpack_require__(1593)},1593:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.stringToU8a=function(value){return value?encoder.encode(value.toString()):new Uint8Array};const encoder=new(__webpack_require__(2012).TextEncoder)},5329:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.stringify=function(value,space){return JSON.stringify(value,replacer,space)};var _bigInt=__webpack_require__(175);function replacer(_,v){return(0,_bigInt.isBigInt)(v)?v.toString():v}},6736:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aCmp=function(a,b){const u8aa=(0,_toU8a.u8aToU8a)(a),u8ab=(0,_toU8a.u8aToU8a)(b);let i=0;for(;;){const overA=i>=u8aa.length,overB=i>=u8ab.length;if(overA&&overB)return 0;if(overA)return-1;if(overB)return 1;if(u8aa[i]!==u8ab[i])return u8aa[i]>u8ab[i]?1:-1;i++}};var _toU8a=__webpack_require__(3365)},1735:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aConcat=function(){const u8as=new Array(arguments.length);let length=0;for(let i=0;i1&&void 0!==arguments[1]?arguments[1]:0,offset=0;if(!length)for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aEmpty=function(value){for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aEq=function(a,b){const u8aa=(0,_toU8a.u8aToU8a)(a),u8ab=(0,_toU8a.u8aToU8a)(b);if(u8aa.length===u8ab.length){const dvA=new DataView(u8aa.buffer,u8aa.byteOffset),dvB=new DataView(u8ab.buffer,u8ab.byteOffset),mod=u8aa.length%4,length=u8aa.length-mod;for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aFixLength=function(value){let bitLength=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,atStart=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const byteLength=Math.ceil(bitLength/8);if(-1===bitLength||value.length===byteLength)return value;if(value.length>byteLength)return value.subarray(0,byteLength);const result=new Uint8Array(byteLength);return result.set(value,atStart?0:byteLength-value.length),result}},7736:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"U8A_WRAP_ETHEREUM",{enumerable:!0,get:function(){return _wrap.U8A_WRAP_ETHEREUM}}),Object.defineProperty(exports,"U8A_WRAP_POSTFIX",{enumerable:!0,get:function(){return _wrap.U8A_WRAP_POSTFIX}}),Object.defineProperty(exports,"U8A_WRAP_PREFIX",{enumerable:!0,get:function(){return _wrap.U8A_WRAP_PREFIX}}),Object.defineProperty(exports,"u8aCmp",{enumerable:!0,get:function(){return _cmp.u8aCmp}}),Object.defineProperty(exports,"u8aConcat",{enumerable:!0,get:function(){return _concat.u8aConcat}}),Object.defineProperty(exports,"u8aConcatStrict",{enumerable:!0,get:function(){return _concat.u8aConcatStrict}}),Object.defineProperty(exports,"u8aEmpty",{enumerable:!0,get:function(){return _empty.u8aEmpty}}),Object.defineProperty(exports,"u8aEq",{enumerable:!0,get:function(){return _eq.u8aEq}}),Object.defineProperty(exports,"u8aFixLength",{enumerable:!0,get:function(){return _fixLength.u8aFixLength}}),Object.defineProperty(exports,"u8aIsWrapped",{enumerable:!0,get:function(){return _wrap.u8aIsWrapped}}),Object.defineProperty(exports,"u8aSorted",{enumerable:!0,get:function(){return _sorted.u8aSorted}}),Object.defineProperty(exports,"u8aToBigInt",{enumerable:!0,get:function(){return _toBigInt.u8aToBigInt}}),Object.defineProperty(exports,"u8aToBn",{enumerable:!0,get:function(){return _toBn.u8aToBn}}),Object.defineProperty(exports,"u8aToBuffer",{enumerable:!0,get:function(){return _toBuffer.u8aToBuffer}}),Object.defineProperty(exports,"u8aToHex",{enumerable:!0,get:function(){return _toHex.u8aToHex}}),Object.defineProperty(exports,"u8aToString",{enumerable:!0,get:function(){return _toString.u8aToString}}),Object.defineProperty(exports,"u8aToU8a",{enumerable:!0,get:function(){return _toU8a.u8aToU8a}}),Object.defineProperty(exports,"u8aUnwrapBytes",{enumerable:!0,get:function(){return _wrap.u8aUnwrapBytes}}),Object.defineProperty(exports,"u8aWrapBytes",{enumerable:!0,get:function(){return _wrap.u8aWrapBytes}});var _cmp=__webpack_require__(6736),_concat=__webpack_require__(1735),_empty=__webpack_require__(5476),_eq=__webpack_require__(6594),_fixLength=__webpack_require__(4693),_sorted=__webpack_require__(4480),_toBigInt=__webpack_require__(6755),_toBn=__webpack_require__(2312),_toBuffer=__webpack_require__(343),_toHex=__webpack_require__(9481),_toString=__webpack_require__(2913),_toU8a=__webpack_require__(3365),_wrap=__webpack_require__(2601)},4480:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aSorted=function(u8as){return u8as.sort(_cmp.u8aCmp)};var _cmp=__webpack_require__(6736)},6755:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aToBigInt=function(value){let options=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!value||!value.length)return(0,_xBigint.BigInt)(0);const{isLe,isNegative}=(0,_spread.objectSpread)({isLe:!0,isNegative:!1},options),u8a=isLe?value.reverse():value;return isNegative?toBigInt(xor(u8a))*-_consts._1n-_consts._1n:toBigInt(u8a)};var _xBigint=__webpack_require__(3059),_consts=__webpack_require__(1405),_spread=__webpack_require__(9704);const U8_MAX=(0,_xBigint.BigInt)(256),U16_MAX=(0,_xBigint.BigInt)(65536);function xor(input){const result=new Uint8Array(input.length),dvI=new DataView(input.buffer,input.byteOffset),dvO=new DataView(result.buffer),mod=input.length%2,length=input.length-mod;for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aToBn=function(value){let options=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{isLe,isNegative}=(0,_spread.objectSpread)({isLe:!0,isNegative:!1},(0,_boolean.isBoolean)(options)?{isLe:options}:options),count=value.length;let bn;if(count<=6){let result=0;for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aToBuffer=function(value){return Buffer.from(value||[])}},9481:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aToHex=function(value){let bitLength=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,isPrefixed=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const length=Math.ceil(bitLength/8);return`${isPrefixed?"0x":""}${value&&value.length?bitLength>0&&value.length>length?`${hex(value.subarray(0,length/2))}…${hex(value.subarray(value.length-length/2))}`:hex(value):""}`};var _alphabet=__webpack_require__(9674);function hex(value){const mod=value.length%2,length=value.length-mod,dv=new DataView(value.buffer,value.byteOffset);let result="";for(let i=0;i{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aToString=function(value){return value?decoder.decode(value):""};const decoder=new(__webpack_require__(7653).TextDecoder)("utf-8")},3365:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.u8aToU8a=function(value){return(0,_u8a.isU8a)(value)?value:(0,_hex.isHex)(value)?(0,_toU8a.hexToU8a)(value):(0,_buffer.isBuffer)(value)||Array.isArray(value)?new Uint8Array(value):(0,_toU8a2.stringToU8a)(value)};var _toU8a=__webpack_require__(2166),_buffer=__webpack_require__(5109),_hex=__webpack_require__(1580),_u8a=__webpack_require__(9727),_toU8a2=__webpack_require__(1593)},2601:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.U8A_WRAP_PREFIX=exports.U8A_WRAP_POSTFIX=exports.U8A_WRAP_ETHEREUM=void 0,exports.u8aIsWrapped=u8aIsWrapped,exports.u8aUnwrapBytes=function(bytes){const u8a=(0,_toU8a.u8aToU8a)(bytes);return u8aIsWrapped(u8a,!1)?u8a.subarray(U8A_WRAP_PREFIX.length,u8a.length-U8A_WRAP_POSTFIX.length):u8a},exports.u8aWrapBytes=function(bytes){const u8a=(0,_toU8a.u8aToU8a)(bytes);return u8aIsWrapped(u8a,!0)?u8a:(0,_concat.u8aConcatStrict)([U8A_WRAP_PREFIX,u8a,U8A_WRAP_POSTFIX])};var _concat=__webpack_require__(1735),_eq=__webpack_require__(6594),_toU8a=__webpack_require__(3365);const U8A_WRAP_ETHEREUM=(0,_toU8a.u8aToU8a)("Ethereum Signed Message:\n");exports.U8A_WRAP_ETHEREUM=U8A_WRAP_ETHEREUM;const U8A_WRAP_PREFIX=(0,_toU8a.u8aToU8a)("");exports.U8A_WRAP_PREFIX=U8A_WRAP_PREFIX;const U8A_WRAP_POSTFIX=(0,_toU8a.u8aToU8a)("");exports.U8A_WRAP_POSTFIX=U8A_WRAP_POSTFIX;const WRAP_LEN=U8A_WRAP_PREFIX.length+U8A_WRAP_POSTFIX.length;function u8aIsWrapped(u8a,withEthereum){return u8a.length>=WRAP_LEN&&(0,_eq.u8aEq)(u8a.subarray(0,U8A_WRAP_PREFIX.length),U8A_WRAP_PREFIX)&&(0,_eq.u8aEq)(u8a.slice(-U8A_WRAP_POSTFIX.length),U8A_WRAP_POSTFIX)||withEthereum&&u8a.length>=U8A_WRAP_ETHEREUM.length&&(0,_eq.u8aEq)(u8a.subarray(0,U8A_WRAP_ETHEREUM.length),U8A_WRAP_ETHEREUM)}},9454:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.detectPackage=function(_ref3,pathOrFn){let{name,path,type,version}=_ref3,deps=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];(0,_assert.assert)(name.startsWith("@polkadot"),(()=>`Invalid package descriptor ${name}`));const entry=getEntry(name);if(entry.push({path:getPath(path,pathOrFn),type,version}),1!==entry.length)warn(`${name} has multiple versions, ensure that there is only one installed.`,entry,formatVersion);else{const mismatches=deps.filter((d=>d&&d.version!==version));mismatches.length&&warn(`${name} requires direct dependencies exactly matching version ${version}.`,mismatches,formatInfo)}};var _xGlobal=__webpack_require__(4793),_function=__webpack_require__(2404),_assert=__webpack_require__(2944);function getEntry(name){const _global=_xGlobal.xglobal;return _global.__polkadotjs||(_global.__polkadotjs={}),_global.__polkadotjs[name]||(_global.__polkadotjs[name]=[]),_global.__polkadotjs[name]}function formatInfo(version,_ref){let{name}=_ref;return[version,name]}function formatVersion(version,_ref2){let extracted,{path,type}=_ref2;if(path&&path.length>=5){const nmIndex=path.indexOf("node_modules");extracted=-1===nmIndex?path:path.substring(nmIndex)}else extracted="";return[`${`${type||""}`.padStart(3)} ${version}`,extracted]}function getPath(infoPath,pathOrFn){if(infoPath)return infoPath;if((0,_function.isFunction)(pathOrFn))try{return pathOrFn()||""}catch(error){return""}return pathOrFn||""}function warn(pre,all,fmt){console.warn(`${pre}\nEither remove and explicitly install matching versions or dedupe using your package manager.\nThe following conflicting packages were found:\n${function(all,fmt){let max=0;for(let i=0;i`\t${fmt(d.version.padEnd(max),d).join("\t")}`)).join("\n")}(all,fmt)}`)}},3059:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BigInt=void 0,Object.defineProperty(exports,"packageInfo",{enumerable:!0,get:function(){return _packageInfo.packageInfo}});var _xGlobal=__webpack_require__(4793),_packageInfo=__webpack_require__(5853);const BigInt="function"==typeof _xGlobal.xglobal.BigInt&&"function"==typeof _xGlobal.xglobal.BigInt.asIntN?_xGlobal.xglobal.BigInt:()=>Number.NaN;exports.BigInt=BigInt},5853:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packageInfo=void 0;const packageInfo={name:"@polkadot/x-bigint",path:__dirname,type:"cjs",version:"9.4.1"};exports.packageInfo=packageInfo},4793:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.exposeGlobal=function(name,fallback){void 0===xglobal[name]&&(xglobal[name]=fallback)},exports.extractGlobal=function(name,fallback){return void 0===xglobal[name]?fallback:xglobal[name]},Object.defineProperty(exports,"packageInfo",{enumerable:!0,get:function(){return _packageInfo.packageInfo}}),exports.xglobal=void 0;var _packageInfo=__webpack_require__(8143);const xglobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this");exports.xglobal=xglobal},8143:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packageInfo=void 0;const packageInfo={name:"@polkadot/x-global",path:__dirname,type:"cjs",version:"9.4.1"};exports.packageInfo=packageInfo},7653:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";var _interopRequireDefault=__webpack_require__(5318);Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextDecoder=void 0,Object.defineProperty(exports,"packageInfo",{enumerable:!0,get:function(){return _packageInfo.packageInfo}});var _util=_interopRequireDefault(__webpack_require__(3837)),_xGlobal=__webpack_require__(4793),_packageInfo=__webpack_require__(370);const TextDecoder=(0,_xGlobal.extractGlobal)("TextDecoder",_util.default.TextDecoder);exports.TextDecoder=TextDecoder},370:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packageInfo=void 0;const packageInfo={name:"@polkadot/x-textdecoder",path:__dirname,type:"cjs",version:"9.4.1"};exports.packageInfo=packageInfo},2012:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";var _interopRequireDefault=__webpack_require__(5318);Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextEncoder=void 0,Object.defineProperty(exports,"packageInfo",{enumerable:!0,get:function(){return _packageInfo.packageInfo}});var _util=_interopRequireDefault(__webpack_require__(3837)),_xGlobal=__webpack_require__(4793),_packageInfo=__webpack_require__(413);const TextEncoder=(0,_xGlobal.extractGlobal)("TextEncoder",class{#encoder;constructor(){this.#encoder=new _util.default.TextEncoder}encode(value){return Uint8Array.from(this.#encoder.encode(value))}});exports.TextEncoder=TextEncoder},413:(__unused_webpack_module,exports)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packageInfo=void 0;const packageInfo={name:"@polkadot/x-textencoder",path:__dirname,type:"cjs",version:"9.4.1"};exports.packageInfo=packageInfo}},__webpack_module_cache__={};function __webpack_require__(moduleId){var cachedModule=__webpack_module_cache__[moduleId];if(void 0!==cachedModule)return cachedModule.exports;var module=__webpack_module_cache__[moduleId]={id:moduleId,loaded:!1,exports:{}};return __webpack_modules__[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}__webpack_require__.nmd=module=>(module.paths=[],module.children||(module.children=[]),module);return function(){var g;function r(a){var b=typeof a;return"object"!=b?b:a?Array.isArray(a)?"array":b:"null"}function aa(a){return Object.prototype.hasOwnProperty.call(a,ba)&&a[ba]||(a[ba]=++ca)}var ba="closure_uid_"+(1e9*Math.random()>>>0),ca=0;function da(a){const b=[];let c=0;for(const d in a)b[c++]=d;return b}function fa(a,b){null!=a&&this.append.apply(this,arguments)}(g=fa.prototype).Ba="",g.set=function(a){this.Ba=""+a},g.append=function(a,b,c){if(this.Ba+=String(a),null!=b)for(let d=1;d>>16&65535)*d+c*(b>>>16&65535)<<16>>>0)|0};function Ab(a){return a=zb(0|a,-862048943),zb(a<<15|a>>>-15,461845907)}function Bb(a,b){return zb((a=(0|a)^(0|b))<<13|a>>>-13,5)+-430675100|0}function Cb(a,b){return a=zb((a=(0|a)^b)^a>>>16,-2048144789),(a=zb(a^a>>>13,-1028477387))^a>>>16}function Db(a){a:for(var b=1,c=0;;){if(!(b>2)}function Jb(a,b,c,d,e){this.fb=a,this.name=b,this.Aa=c,this.Ta=d,this.ra=e,this.j=2154168321,this.A=4096}(g=Jb.prototype).toString=function(){return this.Aa},g.K=function(a,b){return b instanceof Jb&&this.Aa===b.Aa},g.call=function(a){switch(arguments.length-1){case 1:return this.g(arguments[1]);case 2:return this.h(arguments[1],arguments[2]);default:throw Error(["Invalid arity: ",z.g(arguments.length-1)].join(""))}},g.apply=function(a,b){return this.call.apply(this,[this].concat(B(b)))},g.g=function(a){return I.h?I.h(a,this):I.call(null,a,this)},g.h=function(a,b){return I.l?I.l(a,this,b):I.call(null,a,this,b)},g.O=function(){return this.ra},g.S=function(a,b){return new Jb(this.fb,this.name,this.Aa,this.Ta,b)},g.N=function(){var a=this.Ta;return null!=a?a:this.Ta=a=Ib(Db(this.name),Gb(this.fb))},g.M=function(a,b){return H(b,this.Aa)};var Kb=function Kb(a){switch(arguments.length){case 1:return Kb.g(arguments[0]);case 2:return Kb.h(arguments[0],arguments[1]);default:throw Error(["Invalid arity: ",z.g(arguments.length)].join(""))}};function Lb(a){return null!=a?!!(131072&a.A||u===a.Xb)||!a.A&&w(vb,a):w(vb,a)}function M(a){if(null==a)return null;if(null!=a&&(8388608&a.j||u===a.Nb))return a.I(null);if(Array.isArray(a)||"string"==typeof a)return 0===a.length?null:new N(a,0,null);if(null!=a&&null!=a[xa])return a=(null!==a&&xa in a?a[xa]:void 0).call(a),Mb.g?Mb.g(a):Mb.call(null,a);if(w(fb,a))return gb(a);throw Error([z.g(a)," is not ISeqable"].join(""))}function O(a){return null==a?null:null!=a&&(64&a.j||u===a.Va)?a.da(null):null==(a=M(a))?null:E(a)}function Nb(a){return null!=a&&(null!=a&&(64&a.j||u===a.Va)||(a=M(a)))?a.ga(null):P}function Q(a){return null==a?null:null!=a&&(128&a.j||u===a.Za)?a.aa():M(Nb(a))}Kb.g=function(a){for(;;){if(a instanceof Jb)return a;if("string"==typeof a){var b=a.indexOf("/");return 1>b?Kb.h(null,a):Kb.h(a.substring(0,b),a.substring(b+1,a.length))}if(!(a instanceof J))throw Error("no conversion to symbol");a=a.va}},Kb.h=function(a,b){return new Jb(a,b,null!=a?[z.g(a),"/",z.g(b)].join(""):b,null,null)},Kb.U=2;var S=function S(a){switch(arguments.length){case 1:return S.g(arguments[0]);case 2:return S.h(arguments[0],arguments[1]);default:for(var c=[],d=arguments.length,e=0;e=d)return-1;for(!(0c&&(c=0>(c+=d)?0:c);;){if(!(cc?d+c:c;;){if(!(0<=c))return-1;if(S.h(cc?cc(a,c):dc.call(null,a,c),b))return c;--c}}function ec(a,b){this.i=a,this.o=b}function N(a,b,c){this.i=a,this.o=b,this.u=c,this.j=166592766,this.A=139264}function gc(a){return 0a?0:a},g.N=function(){return Rb(this)},g.K=function(a,b){return fc.h?fc.h(this,b):fc.call(null,this,b)},g.Y=function(){return P},g.ba=function(a,b){return $b(this.i,b,this.i[this.o],this.o+1)},g.ca=function(a,b,c){return $b(this.i,b,c,this.o)},g.da=function(){return this.i[this.o]},g.ga=function(){return this.o+1b)throw Error("Index out of bounds");a:for(;;){if(null==a)throw Error("Index out of bounds");if(0===b){if(M(a)){a=O(a);break a}throw Error("Index out of bounds")}if(bc(a)){a=D(a,b);break a}if(!M(a))throw Error("Index out of bounds");a=Q(a),--b}return a}if(w(Ha,a))return D(a,b);throw Error(["nth not supported on this type ",z.g(wa(null==a?null:a.constructor))].join(""))}function X(a,b,c){if("number"!=typeof b)throw Error("Index argument to nth must be a number.");if(null==a)return c;if(null!=a&&(16&a.j||u===a.tb))return a.la(null,b,c);if(Array.isArray(a))return-1b?c:function(a,b,c){for(;;){if(null==a)return c;if(0===b)return M(a)?O(a):c;if(bc(a))return D(a,b,c);if(!M(a))return c;a=Q(a),--b}}(a,b,c);if(w(Ha,a))return D(a,b,c);throw Error(["nth not supported on this type ",z.g(wa(null==a?null:a.constructor))].join(""))}hc.F=function(){return ic},hc.g=function(a){return a},hc.h=function(a,b){return null!=a?Ga(a,b):new jc(null,b,null,1,null)},hc.G=function(a,b,c){for(;;){if(!v(c))return hc.h(a,b);a=hc.h(a,b),b=O(c),c=Q(c)}},hc.T=function(a){var b=O(a),c=Q(a);return a=O(c),c=Q(c),this.G(b,a,c)},hc.U=2;var I=function I(a){switch(arguments.length){case 2:return I.h(arguments[0],arguments[1]);case 3:return I.l(arguments[0],arguments[1],arguments[2]);default:throw Error(["Invalid arity: ",z.g(arguments.length)].join(""))}};I.h=function(a,b){return null==a?null:null!=a&&(256&a.j||u===a.Gb)?a.ka(null,b):Array.isArray(a)?null!=b&&b>1&1431655765))+(a>>2&858993459))+(a>>4)&252645135)>>24}var z=function z(a){switch(arguments.length){case 0:return z.F();case 1:return z.g(arguments[0]);default:for(var c=[],d=arguments.length,e=0;e(a=a.m)?0:a-1>>>5<<5}function qd(a,b,c){for(;;){if(0===b)return c;var d=od(a);d.i[0]=c,c=d,b-=5}}Y.g=function(a){return function(b){return function(){function c(k,l){return l=a.g?a.g(l):a.call(null,l),b.h?b.h(k,l):b.call(null,k,l)}function d(k){return b.g?b.g(k):b.call(null,k)}function e(){return b.F?b.F():b.call(null)}var f,h=function(){function k(m,n,p){var q=null;if(2>>b&31;return 5===b?f.i[h]=d:(null!=(c=c.i[h])?(b-=5,a=rd.R?rd.R(a,b,c,d):rd.call(null,a,b,c,d)):a=qd(null,b-5,d),f.i[h]=a),f};function sd(a,b){if(b>=pd(a))return a.fa;var c=a.root;for(a=a.shift;;){if(!(0>>a&31],a=d}}function td(a,b){if(!(0<=b&&b>>b&31;b-=5,c=c.i[k],a=ud.ua?ud.ua(a,b,c,d,e):ud.call(null,a,b,c,d,e),h.i[k]=a}return h};function vd(a,b,c){this.lb=this.o=0,this.i=a,this.Rb=b,this.start=0,this.end=c}function wd(a,b,c,d){return c=this.m)return new N(this.fa,0,null);a:for(var a=this.root,b=this.shift;;){if(!(0this.m-pd(this)){a=this.fa.length;for(var c=Array(a+1),d=0;d>>5>1<>>b&31;if(5===b)a=d;else{var h=c.i[f];null!=h?(b-=5,a=Id.R?Id.R(a,b,h,d):Id.call(null,a,b,h,d)):a=qd(a.root.D,b-5,d)}return c.i[f]=a,c};function zd(a,b,c,d){this.m=a,this.shift=b,this.root=c,this.fa=d,this.A=88,this.j=275}function Kd(){this.j=2097152,this.A=0}(g=zd.prototype).$a=function(a,b){if(this.root.D){if(32>this.m-pd(this))this.fa[31&this.m]=b;else{a=new nd(this.root.D,this.fa);var c=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null];c[0]=b,this.fa=c,this.m>>>5>1<>>f&31;f=k(f-5,h.i[l]),h.i[l]=f}return h}(a.shift,a.root);a.root=d}return a}if(b===a.m)return a.$a(null,c);throw Error(["Index ",z.g(b)," out of bounds for TransientVector of length",z.g(a.m)].join(""))}throw Error("assoc! after persistent!")}(this,b,c);throw Error("TransientVector's key for assoc! must be a number.")},g.X=function(){if(this.root.D)return this.m;throw Error("count after persistent!")},g.Z=function(a,b){if(this.root.D)return td(this,b)[31&b];throw Error("nth after persistent!")},g.la=function(a,b,c){return 0<=b&&b=e))return h;if(Yd(c[e],c[h]))return h;h-=2}}(),a[f]=c[e],a[f+1]=c[b+1],e=2+e,f=b=2+f):(e=2+e,f=b=f);return new pa(null,a.length/2,a,null)}return new pa(null,c.length/2,c,null)}(a,c):new pa(null,b/2,a,null)}function Vd(a,b){this.Xa={},this.Sa=a,this.i=b,this.j=259,this.A=56}function ee(a,b){for(var c=mb(Xd),d=0;;){if(!(db?4:2*(b+1));return xc(this.i,0,c,0,2*b),new ke(a,this.P,c)},g.bb=function(){return le?le(this.i):me.call(null,this.i)},g.cb=function(a,b){return ie(this.i,a,b)},g.za=function(a,b,c,d){var e=1<<(b>>>a&31);if(0==(this.P&e))return d;var f=Kc(this.P&e-1);return e=this.i[2*f],f=this.i[2*f+1],null==e?f.za(a+5,b,c,d):Yd(c,e)?f:d},g.na=function(a,b,c,d,e,f){var h=1<<(c>>>b&31),k=Kc(this.P&h-1);if(0==(this.P&h)){var l=Kc(this.P);if(2*l>>b&31]=ne.na(a,b+5,c,d,e,f),e=d=0;32>d;)0==(this.P>>>d&1)||(k[d]=null!=this.i[e]?ne.na(a,b+5,Hb(this.i[e]),this.i[e],this.i[e+1],f):this.i[e+1],e+=2),d+=1;return new oe(a,l+1,k)}return b=Array(2*(l+4)),xc(this.i,0,b,0,2*k),b[2*k]=d,b[2*k+1]=e,xc(this.i,2*k,b,2*(k+1),2*(l-k)),f.J=!0,(a=this.Ra(a)).i=b,a.P|=h,a}return l=this.i[2*k],h=this.i[2*k+1],null==l?(l=h.na(a,b+5,c,d,e,f))===h?this:he(this,a,2*k+1,l):Yd(d,l)?e===h?this:he(this,a,2*k+1,e):(f.J=!0,f=b+5,d=pe?pe(a,f,l,h,c,d,e):qe.call(null,a,f,l,h,c,d,e),e=2*k,k=2*k+1,(a=this.Ra(a)).i[e]=null,a.i[k]=d,a)},g.ma=function(a,b,c,d,e){var f=1<<(b>>>a&31),h=Kc(this.P&f-1);if(0==(this.P&f)){var k=Kc(this.P);if(16<=k){for((h=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null])[b>>>a&31]=ne.ma(a+5,b,c,d,e),d=c=0;32>c;)0==(this.P>>>c&1)||(h[c]=null!=this.i[d]?ne.ma(a+5,Hb(this.i[d]),this.i[d],this.i[d+1],e):this.i[d+1],d+=2),c+=1;return new oe(null,k+1,h)}return a=Array(2*(k+1)),xc(this.i,0,a,0,2*h),a[2*h]=c,a[2*h+1]=d,xc(this.i,2*h,a,2*(h+1),2*(k-h)),e.J=!0,new ke(null,this.P|f,a)}var l=this.i[2*h];return f=this.i[2*h+1],null==l?(k=f.ma(a+5,b,c,d,e))===f?this:new ke(null,this.P,ge(this.i,2*h+1,k)):Yd(c,l)?d===f?this:new ke(null,this.P,ge(this.i,2*h+1,d)):(e.J=!0,e=this.P,k=this.i,a+=5,a=re?re(a,l,f,b,c,d):qe.call(null,a,l,f,b,c,d),c=2*h,h=2*h+1,(d=B(k))[c]=null,d[h]=a,new ke(null,e,d))},g.sa=function(){return new je(this.i)};var ne=new ke(null,0,[]);function se(a){this.i=a,this.o=0,this.pa=null}function oe(a,b,c){this.D=a,this.m=b,this.i=c,this.A=131072,this.j=0}function ve(a,b,c){b*=2;for(var d=0;;){if(!(d>>a&31];return null!=e?e.za(a+5,b,c,d):d},g.na=function(a,b,c,d,e,f){var h=c>>>b&31,k=this.i[h];return null==k?((a=he(this,a,h,ne.na(a,b+5,c,d,e,f))).m+=1,a):(b=k.na(a,b+5,c,d,e,f))===k?this:he(this,a,h,b)},g.ma=function(a,b,c,d,e){var f=b>>>a&31,h=this.i[f];return null==h?new oe(null,this.m+1,ge(this.i,f,ne.ma(a+5,b,c,d,e))):(a=h.ma(a+5,b,c,d,e))===h?this:new oe(null,this.m,ge(this.i,f,a))},g.sa=function(){return new se(this.i)},(g=we.prototype).Ra=function(a){if(a===this.D)return this;var b=Array(2*(this.m+1));return xc(this.i,0,b,0,2*this.m),new we(a,this.ya,this.m,b)},g.bb=function(){return le?le(this.i):me.call(null,this.i)},g.cb=function(a,b){return ie(this.i,a,b)},g.za=function(a,b,c,d){return 0>(a=ve(this.i,this.m,c))?d:Yd(c,this.i[a])?this.i[a+1]:d},g.na=function(a,b,c,d,e,f){return c===this.ya?-1===(b=ve(this.i,this.m,d))?this.i.length>2*this.m?(b=2*this.m,c=2*this.m+1,(a=this.Ra(a)).i[b]=d,a.i[c]=e,f.J=!0,a.m+=1,a):(c=this.i.length,b=Array(c+2),xc(this.i,0,b,0,c),b[c]=d,b[c+1]=e,f.J=!0,d=this.m+1,a===this.D?(this.i=b,this.m=d,a=this):a=new we(this.D,this.ya,d,b),a):this.i[b+1]===e?this:he(this,a,b+1,e):new ke(a,1<<(this.ya>>>b&31),[null,this,null,null]).na(a,b,c,d,e,f)},g.ma=function(a,b,c,d,e){return b===this.ya?-1===(a=ve(this.i,this.m,c))?(a=2*this.m,b=Array(a+2),xc(this.i,0,b,0,a),b[a]=c,b[a+1]=d,e.J=!0,new we(null,this.ya,this.m+1,b)):S.h(this.i[a+1],d)?this:new we(null,this.ya,this.m,ge(this.i,a+1,d)):new ke(null,1<<(this.ya>>>a&31),[null,this]).ma(a,b,c,d,e)},g.sa=function(){return new je(this.i)},(g=xe.prototype).toString=function(){return yb(this)},g.indexOf=function(){var a;return a=function(b,c){switch(arguments.length){case 1:return T(this,b,0);case 2:return T(this,b,c)}throw Error("Invalid arity: "+arguments.length)},a.g=function(b){return T(this,b,0)},a.h=function(b,c){return T(this,b,c)},a}(),g.lastIndexOf=function(){function a(c){return V(this,c,U(this))}var b;return b=function(c,d){switch(arguments.length){case 1:return a.call(this,c);case 2:return V(this,c,d)}throw Error("Invalid arity: "+arguments.length)},b.g=a,b.h=function(c,d){return V(this,c,d)},b}(),g.O=function(){return this.u},g.aa=function(){if(null==this.C){var a=this.qa,b=this.o+2;return ye?ye(a,b,null):me.call(null,a,b,null)}a=this.qa,b=this.o;var c=Q(this.C);return ye?ye(a,b,c):me.call(null,a,b,c)},g.N=function(){var a=this.v;return null!=a?a:this.v=a=Rb(this)},g.K=function(a,b){return fc(this,b)},g.Y=function(){return P},g.ba=function(a,b){return Cc(b,this)},g.ca=function(a,b,c){return Dc(b,c,this)},g.da=function(){return null==this.C?new Pd(this.qa[this.o],this.qa[this.o+1]):O(this.C)},g.ga=function(){var c,d,a=this,b=null==a.C?(c=a.qa,d=a.o+2,ye?ye(c,d,null):me.call(null,c,d,null)):function(){var c=a.qa,d=a.o,e=Q(a.C);return ye?ye(c,d,e):me.call(null,c,d,e)}();return null!=b?b:P},g.I=function(){return this},g.S=function(a,b){return b===this.u?this:new xe(b,this.qa,this.o,this.C,this.v)},g.W=function(a,b){return W(b,this)},xe.prototype[xa]=function(){return Pb(this)},(g=ze.prototype).toString=function(){return yb(this)},g.indexOf=function(){var a;return a=function(b,c){switch(arguments.length){case 1:return T(this,b,0);case 2:return T(this,b,c)}throw Error("Invalid arity: "+arguments.length)},a.g=function(b){return T(this,b,0)},a.h=function(b,c){return T(this,b,c)},a}(),g.lastIndexOf=function(){function a(c){return V(this,c,U(this))}var b;return b=function(c,d){switch(arguments.length){case 1:return a.call(this,c);case 2:return V(this,c,d)}throw Error("Invalid arity: "+arguments.length)},b.g=a,b.h=function(c,d){return V(this,c,d)},b}(),g.O=function(){return this.u},g.aa=function(){var a=this.qa,b=this.o,c=Q(this.C);return Ae?Ae(a,b,c):ue.call(null,a,b,c)},g.N=function(){var a=this.v;return null!=a?a:this.v=a=Rb(this)},g.K=function(a,b){return fc(this,b)},g.Y=function(){return P},g.ba=function(a,b){return Cc(b,this)},g.ca=function(a,b,c){return Dc(b,c,this)},g.da=function(){return O(this.C)},g.ga=function(){var a=this.qa,b=this.o,c=Q(this.C);return null!=(a=Ae?Ae(a,b,c):ue.call(null,a,b,c))?a:P},g.I=function(){return this},g.S=function(a,b){return b===this.u?this:new ze(b,this.qa,this.o,this.C,this.v)},g.W=function(a,b){return W(b,this)},ze.prototype[xa]=function(){return Pb(this)},Be.prototype.ia=function(){return!this.qb||this.yb.ia()},Be.prototype.next=function(){return this.qb?this.yb.next():(this.qb=!0,new Pd(null,this.ea))},Be.prototype.remove=function(){return Error("Unsupported operation")},(g=Ce.prototype).toString=function(){return yb(this)},g.keys=function(){return Pb(Td.g?Td.g(this):Td.call(null,this))},g.entries=function(){return new Nd(M(M(this)))},g.values=function(){return Pb(Ud.g?Ud.g(this):Ud.call(null,this))},g.has=function(a){return Bc(this,a)},g.get=function(a,b){return this.H(null,a,b)},g.forEach=function(a){for(var b=M(this),c=null,d=0,e=0;;)if(ena)return H(a,"#");if(H(a,c),0===ua.g(f))M(h)&&H(a,v(t=Ke.g(f))?t:"...");else{if(M(h)){var l=O(h);b.l?b.l(l,a,f):b.call(null,l,a,f)}for(var m=Q(h),n=ua.g(f)-1;;){if(!m||null!=n&&0===n){M(m)&&0===n&&(H(a,d),H(a,function(){var t=Ke.g(f);return v(t)?t:"..."}()));break}H(a,d);var p=O(m);c=a,h=f,b.l?b.l(p,c,h):b.call(null,p,c,h),m=Q(m),n=c=n-1}}return H(a,e)}finally{na=k}}function Le(a,b){b=M(b);for(var c=null,d=0,e=0;;)if(ek)h=new yd(null,k,5,Ed,h,null);else for(var l=32,m=new yd(null,32,5,Ed,h.slice(0,32),null).Ya(null);;){if(!(lclj",a);a=c.h?c.h(a,b):c.call(null,a,b)}}return a}function af(a){var b=gc([bf,!0]),c=function(a){if(null!=a&&(64&a.j||u===a.Va))if(Q(a)){a:{var b=[];for(a=M(a);;){if(null==a)break a;b.push(O(a)),a=Q(a)}}b=nc(b)}else b=M(a)?O(a):hd;else b=a;return b}(b),d=v(c=I.h(c,bf))?Oc:z;return function h(f){return(null!=f?u===f.Vb||!f.dc&&w(Ze,f):w(Ze,f))?$e(f,ed(Fe,b)):null!=f&&(null!=f?64&f.j||u===f.Va||!f.j&&w(Ja,f):w(Ja,f))?function(a){for(var b=a;b=M(b);)b=Q(b);return a}(Y.h(h,f)):Qd(f)?new Pd(h(Sa(f)),h(Ta(f))):null!=f&&(null!=f?8&f.j||u===f.Ub||!f.j&&w(Fa,f):w(Fa,f))?function(a,b,c){if(null!=a&&(4&a.A||u===a.Cb)){var d=rc(a);return Ic(b,function(){function e(h){return Ya(ob(h),d)}var f;return f=function(h,k){switch(arguments.length){case 1:return e.call(this,h);case 2:return nb(h,k)}throw Error("Invalid arity: "+arguments.length)},f.g=e,f.h=function(h,k){return nb(h,k)},f}(),mb(a),c)}return Ic(b,hc,a,c)}(kc(f),Y.g(h),f):Array.isArray(f)?ob(za((function(k,l){return nb(k,l=h(l))}),mb(ic),f)):(null==f?null:f.constructor)===Object?ob(za((function(k,l){return pb(k,d.g?d.g(l):d.call(null,l),l=h(null!==f&&l in f?f[l]:void 0))}),mb(hd),da(f))):f}(a)}N.prototype.$=u,N.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},Qc.prototype.$=u,Qc.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},Pd.prototype.$=u,Pd.prototype.M=function(a,b,c){return Je(b,Z,"["," ","]",c,this)},xe.prototype.$=u,xe.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},Rd.prototype.$=u,Rd.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},Qb.prototype.$=u,Qb.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},Fd.prototype.$=u,Fd.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},Mc.prototype.$=u,Mc.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},Ce.prototype.$=u,Ce.prototype.M=function(a,b,c){return Re(this,Z,b,c)},ze.prototype.$=u,ze.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},Uc.prototype.$=u,Uc.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},kd.prototype.$=u,kd.prototype.M=function(a,b,c){return H(b,"#object[cljs.core.Atom "),Z(new pa(null,1,[Ye,this.state],null),b,c),H(b,"]")},He.prototype.$=u,He.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},yd.prototype.$=u,yd.prototype.M=function(a,b,c){return Je(b,Z,"["," ","]",c,this)},Lc.prototype.$=u,Lc.prototype.M=function(a,b){return H(b,"()")},pa.prototype.$=u,pa.prototype.M=function(a,b,c){return Re(this,Z,b,c)},Ge.prototype.$=u,Ge.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},jc.prototype.$=u,jc.prototype.M=function(a,b,c){return Je(b,Z,"("," ",")",c,this)},"undefined"!=typeof console&&va(),va();var ua=new J(null,"print-length","print-length",1931866356),qa=new J(null,"flush-on-newline","flush-on-newline",-151457939),Ye=new J(null,"val","val",128701612),sa=new J(null,"meta","meta",1499536964),bf=new J(null,"keywordize-keys","keywordize-keys",1310784252),cf=new J(null,"wasm","wasm",-969992002),df=new J(null,"source","source",-433931539),Te=new J(null,"fallback-impl","fallback-impl",-1501286995),ra=new J(null,"readably","readably",1129599760),Se=new J(null,"alt-impl","alt-impl",670969595),ta=new J(null,"dup","dup",556298533),Ke=new J(null,"more-marker","more-marker",-14717935),ef=__webpack_require__(8245),ff=__webpack_require__(7147);la=!1,ka=function(){function a(c){var d=null;if(0::Type; + + #[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + pub struct SwapPair { + pub from: AccountId, + pub to: AccountId, + } + + impl SwapPair { + pub fn new(from: AccountId, to: AccountId) -> Self { + Self { from, to } + } + } + + #[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + pub enum DexError { + PSP22(PSP22Error), + InsufficientAllowanceOf(AccountId), + Arithmethic, + WrongParameterValue, + MissingRole(AccountId, Role), + InkEnv(String), + CrossContractCall(String), + TooMuchSlippage, + NotEnoughLiquidityOf(AccountId), + UnsupportedSwapPair(SwapPair), + } + + impl From for DexError { + fn from(e: PSP22Error) -> Self { + DexError::PSP22(e) + } + } + + impl From for DexError { + fn from(why: InkEnvError) -> Self { + DexError::InkEnv(format!("{:?}", why)) + } + } + + impl From for DexError { + fn from(why: LangError) -> Self { + DexError::CrossContractCall(format!("{:?}", why)) + } + } + + #[ink(event)] + pub struct Deposited { + caller: AccountId, + #[ink(topic)] + token: AccountId, + amount: Balance, + } + + #[ink(event)] + pub struct SwapPairAdded { + #[ink(topic)] + pair: SwapPair, + } + + #[ink(event)] + pub struct SwapPairRemoved { + #[ink(topic)] + pair: SwapPair, + } + + #[ink(event)] + pub struct Swapped { + caller: AccountId, + #[ink(topic)] + token_in: AccountId, + #[ink(topic)] + token_out: AccountId, + amount_in: Balance, + amount_out: Balance, + } + + #[ink(event)] + pub struct SwapFeeSet { + #[ink(topic)] + caller: AccountId, + swap_fee_percentage: u128, + } + + #[ink(storage)] + #[derive(Storage)] + pub struct SimpleDex { + pub swap_fee_percentage: u128, + pub access_control: AccessControlRef, + // a set of pairs that are availiable for swapping between + pub swap_pairs: Mapping, + } + + impl SimpleDex { + #[ink(constructor)] + pub fn new() -> Self { + let caller = Self::env().caller(); + let code_hash = Self::env() + .own_code_hash() + .expect("Called new on a contract with no code hash"); + let required_role = Role::Initializer(code_hash); + let access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); + let access_control = AccessControlRef::from_account_id(access_control); + + if access_control.has_role(caller, required_role) { + Self { + swap_fee_percentage: 0, + access_control, + swap_pairs: Mapping::default(), + } + } else { + panic!("Caller is not allowed to initialize this contract"); + } + } + + /// Swaps the a specified amount of one of the pool's PSP22 tokens to another PSP22 token + /// Calling account needs to give allowance to the DEX contract to spend amount_token_in of token_in on its behalf + /// before executing this tx. + #[ink(message)] + pub fn swap( + &mut self, + token_in: AccountId, + token_out: AccountId, + amount_token_in: Balance, + min_amount_token_out: Balance, + ) -> Result<(), DexError> { + let this = self.env().account_id(); + let caller = self.env().caller(); + + let balance_token_out = self.balance_of(token_out, this); + if balance_token_out < min_amount_token_out { + // throw early if we cannot support this swap anyway due to liquidity being too low + return Err(DexError::NotEnoughLiquidityOf(token_out)); + } + + let swap_pair = SwapPair::new(token_in, token_out); + if !self.swap_pairs.contains(&swap_pair) { + return Err(DexError::UnsupportedSwapPair(swap_pair)); + } + + // check allowance + if self.allowance(token_in, caller, this) < amount_token_in { + return Err(DexError::InsufficientAllowanceOf(token_in)); + } + + let amount_token_out = self.out_given_in(token_in, token_out, amount_token_in)?; + + if amount_token_out < min_amount_token_out { + // thrown if too much slippage occured before this tx gets executed + // as a sandwich attack prevention + return Err(DexError::TooMuchSlippage); + } + + // transfer token_in from user to the contract + self.transfer_from_tx(token_in, caller, this, amount_token_in)?; + // transfer token_out from contract to user + self.transfer_tx(token_out, caller, amount_token_out)?; + + // emit event + Self::emit_event( + self.env(), + Event::Swapped(Swapped { + caller, + token_in, + token_out, + amount_in: amount_token_in, + amount_out: amount_token_out, + }), + ); + + Ok(()) + } + + /// Liquidity deposit + /// + /// Can only be performed by an account with a LiquidityProvider role + /// Caller needs to give at least the passed amount of allowance to the contract to spend the deposited tokens on his behalf + /// prior to executing this tx + #[ink(message)] + pub fn deposit(&mut self, deposits: Vec<(AccountId, Balance)>) -> Result<(), DexError> { + let this = self.env().account_id(); + let caller = self.env().caller(); + + // check role, only designated account can add liquidity + self.check_role(caller, Role::LiquidityProvider(this))?; + + deposits + .into_iter() + .try_for_each(|(token_in, amount)| -> Result<(), DexError> { + // transfer token_in from the caller to the contract + // will revert if the contract does not have enough allowance from the caller + // in which case the whole tx is reverted + self.transfer_from_tx(token_in, caller, this, amount)?; + + Self::emit_event( + self.env(), + Event::Deposited(Deposited { + caller, + token: token_in, + amount, + }), + ); + + Ok(()) + })?; + + Ok(()) + } + + #[ink(message)] + pub fn withdrawal( + &mut self, + withdrawals: Vec<(AccountId, Balance)>, + ) -> Result<(), DexError> { + let this = self.env().account_id(); + let caller = self.env().caller(); + + // check role, only designated account can remove liquidity + self.check_role(caller, Role::LiquidityProvider(this))?; + + withdrawals.into_iter().try_for_each( + |(token_out, amount)| -> Result<(), DexError> { + // transfer token_out from the contract to the caller + self.transfer_tx(token_out, caller, amount)?; + Ok(()) + }, + )?; + + Ok(()) + } + + /// Alters the swap_fee parameter + /// + /// Can only be called by the contract's Admin. + #[ink(message)] + pub fn set_swap_fee_percentage( + &mut self, + swap_fee_percentage: u128, + ) -> Result<(), DexError> { + if swap_fee_percentage.gt(&100) { + return Err(DexError::WrongParameterValue); + } + + let caller = self.env().caller(); + let this = self.env().account_id(); + + self.check_role(caller, Role::Admin(this))?; + + // emit event + Self::emit_event( + self.env(), + Event::SwapFeeSet(SwapFeeSet { + caller, + swap_fee_percentage, + }), + ); + + self.swap_fee_percentage = swap_fee_percentage; + Ok(()) + } + + /// Returns current value of the swap_fee_percentage parameter + #[ink(message)] + pub fn swap_fee_percentage(&self) -> Balance { + self.swap_fee_percentage + } + + /// Sets access_control to a new contract address + /// + /// Potentially very destructive, can only be called by the contract's Owner. + #[ink(message)] + pub fn set_access_control(&mut self, access_control: AccountId) -> Result<(), DexError> + where + Self: AccessControlled, + { + let caller = self.env().caller(); + let this = self.env().account_id(); + + self.check_role(caller, Role::Owner(this))?; + + self.access_control = AccessControlRef::from_account_id(access_control); + Ok(()) + } + + /// Returns current address of the AccessControl contract that holds the account priviledges for this DEX + #[ink(message)] + pub fn access_control(&self) -> AccountId { + self.access_control.to_account_id() + } + + /// Whitelists a token pair for swapping between + /// + /// Token pair is understood as a swap between tokens in one direction + /// Can only be called by an Admin + #[ink(message)] + pub fn add_swap_pair(&mut self, from: AccountId, to: AccountId) -> Result<(), DexError> { + let caller = self.env().caller(); + let this = self.env().account_id(); + self.check_role(caller, Role::Admin(this))?; + + let pair = SwapPair::new(from, to); + self.swap_pairs.insert(&pair, &()); + + Self::emit_event(self.env(), Event::SwapPairAdded(SwapPairAdded { pair })); + + Ok(()) + } + + /// Returns true if a pair of tokens is whitelisted for swapping between + #[ink(message)] + pub fn can_swap_pair(&self, from: AccountId, to: AccountId) -> bool { + self.swap_pairs.contains(&SwapPair::new(from, to)) + } + + /// Blacklists a token pair from swapping + /// + /// Token pair is understood as a swap between tokens in one direction + /// Can only be called by an Admin + #[ink(message)] + pub fn remove_swap_pair(&mut self, from: AccountId, to: AccountId) -> Result<(), DexError> { + let caller = self.env().caller(); + let this = self.env().account_id(); + self.check_role(caller, Role::Admin(this))?; + + let pair = SwapPair::new(from, to); + self.swap_pairs.remove(&pair); + + Self::emit_event(self.env(), Event::SwapPairRemoved(SwapPairRemoved { pair })); + + Ok(()) + } + + /// Terminates the contract. + /// + /// Can only be called by the contract's Owner. + #[ink(message)] + pub fn terminate(&mut self) -> Result<(), DexError> { + let caller = self.env().caller(); + let this = self.env().account_id(); + self.check_role(caller, Role::Owner(this))?; + self.env().terminate_contract(caller) + } + + /// Returns own code hash + #[ink(message)] + pub fn code_hash(&self) -> Result { + self.env() + .own_code_hash() + .map_err(|why| DexError::InkEnv(format!("Can't retrieve own code hash: {:?}", why))) + } + + /// Swap trade output given a curve with equal token weights + /// + /// B_0 - (100 * B_0 * B_i) / (100 * (B_i + A_i) - A_i * swap_fee) + /// where swap_fee (integer) is a percentage of the trade that goes towards the pool + /// and is used to pay the liquidity providers + #[ink(message)] + pub fn out_given_in( + &self, + token_in: AccountId, + token_out: AccountId, + amount_token_in: Balance, + ) -> Result { + let this = self.env().account_id(); + let balance_token_in = self.balance_of(token_in, this); + let balance_token_out = self.balance_of(token_out, this); + + Self::_out_given_in( + amount_token_in, + balance_token_in, + balance_token_out, + self.swap_fee_percentage, + ) + } + + fn _out_given_in( + amount_token_in: Balance, + balance_token_in: Balance, + balance_token_out: Balance, + swap_fee_percentage: Balance, + ) -> Result { + let op0 = amount_token_in + .checked_mul(swap_fee_percentage) + .ok_or(DexError::Arithmethic)?; + + let op1 = balance_token_in + .checked_add(amount_token_in) + .and_then(|result| result.checked_mul(100)) + .ok_or(DexError::Arithmethic)?; + + let op2 = op1.checked_sub(op0).ok_or(DexError::Arithmethic)?; + + let op3 = balance_token_in + .checked_mul(balance_token_out) + .and_then(|result| result.checked_mul(100)) + .ok_or(DexError::Arithmethic)?; + + let op4 = op3.checked_div(op2).ok_or(DexError::Arithmethic)?; + + balance_token_out + .checked_sub(op4) + // If the division is not even, leave the 1 unit of dust in the exchange instead of paying it out. + .and_then(|result| result.checked_sub((op3 % op2 > 0).into())) + .ok_or(DexError::Arithmethic) + } + + /// Transfers a given amount of a PSP22 token to a specified using the callers own balance + fn transfer_tx( + &self, + token: AccountId, + to: AccountId, + amount: Balance, + ) -> Result<(), PSP22Error> { + PSP22Ref::transfer(&token, to, amount, vec![])?; + + Ok(()) + } + + /// Transfers a given amount of a PSP22 token on behalf of a specified account to another account + /// + /// Will revert if not enough allowance was given to the caller prior to executing this tx + fn transfer_from_tx( + &self, + token: AccountId, + from: AccountId, + to: AccountId, + amount: Balance, + ) -> Result<(), DexError> { + PSP22Ref::transfer_from_builder(&token, from, to, amount, vec![0x0]) + .call_flags(CallFlags::default().set_allow_reentry(true)) + .invoke()?; + + Ok(()) + } + + /// Returns the amount of unused allowance that the token owner has given to the spender + fn allowance(&self, token: AccountId, owner: AccountId, spender: AccountId) -> Balance { + PSP22Ref::allowance(&token, owner, spender) + } + + /// Returns DEX balance of a PSP22 token for an account + fn balance_of(&self, token: AccountId, account: AccountId) -> Balance { + PSP22Ref::balance_of(&token, account) + } + + fn check_role(&self, account: AccountId, role: Role) -> Result<(), DexError> { + if self.access_control.has_role(account, role) { + Ok(()) + } else { + Err(DexError::MissingRole(account, role)) + } + } + + fn emit_event(emitter: EE, event: Event) + where + EE: EmitEvent, + { + emitter.emit_event(event); + } + } + + impl Default for SimpleDex { + fn default() -> Self { + SimpleDex::new() + } + } + + #[cfg(test)] + mod test { + use proptest::prelude::*; + + use super::*; + + proptest! { + #[test] + fn rounding_benefits_dex( + balance_token_a in 1..1000u128, + balance_token_b in 1..1000u128, + pay_token_a in 1..1000u128, + fee_percentage in 0..10u128 + ) { + let get_token_b = + SimpleDex::_out_given_in(pay_token_a, balance_token_a, balance_token_b, fee_percentage).unwrap(); + let balance_token_a = balance_token_a + pay_token_a; + let balance_token_b = balance_token_b - get_token_b; + let get_token_a = + SimpleDex::_out_given_in(get_token_b, balance_token_b, balance_token_a, fee_percentage).unwrap(); + + assert!(get_token_a <= pay_token_a); + } + } + } +} diff --git a/contracts/ticket_token/Cargo.lock b/contracts/ticket_token/Cargo.lock new file mode 100644 index 0000000000..fc8f5d449b --- /dev/null +++ b/contracts/ticket_token/Cargo.lock @@ -0,0 +1,1213 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "access_control" +version = "0.2.0" +dependencies = [ + "ink", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "array-init" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfb6d71005dc22a708c7496eee5c8dc0300ee47355de6256c3b35b12b5fef596" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +dependencies = [ + "crypto-mac", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "blake2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +dependencies = [ + "digest 0.10.3", +] + +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byte-slice-cast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" + +[[package]] +name = "camino" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "081e3f0755c1f380c2d010481b6fa2e02973586d5f2b24eebb7a2a1d98b143d8" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "semver-parser", + "serde", + "serde_json", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const_format" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "cpufeatures" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "either" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76b4fc39f3bcab7e042becf5c9dbbebc179fff64924025753a5fafa016e8576d" +dependencies = [ + "derive_more", + "ink_env", + "ink_macro", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage", + "parity-scale-codec", +] + +[[package]] +name = "ink_allocator" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a54dbbaffb0f97bcae062e628dcdc9da4d3c9044f5a53fb2715a328b07221631" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_codegen" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "283b022679ef75898db5c28b89388412d93f91cea4f0b1443426901cb391b079" +dependencies = [ + "blake2 0.10.4", + "derive_more", + "either", + "env_logger", + "heck 0.4.0", + "impl-serde", + "ink_ir", + "ink_primitives", + "itertools", + "log", + "parity-scale-codec", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", +] + +[[package]] +name = "ink_engine" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daed9b710cba6f50f1fa0372a7e8a47a35624d84af4ef2c3a8d34d4e96202d1c" +dependencies = [ + "blake2 0.10.4", + "derive_more", + "ink_primitives", + "parity-scale-codec", + "secp256k1", + "sha2", + "sha3", +] + +[[package]] +name = "ink_env" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41c6a3f4e740e27449f805ed47f536a35fb254ebcd03d2480014589331cda3e" +dependencies = [ + "arrayref", + "blake2 0.10.4", + "cfg-if", + "derive_more", + "ink_allocator", + "ink_engine", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "num-traits", + "parity-scale-codec", + "paste", + "rlibc", + "scale-info", + "secp256k1", + "sha2", + "sha3", + "static_assertions", +] + +[[package]] +name = "ink_ir" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "946b940d26e69ded558daafead0979f25f2e9d7e2cf86027f250c3942aa4d0f1" +dependencies = [ + "blake2 0.10.4", + "either", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink_macro" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6642450e6169cfaf81717b1d62b2abae48a6b41d3f70f885b6aeff7bb14ea96b" +dependencies = [ + "ink_codegen", + "ink_ir", + "ink_primitives", + "parity-scale-codec", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "ink_metadata" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfcfa666ada5729c7e4d3d986cd196365a2c469459fced4fa31dc6ad87c4d8f" +dependencies = [ + "derive_more", + "impl-serde", + "ink_prelude", + "ink_primitives", + "scale-info", + "serde", +] + +[[package]] +name = "ink_prelude" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8080235e5ae921975c2c7772fe9959e1b3c92b4d5a1afcfe104f93fb79aa268" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_primitives" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b3f711d857d2de7c08158369cc32a762833ac211a00aac7931992094e25741" +dependencies = [ + "derive_more", + "ink_prelude", + "parity-scale-codec", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "ink_storage" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2872a5ea4559433381b2d82b08b6acd33ce934b07a22ce951c6f00483680c950" +dependencies = [ + "array-init", + "cfg-if", + "derive_more", + "ink_env", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ink_storage_traits" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c90e11b60233ae5ab877854739da2c380a337cb31b3900cb50328821c0381b6" +dependencies = [ + "ink_metadata", + "ink_prelude", + "ink_primitives", + "parity-scale-codec", + "scale-info", + "syn", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" + +[[package]] +name = "keccak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "obce" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "ink", + "ink_engine", + "obce-macro", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "obce-codegen" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "blake2 0.10.4", + "itertools", + "proc-macro2", + "quote", + "syn", + "tuple", +] + +[[package]] +name = "obce-macro" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "obce-codegen", + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "once_cell" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openbrush" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "ink", + "openbrush_contracts", + "openbrush_lang", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "openbrush_contracts" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "ink", + "openbrush_lang", + "pallet-assets-chain-extension", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "openbrush_lang" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "const_format", + "ink", + "openbrush_lang_macro", + "parity-scale-codec", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "openbrush_lang_codegen" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "blake2 0.9.2", + "cargo_metadata", + "fs2", + "heck 0.3.3", + "ink_ir", + "ink_primitives", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", + "synstructure", + "unwrap", +] + +[[package]] +name = "openbrush_lang_macro" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "openbrush_lang_codegen", + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "pallet-assets-chain-extension" +version = "0.1.1" +source = "git+https://github.com/727-ventures/pallet-assets-chain-extension?branch=polkadot-v0.9.37#f8ea374186df2a3fc139c8d585719e58d83df582" +dependencies = [ + "ink", + "obce", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "parity-scale-codec" +version = "3.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9182e4a71cae089267ab03e67c99368db7cd877baf50f931e5d6d4b71e195ac0" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "paste" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22" + +[[package]] +name = "pest" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69486e2b8c2d2aeb9762db7b4e00b0331156393555cff467f4163ff06821eef8" +dependencies = [ + "thiserror", + "ucd-trie", +] + +[[package]] +name = "proc-macro-crate" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d50bfb8c23f23915855a00d98b5a35ef2e0b871bb52937bacadb798fbb66c8" +dependencies = [ + "once_cell", + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "rlibc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" + +[[package]] +name = "rustix" +version = "0.36.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "scale-info" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "secp256k1" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642a62736682fdd8c71da0eb273e453c8ac74e33b9fb310e22ba5b03ec7651ff" +dependencies = [ + "cc", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.142" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e590c437916fb6b221e1d00df6e3294f3fccd70ca7e92541c475d6ed6ef5fee2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.142" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34b5b8d809babe02f538c2cfec6f2c1ed10804c0e5a6a041a049a4f5588ccc2e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + +[[package]] +name = "sha3" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a31480366ec990f395a61b7c08122d99bd40544fdb5abcfc1b06bb29994312c" +dependencies = [ + "digest 0.10.3", + "keccak", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ticket_token" +version = "2.1.0" +dependencies = [ + "access_control", + "ink", + "openbrush", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "tuple" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39a40ba241047e1174c927dc5f61c141a166b938d61a2ff61838441368cc7d0e" +dependencies = [ + "num-traits", + "serde", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "ucd-trie" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" + +[[package]] +name = "unicode-ident" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" + +[[package]] +name = "unicode-segmentation" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" + +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + +[[package]] +name = "unwrap" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e33648dd74328e622c7be51f3b40a303c63f93e6fa5f08778b6203a4c25c20f" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "wyz" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +dependencies = [ + "tap", +] + +[[package]] +name = "xxhash-rust" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735a71d46c4d68d71d4b24d03fdc2b98e38cea81730595801db779c04fe80d70" diff --git a/contracts/ticket_token/Cargo.toml b/contracts/ticket_token/Cargo.toml new file mode 100644 index 0000000000..86092b273c --- /dev/null +++ b/contracts/ticket_token/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "ticket_token" +version = "2.1.0" +authors = ["Cardinal Cryptography"] +edition = "2021" +license = "Apache 2.0" + +[dependencies] +ink = { version = "=4.0.1", default-features = false } +openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts/", tag = "3.0.0", default-features = false, features = ["psp22"] } + +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } + +access_control = { path = "../access_control", default-features = false, features = ["ink-as-dependency"] } + +[lib] +name = "ticket_token" +path = "lib.rs" +crate-type = [ + # Used for normal contract Wasm blobs. + "cdylib", + # Used for ABI generation. + "rlib", +] + +[features] +default = ["std"] +std = [ + "ink/std", + "openbrush/std", + "scale-info/std", + "scale/std", + "access_control/std", +] +ink-as-dependency = [] + +[profile.dev] +codegen-units = 16 diff --git a/contracts/ticket_token/lib.rs b/contracts/ticket_token/lib.rs new file mode 100644 index 0000000000..40717faa19 --- /dev/null +++ b/contracts/ticket_token/lib.rs @@ -0,0 +1,192 @@ +#![cfg_attr(not(feature = "std"), no_std)] +#![feature(min_specialization)] +#![allow(clippy::let_unit_value)] + +pub use crate::ticket_token::{BALANCE_OF_SELECTOR, TRANSFER_FROM_SELECTOR, TRANSFER_SELECTOR}; + +#[openbrush::contract] +pub mod ticket_token { + use access_control::{roles::Role, AccessControlRef, ACCESS_CONTROL_PUBKEY}; + use ink::{ + codegen::{EmitEvent, Env}, + env::call::FromAccountId, + prelude::{format, string::String}, + reflect::ContractEventBase, + ToAccountId, + }; + use openbrush::{ + contracts::psp22::{extensions::metadata::*, Internal}, + traits::Storage, + }; + + pub const BALANCE_OF_SELECTOR: [u8; 4] = [0x65, 0x68, 0x38, 0x2f]; + pub const TRANSFER_SELECTOR: [u8; 4] = [0xdb, 0x20, 0xf9, 0xf5]; + pub const TRANSFER_FROM_SELECTOR: [u8; 4] = [0x54, 0xb3, 0xc7, 0x6e]; + + #[ink(storage)] + #[derive(Storage)] + pub struct TicketToken { + #[storage_field] + psp22: psp22::Data, + #[storage_field] + metadata: metadata::Data, + access_control: AccessControlRef, + } + + impl PSP22 for TicketToken {} + + impl PSP22Metadata for TicketToken {} + + impl Internal for TicketToken { + fn _emit_transfer_event( + &self, + from: Option, + to: Option, + amount: Balance, + ) { + TicketToken::emit_event( + self.env(), + Event::TransferEvent(TransferEvent { + from, + to, + value: amount, + }), + ); + } + + fn _emit_approval_event(&self, owner: AccountId, spender: AccountId, amount: Balance) { + TicketToken::emit_event( + self.env(), + Event::Approval(Approval { + owner, + spender, + value: amount, + }), + ); + } + } + + /// Result type + pub type Result = core::result::Result; + /// Event type + pub type Event = ::Type; + + /// Event emitted when a token transfer occurs. + #[ink(event)] + #[derive(Debug)] + pub struct TransferEvent { + #[ink(topic)] + pub from: Option, + #[ink(topic)] + pub to: Option, + pub value: Balance, + } + + /// Event emitted when an approval occurs that `spender` is allowed to withdraw + /// up to the amount of `value` tokens from `owner`. + #[ink(event)] + #[derive(Debug)] + pub struct Approval { + #[ink(topic)] + owner: AccountId, + #[ink(topic)] + spender: AccountId, + value: Balance, + } + + impl TicketToken { + /// Creates a new contract with the specified initial supply. + /// + /// Will revert if called from an account without a proper role + #[ink(constructor)] + pub fn new(name: String, symbol: String, total_supply: Balance) -> Self { + let caller = Self::env().caller(); + let code_hash = Self::env() + .own_code_hash() + .expect("Called new on a contract with no code hash"); + + let required_role = Role::Initializer(code_hash); + let access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); + let access_control = AccessControlRef::from_account_id(access_control); + + if access_control.has_role(caller, required_role) { + let metadata = metadata::Data { + name: Some(name.into()), + symbol: Some(symbol.into()), + decimals: 0, + ..Default::default() + }; + + let mut instance = TicketToken { + access_control, + metadata, + psp22: psp22::Data::default(), + }; + + instance + ._mint_to(instance.env().caller(), total_supply) + .expect("Should mint"); + + instance + } else { + panic!("Caller is not allowed to initialize this contract"); + } + } + + pub fn emit_event>(emitter: EE, event: Event) { + emitter.emit_event(event); + } + + /// Terminates the contract. + /// + /// can only be called by the contract's Owner + #[ink(message, selector = 7)] + pub fn terminate(&mut self) -> Result<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + let required_role = Role::Owner(this); + + self.check_role(caller, required_role)?; + self.env().terminate_contract(caller) + } + + /// Returns the contract's access control contract address + #[ink(message, selector = 8)] + pub fn access_control(&self) -> AccountId { + self.access_control.to_account_id() + } + + fn check_role(&self, account: AccountId, role: Role) -> Result<()> { + if self.access_control.has_role(account, role) { + Ok(()) + } else { + Err(PSP22Error::Custom( + format!("Role missing: {:?}", role).into(), + )) + } + } + + /// Sets new access control contract address + /// + /// Can only be called by the contract's Owner + #[ink(message, selector = 9)] + pub fn set_access_control(&mut self, access_control: AccountId) -> Result<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + let required_role = Role::Owner(this); + + self.check_role(caller, required_role)?; + self.access_control = AccessControlRef::from_account_id(access_control); + + Ok(()) + } + + /// Returns own code hash + #[ink(message, selector = 10)] + pub fn code_hash(&self) -> Result { + Self::env().own_code_hash().map_err(|why| { + PSP22Error::Custom(format!("Can't retrieve own code hash: {:?}", why).into()) + }) + } + } +} diff --git a/contracts/wrapped_azero/Cargo.lock b/contracts/wrapped_azero/Cargo.lock new file mode 100644 index 0000000000..a7de9f2225 --- /dev/null +++ b/contracts/wrapped_azero/Cargo.lock @@ -0,0 +1,1214 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "access_control" +version = "0.2.0" +dependencies = [ + "ink", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "array-init" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfb6d71005dc22a708c7496eee5c8dc0300ee47355de6256c3b35b12b5fef596" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +dependencies = [ + "crypto-mac", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "blake2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +dependencies = [ + "digest 0.10.3", +] + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byte-slice-cast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" + +[[package]] +name = "camino" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "081e3f0755c1f380c2d010481b6fa2e02973586d5f2b24eebb7a2a1d98b143d8" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "semver-parser", + "serde", + "serde_json", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const_format" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76b4fc39f3bcab7e042becf5c9dbbebc179fff64924025753a5fafa016e8576d" +dependencies = [ + "derive_more", + "ink_env", + "ink_macro", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage", + "parity-scale-codec", +] + +[[package]] +name = "ink_allocator" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a54dbbaffb0f97bcae062e628dcdc9da4d3c9044f5a53fb2715a328b07221631" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_codegen" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "283b022679ef75898db5c28b89388412d93f91cea4f0b1443426901cb391b079" +dependencies = [ + "blake2 0.10.4", + "derive_more", + "either", + "env_logger", + "heck 0.4.0", + "impl-serde", + "ink_ir", + "ink_primitives", + "itertools", + "log", + "parity-scale-codec", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", +] + +[[package]] +name = "ink_engine" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daed9b710cba6f50f1fa0372a7e8a47a35624d84af4ef2c3a8d34d4e96202d1c" +dependencies = [ + "blake2 0.10.4", + "derive_more", + "ink_primitives", + "parity-scale-codec", + "secp256k1", + "sha2", + "sha3", +] + +[[package]] +name = "ink_env" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41c6a3f4e740e27449f805ed47f536a35fb254ebcd03d2480014589331cda3e" +dependencies = [ + "arrayref", + "blake2 0.10.4", + "cfg-if", + "derive_more", + "ink_allocator", + "ink_engine", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "num-traits", + "parity-scale-codec", + "paste", + "rlibc", + "scale-info", + "secp256k1", + "sha2", + "sha3", + "static_assertions", +] + +[[package]] +name = "ink_ir" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "946b940d26e69ded558daafead0979f25f2e9d7e2cf86027f250c3942aa4d0f1" +dependencies = [ + "blake2 0.10.4", + "either", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ink_macro" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6642450e6169cfaf81717b1d62b2abae48a6b41d3f70f885b6aeff7bb14ea96b" +dependencies = [ + "ink_codegen", + "ink_ir", + "ink_primitives", + "parity-scale-codec", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "ink_metadata" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfcfa666ada5729c7e4d3d986cd196365a2c469459fced4fa31dc6ad87c4d8f" +dependencies = [ + "derive_more", + "impl-serde", + "ink_prelude", + "ink_primitives", + "scale-info", + "serde", +] + +[[package]] +name = "ink_prelude" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8080235e5ae921975c2c7772fe9959e1b3c92b4d5a1afcfe104f93fb79aa268" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_primitives" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b3f711d857d2de7c08158369cc32a762833ac211a00aac7931992094e25741" +dependencies = [ + "derive_more", + "ink_prelude", + "parity-scale-codec", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "ink_storage" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2872a5ea4559433381b2d82b08b6acd33ce934b07a22ce951c6f00483680c950" +dependencies = [ + "array-init", + "cfg-if", + "derive_more", + "ink_env", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ink_storage_traits" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c90e11b60233ae5ab877854739da2c380a337cb31b3900cb50328821c0381b6" +dependencies = [ + "ink_metadata", + "ink_prelude", + "ink_primitives", + "parity-scale-codec", + "scale-info", + "syn", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8bf247779e67a9082a4790b45e71ac7cfd1321331a5c856a74a9faebdab78d0" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" + +[[package]] +name = "keccak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "obce" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "ink", + "ink_engine", + "obce-macro", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "obce-codegen" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "blake2 0.10.4", + "itertools", + "proc-macro2", + "quote", + "syn", + "tuple", +] + +[[package]] +name = "obce-macro" +version = "0.1.0" +source = "git+https://github.com/727-Ventures/obce?branch=polkadot-v0.9.37#d452f6eda1bc1ecb36e7e332d61529ad440d5a89" +dependencies = [ + "obce-codegen", + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "once_cell" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openbrush" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "ink", + "openbrush_contracts", + "openbrush_lang", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "openbrush_contracts" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "ink", + "openbrush_lang", + "pallet-assets-chain-extension", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "openbrush_lang" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "const_format", + "ink", + "openbrush_lang_macro", + "parity-scale-codec", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "openbrush_lang_codegen" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "blake2 0.9.2", + "cargo_metadata", + "fs2", + "heck 0.3.3", + "ink_ir", + "ink_primitives", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", + "synstructure", + "unwrap", +] + +[[package]] +name = "openbrush_lang_macro" +version = "3.0.0" +source = "git+https://github.com/727-Ventures/openbrush-contracts/?tag=3.0.0#9894c2fda2f7b59959a7184c047e8e08aa45ffc2" +dependencies = [ + "openbrush_lang_codegen", + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "pallet-assets-chain-extension" +version = "0.1.1" +source = "git+https://github.com/727-ventures/pallet-assets-chain-extension?branch=polkadot-v0.9.37#f8ea374186df2a3fc139c8d585719e58d83df582" +dependencies = [ + "ink", + "obce", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "parity-scale-codec" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "paste" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" + +[[package]] +name = "pest" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb779fcf4bb850fbbb0edc96ff6cf34fd90c4b1a112ce042653280d9a7364048" +dependencies = [ + "thiserror", + "ucd-trie", +] + +[[package]] +name = "proc-macro-crate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +dependencies = [ + "once_cell", + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "rlibc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" + +[[package]] +name = "rustix" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "scale-info" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "secp256k1" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642a62736682fdd8c71da0eb273e453c8ac74e33b9fb310e22ba5b03ec7651ff" +dependencies = [ + "cc", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9db03534dff993187064c4e0c05a5708d2a9728ace9a8959b77bedf415dac5" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + +[[package]] +name = "sha3" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaedf34ed289ea47c2b741bb72e5357a209512d67bcd4bda44359e5bf0470f56" +dependencies = [ + "digest 0.10.3", + "keccak", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "tuple" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39a40ba241047e1174c927dc5f61c141a166b938d61a2ff61838441368cc7d0e" +dependencies = [ + "num-traits", + "serde", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "ucd-trie" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" + +[[package]] +name = "unicode-ident" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" + +[[package]] +name = "unicode-segmentation" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" + +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + +[[package]] +name = "unwrap" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e33648dd74328e622c7be51f3b40a303c63f93e6fa5f08778b6203a4c25c20f" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "wrapped_azero" +version = "1.0.0" +dependencies = [ + "access_control", + "ink", + "num-traits", + "openbrush", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "wyz" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +dependencies = [ + "tap", +] + +[[package]] +name = "xxhash-rust" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735a71d46c4d68d71d4b24d03fdc2b98e38cea81730595801db779c04fe80d70" diff --git a/contracts/wrapped_azero/Cargo.toml b/contracts/wrapped_azero/Cargo.toml new file mode 100644 index 0000000000..4b6aabb5f3 --- /dev/null +++ b/contracts/wrapped_azero/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "wrapped_azero" +version = "1.0.0" +authors = ["Cardinal Cryptography"] +edition = "2021" +license = "Apache 2.0" + +[dependencies] +ink = { version = "=4.0.1", default-features = false } +openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts/", tag = "3.0.0", default-features = false, features = ["psp22"] } + +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } + +num-traits = { version = "0.2", default-features = false } +access_control = { path = "../access_control", default-features = false, features = ["ink-as-dependency"] } + +[lib] +name = "wrapped_azero" +path = "lib.rs" +crate-type = [ + # Used for normal contract Wasm blobs. + "cdylib", + # Used for ABI generation. + "rlib", +] + +[features] +default = ["std"] +std = [ + "num-traits/std", + "ink/std", + "openbrush/std", + "scale-info", + "scale-info/std", + "scale/std", + "access_control/std", +] +ink-as-dependency = [] + +[profile.dev] +codegen-units = 16 diff --git a/contracts/wrapped_azero/lib.rs b/contracts/wrapped_azero/lib.rs new file mode 100644 index 0000000000..f59dd61c91 --- /dev/null +++ b/contracts/wrapped_azero/lib.rs @@ -0,0 +1,244 @@ +#![cfg_attr(not(feature = "std"), no_std)] +#![feature(min_specialization)] +#![allow(clippy::let_unit_value)] + +pub use crate::wrapped_azero::{ + ALLOWANCE_SELECTOR, BALANCE_OF_SELECTOR, TRANSFER_FROM_SELECTOR, TRANSFER_SELECTOR, +}; + +#[openbrush::contract] +pub mod wrapped_azero { + use access_control::{roles::Role, AccessControlRef, ACCESS_CONTROL_PUBKEY}; + use ink::{ + codegen::{EmitEvent, Env}, + env::call::FromAccountId, + prelude::format, + reflect::ContractEventBase, + ToAccountId, + }; + use num_traits::identities::Zero; + use openbrush::{ + contracts::psp22::{extensions::metadata::*, Internal}, + traits::Storage, + }; + + pub const BALANCE_OF_SELECTOR: [u8; 4] = [0x65, 0x68, 0x38, 0x2f]; + pub const TRANSFER_SELECTOR: [u8; 4] = [0xdb, 0x20, 0xf9, 0xf5]; + pub const TRANSFER_FROM_SELECTOR: [u8; 4] = [0x54, 0xb3, 0xc7, 0x6e]; + pub const ALLOWANCE_SELECTOR: [u8; 4] = [0x4d, 0x47, 0xd9, 0x21]; + + #[ink(storage)] + #[derive(Storage)] + pub struct WrappedAzero { + #[storage_field] + psp22: psp22::Data, + #[storage_field] + metadata: metadata::Data, + access_control: AccessControlRef, + } + + impl Default for WrappedAzero { + fn default() -> Self { + Self::new() + } + } + + impl PSP22 for WrappedAzero {} + + impl PSP22Metadata for WrappedAzero {} + + // emit events + // https://github.com/w3f/PSPs/blob/master/PSPs/psp-22.md + impl Internal for WrappedAzero { + fn _emit_transfer_event( + &self, + _from: Option, + _to: Option, + _amount: Balance, + ) { + WrappedAzero::emit_event( + self.env(), + Event::Transfer(Transfer { + from: _from, + to: _to, + value: _amount, + }), + ); + } + + fn _emit_approval_event(&self, _owner: AccountId, _spender: AccountId, _amount: Balance) { + WrappedAzero::emit_event( + self.env(), + Event::Approval(Approval { + owner: _owner, + spender: _spender, + value: _amount, + }), + ); + } + } + + /// Result type + pub type Result = core::result::Result; + /// Event type + pub type Event = ::Type; + + /// Event emitted when a token transfer occurs. + #[ink(event)] + #[derive(Debug)] + pub struct Transfer { + #[ink(topic)] + pub from: Option, + #[ink(topic)] + pub to: Option, + pub value: Balance, + } + + /// Event emitted when an approval occurs that `spender` is allowed to withdraw + /// up to the amount of `value` tokens from `owner`. + #[ink(event)] + #[derive(Debug)] + pub struct Approval { + #[ink(topic)] + owner: AccountId, + #[ink(topic)] + spender: AccountId, + value: Balance, + } + + #[ink(event)] + #[derive(Debug)] + pub struct Wrapped { + caller: AccountId, + amount: Balance, + } + + #[ink(event)] + #[derive(Debug)] + pub struct UnWrapped { + caller: AccountId, + amount: Balance, + } + + impl WrappedAzero { + /// Creates a new token + /// + /// The token will have its name and symbol set in metadata to the specified values. + /// Decimals are fixed at 12. + /// + /// Will revert if called from an account without a proper role + #[ink(constructor)] + pub fn new() -> Self { + let caller = Self::env().caller(); + let code_hash = Self::env() + .own_code_hash() + .expect("Called new on a contract with no code hash"); + + let access_control = AccountId::from(ACCESS_CONTROL_PUBKEY); + let access_control = AccessControlRef::from_account_id(access_control); + if access_control.has_role(caller, Role::Initializer(code_hash)) { + let metadata = metadata::Data { + name: Some("wAzero".into()), + symbol: Some("wA0".into()), + decimals: 12, // same as AZERO + ..Default::default() + }; + + Self { + psp22: psp22::Data::default(), + metadata, + access_control, + } + } else { + panic!("Caller is not allowed to initialize this contract"); + } + } + + /// Wraps the transferred amount of native token and mints it to the callers account + #[ink(message, payable)] + pub fn wrap(&mut self) -> Result<()> { + let caller = self.env().caller(); + let amount = self.env().transferred_value(); + if !amount.eq(&Balance::zero()) { + self._mint_to(caller, amount)?; + Self::emit_event(self.env(), Event::Wrapped(Wrapped { caller, amount })); + } + + Ok(()) + } + + /// Unwraps a specified amount + #[ink(message)] + pub fn unwrap(&mut self, amount: Balance) -> Result<()> { + if amount.eq(&Balance::zero()) { + return Ok(()); + } + + let caller = self.env().caller(); + + // burn the token form the caller, will fail if the calling account doesn't have enough balance + self._burn_from(caller, amount)?; + + // return the native token to the caller + self.env().transfer(caller, amount).map_err(|why| { + PSP22Error::Custom(format!("Native transfer failed: {:?}", why).into()) + })?; + Self::emit_event(self.env(), Event::UnWrapped(UnWrapped { caller, amount })); + + Ok(()) + } + + /// Terminates the contract. + /// + /// can only be called by the contract's Owner + #[ink(message)] + pub fn terminate(&mut self) -> Result<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + let required_role = Role::Owner(this); + + self.check_role(caller, required_role)?; + self.env().terminate_contract(caller) + } + + /// Returns the contract's access control contract address + #[ink(message)] + pub fn access_control(&self) -> AccountId { + self.access_control.to_account_id() + } + + /// Sets new access control contract address + /// + /// Can only be called by the contract's Owner + #[ink(message)] + pub fn set_access_control(&mut self, access_control: AccountId) -> Result<()> { + let caller = self.env().caller(); + let this = self.env().account_id(); + + self.check_role(caller, Role::Owner(this))?; + + self.access_control = AccessControlRef::from_account_id(access_control); + Ok(()) + } + + /// Returns own code hash + #[ink(message)] + pub fn code_hash(&self) -> Result { + Self::env().own_code_hash().map_err(|why| { + PSP22Error::Custom(format!("Can't retrieve own code hash: {:?}", why).into()) + }) + } + + pub fn emit_event>(emitter: EE, event: Event) { + emitter.emit_event(event); + } + + fn check_role(&self, account: AccountId, role: Role) -> Result<()> { + if self.access_control.has_role(account, role) { + Ok(()) + } else { + Err(PSP22Error::Custom(format!("MissingRole:{:?}", role).into())) + } + } + } +} diff --git a/docker/common.yml b/docker/common.yml index 59a04adf45..3203cd5f9a 100644 --- a/docker/common.yml +++ b/docker/common.yml @@ -7,7 +7,7 @@ services: - CHAIN=/data/chainspec.json - ALLOW_PRIVATE_IPV4=true - DISCOVER_LOCAL=true - - UNIT_CREATION_DELAY=50 + - UNIT_CREATION_DELAY=300 volumes: - ./data/:/data/ diff --git a/docker/smartnet-compose.yml b/docker/smartnet-compose.yml new file mode 100644 index 0000000000..0dc1148ccc --- /dev/null +++ b/docker/smartnet-compose.yml @@ -0,0 +1,39 @@ +version: '3' +services: + + smartnode: + image: $NODE_IMAGE + container_name: smartnode + environment: + - ALLOW_PRIVATE_IPV4=true + - BASE_PATH=/data/$NODE_ID + - CHAIN=/data/chainspec.smartnet.json + - CUSTOM_ARGS=-lerror,runtime::contracts=debug + - DISCOVER_LOCAL=true + - NAME=Smartnode + - NODE_KEY_PATH=/data/$NODE_ID/p2p_secret + - PORT=30333 + - PURGE_BEFORE_START=true + - RPC_PORT=9933 + - RUST_LOG=info + - UNIT_CREATION_DELAY=300 + - WS_PORT=9943 + - BOOT_NODES=/ip4/127.0.0.1/tcp/30333/p2p/$BOOTNODE_PEER_ID + - PUBLIC_ADDR=/ip4/127.0.0.1/tcp/30333 + - VALIDATOR_PORT=30343 + - PUBLIC_VALIDATOR_ADDRESS=127.0.0.1:30343 + volumes: + - ./data/:/data/ + expose: + - 30333 + - 9933 + - 9943 + ports: + - 0.0.0.0:30333:30333 + - 0.0.0.0:9933:9933 + - 0.0.0.0:9943:9943 + +networks: + default: + external: + name: node-network diff --git a/e2e-tests/Cargo.lock b/e2e-tests/Cargo.lock index b898b1f71a..a09eac32ef 100644 --- a/e2e-tests/Cargo.lock +++ b/e2e-tests/Cargo.lock @@ -1131,7 +1131,7 @@ dependencies = [ "paste", "scale-info", "serde", - "sp-api 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-api", "sp-application-crypto 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", @@ -1199,14 +1199,14 @@ dependencies = [ "scale-info", "serde", "smallvec", - "sp-api 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-api", "sp-arithmetic 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-core-hashing-proc-macro 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-core-hashing-proc-macro", "sp-inherents", "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", "sp-state-machine 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-tracing 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", @@ -1265,7 +1265,7 @@ dependencies = [ "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-version 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-version", "sp-weights 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] @@ -2609,7 +2609,7 @@ dependencies = [ "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] @@ -2629,7 +2629,7 @@ dependencies = [ "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-session", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-trie 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] @@ -2652,7 +2652,7 @@ dependencies = [ "sp-application-crypto 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] @@ -2883,12 +2883,12 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-api 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-application-crypto 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", + "sp-api", + "sp-application-crypto 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", + "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] [[package]] @@ -3719,31 +3719,13 @@ dependencies = [ "hash-db", "log", "parity-scale-codec", - "sp-api-proc-macro 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-api-proc-macro", "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-state-machine 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-trie 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-version 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "thiserror", -] - -[[package]] -name = "sp-api" -version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "hash-db", - "log", - "parity-scale-codec", - "sp-api-proc-macro 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-state-machine 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-trie 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-version 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", + "sp-version", "thiserror", ] @@ -3759,18 +3741,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-api-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "blake2", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "sp-application-crypto" version = "7.0.0" @@ -3798,19 +3768,6 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-application-crypto" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "sp-arithmetic" version = "6.0.0" @@ -3841,20 +3798,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "sp-arithmetic" -version = "6.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", - "scale-info", - "serde", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "static_assertions", -] - [[package]] name = "sp-core" version = "7.0.0" @@ -3943,48 +3886,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "sp-core" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "array-bytes", - "base58", - "bitflags", - "blake2", - "dyn-clonable", - "ed25519-zebra", - "futures", - "hash-db", - "hash256-std-hasher", - "impl-serde", - "lazy_static", - "libsecp256k1", - "log", - "merlin", - "parity-scale-codec", - "parking_lot", - "primitive-types", - "rand 0.8.5", - "regex", - "scale-info", - "schnorrkel", - "secp256k1 0.24.3", - "secrecy", - "serde", - "sp-core-hashing 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-debug-derive 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-externalities 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime-interface 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-storage 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "ss58-registry", - "substrate-bip39", - "thiserror", - "tiny-bip39 1.0.0", - "zeroize", -] - [[package]] name = "sp-core-hashing" version = "5.0.0" @@ -4014,20 +3915,6 @@ dependencies = [ "twox-hash", ] -[[package]] -name = "sp-core-hashing" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "blake2", - "byteorder", - "digest 0.10.6", - "sha2 0.10.6", - "sha3", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "twox-hash", -] - [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" @@ -4039,17 +3926,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-core-hashing-proc-macro" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "proc-macro2", - "quote", - "sp-core-hashing 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "syn", -] - [[package]] name = "sp-debug-derive" version = "5.0.0" @@ -4071,16 +3947,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-debug-derive" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "sp-externalities" version = "0.13.0" @@ -4104,17 +3970,6 @@ dependencies = [ "sp-storage 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-externalities" -version = "0.13.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "environmental", - "parity-scale-codec", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-storage 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "sp-inherents" version = "4.0.0-dev" @@ -4181,31 +4036,6 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "sp-io" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "bytes", - "ed25519", - "ed25519-dalek", - "futures", - "libsecp256k1", - "log", - "parity-scale-codec", - "secp256k1 0.24.3", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-externalities 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-keystore 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime-interface 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-state-machine 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-tracing 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-trie 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "tracing", - "tracing-core", -] - [[package]] name = "sp-keystore" version = "0.13.0" @@ -4239,22 +4069,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "sp-keystore" -version = "0.13.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "async-trait", - "futures", - "merlin", - "parity-scale-codec", - "parking_lot", - "schnorrkel", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-externalities 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "thiserror", -] - [[package]] name = "sp-npos-elections" version = "4.0.0-dev" @@ -4290,16 +4104,6 @@ dependencies = [ "regex", ] -[[package]] -name = "sp-panic-handler" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "backtrace", - "lazy_static", - "regex", -] - [[package]] name = "sp-runtime" version = "7.0.0" @@ -4346,28 +4150,6 @@ dependencies = [ "sp-weights 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-runtime" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "either", - "hash256-std-hasher", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "paste", - "rand 0.8.5", - "scale-info", - "serde", - "sp-application-crypto 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-arithmetic 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-weights 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "sp-runtime-interface" version = "7.0.0" @@ -4405,24 +4187,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "sp-runtime-interface" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "bytes", - "impl-trait-for-tuples", - "parity-scale-codec", - "primitive-types", - "sp-externalities 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime-interface-proc-macro 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-storage 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-tracing 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-wasm-interface 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "static_assertions", -] - [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" @@ -4448,18 +4212,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-runtime-interface-proc-macro" -version = "6.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "Inflector", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "sp-session" version = "4.0.0-dev" @@ -4467,10 +4219,10 @@ source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=alep dependencies = [ "parity-scale-codec", "scale-info", - "sp-api 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-api", "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] @@ -4486,18 +4238,6 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-staking" -version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "parity-scale-codec", - "scale-info", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "sp-state-machine" version = "0.13.0" @@ -4541,26 +4281,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "sp-state-machine" -version = "0.13.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "hash-db", - "log", - "parity-scale-codec", - "parking_lot", - "rand 0.8.5", - "smallvec", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-externalities 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-panic-handler 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-trie 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "thiserror", - "tracing", -] - [[package]] name = "sp-std" version = "5.0.0" @@ -4572,11 +4292,6 @@ name = "sp-std" version = "5.0.0" source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" -[[package]] -name = "sp-std" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" - [[package]] name = "sp-storage" version = "7.0.0" @@ -4604,19 +4319,6 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-storage" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "ref-cast", - "serde", - "sp-debug-derive 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "sp-timestamp" version = "4.0.0-dev" @@ -4657,18 +4359,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "sp-tracing" -version = "6.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "parity-scale-codec", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "tracing", - "tracing-core", - "tracing-subscriber", -] - [[package]] name = "sp-trie" version = "7.0.0" @@ -4716,29 +4406,6 @@ dependencies = [ "trie-root", ] -[[package]] -name = "sp-trie" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "ahash 0.8.3", - "hash-db", - "hashbrown 0.12.3", - "lazy_static", - "memory-db 0.31.0", - "nohash-hasher", - "parity-scale-codec", - "parking_lot", - "scale-info", - "schnellru", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "thiserror", - "tracing", - "trie-db", - "trie-root", -] - [[package]] name = "sp-version" version = "5.0.0" @@ -4749,27 +4416,10 @@ dependencies = [ "parity-wasm", "scale-info", "serde", - "sp-core-hashing-proc-macro 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-core-hashing-proc-macro", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-version-proc-macro 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "thiserror", -] - -[[package]] -name = "sp-version" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "parity-wasm", - "scale-info", - "serde", - "sp-core-hashing-proc-macro 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-version-proc-macro 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", + "sp-version-proc-macro", "thiserror", ] @@ -4784,17 +4434,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-version-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "parity-scale-codec", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "sp-wasm-interface" version = "7.0.0" @@ -4821,19 +4460,6 @@ dependencies = [ "wasmtime", ] -[[package]] -name = "sp-wasm-interface" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "wasmi", - "wasmtime", -] - [[package]] name = "sp-weights" version = "4.0.0" @@ -4866,21 +4492,6 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-weights" -version = "4.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde", - "smallvec", - "sp-arithmetic 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-debug-derive 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "spin" version = "0.5.2" diff --git a/e2e-tests/src/config.rs b/e2e-tests/src/config.rs index b79b27de74..80d8838b3d 100644 --- a/e2e-tests/src/config.rs +++ b/e2e-tests/src/config.rs @@ -7,7 +7,7 @@ use primitives::SessionIndex; use crate::accounts::{get_sudo_key, get_validators_keys, get_validators_seeds, NodeKeys}; static GLOBAL_CONFIG: Lazy = Lazy::new(|| { - let node = get_env("NODE_URL").unwrap_or_else(|| "ws://127.0.0.1:9943".to_string()); + let node = get_env("NODE_URL").unwrap_or_else(|| "ws://127.0.0.1:9944".to_string()); let validator_count = get_env("VALIDATOR_COUNT").unwrap_or(5); let validators_seeds = env::var("VALIDATORS_SEEDS") .ok() @@ -27,6 +27,17 @@ static GLOBAL_CONFIG: Lazy = Lazy::new(|| { upgrade_finalization_wait_sessions: get_env("UPGRADE_FINALIZATION_WAIT_SESSIONS"), adder: get_env("ADDER"), adder_metadata: get_env("ADDER_METADATA"), + back_to_the_future: get_env("BACK_TO_THE_FUTURE"), + early_bird_special: get_env("EARLY_BIRD_SPECIAL"), + the_pressiah_cometh: get_env("THE_PRESSIAH_COMETH"), + wrapped_azero: get_env("WRAPPED_AZERO"), + simple_dex: get_env("SIMPLE_DEX"), + button_game_metadata: get_env("BUTTON_GAME_METADATA"), + marketplace_metadata: get_env("MARKETPLACE_METADATA"), + reward_token_metadata: get_env("REWARD_TOKEN_METADATA"), + ticket_token_metadata: get_env("TICKET_TOKEN_METADATA"), + simple_dex_metadata: get_env("SIMPLE_DEX_METADATA"), + wrapped_azero_metadata: get_env("WRAPPED_AZERO_METADATA"), out_latency: get_env("OUT_LATENCY"), synthetic_network_urls: env::var("SYNTHETIC_URLS") .ok() @@ -130,6 +141,39 @@ pub struct TestCaseParams { /// Desired number of non-reserved seats for validators, may be set within the test. pub non_reserved_seats: Option, + /// Address of the Early Bird Special game contract, only used by button game tests. + pub early_bird_special: Option, + + /// Address of the Back to the Future game contract, only used by button game tests. + pub back_to_the_future: Option, + + /// Address of the The Pressiah Cometh game contract, only used by button game tests. + pub the_pressiah_cometh: Option, + + /// Address of the simple dex contract. Only used by button tests. + pub simple_dex: Option, + + /// Address of the wrapped azero contract. Only used by button tests. + pub wrapped_azero: Option, + + /// Path to the button game metadata file. Only used by button tests. + pub button_game_metadata: Option, + + /// Path to the ticket token metadata file. Only used by button tests. + pub ticket_token_metadata: Option, + + /// Path to the reward token metadata file. Only used by button tests. + pub reward_token_metadata: Option, + + /// Path to the marketplace metadata file. Only used by button tests. + pub marketplace_metadata: Option, + + /// Path to the simple_dex metadata file. Only used by button tests. + pub simple_dex_metadata: Option, + + /// Path to wrapped_azero metadata file. Only used by button tests. + pub wrapped_azero_metadata: Option, + /// Version for the VersionUpgrade test. pub upgrade_to_version: Option, diff --git a/e2e-tests/src/lib.rs b/e2e-tests/src/lib.rs index 305204ad1d..f4341b200b 100644 --- a/e2e-tests/src/lib.rs +++ b/e2e-tests/src/lib.rs @@ -1,3 +1,5 @@ +#![feature(pattern)] + #[cfg(test)] mod accounts; #[cfg(test)] diff --git a/e2e-tests/src/test/button_game/contracts.rs b/e2e-tests/src/test/button_game/contracts.rs new file mode 100644 index 0000000000..358b5ff92d --- /dev/null +++ b/e2e-tests/src/test/button_game/contracts.rs @@ -0,0 +1,402 @@ +use std::{fmt::Debug, str::FromStr}; + +use aleph_client::{ + contract::ContractInstance, AccountId, Connection, ConnectionApi, SignedConnection, TxInfo, +}; +use anyhow::{Context, Result}; +use primitives::Balance; + +use crate::config::Config; + +/// A wrapper around the simple dex contract. +/// +/// The methods on this type match contract methods. +#[derive(Debug)] +pub(super) struct SimpleDexInstance { + contract: ContractInstance, +} + +impl<'a> From<&'a SimpleDexInstance> for &'a ContractInstance { + fn from(dex: &'a SimpleDexInstance) -> Self { + &dex.contract + } +} + +impl<'a> From<&'a SimpleDexInstance> for AccountId { + fn from(dex: &'a SimpleDexInstance) -> Self { + dex.contract.address().clone() + } +} + +impl SimpleDexInstance { + pub fn new(config: &Config) -> Result { + let dex_address = config + .test_case_params + .simple_dex + .clone() + .context("Simple dex address not set.")?; + let dex_address = AccountId::from_str(&dex_address) + .ok() + .context("Invalid dex address.")?; + let metadata_path = config + .test_case_params + .simple_dex_metadata + .clone() + .context("Simple dex metadata not set")?; + + Ok(Self { + contract: ContractInstance::new(dex_address, &metadata_path)?, + }) + } + + pub async fn add_swap_pair( + &self, + conn: &SignedConnection, + from: AccountId, + to: AccountId, + ) -> Result { + self.contract + .contract_exec(conn, "add_swap_pair", &[from.to_string(), to.to_string()]) + .await + } + + pub async fn remove_swap_pair( + &self, + conn: &SignedConnection, + from: AccountId, + to: AccountId, + ) -> Result { + self.contract + .contract_exec( + conn, + "remove_swap_pair", + &[&from.to_string(), &to.to_string()], + ) + .await + } + + pub async fn deposit( + &self, + conn: &SignedConnection, + amounts: &[(&PSP22TokenInstance, Balance)], + ) -> Result { + let deposits = amounts + .iter() + .map(|(token, amount)| { + let address: AccountId = (*token).try_into()?; + Ok(format!("({:}, {:})", address, amount)) + }) + .collect::>>()?; + + self.contract + .contract_exec(conn, "deposit", &[format!("[{:}]", deposits.join(","))]) + .await + } + + pub async fn out_given_in( + &self, + conn: &C, + token_in: &PSP22TokenInstance, + token_out: &PSP22TokenInstance, + amount_token_in: Balance, + ) -> Result { + let token_in: AccountId = token_in.into(); + let token_out: AccountId = token_out.into(); + + self.contract + .contract_read( + conn, + "out_given_in", + &[ + token_in.to_string(), + token_out.to_string(), + amount_token_in.to_string(), + ], + ) + .await? + } + + pub async fn swap( + &self, + conn: &SignedConnection, + token_in: &PSP22TokenInstance, + amount_token_in: Balance, + token_out: &PSP22TokenInstance, + min_amount_token_out: Balance, + ) -> Result { + let token_in: AccountId = token_in.into(); + let token_out: AccountId = token_out.into(); + + self.contract + .contract_exec( + conn, + "swap", + &[ + token_in.to_string(), + token_out.to_string(), + amount_token_in.to_string(), + min_amount_token_out.to_string(), + ], + ) + .await + } +} + +/// A wrapper around a button game contract. +/// +/// The methods on this type match contract methods. +#[derive(Debug)] +pub(super) struct ButtonInstance { + contract: ContractInstance, +} + +impl ButtonInstance { + pub fn new(config: &Config, button_address: &Option) -> Result { + let button_address = button_address + .clone() + .context("Button game address not set.")?; + let button_address = AccountId::from_str(&button_address) + .ok() + .context("Invalid button game address")?; + let metadata_path = config + .test_case_params + .button_game_metadata + .clone() + .context("Button game metadata path not set.")?; + Ok(Self { + contract: ContractInstance::new(button_address, &metadata_path)?, + }) + } + + pub async fn deadline(&self, conn: &C) -> Result { + self.contract.contract_read0(conn, "deadline").await + } + + pub async fn is_dead(&self, conn: &C) -> Result { + self.contract.contract_read0(conn, "is_dead").await + } + + pub async fn ticket_token(&self, conn: &C) -> Result { + self.contract.contract_read0(conn, "ticket_token").await + } + + pub async fn reward_token(&self, conn: &C) -> Result { + self.contract.contract_read0(conn, "reward_token").await + } + + pub async fn marketplace(&self, conn: &C) -> Result { + self.contract.contract_read0(conn, "marketplace").await + } + + pub async fn press(&self, conn: &SignedConnection) -> Result { + self.contract.contract_exec0(conn, "press").await + } + + pub async fn reset(&self, conn: &SignedConnection) -> Result { + self.contract.contract_exec0(conn, "reset").await + } +} + +impl<'a> From<&'a ButtonInstance> for &'a ContractInstance { + fn from(button: &'a ButtonInstance) -> Self { + &button.contract + } +} + +impl From<&ButtonInstance> for AccountId { + fn from(button: &ButtonInstance) -> Self { + button.contract.address().clone() + } +} + +/// A wrapper around a PSP22 contract. +/// +/// The methods on this type match contract methods. +#[derive(Debug)] +pub(super) struct PSP22TokenInstance { + contract: ContractInstance, +} + +impl PSP22TokenInstance { + pub fn new(address: AccountId, metadata_path: &Option) -> Result { + let metadata_path = metadata_path + .as_ref() + .context("PSP22Token metadata not set.")?; + Ok(Self { + contract: ContractInstance::new(address, metadata_path)?, + }) + } + + pub async fn transfer( + &self, + conn: &SignedConnection, + to: &AccountId, + amount: Balance, + ) -> Result { + self.contract + .contract_exec( + conn, + "PSP22::transfer", + &[to.to_string(), amount.to_string(), "0x00".to_string()], + ) + .await + } + + pub async fn mint( + &self, + conn: &SignedConnection, + to: &AccountId, + amount: Balance, + ) -> Result { + self.contract + .contract_exec( + conn, + "PSP22Mintable::mint", + &[to.to_string(), amount.to_string()], + ) + .await + } + + pub async fn approve( + &self, + conn: &SignedConnection, + spender: &AccountId, + value: Balance, + ) -> Result { + self.contract + .contract_exec( + conn, + "PSP22::approve", + &[spender.to_string(), value.to_string()], + ) + .await + } + + pub async fn balance_of(&self, conn: &Connection, account: &AccountId) -> Result { + self.contract + .contract_read(conn, "PSP22::balance_of", &[account.to_string()]) + .await + } +} + +impl<'a> From<&'a PSP22TokenInstance> for &'a ContractInstance { + fn from(token: &'a PSP22TokenInstance) -> Self { + &token.contract + } +} + +impl From<&PSP22TokenInstance> for AccountId { + fn from(token: &PSP22TokenInstance) -> AccountId { + token.contract.address().clone() + } +} + +/// A wrapper around a marketplace contract instance. +/// +/// The methods on this type match contract methods. +#[derive(Debug)] +pub(super) struct MarketplaceInstance { + contract: ContractInstance, +} + +impl MarketplaceInstance { + pub fn new(address: AccountId, metadata_path: &Option) -> Result { + Ok(Self { + contract: ContractInstance::new( + address, + metadata_path + .as_ref() + .context("Marketplace metadata not set.")?, + )?, + }) + } + + pub async fn reset(&self, conn: &SignedConnection) -> Result { + self.contract.contract_exec0(conn, "reset").await + } + + pub async fn buy(&self, conn: &SignedConnection, max_price: Option) -> Result { + let max_price = max_price.map_or_else(|| "None".to_string(), |x| format!("Some({})", x)); + + self.contract + .contract_exec(conn, "buy", &[max_price.as_str()]) + .await + } + + pub async fn price(&self, conn: &C) -> Result { + self.contract.contract_read0(conn, "price").await + } +} + +impl<'a> From<&'a MarketplaceInstance> for &'a ContractInstance { + fn from(marketplace: &'a MarketplaceInstance) -> Self { + &marketplace.contract + } +} + +impl From<&MarketplaceInstance> for AccountId { + fn from(marketplace: &MarketplaceInstance) -> AccountId { + marketplace.contract.address().clone() + } +} + +#[derive(Debug)] +pub struct WAzeroInstance { + contract: ContractInstance, +} + +impl WAzeroInstance { + pub fn new(config: &Config) -> Result { + let wazero_address = config + .test_case_params + .wrapped_azero + .clone() + .context("Wrapped AZERO address not set.")?; + let wazero_address = AccountId::from_str(&wazero_address) + .ok() + .context("Invalid address.")?; + let metadata_path = config + .test_case_params + .wrapped_azero_metadata + .clone() + .context("Wrapped AZERO metadata path not set.")?; + + Ok(Self { + contract: ContractInstance::new(wazero_address, &metadata_path)?, + }) + } + + pub async fn wrap(&self, conn: &SignedConnection, value: Balance) -> Result { + self.contract + .contract_exec_value0(conn, "wrap", value) + .await + } + + pub async fn unwrap(&self, conn: &SignedConnection, amount: Balance) -> Result { + self.contract + .contract_exec(conn, "unwrap", &[amount.to_string()]) + .await + } + + pub async fn balance_of( + &self, + conn: &C, + account: &AccountId, + ) -> Result { + self.contract + .contract_read(conn, "PSP22::balance_of", &[account.to_string()]) + .await + } +} + +impl<'a> From<&'a WAzeroInstance> for &'a ContractInstance { + fn from(wazero: &'a WAzeroInstance) -> Self { + &wazero.contract + } +} + +impl<'a> From<&'a WAzeroInstance> for AccountId { + fn from(wazero: &'a WAzeroInstance) -> Self { + wazero.contract.address().clone() + } +} diff --git a/e2e-tests/src/test/button_game/helpers.rs b/e2e-tests/src/test/button_game/helpers.rs new file mode 100644 index 0000000000..99d62a84c9 --- /dev/null +++ b/e2e-tests/src/test/button_game/helpers.rs @@ -0,0 +1,421 @@ +use std::{ + fmt::Debug, + sync::Arc, + time::{Duration, Instant}, +}; + +use aleph_client::{ + contract::event::{listen_contract_events, ContractEvent}, + pallets::balances::BalanceUserApi, + Connection, ConnectionApi, KeyPair, SignedConnection, TxStatus, +}; +use anyhow::{bail, Result}; +use futures::{ + channel::mpsc::{unbounded, UnboundedReceiver}, + StreamExt, +}; +use itertools::Itertools; +use log::{info, warn}; +use primitives::Balance; +use rand::Rng; +use tokio::time::timeout; + +use super::contracts::{ + ButtonInstance, MarketplaceInstance, PSP22TokenInstance, SimpleDexInstance, WAzeroInstance, +}; +use crate::config::Config; + +/// Creates a copy of the `connection` signed by `signer` +pub fn sign(conn: &Connection, signer: &KeyPair) -> SignedConnection { + let signer = KeyPair::new(signer.signer().clone()); + SignedConnection::from_connection(conn.clone(), signer) +} + +/// Returns a ticket token instance for the given button instance +pub(super) async fn ticket_token( + conn: &C, + button: &ButtonInstance, + config: &Config, +) -> Result { + PSP22TokenInstance::new( + button.ticket_token(conn).await?, + &config.test_case_params.ticket_token_metadata, + ) +} + +/// Returns a reward token instance for the given button instance +pub(super) async fn reward_token( + conn: &C, + button: &ButtonInstance, + config: &Config, +) -> Result { + PSP22TokenInstance::new( + button.reward_token(conn).await?, + &config.test_case_params.reward_token_metadata, + ) +} + +/// Returns a marketplace instance for the given button instance +pub(super) async fn marketplace( + conn: &C, + button: &ButtonInstance, + config: &Config, +) -> Result { + MarketplaceInstance::new( + button.marketplace(conn).await?, + &config.test_case_params.marketplace_metadata, + ) +} + +/// Derives a test account based on a randomized string +pub fn random_account() -> KeyPair { + aleph_client::keypair_from_string(&format!( + "//TestAccount/{}", + rand::thread_rng().gen::() + )) +} + +/// Transfer `amount` from `from` to `to` +pub async fn transfer( + conn: &Connection, + from: &KeyPair, + to: &KeyPair, + amount: Balance, +) -> Result<()> { + let from = KeyPair::new(from.signer().clone()); + SignedConnection::from_connection(conn.clone(), from) + .transfer(to.account_id().clone(), amount, TxStatus::Finalized) + .await + .map(|_| ()) +} + +/// Returns a number representing the given amount of alephs (adding decimals) +pub fn alephs(basic_unit_amount: Balance) -> Balance { + basic_unit_amount * 1_000_000_000_000 +} + +/// Returns the given number multiplied by 10^6. +pub fn mega(x: Balance) -> Balance { + x * 1_000_000 +} + +pub(super) struct ButtonTestContext { + pub button: Arc, + pub ticket_token: Arc, + pub reward_token: Arc, + pub marketplace: Arc, + pub conn: Connection, + /// A [BufferedReceiver] preconfigured to listen for events of `button`, `ticket_token`, `reward_token`, and + /// `marketplace`. + pub events: BufferedReceiver>, + /// The authority owning the initial supply of tickets and with the power to mint game tokens. + pub authority: KeyPair, + /// A random account with some money for transaction fees. + pub player: KeyPair, +} + +pub(super) struct DexTestContext { + pub conn: Connection, + /// An authority with the power to mint tokens and manage the dex. + pub authority: KeyPair, + /// A random account with some money for fees. + pub account: KeyPair, + pub dex: Arc, + pub token1: Arc, + pub token2: Arc, + pub token3: Arc, + /// A [BufferedReceiver] preconfigured to listen for events of `dex`, `token1`, `token2`, and `token3`. + pub events: BufferedReceiver>, +} + +pub(super) struct WAzeroTestContext { + pub conn: Connection, + /// A random account with some money for fees. + pub account: KeyPair, + pub wazero: Arc, + /// A [BufferedReceiver] preconfigured to listen for events of `wazero`. + pub events: BufferedReceiver>, +} + +pub(super) async fn setup_wrapped_azero_test(config: &Config) -> Result { + let (conn, _authority, account) = basic_test_context(config).await?; + let wazero = Arc::new(WAzeroInstance::new(config)?); + + let contract = wazero.clone(); + let (events_tx, events_rx) = unbounded(); + let listen_conn = conn.clone(); + + tokio::spawn(async move { + let contract_metadata = vec![contract.as_ref().into()]; + + listen_contract_events(&listen_conn, &contract_metadata, events_tx) + .await + .unwrap(); + }); + + let events = BufferedReceiver::new(events_rx, Duration::from_secs(10)); + + Ok(WAzeroTestContext { + conn, + account, + wazero, + events, + }) +} + +pub(super) async fn setup_dex_test(config: &Config) -> Result { + let (conn, authority, account) = basic_test_context(config).await?; + + let dex = Arc::new(SimpleDexInstance::new(config)?); + let token1 = + reward_token_for_button(config, &conn, &config.test_case_params.early_bird_special).await?; + let token2 = + reward_token_for_button(config, &conn, &config.test_case_params.the_pressiah_cometh) + .await?; + let token3 = + reward_token_for_button(config, &conn, &config.test_case_params.back_to_the_future).await?; + + let c1 = dex.clone(); + let c2 = token1.clone(); + let c3 = token2.clone(); + let c4 = token3.clone(); + + let (events_tx, events_rx) = unbounded(); + let listen_conn = conn.clone(); + + tokio::spawn(async move { + let contract_metadata = vec![ + c1.as_ref().into(), + c2.as_ref().into(), + c3.as_ref().into(), + c4.as_ref().into(), + ]; + + listen_contract_events(&listen_conn, &contract_metadata, events_tx) + .await + .unwrap(); + }); + + let events = BufferedReceiver::new(events_rx, Duration::from_secs(10)); + + Ok(DexTestContext { + conn, + authority, + account, + dex, + token1, + token2, + token3, + events, + }) +} + +async fn reward_token_for_button( + config: &Config, + conn: &Connection, + button_contract_address: &Option, +) -> Result> { + let button = ButtonInstance::new(config, button_contract_address)?; + Ok(Arc::new(reward_token(conn, &button, config).await?)) +} + +/// Sets up a number of objects commonly used in button game tests. +pub(super) async fn setup_button_test( + config: &Config, + button_contract_address: &Option, +) -> Result { + let (conn, authority, player) = basic_test_context(config).await?; + + let button = Arc::new(ButtonInstance::new(config, button_contract_address)?); + let ticket_token = Arc::new(ticket_token(&conn, &button, config).await?); + let reward_token = Arc::new(reward_token(&conn, &button, config).await?); + let marketplace = Arc::new(marketplace(&conn, &button, config).await?); + + let c1 = button.clone(); + let c2 = ticket_token.clone(); + let c3 = reward_token.clone(); + let c4 = marketplace.clone(); + + let (events_tx, events_rx) = unbounded(); + let listen_conn = conn.clone(); + + tokio::spawn(async move { + let contract_metadata = vec![ + c1.as_ref().into(), + c2.as_ref().into(), + c3.as_ref().into(), + c4.as_ref().into(), + ]; + + listen_contract_events(&listen_conn, &contract_metadata, events_tx) + .await + .unwrap(); + }); + + let events = BufferedReceiver::new(events_rx, Duration::from_secs(10)); + + Ok(ButtonTestContext { + button, + ticket_token, + reward_token, + marketplace, + conn, + events, + authority, + player, + }) +} + +/// Prepares a `(conn, authority, account)` triple with some money in `account` for fees. +async fn basic_test_context(config: &Config) -> Result<(Connection, KeyPair, KeyPair)> { + let conn = Connection::new(&config.node).await; + let authority = aleph_client::keypair_from_string(&config.sudo_seed); + let account = random_account(); + + transfer(&conn, &authority, &account, alephs(100)).await?; + + Ok((conn, authority, account)) +} + +/// A receiver where it's possible to wait for messages out of order. +pub struct BufferedReceiver { + buffer: Vec, + receiver: UnboundedReceiver, + default_timeout: Duration, +} + +impl BufferedReceiver { + pub fn new(receiver: UnboundedReceiver, default_timeout: Duration) -> Self { + Self { + buffer: Vec::new(), + receiver, + default_timeout, + } + } + + /// Receive a message satisfying `filter`. + /// + /// If such a message was received earlier and is waiting in the buffer, returns the message immediately and removes + /// it from the buffer. Otherwise, listens for messages for `default_timeout`, storing them in the buffer. If a + /// matching message is found during that time, it is returned. If not, `Err(RecvTimeoutError)` is returned. + pub async fn recv_timeout bool>(&mut self, filter: F) -> Result + where + T: Debug, + { + match self.buffer.iter().find_position(|m| filter(m)) { + Some((i, _)) => Ok(self.buffer.remove(i)), + None => { + let mut remaining_timeout = self.default_timeout; + + while remaining_timeout > Duration::from_millis(0) { + let start = Instant::now(); + match timeout(remaining_timeout, self.receiver.next()).await? { + Some(msg) => { + if filter(&msg) { + return Ok(msg); + } else { + info!("Buffering {:?}", msg); + self.buffer.push(msg); + remaining_timeout -= Instant::now().duration_since(start); + } + } + None => bail!("Receiver closed while waiting for message"), + } + } + + bail!("Timeout while waiting for a message") + } + } + } +} + +/// Wait until `button` is dead. +/// +/// Returns `Err(_)` if the button doesn't die within 30 seconds. +pub(super) async fn wait_for_death( + conn: &C, + button: &ButtonInstance, +) -> Result<()> { + info!("Waiting for button to die"); + let mut iters = 0u8; + let mut is_dead = false; + + while iters <= 10 { + match timeout(Duration::from_secs(2), button.is_dead(conn)).await? { + Err(e) => println!("Error while querying button.is_dead: {:?}", e), + Ok(status) => is_dead = status, + } + + if !is_dead { + let _ = tokio::time::sleep(Duration::from_secs(3)).await; + iters += 1; + } + + if is_dead { + break; + } + } + + if !is_dead { + bail!("Button didn't die in time") + } + + info!("Button died"); + Ok(()) +} + +/// Asserts that a message with `id` is received (within `events.default_timeout`) and returns it. +pub async fn assert_recv_id( + events: &mut BufferedReceiver>, + id: &str, +) -> ContractEvent { + assert_recv( + events, + |event| event.name == Some(id.to_string()), + &format!("Expected {:?} contract event", id), + ) + .await +} + +/// Asserts that a message matching `filter` is received (within `events.default_timeout`) and returns it. +pub async fn assert_recv bool>( + events: &mut BufferedReceiver>, + filter: F, + context: &str, +) -> T { + let event = recv_timeout_with_log(events, filter).await; + + assert!(event.is_ok(), "{}", context); + + event.unwrap() +} + +/// Asserts that a message with `id` is not received (within `events.default_timeout`). +pub async fn refute_recv_id(events: &mut BufferedReceiver>, id: &str) { + if let Ok(event) = + recv_timeout_with_log(events, |event| event.name == Some(id.to_string())).await + { + panic!("Received unexpected event {:?}", event); + } +} + +async fn recv_timeout_with_log bool>( + events: &mut BufferedReceiver>, + filter: F, +) -> Result { + match events + .recv_timeout(|event_or_error| { + if event_or_error.is_ok() { + info!("Received contract event {:?}", event_or_error); + } else { + warn!("Contract event error {:?}", event_or_error); + } + + event_or_error.as_ref().map(&filter).unwrap_or(false) + }) + .await + { + Ok(event) => Ok(event.unwrap()), + Err(err) => bail!(err), + } +} diff --git a/e2e-tests/src/test/button_game/mod.rs b/e2e-tests/src/test/button_game/mod.rs new file mode 100644 index 0000000000..68ff46fd38 --- /dev/null +++ b/e2e-tests/src/test/button_game/mod.rs @@ -0,0 +1,487 @@ +use std::time::Duration; + +use aleph_client::{contract_transcode::Value, pallets::system::SystemApi}; +use anyhow::Result; +use assert2::{assert, let_assert}; +use helpers::sign; +use log::info; +use tokio::time::sleep; + +use crate::{ + config::{setup_test, Config}, + test::button_game::helpers::{ + alephs, assert_recv, assert_recv_id, mega, refute_recv_id, setup_button_test, + setup_dex_test, setup_wrapped_azero_test, wait_for_death, ButtonTestContext, + DexTestContext, WAzeroTestContext, + }, +}; + +mod contracts; +mod helpers; + +/// Test wrapped azero +/// +/// The scenario: +/// +/// 1. Wraps some azero and checks that the PSP22 balance increased accordingly. +/// 2. Unwraps half of the amount, checks that some wrapped funds remained while the rest has been returned to azero, +/// minus fees. +#[tokio::test] +pub async fn wrapped_azero() -> Result<()> { + let config = setup_test(); + let WAzeroTestContext { + conn, + account, + wazero, + mut events, + .. + } = setup_wrapped_azero_test(config).await?; + let account_conn = &sign(&conn, &account); + let account_id = account.account_id(); + + wazero.wrap(account_conn, alephs(2)).await?; + + let event = assert_recv_id(&mut events, "Wrapped").await; + let_assert!(Some(Value::Literal(acc_id)) = event.data.get("caller")); + assert!(*acc_id == account_id.to_string()); + assert!(event.data.get("amount") == Some(&Value::UInt(alephs(2)))); + assert!( + wazero + .balance_of(account_conn, account.account_id()) + .await? + == alephs(2) + ); + + let balance_before = conn.get_free_balance(account_id.clone(), None).await; + wazero.unwrap(account_conn, alephs(1)).await?; + + let event = assert_recv_id(&mut events, "UnWrapped").await; + let balance_after = conn.get_free_balance(account_id.clone(), None).await; + let max_fee = alephs(1) / 100; + assert!(balance_after - balance_before > alephs(1) - max_fee); + let_assert!(Some(Value::Literal(acc_id)) = event.data.get("caller")); + assert!(*acc_id == account_id.to_string()); + assert!(event.data.get("amount") == Some(&Value::UInt(alephs(1)))); + assert!( + wazero + .balance_of(account_conn, account.account_id()) + .await? + == alephs(1) + ); + + Ok(()) +} + +/// Test trading on simple_dex. +/// +/// The scenario does the following (given 3 tokens A, B, C): +/// +/// 1. Enables A <-> B, and A -> C swaps. +/// 2. Adds (A, 2000M), (B, 5000M), (C, 10000M) of liquidity. +/// 3. Makes a swap A -> B and then B -> A for the amount of B received in the first swap. +/// 4. Makes a swap A -> B expecting negative slippage (this should fail). +/// 5. Checks that the price after the two swaps is the same as before (with a dust allowance of 1 for rounding). +/// 6. Checks that it's possible to make an A -> C swap, but impossible to make a C -> A swap. +#[tokio::test] +pub async fn simple_dex() -> Result<()> { + let config = setup_test(); + let DexTestContext { + conn, + authority, + account, + dex, + token1, + token2, + token3, + mut events, + } = setup_dex_test(config).await?; + + let authority_conn = &sign(&conn, &authority); + let account_conn = &sign(&conn, &account); + let token1 = token1.as_ref(); + let token2 = token2.as_ref(); + let token3 = token3.as_ref(); + let dex = dex.as_ref(); + + dex.add_swap_pair(authority_conn, token1.into(), token2.into()) + .await?; + assert_recv_id(&mut events, "SwapPairAdded").await; + + dex.add_swap_pair(authority_conn, token2.into(), token1.into()) + .await?; + assert_recv_id(&mut events, "SwapPairAdded").await; + + dex.add_swap_pair(authority_conn, token1.into(), token3.into()) + .await?; + assert_recv_id(&mut events, "SwapPairAdded").await; + + token1 + .mint(authority_conn, authority.account_id(), mega(3000)) + .await?; + assert_recv_id(&mut events, "Transfer").await; + token2 + .mint(authority_conn, authority.account_id(), mega(5000)) + .await?; + assert_recv_id(&mut events, "Transfer").await; + token3 + .mint(authority_conn, authority.account_id(), mega(10000)) + .await?; + assert_recv_id(&mut events, "Transfer").await; + + token1 + .approve(authority_conn, &dex.into(), mega(3000)) + .await?; + assert_recv_id(&mut events, "Approval").await; + token2 + .approve(authority_conn, &dex.into(), mega(5000)) + .await?; + assert_recv_id(&mut events, "Approval").await; + token3 + .approve(authority_conn, &dex.into(), mega(10000)) + .await?; + assert_recv_id(&mut events, "Approval").await; + + dex.deposit( + authority_conn, + &[ + (token1, mega(3000)), + (token2, mega(5000)), + (token3, mega(10000)), + ], + ) + .await?; + assert_recv_id(&mut events, "Deposited").await; + + let more_than_liquidity = mega(1_000_000); + let res = dex + .swap(account_conn, token1, 100, token2, more_than_liquidity) + .await; + assert!(res.is_err()); + refute_recv_id(&mut events, "Swapped").await; + + let initial_amount = mega(100); + token1 + .mint(authority_conn, account.account_id(), initial_amount) + .await?; + let expected_output = dex + .out_given_in(account_conn, token1, token2, initial_amount) + .await?; + assert!(expected_output > 0); + + let at_most_10_percent_slippage = expected_output * 9 / 10; + token1 + .approve(account_conn, &dex.into(), initial_amount) + .await?; + dex.swap( + account_conn, + token1, + initial_amount, + token2, + at_most_10_percent_slippage, + ) + .await?; + assert_recv_id(&mut events, "Swapped").await; + assert!(token2.balance_of(&conn, account.account_id()).await? == expected_output); + + token2 + .approve(account_conn, &dex.into(), expected_output) + .await?; + dex.swap(account_conn, token2, expected_output, token1, mega(90)) + .await?; + assert_recv_id(&mut events, "Swapped").await; + + let balance_after = token1.balance_of(&conn, account.account_id()).await?; + assert!(initial_amount.abs_diff(balance_after) <= 1); + assert!( + dex.out_given_in(account_conn, token1, token2, initial_amount) + .await? + .abs_diff(expected_output) + <= 1 + ); + + token1 + .approve(account_conn, &dex.into(), balance_after) + .await?; + let unreasonable_slippage = expected_output * 11 / 10; + assert!( + dex.swap( + account_conn, + token1, + balance_after, + token2, + unreasonable_slippage, + ) + .await + .is_err(), + "expected swap to fail" + ); + refute_recv_id(&mut events, "Swapped").await; + + dex.swap(account_conn, token1, balance_after, token3, mega(90)) + .await?; + assert_recv_id(&mut events, "Swapped").await; + + // can't swap a pair not on the whitelist + dex.remove_swap_pair(authority_conn, token3.into(), token1.into()) + .await?; + assert_recv_id(&mut events, "SwapPairRemoved").await; + + let balance_token3 = token3.balance_of(&conn, account.account_id()).await?; + token3 + .approve(account_conn, &dex.into(), balance_token3) + .await?; + assert!( + dex.swap(account_conn, token3, balance_token3, token1, mega(90)) + .await + .is_err(), + "can't swap pair that is not whitelisted" + ); + refute_recv_id(&mut events, "Swapped").await; + + Ok(()) +} + +/// Tests trading on the marketplace. +/// +/// The scenario: +/// +/// 1. Buys a ticket without setting the max price (this should succeed). +/// 2. Tries to buy a ticket with setting the max price too low (this should fail). +/// 3. Tries to buy a ticket with setting the max price appropriately (this should succeed). +#[tokio::test] +pub async fn marketplace() -> Result<()> { + let config = setup_test(); + let ButtonTestContext { + conn, + authority, + player, + marketplace, + ticket_token, + reward_token, + mut events, + .. + } = setup_button_test(config, &config.test_case_params.early_bird_special).await?; + let player = &player; + + marketplace.reset(&sign(&conn, &authority)).await?; + assert_recv_id(&mut events, "Reset").await; + ticket_token + .transfer(&sign(&conn, &authority), &marketplace.as_ref().into(), 2) + .await?; + + let early_price = marketplace.price(&conn).await?; + sleep(Duration::from_secs(2)).await; + let later_price = marketplace.price(&conn).await?; + assert!(later_price < early_price); + + let player_balance = 100 * later_price; + reward_token + .mint( + &sign(&conn, &authority), + player.account_id(), + player_balance, + ) + .await?; + reward_token + .approve( + &sign(&conn, player), + &marketplace.as_ref().into(), + later_price, + ) + .await?; + marketplace.buy(&sign(&conn, player), None).await?; + + let event = assert_recv_id(&mut events, "Bought").await; + assert!(event.contract == marketplace.as_ref().into()); + let_assert!(Some(&Value::UInt(price)) = event.data.get("price")); + assert!(price <= later_price); + let_assert!(Some(Value::Literal(acc_id)) = event.data.get("account_id")); + assert!(acc_id == &player.account_id().to_string()); + assert!(ticket_token.balance_of(&conn, player.account_id()).await? == 1); + assert!(reward_token.balance_of(&conn, player.account_id()).await? <= player_balance - price); + assert!(marketplace.price(&conn).await? > price); + + let latest_price = marketplace.price(&conn).await?; + + info!("Setting max price too low"); + assert!( + marketplace + .buy(&sign(&conn, player), Some(latest_price / 2)) + .await + .is_err(), + "set price too low, should fail" + ); + refute_recv_id(&mut events, "Bought").await; + assert!(ticket_token.balance_of(&conn, player.account_id()).await? == 1); + + info!("Setting max price high enough"); + marketplace + .buy(&sign(&conn, player), Some(latest_price * 2)) + .await?; + assert_recv_id(&mut events, "Bought").await; + assert!(ticket_token.balance_of(&conn, player.account_id()).await? == 2); + + Ok(()) +} + +/// Tests resetting the button game. +#[tokio::test] +pub async fn button_game_reset() -> Result<()> { + let config = setup_test(); + let ButtonTestContext { + conn, + button, + mut events, + authority, + marketplace, + ticket_token, + .. + } = setup_button_test(config, &config.test_case_params.early_bird_special).await?; + + let deadline_old = button.deadline(&conn).await?; + let marketplace_initial = ticket_token + .balance_of(&conn, &marketplace.as_ref().into()) + .await?; + ticket_token + .transfer(&sign(&conn, &authority), &button.as_ref().into(), 1) + .await?; + + wait_for_death(&conn, &button).await?; + button.reset(&sign(&conn, &authority)).await?; + + assert_recv_id(&mut events, "GameReset").await; + assert_recv_id(&mut events, "Reset").await; + + let deadline_new = button.deadline(&conn).await?; + assert!(deadline_new > deadline_old); + assert!( + ticket_token + .balance_of(&conn, &marketplace.as_ref().into()) + .await? + == marketplace_initial + 1 + ); + + Ok(()) +} + +#[tokio::test] +pub async fn early_bird_special() -> Result<()> { + let config = setup_test(); + button_game_play( + config, + &config.test_case_params.early_bird_special, + |early_presser_score, late_presser_score| { + assert!(early_presser_score > late_presser_score); + }, + ) + .await +} + +#[tokio::test] +pub async fn back_to_the_future() -> Result<()> { + let config = setup_test(); + button_game_play( + config, + &config.test_case_params.back_to_the_future, + |early_presser_score, late_presser_score| { + assert!(early_presser_score < late_presser_score); + }, + ) + .await +} + +#[tokio::test] +pub async fn the_pressiah_cometh() -> Result<()> { + let config = setup_test(); + button_game_play( + config, + &config.test_case_params.the_pressiah_cometh, + |early_presser_score, late_presser_score| { + assert!(early_presser_score == 1); + assert!(late_presser_score == 2); + }, + ) + .await +} + +/// Tests a basic scenario of playing the game. +/// +/// The scenario: +/// +/// 1. Resets the button. +/// 2. Gives 2 tickets to the player. +/// 3. Presses the button. +/// 4. Waits a bit and presses the button again. +/// 5. Waits until the button dies and checks the pressiah's score. +/// +/// Passes the scores received by an early presser and late presser to `score_check` so that different scoring rules +/// can be tested generically. +async fn button_game_play( + config: &Config, + button_contract_address: &Option, + score_check: F, +) -> Result<()> { + let ButtonTestContext { + conn, + button, + mut events, + authority, + ticket_token, + reward_token, + player, + .. + } = setup_button_test(config, button_contract_address).await?; + let player = &player; + + ticket_token + .transfer(&sign(&conn, &authority), player.account_id(), 2) + .await?; + wait_for_death(&conn, &button).await?; + button.reset(&sign(&conn, &authority)).await?; + let event = assert_recv_id(&mut events, "GameReset").await; + let_assert!(Some(&Value::UInt(reset_at)) = event.data.get("when")); + let old_button_balance = ticket_token + .balance_of(&conn, &button.as_ref().into()) + .await?; + + ticket_token + .approve(&sign(&conn, player), &button.as_ref().into(), 2) + .await?; + button.press(&sign(&conn, player)).await?; + + let event = assert_recv_id(&mut events, "ButtonPressed").await; + let_assert!(Some(&Value::UInt(early_presser_score)) = event.data.get("score")); + assert!(event.data.get("by") == Some(&Value::Literal(player.account_id().to_string()))); + assert!(reward_token.balance_of(&conn, player.account_id()).await? == early_presser_score); + assert!(early_presser_score > 0); + assert!(ticket_token.balance_of(&conn, player.account_id()).await? == 1); + assert!( + ticket_token + .balance_of(&conn, &button.as_ref().into()) + .await? + == old_button_balance + 1 + ); + let_assert!(Some(&Value::UInt(pressed_at)) = event.data.get("when")); + let time_to_sleep = pressed_at - reset_at + 3; + + info!("Waiting {} seconds before pressing again", time_to_sleep); + sleep(Duration::from_secs(time_to_sleep as u64)).await; + + button.press(&sign(&conn, player)).await?; + let event = assert_recv_id(&mut events, "ButtonPressed").await; + let_assert!(Some(&Value::UInt(late_presser_score)) = event.data.get("score")); + score_check(early_presser_score, late_presser_score); + let total_score = early_presser_score + late_presser_score; + assert!(reward_token.balance_of(&conn, player.account_id()).await? == total_score); + + wait_for_death(&conn, &button).await?; + button.reset(&sign(&conn, &authority)).await?; + assert_recv_id(&mut events, "Reset").await; + + let pressiah_score = total_score / 4; + assert!( + reward_token.balance_of(&conn, player.account_id()).await? == total_score + pressiah_score + ); + + Ok(()) +} diff --git a/e2e-tests/src/test/mod.rs b/e2e-tests/src/test/mod.rs index 6604de44df..a181eaf31b 100644 --- a/e2e-tests/src/test/mod.rs +++ b/e2e-tests/src/test/mod.rs @@ -1,6 +1,10 @@ pub use ban::{ ban_automatic, ban_manual, ban_threshold, clearing_session_count, permissionless_ban, }; +pub use button_game::{ + back_to_the_future, button_game_reset, early_bird_special, marketplace, simple_dex, + the_pressiah_cometh, wrapped_azero, +}; pub use electing_validators::authorities_are_staking; pub use era_payout::era_payouts_calculated_correctly; pub use era_validators::era_validators; @@ -21,6 +25,7 @@ pub use validators_rotate::validators_rotate; mod adder; mod ban; +mod button_game; mod electing_validators; mod era_payout; mod era_validators; diff --git a/scripts/run_checks_on_excluded_packages.sh b/scripts/run_checks_on_excluded_packages.sh index 6b8414b30c..1524b2c81e 100755 --- a/scripts/run_checks_on_excluded_packages.sh +++ b/scripts/run_checks_on_excluded_packages.sh @@ -10,6 +10,14 @@ packages=( "fork-off" "benches/payout-stakers" "bin/cliain" + "contracts/access_control" + "contracts/button" + "contracts/game_token" + "contracts/marketplace" + "contracts/simple_dex" + "contracts/ticket_token" + "contracts/wrapped_azero" + "contracts/adder, " ) for p in ${packages[@]}