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
use crate::types::factory::CodeIdType;
use cosmwasm_std::{Addr, Binary, Coin, Response, StdError};
use cw2::ContractVersion;
use sylvia::types::{ExecCtx, QueryCtx};
use sylvia::{interface, schemars};
pub mod factory_service_trait {
use crate::types::factory::{CreateWalletMsg, MigrateWalletMsg};
use sylvia::types::ExecCtx;
use super::*;
/// The trait for users to interact with factory contract
#[interface]
pub trait FactoryServiceTrait {
type Error: From<StdError>;
#[msg(exec)]
fn create_wallet(
&self,
ctx: ExecCtx,
create_wallet_msg: CreateWalletMsg,
) -> Result<Response, Self::Error>;
#[msg(exec)]
fn migrate_wallet(
&self,
ctx: ExecCtx,
migrations_msg: MigrateWalletMsg,
) -> Result<Response, Self::Error>;
/// Returns the wallet address of this vectis ID
#[msg(query)]
fn wallet_by_vid(&self, ctx: QueryCtx, vid: String) -> Result<Option<Addr>, StdError>;
/// Returns the wallet address of this vectis ID and chain_id
#[msg(query)]
fn wallet_by_vid_chain(
&self,
ctx: QueryCtx,
vid: String,
chain_id: String,
) -> Result<Option<String>, StdError>;
}
}
pub mod factory_management_trait {
use super::*;
use crate::types::{
authenticator::AuthenticatorType,
factory::{ChainConnection, FeeType, FeesResponse},
};
/// The trait for deployer to interact with factory contract
#[interface]
pub trait FactoryManagementTrait {
type Error: From<StdError>;
/// Deployer only: update the newest code_id supported by Vectis
/// removes supported ones if version is `None`;
/// fails if code_id exist and version is `Some`;
#[msg(exec)]
fn update_code_id(
&self,
ctx: ExecCtx,
ty: CodeIdType,
code_id: u64,
version: Option<String>,
set_as_default: bool,
) -> Result<Response, Self::Error>;
/// Deployer only: update the fee associated with using Vectis services
#[msg(exec)]
fn update_config_fee(
&self,
ctx: ExecCtx,
ty: FeeType,
new_fee: Coin,
) -> Result<Response, Self::Error>;
/// Deployer only: update the supported chains
#[msg(exec)]
fn update_supported_interchain(
&self,
ctx: ExecCtx,
chain_id: String,
chain_connection: Option<ChainConnection>,
) -> Result<Response, Self::Error>;
/// Deployer only: update address associated by the deployer role
#[msg(exec)]
fn update_deployer(&self, ctx: ExecCtx, addr: String) -> Result<Response, Self::Error>;
/// Deployer only: update address associated by the wallet creator role
#[msg(exec)]
fn update_wallet_creator(
&self,
ctx: ExecCtx,
addr: String,
) -> Result<Response, Self::Error>;
/// Updates the authenticator provider
/// if `new_code_id` and `new_inst_msg` is `None`,
/// the `ty` assumes to exist and will be removed.
/// Otherwise, it will be added (if does not exist) or migrated
#[msg(exec)]
fn update_auth_provider(
&self,
ctx: ExecCtx,
ty: AuthenticatorType,
new_code_id: Option<u64>,
new_inst_msg: Option<Binary>,
) -> Result<Response, Self::Error>;
/// Returns total wallets created
#[msg(query)]
fn total_created(&self, ctx: QueryCtx) -> Result<u64, StdError>;
/// Returns existing codeIds of the proxy and others
#[msg(query)]
fn default_proxy_code_id(&self, ctx: QueryCtx) -> Result<u64, StdError>;
/// Returns address of the deployer
#[msg(query)]
fn deployer(&self, ctx: QueryCtx) -> Result<Addr, StdError>;
/// Returns address of the wallet creator
#[msg(query)]
fn wallet_creator(&self, ctx: QueryCtx) -> Result<Addr, StdError>;
/// Returns supported chains
#[msg(query)]
fn supported_chains(
&self,
ctx: QueryCtx,
start_after: Option<String>,
limit: Option<u32>,
) -> Result<Vec<(String, ChainConnection)>, StdError>;
/// Returns supported proxies
#[msg(query)]
fn supported_proxies(
&self,
ctx: QueryCtx,
start_after: Option<u64>,
limit: Option<u32>,
) -> Result<Vec<(u64, String)>, StdError>;
/// Returns current fee `FeeResponse`
#[msg(query)]
fn fees(&self, ctx: QueryCtx) -> Result<FeesResponse, StdError>;
/// Returns address of the authenticator
#[msg(query)]
fn auth_provider_addr(
&self,
ctx: QueryCtx,
ty: AuthenticatorType,
) -> Result<Option<Addr>, StdError>;
#[msg(query)]
fn contract_version(&self, ctx: QueryCtx) -> Result<ContractVersion, StdError>;
}
}