@@ -4,15 +4,18 @@ use cosmwasm_std::{
4
4
} ;
5
5
use cw2:: set_contract_version;
6
6
use cw20_base:: {
7
- contract:: { execute_mint , query_balance as cw20_query_balance} ,
7
+ contract:: query_balance as cw20_query_balance,
8
8
state:: { MinterData , TokenInfo , TOKEN_INFO } ,
9
9
} ;
10
10
use quartz_cw:: { handler:: RawHandler , state:: EPOCH_COUNTER } ;
11
11
12
12
use crate :: {
13
13
error:: ContractError ,
14
14
msg:: {
15
- execute:: { SubmitObligationMsg , SubmitObligationsMsg , SubmitSetoffsMsg } ,
15
+ execute:: {
16
+ Cw20Transfer , FaucetMintMsg , SubmitObligationMsg , SubmitObligationsMsg ,
17
+ SubmitSetoffsMsg ,
18
+ } ,
16
19
ExecuteMsg , InstantiateMsg , QueryMsg ,
17
20
} ,
18
21
state:: {
@@ -63,35 +66,6 @@ pub fn instantiate(
63
66
} ;
64
67
TOKEN_INFO . save ( deps. storage , & data) ?;
65
68
66
- let info = MessageInfo {
67
- sender : env. contract . address . clone ( ) ,
68
- funds : vec ! [ ] ,
69
- } ;
70
-
71
- execute_mint (
72
- deps. branch ( ) ,
73
- env. clone ( ) ,
74
- info. clone ( ) ,
75
- "wasm1qv9nel6lwtrq5jmwruxfndqw7ejskn5ysz53hp" . to_owned ( ) ,
76
- Uint128 :: new ( 1000 ) ,
77
- ) ?;
78
-
79
- execute_mint (
80
- deps. branch ( ) ,
81
- env. clone ( ) ,
82
- info. clone ( ) ,
83
- "wasm1tfxrdcj5kk6rewzmmkku4d9htpjqr0kk6lcftv" . to_owned ( ) ,
84
- Uint128 :: new ( 1000 ) ,
85
- ) ?;
86
-
87
- execute_mint (
88
- deps. branch ( ) ,
89
- env. clone ( ) ,
90
- info. clone ( ) ,
91
- "wasm1gjg72awjl7jvtmq4kjqp3al9p6crstpar8wgn5" . to_owned ( ) ,
92
- Uint128 :: new ( 1000 ) ,
93
- ) ?;
94
-
95
69
Ok ( Response :: new ( )
96
70
. add_attribute ( "method" , "instantiate" )
97
71
. add_attribute ( "owner" , info. sender ) )
@@ -106,6 +80,12 @@ pub fn execute(
106
80
) -> Result < Response , ContractError > {
107
81
match msg {
108
82
ExecuteMsg :: Quartz ( msg) => msg. handle_raw ( deps, & env, & info) . map_err ( Into :: into) ,
83
+ ExecuteMsg :: FaucetMint ( FaucetMintMsg { recipient, amount } ) => {
84
+ execute:: faucet_mint ( deps, env, recipient, amount)
85
+ }
86
+ ExecuteMsg :: Transfer ( Cw20Transfer { recipient, amount } ) => Ok (
87
+ cw20_base:: contract:: execute_transfer ( deps, env, info, recipient, amount. into ( ) ) ?,
88
+ ) ,
109
89
ExecuteMsg :: SubmitObligation ( SubmitObligationMsg { ciphertext, digest } ) => {
110
90
execute:: submit_obligation ( deps, ciphertext, digest)
111
91
}
@@ -120,7 +100,7 @@ pub fn execute(
120
100
Ok ( Response :: new ( ) )
121
101
}
122
102
ExecuteMsg :: SubmitSetoffs ( SubmitSetoffsMsg { setoffs_enc } ) => {
123
- execute:: submit_setoffs ( deps, env, info , setoffs_enc)
103
+ execute:: submit_setoffs ( deps, env, setoffs_enc)
124
104
}
125
105
ExecuteMsg :: InitClearing => execute:: init_clearing ( deps) ,
126
106
}
@@ -131,6 +111,7 @@ pub mod execute {
131
111
132
112
use cosmwasm_std:: { DepsMut , Env , HexBinary , MessageInfo , Response , StdResult } ;
133
113
use cw20_base:: contract:: { execute_burn, execute_mint} ;
114
+ use k256:: ecdsa:: VerifyingKey ;
134
115
use quartz_cw:: state:: { Hash , EPOCH_COUNTER } ;
135
116
136
117
use crate :: {
@@ -141,6 +122,28 @@ pub mod execute {
141
122
ContractError ,
142
123
} ;
143
124
125
+ pub fn faucet_mint (
126
+ mut deps : DepsMut ,
127
+ env : Env ,
128
+ recipient : String ,
129
+ amount : u64 ,
130
+ ) -> Result < Response , ContractError > {
131
+ let info = MessageInfo {
132
+ sender : env. contract . address . clone ( ) ,
133
+ funds : vec ! [ ] ,
134
+ } ;
135
+
136
+ execute_mint (
137
+ deps. branch ( ) ,
138
+ env. clone ( ) ,
139
+ info. clone ( ) ,
140
+ recipient. to_string ( ) ,
141
+ amount. into ( ) ,
142
+ ) ?;
143
+
144
+ Ok ( Response :: new ( ) . add_attribute ( "action" , "faucet_mint" ) )
145
+ }
146
+
144
147
pub fn submit_obligation (
145
148
deps : DepsMut ,
146
149
ciphertext : HexBinary ,
@@ -167,11 +170,12 @@ pub mod execute {
167
170
168
171
pub fn append_liquidity_sources (
169
172
deps : DepsMut ,
170
- liquidity_sources : Vec < String > ,
173
+ liquidity_sources : Vec < HexBinary > ,
171
174
) -> Result < ( ) , ContractError > {
175
+ // validate liquidity sources as public keys
172
176
liquidity_sources
173
177
. iter ( )
174
- . try_for_each ( |ls| deps . api . addr_validate ( ls) . map ( |_| ( ) ) ) ?;
178
+ . try_for_each ( |ls| VerifyingKey :: from_sec1_bytes ( ls) . map ( |_| ( ) ) ) ?;
175
179
176
180
// store the liquidity sources
177
181
LiquiditySourcesItem :: new ( & current_epoch_key ( LIQUIDITY_SOURCES_KEY , deps. storage ) ?)
@@ -186,7 +190,6 @@ pub mod execute {
186
190
pub fn submit_setoffs (
187
191
mut deps : DepsMut ,
188
192
env : Env ,
189
- _info : MessageInfo ,
190
193
setoffs_enc : BTreeMap < RawHash , SettleOff > ,
191
194
) -> Result < Response , ContractError > {
192
195
// store the `BTreeMap<RawHash, RawCipherText>`
0 commit comments