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
use crate::types::wallet::WalletInfo;
use cosmwasm_std::{Binary, CosmosMsg, Response, StdError};
use sylvia::types::{ExecCtx, QueryCtx};
use sylvia::{interface, schemars};
pub mod wallet_trait {
use super::*;
use crate::types::wallet::{Controller, RelayTransaction};
/// The trait for each authenticator contract
#[interface]
pub trait WalletTrait {
type Error: From<StdError>;
/// Returns the wallet info
#[msg(query)]
fn info(&self, ctx: QueryCtx) -> Result<WalletInfo, StdError>;
/// Returns the data given the key
#[msg(query)]
fn data(&self, ctx: QueryCtx, key: Binary) -> Result<Option<Binary>, StdError>;
/// Permission: contract self (controller / plugins)
#[msg(exec)]
fn controller_rotation(
&self,
ctx: ExecCtx,
new_controller: Controller,
) -> Result<Response, Self::Error>;
/// Permission: Open
/// Main exec function and checks for auth from controller
#[msg(exec)]
fn auth_exec(
&self,
ctx: ExecCtx,
transaction: RelayTransaction,
) -> Result<Response, Self::Error>;
/// Permission: Open
/// This allows for exec of tx without called any plugins.
/// Allowing for the removal of faulty plugins on the proxy wallet
#[msg(exec)]
fn auth_exec_without_plugins(
&self,
ctx: ExecCtx,
transaction: RelayTransaction,
) -> Result<Response, Self::Error>;
/// Permission: factory
/// This is used by the factory in the case the wallet migrates
#[msg(exec)]
fn controller_nonce_update(&self, ctx: ExecCtx) -> Result<Response, Self::Error>;
/// Permission: Controller
/// Updates the data stored (auto replace existing)
#[msg(exec)]
fn update_data(
&self,
ctx: ExecCtx,
// TODO: Would be great to use `Record` but might have ts-codegen error
data: Vec<(Binary, Option<Binary>)>,
) -> Result<Response, Self::Error>;
}
}
pub mod wallet_plugin_trait {
use crate::types::plugin::{
PluginInstallParams, PluginListResponse, PluginMigrateParams, PluginPermission,
};
use super::*;
/// The trait for each authenticator contract
#[interface]
pub trait WalletPluginTrait {
type Error: From<StdError>;
/// Returns all installed plugins by types
#[msg(query)]
fn plugins(
&self,
ctx: QueryCtx,
ty: PluginPermission,
start_after: Option<String>,
limit: Option<u32>,
) -> Result<PluginListResponse, StdError>;
#[msg(exec)]
fn plugin_execute(
&self,
ctx: ExecCtx,
msg: Vec<CosmosMsg>,
) -> Result<Response, Self::Error>;
#[msg(exec)]
fn install_plugins(
&self,
ctx: ExecCtx,
install: Vec<PluginInstallParams>,
) -> Result<Response, Self::Error>;
#[msg(exec)]
fn update_plugins(
&self,
ctx: ExecCtx,
migrate: Vec<PluginMigrateParams>,
) -> Result<Response, Self::Error>;
/// Removing plugin: called by registry contract
/// This is done so that it must be removed in both the registry and proxy states
#[msg(exec)]
fn remove_plugins(
&self,
ctx: ExecCtx,
plugin_addrs: Vec<String>,
) -> Result<Response, Self::Error>;
}
}