forked from base/contract-deployments
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultisig.mk
More file actions
39 lines (31 loc) · 1.48 KB
/
Multisig.mk
File metadata and controls
39 lines (31 loc) · 1.48 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
# ---------- Common fragments ----------
LEDGER_HD_PATH = "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0"
empty :=
space := $(empty) $(empty)
comma := ,
# Join a whitespace-separated list with ", " and normalize whitespace
comma_join = $(subst $(space),$(comma) ,$(strip $(foreach w,$(1),$(w))))
# Validation helper for required variables
require_vars = $(foreach _var,$(2),$(if $(strip $($(_var))),,$(error $(1): required variable $(_var) is not defined)))
# ---------- Procedures ----------
# MULTISIG_SIGN: $(1)=address list (space-separated)
define MULTISIG_SIGN
$(call require_vars,MULTISIG_SIGN,LEDGER_ACCOUNT RPC_URL SCRIPT_NAME)
$(GOPATH)/bin/eip712sign --ledger --hd-paths $(LEDGER_HD_PATH) -- \
forge script --rpc-url $(RPC_URL) $(SCRIPT_NAME) \
--sig "sign(address[])" "[$(call comma_join,$(1))]"
endef
# MULTISIG_APPROVE: $(1)=address list (space-separated), $(2)=signatures (e.g., 0x or $(SIGNATURES))
define MULTISIG_APPROVE
$(call require_vars,MULTISIG_APPROVE,LEDGER_ACCOUNT RPC_URL SCRIPT_NAME)
forge script --rpc-url $(RPC_URL) $(SCRIPT_NAME) \
--sig "approve(address[],bytes)" "[$(call comma_join,$(1))]" $(2) \
--ledger --hd-paths $(LEDGER_HD_PATH) --broadcast -vvvv
endef
# MULTISIG_EXECUTE: $(1)=signatures for run(bytes) (e.g., 0x or $(SIGNATURES))
define MULTISIG_EXECUTE
$(call require_vars,MULTISIG_EXECUTE,LEDGER_ACCOUNT RPC_URL SCRIPT_NAME)
forge script --rpc-url $(RPC_URL) $(SCRIPT_NAME) \
--sig "run(bytes)" $(1) \
--ledger --hd-paths $(LEDGER_HD_PATH) --broadcast -vvvv
endef