Skip to content

Commit

Permalink
More formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ffakenz committed May 2, 2024
1 parent 7ec8904 commit 29d7d22
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SHELL := /bin/bash

# Load environment variables from .env file
include .env

Expand Down
28 changes: 18 additions & 10 deletions make/test/deposit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,32 @@

set -e

get_balance() {
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"

# Call the bounty canister to deposit from caller and capture the output
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: $(get_balance "$CALLER")"
echo "Bounty initial balance: $(get_balance "$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: $(get_balance "$CALLER")"
echo "Bounty final balance: $(get_balance "$BOUNTY")"

0 comments on commit 29d7d22

Please sign in to comment.