From 40b5f999fda33acf7629dc888727678b9bc710b2 Mon Sep 17 00:00:00 2001 From: Franco Testagrossa Date: Fri, 3 May 2024 01:38:10 +0200 Subject: [PATCH] More formatting changes --- Makefile | 2 ++ make/test/deposit.sh | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index f8d1404..f5e73c2 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +SHELL := /bin/bash + # Load environment variables from .env file include .env diff --git a/make/test/deposit.sh b/make/test/deposit.sh index 325ec7b..ebaae17 100755 --- a/make/test/deposit.sh +++ b/make/test/deposit.sh @@ -2,6 +2,18 @@ set -e +balance_of() { + dfx canister call icrc1_index icrc1_balance_of "(record{owner = principal \"$1\"; })" +} + +approve_allowance() { + dfx canister call icrc1_ledger icrc2_approve "(record { amount = $1; spender = record{owner = principal \"$2\";} })" +} + +deposit() { + dfx canister call bounty deposit "()" +} + CALLER=$(dfx identity get-principal) BOUNTY="bd3sg-teaaa-aaaaa-qaaba-cai" @@ -9,17 +21,13 @@ BOUNTY="bd3sg-teaaa-aaaaa-qaaba-cai" echo "Calling deposit on bounty canister..." # check initial balances -echo "Caller initial balance:" -dfx canister call icrc1_index icrc1_balance_of "(record{owner = principal \"${CALLER}\"; })" -echo "Bounty initial balance:" -dfx canister call icrc1_index icrc1_balance_of "(record{owner = principal \"${BOUNTY}\"; })" +echo "Caller initial balance: $(balance_of "$CALLER")" +echo "Bounty initial balance: $(balance_of "$BOUNTY")" # deposit -dfx canister call icrc1_ledger icrc2_approve "(record { amount = 100_000; spender = record{owner = principal \"${BOUNTY}\";} })" -dfx canister call bounty deposit '()' +echo "Bounty allowance: $(approve_allowance 100_000 "$BOUNTY")" +echo "Bounty deposit: $(deposit)" # check final balances -echo "Caller final balance:" -dfx canister call icrc1_index icrc1_balance_of "(record{owner = principal \"${CALLER}\"; })" -echo "Bounty final balance:" -dfx canister call icrc1_index icrc1_balance_of "(record{owner = principal \"${BOUNTY}\"; })" +echo "Caller final balance: $(balance_of "$CALLER")" +echo "Bounty final balance: $(balance_of "$BOUNTY")"