-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (53 loc) · 2.41 KB
/
Makefile
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Load environment variables from .env file
include .env
# Common variables
RPC_URL := --rpc-url ${AMOY_RPC_URL}
CHAIN_ID := --chain 80002
CONTRACT := src/ShdV1.sol:ShdV1
# PHONY targets
.PHONY: all compile test deploy verify approve create purchase setPrice balance send allowance deposit withdraw withdrawBenefit checkUsePermissionForShd
# Default target
all: compile
# Compilation
compile:
forge compile
# Testing
test:
forge test -vvvvv
# Deployment
deploy:
forge create --constructor-args ${SRC_TEST_TOKEN_ADDRESS} "SHD" 1000000000000000000 0xfF9fdF34a7C3590ec24C879767F8Becb04558ce2 60 30 --private-key ${OWNER_PRIVATE_KEY} $(CHAIN_ID) $(RPC_URL) $(CONTRACT)
# Verification
verify:
forge verify-contract --constructor-args ${ABI_ENCODED_CONSTRUCTOR} -e ${AMOY_SCAN_KEY} $(RPC_URL) $(CHAIN_ID) ${CONTRACT_ADDRESS} $(CONTRACT)
# Approve function for multiple users (pattern rule)
approve%:
cast send ${SRC_TEST_TOKEN_ADDRESS} "approve(address,uint256)" ${CONTRACT_ADDRESS} ${AMOUNT} $(RPC_URL) --private-key ${USER$*_PRIVATE_KEY}
# Other contract interactions
create:
cast send ${CONTRACT_ADDRESS} "createShd()" $(RPC_URL) --private-key ${OWNER_PRIVATE_KEY}
purchase:
cast send ${CONTRACT_ADDRESS} "purchase(uint256)" 0 $(RPC_URL) --private-key ${USER2_PRIVATE_KEY}
setPrice:
cast send ${CONTRACT_ADDRESS} "setPrice(uint256,uint256,uint256)" 0 2ether 1ether $(RPC_URL) --private-key ${USER2_PRIVATE_KEY}
# Balance check for multiple users (pattern rule)
balance%:
cast call ${SRC_TEST_TOKEN_ADDRESS} "balanceOf(address)(uint256)" ${USER$*_ADDRESS} $(RPC_URL)
# Transfer tokens
send:
cast send ${SRC_TEST_TOKEN_ADDRESS} "transfer(address,uint256)" ${USER2_ADDRESS} ${AMOUNT} $(RPC_URL) --private-key ${OWNER_PRIVATE_KEY}
# Check allowance
allowance:
cast call ${SRC_TEST_TOKEN_ADDRESS} "allowance(address,address)(uint256)" ${CONTRACT_ADDRESS} ${USER3_ADDRESS} $(RPC_URL)
# Deposit
deposit:
cast send ${CONTRACT_ADDRESS} "deposit(uint256,uint256)" 0 100000000000000000 $(RPC_URL) --private-key ${USER1_PRIVATE_KEY}
# Withdraw
withdraw:
cast send ${CONTRACT_ADDRESS} "withdraw(uint256,uint256)" 0 1000000 $(RPC_URL) --private-key ${USER1_PRIVATE_KEY}
# Withdraw benefits
withdrawBenefit:
cast send ${CONTRACT_ADDRESS} "withdrawAllForBeneficiary()" $(RPC_URL) --private-key ${OWNER_PRIVATE_KEY}
# Check SHD usage permission
checkUsePermissionForShd:
cast call ${CONTRACT_ADDRESS} "checkUsePermissionForShd(uint256)(bool)" 0 $(RPC_URL)