-
Notifications
You must be signed in to change notification settings - Fork 595
Expand file tree
/
Copy pathup_quick_start.sh
More file actions
executable file
·56 lines (43 loc) · 2.05 KB
/
up_quick_start.sh
File metadata and controls
executable file
·56 lines (43 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# Run locally from end-to-end folder while running anvil and local network with:
# PATH=$PATH:../node_modules/.bin ./src/guides/up_quick_start.sh
set -eux
export WALLET_DATA_DIRECTORY=$(mktemp -d)/up_quick_start
export PXE_PROVER="none"
function on_exit {
echo "Cleaning up $WALLET_DATA_DIRECTORY..."
rm -rf $WALLET_DATA_DIRECTORY
}
trap on_exit EXIT
aztec-wallet() {
node --no-warnings ../cli-wallet/dest/bin/index.js "$@"
}
aztec-wallet import-test-accounts
# docs:start:declare-accounts
aztec-wallet create-account -a alice -f test0
aztec-wallet create-account -a bob -f test0
# docs:end:declare-accounts
aztec-wallet bridge-fee-juice 1000000000000000000000 accounts:alice --mint --no-wait
DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:test0 Test TST 18 -f test0)
TOKEN_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE 'Contract deployed at 0x[0-9a-fA-F]+' | cut -d ' ' -f4)
echo "Deployed contract at $TOKEN_ADDRESS"
MINT_AMOUNT=69
aztec-wallet send mint_to_private -ca last --args accounts:alice $MINT_AMOUNT -f test0
ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
if ! echo $ALICE_BALANCE | grep -q $MINT_AMOUNT; then
echo "Incorrect Alice balance after transaction (expected $MINT_AMOUNT but got $ALICE_BALANCE)"
exit 1
fi
TRANSFER_AMOUNT=42
aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 0 -f alice --payment method=fee_juice,claim
# Test end result
ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
if ! echo $ALICE_BALANCE | grep -q "$(($MINT_AMOUNT - $TRANSFER_AMOUNT))"; then
echo "Incorrect Alice balance after transaction (expected 27 but got $ALICE_BALANCE)"
exit 1
fi
BOB_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:bob -f bob)
if ! echo $BOB_BALANCE | grep -q $TRANSFER_AMOUNT; then
echo "Incorrect Bob balance after transaction (expected $TRANSFER_AMOUNT but got $BOB_BALANCE)"
exit 1
fi