croncat_sdk_tasks/
msg.rs

1use cosmwasm_schema::{cw_serde, QueryResponses};
2use cosmwasm_std::Addr;
3use croncat_sdk_core::internal_messages::tasks::{TasksRemoveTaskByManager, TasksRescheduleTask};
4
5use crate::types::TaskRequest;
6
7#[cw_serde]
8pub struct TasksInstantiateMsg {
9    /// Chain name to add prefix to the task_hash
10    pub chain_name: String,
11
12    /// Assigned by Factory, denotes the version of this contract (CW2 spec) & used as the task verion as well.
13    pub version: Option<String>,
14
15    /// A multisig admin whose sole responsibility is to pause the contract in event of emergency.
16    /// Must be a different contract address than DAO, cannot be a regular keypair
17    /// Does not have the ability to unpause, must rely on the DAO to assess the situation and act accordingly
18    pub pause_admin: Addr,
19
20    /// Name of the key for raw querying Manager address from the factory
21    pub croncat_manager_key: (String, [u8; 2]),
22    /// Name of the key for raw querying Agents address from the factory
23    pub croncat_agents_key: (String, [u8; 2]),
24
25    /// Time in nanos for each bucket of tasks
26    pub slot_granularity_time: Option<u64>,
27
28    /// Gas needed to cover proxy call without any action
29    pub gas_base_fee: Option<u64>,
30    /// Gas needed to cover single non-wasm task's Action
31    pub gas_action_fee: Option<u64>,
32    /// Gas needed to cover single query
33    pub gas_query_fee: Option<u64>,
34
35    /// Gas limit, to make sure task won't lock contract
36    pub gas_limit: Option<u64>,
37}
38
39#[cw_serde]
40pub struct UpdateConfigMsg {
41    pub croncat_factory_addr: Option<String>,
42    pub croncat_manager_key: Option<(String, [u8; 2])>,
43    pub croncat_agents_key: Option<(String, [u8; 2])>,
44    pub slot_granularity_time: Option<u64>,
45    pub gas_base_fee: Option<u64>,
46    pub gas_action_fee: Option<u64>,
47    pub gas_query_fee: Option<u64>,
48    pub gas_limit: Option<u64>,
49}
50
51#[cw_serde]
52pub enum TasksExecuteMsg {
53    UpdateConfig(UpdateConfigMsg),
54    /// Allows any user or contract to pay for future txns based on a specific schedule
55    /// contract, function id & other settings. When the task runs out of balance
56    /// the task is no longer executed, any additional funds will be returned to task owner.
57    CreateTask {
58        task: Box<TaskRequest>,
59    },
60
61    /// Deletes a task in its entirety, returning any remaining balance to task owner.
62    RemoveTask {
63        task_hash: String,
64    },
65    // Methods for other internal contracts
66    /// Remove task, used by the manager if task reached it's stop condition
67    RemoveTaskByManager(TasksRemoveTaskByManager),
68    /// Try to reschedule a task, if possible, used by the manager
69    RescheduleTask(TasksRescheduleTask),
70    /// Pauses all operations for this contract, can only be done by pause_admin
71    PauseContract {},
72    /// unpauses all operations for this contract, can only be unpaused by owner_addr
73    UnpauseContract {},
74}
75
76#[cw_serde]
77#[derive(QueryResponses)]
78pub enum TasksQueryMsg {
79    #[returns(crate::types::Config)]
80    Config {},
81    /// Helper for query responses on versioned contracts
82    #[returns[bool]]
83    Paused {},
84    /// Get the total amount of tasks
85    #[returns(cosmwasm_std::Uint64)]
86    TasksTotal {},
87    /// returns the total task count & last task creation timestamp for agent nomination checks
88    #[returns(crate::types::CurrentTaskInfoResponse)]
89    CurrentTaskInfo {},
90    /// Get next task to be done
91    #[returns(crate::types::TaskResponse)]
92    CurrentTask {},
93    /// Get task by the task hash
94    #[returns(crate::types::TaskResponse)]
95    Task { task_hash: String },
96    /// Get list of all tasks
97    #[returns(Vec<crate::types::TaskInfo>)]
98    Tasks {
99        from_index: Option<u64>,
100        limit: Option<u64>,
101    },
102    #[returns(Vec<u64>)]
103    EventedIds {
104        from_index: Option<u64>,
105        limit: Option<u64>,
106    },
107    #[returns(Vec<String>)]
108    EventedHashes {
109        id: Option<u64>,
110        from_index: Option<u64>,
111        limit: Option<u64>,
112    },
113    /// Get list of event driven tasks
114    #[returns(Vec<crate::types::TaskInfo>)]
115    EventedTasks {
116        start: Option<u64>,
117        from_index: Option<u64>,
118        limit: Option<u64>,
119    },
120    /// Get tasks created by the given address
121    #[returns(Vec<crate::types::TaskInfo>)]
122    TasksByOwner {
123        owner_addr: String,
124        from_index: Option<u64>,
125        limit: Option<u64>,
126    },
127    /// Simulate task_hash by the given task
128    #[returns(String)]
129    TaskHash { task: Box<crate::types::Task> },
130    /// Get slot hashes by given slot
131    #[returns(crate::types::SlotHashesResponse)]
132    SlotHashes { slot: Option<u64> },
133    /// Get active slots
134    #[returns(crate::types::SlotIdsResponse)]
135    SlotIds {
136        from_index: Option<u64>,
137        limit: Option<u64>,
138    },
139    #[returns(crate::types::SlotTasksTotalResponse)]
140    SlotTasksTotal { offset: Option<u64> },
141}