From 915b06b6f111c39785d5203fa0b534ac63813e25 Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 13 Dec 2022 09:07:47 +0100 Subject: [PATCH 01/11] add query --- contracts/simple_dex/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contracts/simple_dex/lib.rs b/contracts/simple_dex/lib.rs index d73051912b..5f0cf19c6c 100644 --- a/contracts/simple_dex/lib.rs +++ b/contracts/simple_dex/lib.rs @@ -322,6 +322,11 @@ mod simple_dex { Ok(()) } + #[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 From 6897dd2f6c83aea7337331084ddcdb317a21ad63 Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 13 Dec 2022 09:34:17 +0100 Subject: [PATCH 02/11] whitelist tokens --- contracts/scripts/deploy.sh | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/contracts/scripts/deploy.sh b/contracts/scripts/deploy.sh index 2088495fb6..6c65959d0a 100755 --- a/contracts/scripts/deploy.sh +++ b/contracts/scripts/deploy.sh @@ -104,7 +104,6 @@ function deploy_button_game { 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) local contract_address=$(echo "$contract_address" | grep Contract | tail -1 | cut -c 14-) - echo "$game_type contract instance address: $contract_address" # --- GRANT PRIVILEGES ON THE CONTRACT @@ -181,6 +180,16 @@ function deploy_simple_dex { eval "$__resultvar='$contract_address'" } +# TODO +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 @@ -297,15 +306,29 @@ 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 -# --- DEPLOY WRAPPED AZERO CONTRACT +# TODO : whitelist token pairs +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 -echo "Wrapped Azero" -deploy_wrapped_azero 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" From 80c9b7dc8f954a099caf1ec1732bd034c59d1064 Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 13 Dec 2022 12:34:09 +0100 Subject: [PATCH 03/11] use benjamin feature env image --- .github/scripts/run_smartnet.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/scripts/run_smartnet.sh b/.github/scripts/run_smartnet.sh index d2b1b23a71..3710d7c12a 100755 --- a/.github/scripts/run_smartnet.sh +++ b/.github/scripts/run_smartnet.sh @@ -2,7 +2,9 @@ set -e -export NODE_IMAGE=public.ecr.aws/p6e8q1z1/aleph-node:latest +export NODE_IMAGE=573243519133.dkr.ecr.us-east-1.amazonaws.com/feature-env-aleph-node:fe-benjamin_c643069 +# export NODE_IMAGE=public.ecr.aws/p6e8q1z1/aleph-node:latest + # key derived from "//0" export NODE_ID=5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH export ALICE=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY From be36c62933ff9d7f4cb152daefc736fecb5a4655 Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 13 Dec 2022 13:13:20 +0100 Subject: [PATCH 04/11] try private --- .../contracts-e2e-tests-and-deploy.yaml | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/contracts-e2e-tests-and-deploy.yaml b/.github/workflows/contracts-e2e-tests-and-deploy.yaml index 721ff0e994..298bf71e8d 100644 --- a/.github/workflows/contracts-e2e-tests-and-deploy.yaml +++ b/.github/workflows/contracts-e2e-tests-and-deploy.yaml @@ -81,11 +81,21 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} aws-region: eu-central-1 - - name: Login to Public Amazon ECR - id: login-public-ecr + # - name: Login to Public Amazon ECR + # id: login-public-ecr + # uses: docker/login-action@v1 + # with: + # registry: public.ecr.aws + # username: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }} + # password: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} + # env: + # AWS_REGION: us-east-1 + + - name: Login to Private Amazon ECR + id: login-private-ecr uses: docker/login-action@v1 with: - registry: public.ecr.aws + registry: 573243519133.dkr.ecr.us-east-1.amazonaws.com username: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }} password: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} env: @@ -249,15 +259,15 @@ jobs: 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 From 161c27fabfa19cb47fc9c33d6fb6ec45c23a5cb4 Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 13 Dec 2022 13:16:18 +0100 Subject: [PATCH 05/11] simplify workflow to test it --- .../contracts-e2e-tests-and-deploy.yaml | 81 ++++++++++--------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/.github/workflows/contracts-e2e-tests-and-deploy.yaml b/.github/workflows/contracts-e2e-tests-and-deploy.yaml index 298bf71e8d..61c45d7b51 100644 --- a/.github/workflows/contracts-e2e-tests-and-deploy.yaml +++ b/.github/workflows/contracts-e2e-tests-and-deploy.yaml @@ -26,53 +26,54 @@ jobs: env: RUST_BACKTRACE: full steps: - - name: Install binaryen - run: | - wget https://github.com/WebAssembly/binaryen/releases/download/version_101/binaryen-version_101-x86_64-linux.tar.gz - tar xvzf binaryen-version_101-x86_64-linux.tar.gz - cd binaryen-version_101 - sudo cp -r bin/* /bin - sudo cp -r include/* /usr/include - sudo cp -r lib64/* /lib64 - - - name: Display binaryen version - shell: bash - run: wasm-opt --version - - name: Checkout Source code - uses: actions/checkout@v3 + # - name: Install binaryen + # run: | + # wget https://github.com/WebAssembly/binaryen/releases/download/version_101/binaryen-version_101-x86_64-linux.tar.gz + # tar xvzf binaryen-version_101-x86_64-linux.tar.gz + # cd binaryen-version_101 + # sudo cp -r bin/* /bin + # sudo cp -r include/* /usr/include + # sudo cp -r lib64/* /lib64 - - name: Install Rust Toolchain - uses: actions-rs/toolchain@v1 + # - name: Display binaryen version + # shell: bash + # run: wasm-opt --version - - name: Install WASM target - run: rustup target add wasm32-unknown-unknown + # - name: Checkout Source code + # uses: actions/checkout@v3 - - name: Install rust-src - run: rustup component add rust-src + # - name: Install Rust Toolchain + # uses: actions-rs/toolchain@v1 - - name: Restore cache - uses: ./.github/actions/restore-cache - with: - target-key: e2e-contracts - cargo-key: e2e-contracts - cache-version: v3 - cargo-targets: | - e2e-tests/target/ - 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 WASM target + # run: rustup target add wasm32-unknown-unknown + + # - name: Install rust-src + # run: rustup component add rust-src + + # - name: Restore cache + # uses: ./.github/actions/restore-cache + # with: + # target-key: e2e-contracts + # cargo-key: e2e-contracts + # cache-version: v3 + # cargo-targets: | + # e2e-tests/target/ + # 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/ # TODO : this should NOT be built every time - - name: Install cargo-contract - run: | - cargo install cargo-dylint dylint-link --force - # revision merging Hans's PR changes [fix for node URL parsing ] - cargo install --git https://github.com/paritytech/cargo-contract.git --rev ${{ env.CARGOCONTRACT_REV }} --force + # - name: Install cargo-contract + # run: | + # cargo install cargo-dylint dylint-link --force + # # revision merging Hans's PR changes [fix for node URL parsing ] + # cargo install --git https://github.com/paritytech/cargo-contract.git --rev ${{ env.CARGOCONTRACT_REV }} --force - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 From 90801b3f8cb29a80c60cec8229fa6fe17ad48551 Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 13 Dec 2022 13:25:54 +0100 Subject: [PATCH 06/11] fuck --- .github/workflows/contracts-e2e-tests-and-deploy.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/contracts-e2e-tests-and-deploy.yaml b/.github/workflows/contracts-e2e-tests-and-deploy.yaml index 61c45d7b51..123cbee3ee 100644 --- a/.github/workflows/contracts-e2e-tests-and-deploy.yaml +++ b/.github/workflows/contracts-e2e-tests-and-deploy.yaml @@ -27,6 +27,9 @@ jobs: RUST_BACKTRACE: full steps: + - name: Checkout Source code + uses: actions/checkout@v3 + # - name: Install binaryen # run: | # wget https://github.com/WebAssembly/binaryen/releases/download/version_101/binaryen-version_101-x86_64-linux.tar.gz @@ -40,9 +43,6 @@ jobs: # shell: bash # run: wasm-opt --version - # - name: Checkout Source code - # uses: actions/checkout@v3 - # - name: Install Rust Toolchain # uses: actions-rs/toolchain@v1 From d4634d299344c1887cae2439edda4f112d8ab191 Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 13 Dec 2022 13:29:34 +0100 Subject: [PATCH 07/11] use exported image --- docker/smartnet-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/smartnet-compose.yml b/docker/smartnet-compose.yml index 4733ebb9c2..bee3b91850 100644 --- a/docker/smartnet-compose.yml +++ b/docker/smartnet-compose.yml @@ -2,7 +2,7 @@ version: '3' services: smartnode: - image: public.ecr.aws/p6e8q1z1/aleph-node:latest + image: $NODE_IMAGE container_name: smartnode environment: - ALLOW_PRIVATE_IPV4=true From 3c8c9abafc2fff39f68552367d376d8b364c89be Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 13 Dec 2022 13:45:03 +0100 Subject: [PATCH 08/11] uncommment --- .../contracts-e2e-tests-and-deploy.yaml | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/.github/workflows/contracts-e2e-tests-and-deploy.yaml b/.github/workflows/contracts-e2e-tests-and-deploy.yaml index 123cbee3ee..e925895310 100644 --- a/.github/workflows/contracts-e2e-tests-and-deploy.yaml +++ b/.github/workflows/contracts-e2e-tests-and-deploy.yaml @@ -30,50 +30,50 @@ jobs: - name: Checkout Source code uses: actions/checkout@v3 - # - name: Install binaryen - # run: | - # wget https://github.com/WebAssembly/binaryen/releases/download/version_101/binaryen-version_101-x86_64-linux.tar.gz - # tar xvzf binaryen-version_101-x86_64-linux.tar.gz - # cd binaryen-version_101 - # sudo cp -r bin/* /bin - # sudo cp -r include/* /usr/include - # sudo cp -r lib64/* /lib64 - - # - name: Display binaryen version - # shell: bash - # run: wasm-opt --version - - # - name: Install Rust Toolchain - # uses: actions-rs/toolchain@v1 - - # - name: Install WASM target - # run: rustup target add wasm32-unknown-unknown - - # - name: Install rust-src - # run: rustup component add rust-src - - # - name: Restore cache - # uses: ./.github/actions/restore-cache - # with: - # target-key: e2e-contracts - # cargo-key: e2e-contracts - # cache-version: v3 - # cargo-targets: | - # e2e-tests/target/ - # 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 binaryen + run: | + wget https://github.com/WebAssembly/binaryen/releases/download/version_101/binaryen-version_101-x86_64-linux.tar.gz + tar xvzf binaryen-version_101-x86_64-linux.tar.gz + cd binaryen-version_101 + sudo cp -r bin/* /bin + sudo cp -r include/* /usr/include + sudo cp -r lib64/* /lib64 + + - name: Display binaryen version + shell: bash + run: wasm-opt --version + + - name: Install Rust Toolchain + uses: actions-rs/toolchain@v1 + + - name: Install WASM target + run: rustup target add wasm32-unknown-unknown + + - name: Install rust-src + run: rustup component add rust-src + + - name: Restore cache + uses: ./.github/actions/restore-cache + with: + target-key: e2e-contracts + cargo-key: e2e-contracts + cache-version: v3 + cargo-targets: | + e2e-tests/target/ + 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/ # TODO : this should NOT be built every time - # - name: Install cargo-contract - # run: | - # cargo install cargo-dylint dylint-link --force - # # revision merging Hans's PR changes [fix for node URL parsing ] - # cargo install --git https://github.com/paritytech/cargo-contract.git --rev ${{ env.CARGOCONTRACT_REV }} --force + - name: Install cargo-contract + run: | + cargo install cargo-dylint dylint-link --force + # revision merging Hans's PR changes [fix for node URL parsing ] + cargo install --git https://github.com/paritytech/cargo-contract.git --rev ${{ env.CARGOCONTRACT_REV }} --force - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 From a4e689c8fe454d83fc4a185e5a5982da92335420 Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 13 Dec 2022 14:34:38 +0100 Subject: [PATCH 09/11] cleanup --- .github/scripts/run_smartnet.sh | 1 - .github/workflows/contracts-e2e-tests-and-deploy.yaml | 10 ---------- contracts/scripts/deploy.sh | 2 -- 3 files changed, 13 deletions(-) diff --git a/.github/scripts/run_smartnet.sh b/.github/scripts/run_smartnet.sh index 3710d7c12a..72223e9e3f 100755 --- a/.github/scripts/run_smartnet.sh +++ b/.github/scripts/run_smartnet.sh @@ -3,7 +3,6 @@ set -e export NODE_IMAGE=573243519133.dkr.ecr.us-east-1.amazonaws.com/feature-env-aleph-node:fe-benjamin_c643069 -# export NODE_IMAGE=public.ecr.aws/p6e8q1z1/aleph-node:latest # key derived from "//0" export NODE_ID=5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH diff --git a/.github/workflows/contracts-e2e-tests-and-deploy.yaml b/.github/workflows/contracts-e2e-tests-and-deploy.yaml index e925895310..f4a226b521 100644 --- a/.github/workflows/contracts-e2e-tests-and-deploy.yaml +++ b/.github/workflows/contracts-e2e-tests-and-deploy.yaml @@ -82,16 +82,6 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} aws-region: eu-central-1 - # - name: Login to Public Amazon ECR - # id: login-public-ecr - # uses: docker/login-action@v1 - # with: - # registry: public.ecr.aws - # username: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }} - # password: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} - # env: - # AWS_REGION: us-east-1 - - name: Login to Private Amazon ECR id: login-private-ecr uses: docker/login-action@v1 diff --git a/contracts/scripts/deploy.sh b/contracts/scripts/deploy.sh index 6c65959d0a..ecdd343570 100755 --- a/contracts/scripts/deploy.sh +++ b/contracts/scripts/deploy.sh @@ -180,7 +180,6 @@ function deploy_simple_dex { eval "$__resultvar='$contract_address'" } -# TODO function whitelist_swap_pair() { local from_address=$1 local to_address=$2 @@ -316,7 +315,6 @@ deploy_wrapped_azero WRAPPED_AZERO echo "Simple Dex" deploy_simple_dex SIMPLE_DEX -# TODO : whitelist token pairs 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 From 417cd6036f3fdeebe7f8026389e9ec23851eefd1 Mon Sep 17 00:00:00 2001 From: filip Date: Tue, 13 Dec 2022 15:19:43 +0100 Subject: [PATCH 10/11] remove form whitelist --- e2e-tests/src/test/button_game/contracts.rs | 13 +++++++++++++ e2e-tests/src/test/button_game/mod.rs | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/e2e-tests/src/test/button_game/contracts.rs b/e2e-tests/src/test/button_game/contracts.rs index 65868dc2b9..7d5b2c4949 100644 --- a/e2e-tests/src/test/button_game/contracts.rs +++ b/e2e-tests/src/test/button_game/contracts.rs @@ -55,6 +55,19 @@ impl SimpleDexInstance { .contract_exec(conn, "add_swap_pair", &[&from.to_string(), &to.to_string()]) } + pub 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()], + ) + } + pub fn deposit( &self, conn: &SignedConnection, diff --git a/e2e-tests/src/test/button_game/mod.rs b/e2e-tests/src/test/button_game/mod.rs index ac116ef382..edd2e88532 100644 --- a/e2e-tests/src/test/button_game/mod.rs +++ b/e2e-tests/src/test/button_game/mod.rs @@ -115,6 +115,7 @@ pub fn simple_dex(config: &Config) -> Result<()> { let more_than_liquidity = mega(1_000_000); dex.swap(account_conn, token1, 100, token2, more_than_liquidity)?; + refute_recv_id(&mut events, "Swapped"); let initial_amount = mega(100); @@ -159,6 +160,12 @@ pub fn simple_dex(config: &Config) -> Result<()> { dex.swap(account_conn, token1, balance_after, token3, mega(90))?; assert_recv_id(&mut events, "Swapped"); + + // can't swap a pair not on the whitelist + + dex.remove_swap_pair(authority_conn, token3.into(), token1.into())?; + assert_recv_id(&mut events, "SwapPairRemoved"); + let balance_token3 = token3.balance_of(&conn, &account.public().into())?; token3.approve(account_conn, &dex.into(), balance_token3)?; dex.swap(account_conn, token3, balance_token3, token1, mega(90))?; From eb3cd1c7c8bd34595a66df10d00cfe96e106e562 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 14 Dec 2022 10:12:44 +0100 Subject: [PATCH 11/11] docstring --- contracts/simple_dex/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/simple_dex/lib.rs b/contracts/simple_dex/lib.rs index 5f0cf19c6c..933c6a8208 100644 --- a/contracts/simple_dex/lib.rs +++ b/contracts/simple_dex/lib.rs @@ -322,6 +322,7 @@ mod simple_dex { 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))