-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
271 lines (209 loc) · 9.83 KB
/
deploy.sh
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
set -ex
BACKEND_CANISTER=$(dfx canister id backend)
dfx deploy geonft --argument "record {admin_principal = principal \"$BACKEND_CANISTER\";}" --mode reinstall
dfx identity new alice --storage-mode=plaintext || true
dfx identity use alice
ALICE_PRINCIPAL=$(dfx identity get-principal)
dfx identity new bob --storage-mode=plaintext || true
dfx identity use bob
BOB_PRINCIPAL=$(dfx identity get-principal)
dfx identity new icrc7_deployer --storage-mode=plaintext || true
dfx identity use icrc7_deployer
ADMIN_PRINCIPAL=$(dfx identity get-principal)
#Deploy the canister
dfx deploy icrc7 --argument 'record {icrc7_args = null; icrc37_args =null; icrc3_args =null;}' --mode reinstall
ICRC7_CANISTER=$(dfx canister id geonft)
echo $ICRC7_CANISTER
#init the canister
dfx canister call backend set_nft_canister "(\"$ICRC7_CANISTER\")"
# Get Name
dfx canister call icrc7 icrc7_name --query
# Get Symbol
dfx canister call icrc7 icrc7_symbol --query
# Get Description
dfx canister call icrc7 icrc7_description --query
# Get Logo
dfx canister call icrc7 icrc7_logo --query
# Mint 4 NFTs
dfx canister call icrc7 icrcX_mint "(
vec {
record {
token_id = 0 : nat;
owner = opt record { owner = principal \"$ICRC7_CANISTER\"; subaccount = null;};
metadata = variant {
Map = vec {
record { \"icrc97:metadata\"; variant { Map = vec {
record { \"name\"; variant { Text = \"Image 1\" } };
record { \"description\"; variant { Text = \"A beautiful space image from NASA.\" } };
record { \"assets\"; variant { Array = vec {
variant { Map = vec {
record { \"url\"; variant { Text = \"https://images-assets.nasa.gov/image/PIA18249/PIA18249~orig.jpg\" } };
record { \"mime\"; variant { Text = \"image/jpeg\" } };
record { \"purpose\"; variant { Text = \"icrc97:image\" } }
}}
}}}
}}}
}
};
memo = opt blob \"\00\01\";
override = true;
created_at_time = null;
};
record {
token_id = 1 : nat;
owner = opt record { owner = principal \"$ICRC7_CANISTER\"; subaccount = null;};
metadata = variant {
Map = vec {
record { \"icrc97:metadata\"; variant { Map = vec {
record { \"name\"; variant { Text = \"Image 2\" }};
record { \"description\"; variant { Text = \"Another stunning NASA image.\" } };
record { \"assets\"; variant { Array = vec {
variant { Map = vec {
record { \"url\"; variant { Text = \"https://images-assets.nasa.gov/image/GSFC_20171208_Archive_e001465/GSFC_20171208_Archive_e001465~orig.jpg\" } };
record { \"mime\"; variant { Text = \"image/jpeg\" } };
record { \"purpose\"; variant { Text = \"icrc97:image\" } }
}}
}}}
}}}
}
};
memo = opt blob \"\00\01\";
override = true;
created_at_time = null;
};
record {
token_id = 2 : nat;
owner = opt record { owner = principal \"$ICRC7_CANISTER\"; subaccount = null;};
metadata = variant {
Map = vec {
record { \"icrc97:metadata\"; variant { Map = vec {
record { \"name\"; variant { Text = \"Image 3\" } };
record { \"description\"; variant { Text = \"Hubble sees the wings of a butterfly.\" } };
record { \"assets\"; variant { Array = vec {
variant { Map = vec {
record { \"url\"; variant { Text = \"https://images-assets.nasa.gov/image/hubble-sees-the-wings-of-a-butterfly-the-twin-jet-nebula_20283986193_o/hubble-sees-the-wings-of-a-butterfly-the-twin-jet-nebula_20283986193_o~orig.jpg\" } };
record { \"mime\"; variant { Text = \"image/jpeg\" } };
record { \"purpose\"; variant { Text = \"icrc97:image\" } }
}}
}}}
}}}
}
};
memo = opt blob \"\00\01\";
override = true;
created_at_time = null;
};
record {
token_id = 3 : nat;
owner = opt record { owner = principal \"$ICRC7_CANISTER\"; subaccount = null;};
metadata = variant {
Map = vec {
record { \"icrc97:metadata\"; variant { Map = vec {
record { \"name\"; variant { Text = \"Image 4\" } };
record { \"description\"; variant { Text = \"Another beautiful image from NASA archives.\" } };
record { \"assets\"; variant { Array = vec {
variant { Map = vec {
record { \"url\"; variant { Text = \"https://images-assets.nasa.gov/image/GSFC_20171208_Archive_e001518/GSFC_20171208_Archive_e001518~orig.jpg\" } };
record { \"mime\"; variant { Text = \"image/jpeg\" } };
record { \"purpose\"; variant { Text = \"icrc97:image\" } }
}}
}}}
}}}
}
};
memo = opt blob \"\00\01\";
override = true;
created_at_time = null;
};
}
)"
# Get total supply
dfx canister call icrc7 icrc7_total_supply --query
# Get supply cap
dfx canister call icrc7 icrc7_supply_cap --query
# Get max query batch size
dfx canister call icrc7 icrc7_max_query_batch_size --query
# Get max update size
dfx canister call icrc7 icrc7_max_update_batch_size --query
# Get default take value
dfx canister call icrc7 icrc7_default_take_value --query
# Get max take value
dfx canister call icrc7 icrc7_max_take_value --query
# Get max memo size
dfx canister call icrc7 icrc7_max_memo_size --query
# Get collection metadata
dfx canister call icrc7 icrc7_collection_metadata --query
# Get suported standards
dfx canister call icrc7 icrc10_supported_standards --query
# Get max approvals per token or collection
dfx canister call icrc7 icrc37_max_approvals_per_token_or_collection --query
#Get a max revoke approvals
dfx canister call icrc7 icrc37_max_revoke_approvals '(null, null)'
#All tokens should be owned by the canister
dfx canister call icrc7 icrc7_tokens_of "(record { owner = principal \"$ICRC7_CANISTER\"; subaccount = null;},null,null)"
#Should be approved to transfer
dfx canister call icrc7 icrc37_is_approved "(vec{record { spender=record {owner = principal \"$ADMIN_PRINCIPAL\"; subaccount = null;}; from_subaccount=null; token_id=0;}})" --query
#Check that the owner is spender
dfx canister call icrc7 icrc37_get_collection_approvals "(record { owner = principal \"$ICRC7_CANISTER\"; subaccount = null;},null, null)" --query
#tranfer from a token to the admin
dfx canister call icrc7 icrc37_transfer_from "(vec{record {
spender = principal \"$ADMIN_PRINCIPAL\";
from = record { owner = principal \"$ICRC7_CANISTER\"; subaccount = null};
to = record { owner = principal \"$ADMIN_PRINCIPAL\"; subaccount = null};
token_id = 0 : nat;
memo = null;
created_at_time = null;}})"
#Internally use transfer to transfer to admin
dfx canister call icrc7 assign "(1, record { owner = principal \"$ADMIN_PRINCIPAL\"; subaccount = null})";
# Admin should own two tokens
dfx canister call icrc7 icrc7_tokens_of "(record { owner = principal \"$ADMIN_PRINCIPAL\"; subaccount = null}, null, null)" --query
# List owner of all tokens
dfx canister call icrc7 icrc7_owner_of '(vec {0;1})' --query
#Get token metadta
dfx canister call icrc7 icrc7_token_metadata '(vec {0})' --query
# Approve Alice to spend token 0
dfx canister call icrc7 icrc37_approve_tokens "(vec {record { token_id=0; approval_info= record {from_subaccount = null; spender = record {owner = principal \"$ALICE_PRINCIPAL\"; subaccount = null}; memo = null; expires_at = null; created_at_time = null }}})"
# Retrieve Alice Token approvals
dfx canister call icrc7 icrc37_is_approved "(vec { record {spender= record { owner = principal \"$ALICE_PRINCIPAL\"; subaccount = null;}; from_subaccount=null; token_id=0}})" --query
dfx canister call icrc7 icrc37_get_token_approvals "(vec { 0;},null,null)" --query
# Switch to Alice
dfx identity use alice
# Transfer to Bob
dfx canister call icrc7 icrc37_transfer_from "(vec {record {
spender = principal \"$ALICE_PRINCIPAL\";
from = record { owner = principal \"$ADMIN_PRINCIPAL\"; subaccount = null};
to = record { owner = principal \"$BOB_PRINCIPAL\"; subaccount = null};
token_id = 0 : nat;
memo = null;
created_at_time = null;}})"
#Switch to Bob
dfx identity use bob
#Let bob approve the collection for admin
dfx canister call icrc7 icrc37_approve_collection "(vec {record { approval_info = record {from_subaccount = null; spender = record {owner = principal \"$ADMIN_PRINCIPAL\"; subaccount = null}; memo = null; expires_at = null; created_at_time = null }}})"
dfx canister call icrc7 icrc37_get_collection_approvals "(record{owner = principal \"$ADMIN_PRINCIPAL\"; subaccount = null} ,null, null)" --query
#Revoke the approval
dfx canister call icrc7 icrc37_revoke_collection_approvals "(vec {record {
from_subaccount = null;
spender = null;
memo = null;
created_at_time = null;
}})"
#Check it is removed
#approve the token for admin
dfx canister call icrc7 icrc37_approve_tokens "(vec{record { token_id=0; approval_info = record {from_subaccount = null; spender = record {owner = principal \"$ADMIN_PRINCIPAL\"; subaccount = null}; memo = null; expires_at = null; created_at_time = null }}})"
dfx canister call icrc7 icrc37_get_token_approvals "(vec { 0;},null,null)" --query
#Revoke the approval
dfx canister call icrc7 icrc37_revoke_token_approvals "(vec{record {
token_id = 0;
from_subaccount = null;
spender = null;
memo = null;
created_at_time = null;
}})"
#Check it is removed
dfx canister call icrc7 icrc37_get_token_approvals "(vec { 0;},null,null)" --query
#Get the transaction log
dfx canister call icrc7 icrc3_get_blocks "(vec {record {start =0; length = 1000}})" --query
#Get the archive log
dfx canister call icrc7 icrc3_get_archives "(record {from = null})" --query
uid: hhpjb-exv4h-wwrca-p3lqg-7zufr-guknm-mx3u2-lee2u-2lreh-wvfnw-kqe