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
use cosmwasm_schema::QueryResponses;
use cosmwasm_std::{Addr, Empty};
use serde::Serialize;
use crate::base::{
ExecuteMsg as MiddlewareExecMsg, InstantiateMsg as MiddlewareInstantiateMsg,
QueryMsg as MiddlewareQueryMsg,
};
pub type ExecuteMsg<Request, ReceiveMsg = Empty> =
MiddlewareExecMsg<BaseExecuteMsg, ApiRequestMsg<Request>, ReceiveMsg>;
pub type QueryMsg<AppMsg = Empty> = MiddlewareQueryMsg<BaseQueryMsg, AppMsg>;
pub type InstantiateMsg<AppMsg = Empty> = MiddlewareInstantiateMsg<BaseInstantiateMsg, AppMsg>;
pub trait ApiExecuteMsg: Serialize {}
impl<T: ApiExecuteMsg> From<T> for ExecuteMsg<T> {
fn from(api_msg: T) -> Self {
Self::App(ApiRequestMsg {
proxy_address: None,
request: api_msg,
})
}
}
pub trait ApiQueryMsg: Serialize {}
impl<T: ApiQueryMsg> From<T> for QueryMsg<T> {
fn from(app: T) -> Self {
Self::App(app)
}
}
impl ApiQueryMsg for Empty {}
#[cosmwasm_schema::cw_serde]
pub struct BaseInstantiateMsg {
pub ans_host_address: String,
pub version_control_address: String,
}
impl<RequestMsg, ReceiveMsg> From<BaseExecuteMsg>
for MiddlewareExecMsg<BaseExecuteMsg, RequestMsg, ReceiveMsg>
{
fn from(api_msg: BaseExecuteMsg) -> Self {
Self::Base(api_msg)
}
}
impl<RequestMsg, Request, BaseExecMsg> From<ApiRequestMsg<RequestMsg>>
for MiddlewareExecMsg<BaseExecMsg, ApiRequestMsg<RequestMsg>, Request>
{
fn from(request_msg: ApiRequestMsg<RequestMsg>) -> Self {
Self::App(request_msg)
}
}
#[cosmwasm_schema::cw_serde]
pub struct ApiRequestMsg<Request> {
pub proxy_address: Option<String>,
pub request: Request,
}
impl<Request: Serialize> ApiRequestMsg<Request> {
pub fn new(proxy_address: Option<String>, request: Request) -> Self {
Self {
proxy_address,
request,
}
}
}
#[cosmwasm_schema::cw_serde]
#[cfg_attr(feature = "boot", derive(boot_core::ExecuteFns))]
#[cfg_attr(feature = "boot", impl_into(ExecuteMsg<T>))]
pub enum BaseExecuteMsg {
UpdateTraders {
to_add: Option<Vec<String>>,
to_remove: Option<Vec<String>>,
},
Remove {},
}
#[cosmwasm_schema::cw_serde]
#[derive(QueryResponses)]
#[cfg_attr(feature = "boot", derive(boot_core::QueryFns))]
#[cfg_attr(feature = "boot", impl_into(QueryMsg<AppMsg>))]
pub enum BaseQueryMsg {
#[returns(ApiConfigResponse)]
Config {},
#[returns(TradersResponse)]
Traders { proxy_address: String },
}
impl<T> From<BaseQueryMsg> for QueryMsg<T> {
fn from(base: BaseQueryMsg) -> Self {
Self::Base(base)
}
}
#[cosmwasm_schema::cw_serde]
pub struct ApiConfigResponse {
pub version_control_address: Addr,
pub ans_host_address: Addr,
pub dependencies: Vec<String>,
}
#[cosmwasm_schema::cw_serde]
pub struct TradersResponse {
pub traders: Vec<Addr>,
}