1
+ SHELL := /bin/bash
2
+
3
+ # Disable built-in rules and variables
4
+ MAKEFLAGS += --no-builtin-rules
5
+ MAKEFLAGS += --no-builtin-variables
6
+
7
+ NETWORK ?= local
8
+ DFX_WEBSERVER_PORT ?= $(shell dfx info webserver-port)
9
+ IDENTITY ?= $(shell dfx identity whoami)
10
+
11
+ # ##########################################################################
12
+ # Some constants
13
+ CANISTER_INSTALL_MODE ?= install
14
+ CANISTER_CANDID_UI_IC ?= "a4gq6-oaaaa-aaaab-qaa4q-cai"
15
+
16
+ # Some defaults
17
+ CANISTER_NAME ?= ctrlb_canister
18
+
19
+
20
+ .PHONY : dfx-cycles-to-canister
21
+ dfx-cycles-to-canister :
22
+ @$(eval CANISTER_ID := $(shell dfx canister --network ic id ctrlb_canister) )
23
+ @echo " -------------------------------------------------------------------------"
24
+ @echo " dfx identity : $( IDENTITY) "
25
+ @echo " - balance before: "
26
+ @dfx wallet --network ic balance
27
+ @echo " -------------------------------------------------------------------------"
28
+ @echo " ctrlb_canister before : $( CANISTER_ID) "
29
+ @dfx canister --network=ic status ctrlb_canister
30
+ @echo " -------------------------------------------------------------------------"
31
+ @echo " Sending 0.5T cycles to ctrlb_canister"
32
+ dfx wallet --network ic send $(CANISTER_ID ) 500000000000
33
+ @echo " -------------------------------------------------------------------------"
34
+ @echo " dfx identity : $( IDENTITY) "
35
+ @echo " - balance after: "
36
+ @dfx wallet --network ic balance
37
+ @echo " -------------------------------------------------------------------------"
38
+ @echo " ctrlb_canister after : $( CANISTER_ID) "
39
+ @dfx canister --network=ic status ctrlb_canister
40
+
41
+ .PHONY : dfx-canisters-of-project-ic
42
+ dfx-canisters-of-project-ic :
43
+ @$(eval IDENTITY_PRINCIPAL := $(shell dfx identity --network ic get-principal) )
44
+ @$(eval IDENTITY_CYCLES_WALLET := $(shell dfx identity --network ic get-wallet) )
45
+ @$(eval IDENTITY_ICP_WALLET := $(shell dfx ledger --network ic account-id) )
46
+ @$(eval IDENTITY_ICP_BALANCE := $(shell dfx ledger --network ic balance) )
47
+ @$(eval crtlb_canister_ID := $(shell dfx canister --network ic id ctrlb_canister) )
48
+
49
+ @echo '-------------------------------------------------'
50
+ @echo "NETWORK : ic"
51
+ @echo "dfx identity : $(IDENTITY)"
52
+ @echo "identity's principal : $(IDENTITY_PRINCIPAL)"
53
+ @echo "identity's cycles wallet : $(IDENTITY_CYCLES_WALLET)"
54
+ @echo "identity's ICP wallet : $(IDENTITY_ICP_WALLET)"
55
+ @echo "identity's ICP balance : $(IDENTITY_ICP_BALANCE)"
56
+ @echo '-------------------------------------------------'
57
+ @echo "identity's cycles wallet : $(IDENTITY_CYCLES_WALLET)"
58
+ @echo "- balance: "
59
+ @dfx wallet --network ic balance
60
+ @echo "- status: "
61
+ @dfx canister --network=ic status $(IDENTITY_CYCLES_WALLET)
62
+ @echo '-------------------------------------------------'
63
+ @echo "ctrlb_canister : $(crtlb_canister_ID)"
64
+ @dfx canister --network=ic status ctrlb_canister
65
+ @echo '-------------------------------------------------'
66
+ @echo 'View in browser at:'
67
+ @echo "identity's wallet : https://$(IDENTITY_CYCLES_WALLET).raw.ic0.app/"
68
+ @echo "Candid UI : https://$(CANISTER_CANDID_UI_IC).raw.ic0.app/"
69
+
70
+
71
+ .PHONY : dfx-wallet-details
72
+ dfx-wallet-details :
73
+ @$(eval IDENTITY_CYCLES_WALLET := $(shell dfx identity --network $(NETWORK ) get-wallet) )
74
+ @echo " -------------------------------------------------------------------------"
75
+ @echo " make dfx-wallet-details NETWORK=$( NETWORK) "
76
+ @if [[ ${NETWORK} == " ic" ]]; then \
77
+ echo " View details at : https://$( IDENTITY_CYCLES_WALLET) .raw.ic0.app/" ; \
78
+ else \
79
+ echo " View details at : ?? http://localhost:$( DFX_WEBSERVER_PORT) ?canisterId=$( IDENTITY_CYCLES_WALLET) ?? " ; \
80
+ fi
81
+
82
+ @echo " -------------------------------------------------------------------------"
83
+ @echo -n " cycles canister id : " && dfx identity --network $(NETWORK ) get-wallet
84
+ @echo -n " cycles canister name : " && dfx wallet --network $(NETWORK ) name
85
+ @echo -n " cycles canister balance : " && dfx wallet --network $(NETWORK ) balance
86
+ @echo " -------------------------------------------------------------------------"
87
+ @echo " controllers: "
88
+ @dfx wallet --network $(NETWORK ) controllers
89
+ @echo " -------------------------------------------------------------------------"
90
+ @echo " custodians: "
91
+ @dfx wallet --network $(NETWORK ) custodians
92
+ @echo " -------------------------------------------------------------------------"
93
+ @echo " addresses: "
94
+ @dfx wallet --network $(NETWORK ) addresses
95
+
96
+ .PHONY : dfx-wallet-controller-add
97
+ dfx-wallet-controller-add :
98
+ @[ " ${PRINCIPAL} " ] || ( echo " >> Define PRINCIPAL to add as controller: 'make dfx-cycles-controller-add PRINCIPAL=....' " ; exit 1 )
99
+ @echo " NETWORK : $( NETWORK) "
100
+ @echo " PRINCIPAL : $( PRINCIPAL) "
101
+ @dfx wallet --network $(NETWORK ) add-controller $(PRINCIPAL )
102
+
103
+ .PHONY : dfx-wallet-controller-remove
104
+ dfx-wallet-controller-remove :
105
+ @[ " ${PRINCIPAL} " ] || ( echo " >> Define PRINCIPAL to remove as controller: 'make dfx-cycles-controller-remove PRINCIPAL=....' " ; exit 1 )
106
+ @echo " NETWORK : $( NETWORK) "
107
+ @echo " PRINCIPAL : $( PRINCIPAL) "
108
+ @dfx wallet --network $(NETWORK ) remove-controller $(PRINCIPAL )
0 commit comments