vectis_wallet/interface/
wallet.rs

1use crate::types::wallet::WalletInfo;
2use cosmwasm_std::{Binary, CosmosMsg, Response, StdError};
3use sylvia::types::{ExecCtx, QueryCtx};
4use sylvia::{interface, schemars};
5
6pub mod wallet_trait {
7    use super::*;
8    use crate::types::wallet::{Controller, RelayTransaction};
9
10    /// The trait for each authenticator contract
11    #[interface]
12    pub trait WalletTrait {
13        type Error: From<StdError>;
14
15        /// Returns the wallet info
16        #[msg(query)]
17        fn info(&self, ctx: QueryCtx) -> Result<WalletInfo, StdError>;
18
19        /// Returns the data given the key
20        #[msg(query)]
21        fn data(&self, ctx: QueryCtx, key: Binary) -> Result<Option<Binary>, StdError>;
22
23        /// Permission: contract self (controller / plugins)
24        #[msg(exec)]
25        fn controller_rotation(
26            &self,
27            ctx: ExecCtx,
28            new_controller: Controller,
29        ) -> Result<Response, Self::Error>;
30
31        /// Permission: Open
32        /// Main exec function and checks for auth from controller
33        #[msg(exec)]
34        fn auth_exec(
35            &self,
36            ctx: ExecCtx,
37            transaction: RelayTransaction,
38        ) -> Result<Response, Self::Error>;
39
40        /// Permission: Open
41        /// This allows for exec of tx without called any plugins.
42        /// Allowing for the removal of faulty plugins on the proxy wallet
43        #[msg(exec)]
44        fn auth_exec_without_plugins(
45            &self,
46            ctx: ExecCtx,
47            transaction: RelayTransaction,
48        ) -> Result<Response, Self::Error>;
49
50        /// Permission: factory
51        /// This is used by the factory in the case the wallet migrates
52        #[msg(exec)]
53        fn controller_nonce_update(&self, ctx: ExecCtx) -> Result<Response, Self::Error>;
54
55        /// Permission: Controller
56        /// Updates the data stored (auto replace existing)
57        #[msg(exec)]
58        fn update_data(
59            &self,
60            ctx: ExecCtx,
61            //  TODO: Would be great to use `Record` but might have ts-codegen error
62            data: Vec<(Binary, Option<Binary>)>,
63        ) -> Result<Response, Self::Error>;
64    }
65}
66
67pub mod wallet_plugin_trait {
68    use crate::types::plugin::{
69        PluginInstallParams, PluginListResponse, PluginMigrateParams, PluginPermission,
70    };
71
72    use super::*;
73
74    /// The trait for each authenticator contract
75    #[interface]
76    pub trait WalletPluginTrait {
77        type Error: From<StdError>;
78
79        /// Returns all installed plugins by types
80        #[msg(query)]
81        fn plugins(
82            &self,
83            ctx: QueryCtx,
84            ty: PluginPermission,
85            start_after: Option<String>,
86            limit: Option<u32>,
87        ) -> Result<PluginListResponse, StdError>;
88
89        #[msg(exec)]
90        fn plugin_execute(
91            &self,
92            ctx: ExecCtx,
93            msg: Vec<CosmosMsg>,
94        ) -> Result<Response, Self::Error>;
95
96        #[msg(exec)]
97        fn install_plugins(
98            &self,
99            ctx: ExecCtx,
100            install: Vec<PluginInstallParams>,
101        ) -> Result<Response, Self::Error>;
102
103        #[msg(exec)]
104        fn update_plugins(
105            &self,
106            ctx: ExecCtx,
107            migrate: Vec<PluginMigrateParams>,
108        ) -> Result<Response, Self::Error>;
109
110        /// Removing plugin: called by registry contract
111        /// This is done so that it must be removed in both the registry and proxy states
112        #[msg(exec)]
113        fn remove_plugins(
114            &self,
115            ctx: ExecCtx,
116            plugin_addrs: Vec<String>,
117        ) -> Result<Response, Self::Error>;
118    }
119}