croncat_sdk_manager/msg.rs
1use crate::types::UpdateConfig;
2use cosmwasm_schema::{cw_serde, QueryResponses};
3use cosmwasm_std::{Addr, Uint128};
4use croncat_sdk_core::internal_messages::agents::AgentWithdrawOnRemovalArgs;
5use croncat_sdk_core::internal_messages::manager::{ManagerCreateTaskBalance, ManagerRemoveTask};
6use croncat_sdk_core::types::GasPrice;
7
8use cw20::Cw20Coin;
9
10#[cw_serde]
11pub struct ManagerInstantiateMsg {
12 /// CW2 Version provided by factory
13 pub version: Option<String>,
14 /// Name of the key for raw querying Tasks address from the factory
15 pub croncat_tasks_key: (String, [u8; 2]),
16 /// Name of the key for raw querying Agents address from the factory
17 pub croncat_agents_key: (String, [u8; 2]),
18 /// A multisig admin whose sole responsibility is to pause the contract in event of emergency.
19 /// Must be a different contract address than DAO, cannot be a regular keypair
20 /// Does not have the ability to unpause, must rely on the DAO to assess the situation and act accordingly
21 pub pause_admin: Addr,
22 /// Gas prices that expected to be used by the agent
23 pub gas_price: Option<GasPrice>,
24
25 /// Contract's treasury.
26 /// Fees from tasks will go to this address, if set or to the owner address otherwise
27 pub treasury_addr: Option<String>,
28
29 /// List of whitelisted cw20s
30 pub cw20_whitelist: Option<Vec<String>>,
31}
32
33#[cw_serde]
34pub enum ManagerExecuteMsg {
35 /// Updates the croncat Config.
36 /// Note: it's shared across contracts
37 // Boxing cause of large enum variant
38 UpdateConfig(Box<UpdateConfig>),
39
40 /// Execute current task in the queue or task with queries if task_hash given
41 ProxyCall {
42 task_hash: Option<String>,
43 },
44
45 /// Execute current task in the queue or task with queries if task_hash given
46 ProxyBatch(Vec<Option<String>>),
47
48 /// Execute task just like in ProxyCall but used in conjunction of ProxyBatch.
49 /// Can only be used internally via ProxyBatch entry point.
50 ProxyCallForwarded {
51 agent_addr: Addr,
52 task_hash: Option<String>,
53 },
54
55 /// Receive native coins to include them to the task
56 RefillTaskBalance {
57 task_hash: String,
58 },
59 RefillTaskCw20Balance {
60 task_hash: String,
61 cw20: Cw20Coin,
62 },
63
64 /// Receive cw20 coin
65 Receive(cw20::Cw20ReceiveMsg),
66
67 /// Create task's balance, called by the tasks contract
68 CreateTaskBalance(Box<ManagerCreateTaskBalance>),
69
70 /// Remove task's balance, called by the tasks contract
71 RemoveTask(ManagerRemoveTask),
72
73 /// Move balances from the manager to the owner address, or treasury_addr if set
74 OwnerWithdraw {},
75
76 /// Withdraw temp coins for users
77 UserWithdraw {
78 // In case user somehow manages to have too many coins we don't want them to get locked funds
79 limit: Option<u64>,
80 },
81
82 /// Withdraw agent rewards on agent removal, this should be called only by agent contract
83 AgentWithdraw(Option<AgentWithdrawOnRemovalArgs>),
84
85 /// Pauses all operations for this contract, can only be done by pause_admin
86 PauseContract {},
87 /// unpauses all operations for this contract, can only be unpaused by owner_addr
88 UnpauseContract {},
89}
90
91#[cw_serde]
92#[derive(QueryResponses)]
93pub enum ManagerQueryMsg {
94 /// Gets current croncat config
95 #[returns(crate::types::Config)]
96 Config {},
97
98 /// Helper for query responses on versioned contracts
99 #[returns[bool]]
100 Paused {},
101
102 /// Gets manager available balances
103 #[returns(cosmwasm_std::Uint128)]
104 TreasuryBalance {},
105 /// Gets Cw20 balances of the given wallet address
106 #[returns(Vec<cw20::Cw20CoinVerified>)]
107 UsersBalances {
108 address: String,
109 from_index: Option<u64>,
110 limit: Option<u64>,
111 },
112 /// Get task balance
113 #[returns(crate::types::TaskBalanceResponse)]
114 TaskBalance { task_hash: String },
115
116 #[returns(cosmwasm_std::Uint128)]
117 AgentRewards { agent_id: String },
118}
119
120#[cw_serde]
121pub enum ManagerReceiveMsg {
122 RefillTempBalance {},
123 RefillTaskBalance { task_hash: String },
124}
125#[cw_serde]
126pub struct AgentWithdrawCallback {
127 pub agent_id: String,
128 pub amount: Uint128,
129 pub payable_account_id: String,
130}