-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforge-create.sh
More file actions
executable file
·81 lines (73 loc) · 2.57 KB
/
forge-create.sh
File metadata and controls
executable file
·81 lines (73 loc) · 2.57 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# Version constant
VERSION="v0.1.2"
# Function to display usage information
display_usage() {
echo "Usage: forge-create [command] [options]"
echo ""
echo "Commands:"
echo " <default> Run forge create with deployment info saving capabilities"
echo " save Save deployment info for an existing transaction"
echo " --version, -v Show version information"
echo ""
echo "For 'create' command options:"
echo " forge-create.sh [script options] [forge create arguments]"
echo " Script options:"
echo " --no-save Don't save output to JSON file"
echo " --save-out PATH Path where to save JSON files (default: ./deployments)"
echo " --comment TEXT Add a comment to the stored JSON file"
echo ""
echo "For 'save' command options:"
echo " forge-create.sh save TX_HASH --commit COMMIT_HASH --contract-path CONTRACT_PATH [options]"
echo " Required arguments:"
echo " TX_HASH Transaction hash of the deployment"
echo " --commit HASH Commit hash of the source code (must exist in repo)"
echo " --contract-path PATH Path to the contract source (format: path/to/Contract.sol:ContractName)"
echo " Options:"
echo " --constructor-args ARGS Constructor arguments (as a string)"
echo " --comment TEXT Comment for the deployment"
echo " --rpc-url URL RPC URL to use (for fetching tx data)"
echo " --save-out PATH Directory to save deployment info (default: ./deployments)"
exit 1
}
# Make sure the helper scripts exist and are executable
REALPATH_RESULT=$(realpath "$0")
SCRIPT_DIR="$(dirname "${REALPATH_RESULT}")"
CREATE_SCRIPT="${SCRIPT_DIR}/forge-create-create.sh"
SAVE_SCRIPT="${SCRIPT_DIR}/forge-create-save.sh"
if [[ ! -f "${CREATE_SCRIPT}" ]]
then
echo "Error: Could not find create script at ${CREATE_SCRIPT}"
exit 1
fi
if [[ ! -f "${SAVE_SCRIPT}" ]]
then
echo "Error: Could not find save script at ${SAVE_SCRIPT}"
exit 1
fi
# Make them executable if they aren't already
chmod +x "${CREATE_SCRIPT}" 2>/dev/null
chmod +x "${SAVE_SCRIPT}" 2>/dev/null
# If no arguments provided, show usage
if [[ $# -eq 0 ]]
then
display_usage
fi
# Check for the command (first argument)
if [[ "$1" = "save" ]]
then
# Pass all arguments to the save script
"${SAVE_SCRIPT}" "$@"
exit $?
elif [[ "$1" = "help" ]] || [[ "$1" = "--help" ]] || [[ "$1" = "-h" ]]
then
display_usage
elif [[ "$1" = "--version" ]] || [[ "$1" = "-v" ]]
then
echo "${VERSION}"
exit 0
else
# Pass all arguments to the create script
"${CREATE_SCRIPT}" "$@"
exit $?
fi