-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·173 lines (164 loc) · 4.49 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
#!/bin/bash
export ALICE=$(dfx --identity alice identity get-principal)
export BOB=$(dfx --identity bob identity get-principal)
export DEFAULT=$(dfx --identity default identity get-principal)
# 1741447837000000000 nanoseconds = 1741447837 = March 8, 2025 10:30:37 PM GMT+07:00
echo Deploy Certified Asset Provenance - CAP Router
echo ================================================================
echo ""
dfx deploy --ic router
echo ""
echo Deploy BrownFi Core
echo ================================================================
echo ""
dfx canister --ic create core
dfx deploy --ic core --argument="(
principal \"$(dfx identity --ic get-principal)\",
principal \"$(dfx canister --ic id core)\",
principal \"$(dfx canister --ic id router)\"
)"
echo ""
echo Deploy TokenA
echo ================================================================
echo ""
dfx deploy --ic tokenA --argument '
(variant {
Init = record {
token_name = "Token A";
token_symbol = "A";
minting_account = record {
owner = principal "'${DEFAULT}'";
};
initial_balances = vec {
record {
record {
owner = principal "'${ALICE}'";
};
10_000_000_000_000;
};
record {
record {
owner = principal "'${BOB}'";
};
10_000_000_000_000;
};
};
metadata = vec {};
transfer_fee = 0;
archive_options = record {
trigger_threshold = 2000;
num_blocks_to_archive = 1000;
controller_id = principal "'${DEFAULT}'";
};
feature_flags = opt record {
icrc2 = true;
};
}
})
'
echo ""
echo Deploy TokenB
echo ================================================================
echo ""
dfx deploy --ic tokenB --argument '
(variant {
Init = record {
token_name = "Token B";
token_symbol = "B";
minting_account = record {
owner = principal "'${DEFAULT}'";
};
initial_balances = vec {
record {
record {
owner = principal "'${ALICE}'";
};
10_000_000_000_000;
};
record {
record {
owner = principal "'${BOB}'";
};
10_000_000_000_000;
};
};
metadata = vec {};
transfer_fee = 0;
archive_options = record {
trigger_threshold = 2000;
num_blocks_to_archive = 1000;
controller_id = principal "'${DEFAULT}'";
};
feature_flags = opt record {
icrc2 = true;
};
}
})
'
echo ""
echo Register and Create: TokenA and TokenB
echo ================================================================
echo ""
dfx canister call --ic core setToken '(
(principal "'$(dfx canister --ic id tokenA)'")
)'
dfx canister call --ic core setToken '(
(principal "'$(dfx canister --ic id tokenB)'")
)'
dfx canister call --ic core setPair '(
(principal "'$(dfx canister --ic id tokenA)'"), (principal "'$(dfx canister --ic id tokenB)'")
)'
echo ""
echo Approve and Deposit
echo ================================================================
echo ""
dfx canister call --ic --identity alice tokenA icrc2_approve '(
record {
spender = record {
owner = (principal "'$(dfx canister --ic id core)'")
};
amount = '550000';
}
)'
dfx canister call --ic --identity alice tokenB icrc2_approve '(
record {
spender = record {
owner = (principal "'$(dfx canister --ic id core)'")
};
amount = '550000';
}
)'
dfx canister call --ic --identity bob tokenA icrc2_approve '(
record {
spender = record {
owner = (principal "'$(dfx canister --ic id core)'")
};
amount = '550000';
}
)'
dfx canister call --ic --identity bob tokenB icrc2_approve '(
record {
spender = record {
owner = (principal "'$(dfx canister --ic id core)'")
};
amount = '550000';
}
)'
dfx canister call --ic --identity alice core deposit '(
(principal "'$(dfx canister --ic id tokenA)'"), '500000'
)'
dfx canister call --ic --identity alice core deposit '(
(principal "'$(dfx canister --ic id tokenB)'"), '500000'
)'
dfx canister call --ic --identity bob core deposit '(
(principal "'$(dfx canister --ic id tokenB)'"), '100000'
)'
echo ""
echo Add Liquidity
echo ================================================================
echo ""
dfx canister call --ic --identity alice core addLiquidity '(
(principal "'$(dfx canister --ic id tokenA)'"), (principal "'$(dfx canister --ic id tokenB)'"),
'500000', '500000', '1741447837000000000'
)'
echo ""