vectis_wallet/interface/
factory.rs

1use crate::types::factory::CodeIdType;
2use cosmwasm_std::{Addr, Binary, Coin, Response, StdError};
3use cw2::ContractVersion;
4use sylvia::types::{ExecCtx, QueryCtx};
5use sylvia::{interface, schemars};
6
7pub mod factory_service_trait {
8    use crate::types::factory::{CreateWalletMsg, MigrateWalletMsg};
9    use sylvia::types::ExecCtx;
10
11    use super::*;
12
13    /// The trait for users to interact with factory contract
14    #[interface]
15    pub trait FactoryServiceTrait {
16        type Error: From<StdError>;
17
18        #[msg(exec)]
19        fn create_wallet(
20            &self,
21            ctx: ExecCtx,
22            create_wallet_msg: CreateWalletMsg,
23        ) -> Result<Response, Self::Error>;
24
25        #[msg(exec)]
26        fn migrate_wallet(
27            &self,
28            ctx: ExecCtx,
29            migrations_msg: MigrateWalletMsg,
30        ) -> Result<Response, Self::Error>;
31
32        /// Returns the wallet address of this vectis ID
33        #[msg(query)]
34        fn wallet_by_vid(&self, ctx: QueryCtx, vid: String) -> Result<Option<Addr>, StdError>;
35
36        /// Returns the wallet address of this vectis ID and chain_id
37        #[msg(query)]
38        fn wallet_by_vid_chain(
39            &self,
40            ctx: QueryCtx,
41            vid: String,
42            chain_id: String,
43        ) -> Result<Option<String>, StdError>;
44    }
45}
46
47pub mod factory_management_trait {
48
49    use super::*;
50    use crate::types::{
51        authenticator::AuthenticatorType,
52        factory::{ChainConnection, FeeType, FeesResponse},
53    };
54
55    /// The trait for deployer to interact with factory contract
56    #[interface]
57    pub trait FactoryManagementTrait {
58        type Error: From<StdError>;
59
60        /// Deployer only: update the newest code_id supported by Vectis
61        /// removes supported ones if version is `None`;
62        /// fails if code_id exist and version is `Some`;
63        #[msg(exec)]
64        fn update_code_id(
65            &self,
66            ctx: ExecCtx,
67            ty: CodeIdType,
68            code_id: u64,
69            version: Option<String>,
70            set_as_default: bool,
71        ) -> Result<Response, Self::Error>;
72
73        /// Deployer only: update the fee associated with using Vectis services
74        #[msg(exec)]
75        fn update_config_fee(
76            &self,
77            ctx: ExecCtx,
78            ty: FeeType,
79            new_fee: Coin,
80        ) -> Result<Response, Self::Error>;
81
82        /// Deployer only: update the supported chains
83        #[msg(exec)]
84        fn update_supported_interchain(
85            &self,
86            ctx: ExecCtx,
87            chain_id: String,
88            chain_connection: Option<ChainConnection>,
89        ) -> Result<Response, Self::Error>;
90
91        /// Deployer only: update address associated by the deployer role
92        #[msg(exec)]
93        fn update_deployer(&self, ctx: ExecCtx, addr: String) -> Result<Response, Self::Error>;
94
95        /// Deployer only: update address associated by the wallet creator role
96        #[msg(exec)]
97        fn update_wallet_creator(
98            &self,
99            ctx: ExecCtx,
100            addr: String,
101        ) -> Result<Response, Self::Error>;
102
103        /// Updates the authenticator provider
104        /// if `new_code_id` and `new_inst_msg` is `None`,
105        /// the `ty` assumes to exist and will be removed.
106        /// Otherwise, it will be added (if does not exist) or migrated
107        #[msg(exec)]
108        fn update_auth_provider(
109            &self,
110            ctx: ExecCtx,
111            ty: AuthenticatorType,
112            new_code_id: Option<u64>,
113            new_inst_msg: Option<Binary>,
114        ) -> Result<Response, Self::Error>;
115
116        /// Returns total wallets created
117        #[msg(query)]
118        fn total_created(&self, ctx: QueryCtx) -> Result<u64, StdError>;
119
120        /// Returns existing codeIds of the proxy and others
121        #[msg(query)]
122        fn default_proxy_code_id(&self, ctx: QueryCtx) -> Result<u64, StdError>;
123
124        /// Returns address of the deployer
125        #[msg(query)]
126        fn deployer(&self, ctx: QueryCtx) -> Result<Addr, StdError>;
127
128        /// Returns address of the wallet creator
129        #[msg(query)]
130        fn wallet_creator(&self, ctx: QueryCtx) -> Result<Addr, StdError>;
131
132        /// Returns supported chains
133        #[msg(query)]
134        fn supported_chains(
135            &self,
136            ctx: QueryCtx,
137            start_after: Option<String>,
138            limit: Option<u32>,
139        ) -> Result<Vec<(String, ChainConnection)>, StdError>;
140
141        /// Returns supported proxies
142        #[msg(query)]
143        fn supported_proxies(
144            &self,
145            ctx: QueryCtx,
146            start_after: Option<u64>,
147            limit: Option<u32>,
148        ) -> Result<Vec<(u64, String)>, StdError>;
149
150        /// Returns current fee `FeeResponse`
151        #[msg(query)]
152        fn fees(&self, ctx: QueryCtx) -> Result<FeesResponse, StdError>;
153
154        /// Returns address of the authenticator
155        #[msg(query)]
156        fn auth_provider_addr(
157            &self,
158            ctx: QueryCtx,
159            ty: AuthenticatorType,
160        ) -> Result<Option<Addr>, StdError>;
161
162        #[msg(query)]
163        fn contract_version(&self, ctx: QueryCtx) -> Result<ContractVersion, StdError>;
164    }
165}