#调度 #cron-cat #查询 #规则 #代理 #ifttt #消息

cw-croncat-core

CronCat 核心逻辑,允许自动调度跨链交易和 IFTTT

6 个版本

0.1.5 2022 年 12 月 22 日
0.1.4 2022 年 12 月 12 日
0.1.3 2022 年 10 月 23 日

#5 in #ifttt

MIT/Apache

86KB
2K SLoC

CronCat 核心

这个库基于 CosmWasm,包含所有用于 CronCat 管理合约的消息、类型和特质。它还由 CronCat 代理规则合约 使用。

消息

实例化消息

InstantiateMsg 定义了 denomcw_rules_addr 用于查询合约地址以及其他一些可选参数。

执行消息

pub enum ExecuteMsg {
    // Task managment
    CreateTask {
        task: TaskRequest,
    },
    RemoveTask {
        task_hash: String,
    },
    RefillTaskBalance {
        task_hash: String,
    },
    RefillTaskCw20Balance {..},

    // For handling agent
    RegisterAgent {..},
    UpdateAgent {..},
    CheckInAgent {},
    UnregisterAgent {},
    WithdrawReward {},

    // Executing a task
    ProxyCall {
        task_hash: Option<String>,
    },

    // Updating config 
    UpdateSettings {..},

    // Moving balance to DAO or letting treasury transfer to itself
    MoveBalances {..},

    // Adding and withdrawing cw20 coins from user balance
    Receive(cw20::Cw20ReceiveMsg),
    WithdrawWalletBalance {
        cw20_amounts: Vec<Cw20Coin>,
    },

    // Helps manage and cleanup agents
    Tick {},
}

查询消息

pub enum QueryMsg {
    // Query all tasks with queries starting with `from_index` till `limit`
    GetTasks {
        from_index: Option<u64>,
        limit: Option<u64>,
    },
    // Query all tasks without queries starting with `from_index` till `limit`
    GetTasksWithQueries {
        from_index: Option<u64>,
        limit: Option<u64>,
    },
    // Query tasks created by owner_id
    GetTasksByOwner {
        owner_id: String,
    },
    // Query task by hash and vice versa
    GetTask {
        task_hash: String,
    },
    GetTaskHash {
        task: Box<Task>,
    },

    // Queries the information about all agents or the specific agent with address `account_id`
    GetAgent {
        account_id: String,
    },
    GetAgentIds {},
    GetAgentTasks {
        account_id: String,
    },

    // Checks if the interval is valid, returns bool
    ValidateInterval {
        interval: Interval,
    },

    // Query the current config
    GetConfig {},

    // Query native and cw20 balances
    GetBalances {},
    // Query user's cw20 balances
    GetWalletBalances {
        wallet: String,
    },

    // Query a list of active slot ids 
    GetSlotIds {},
    // Query list of task hashes by the slot
    GetSlotHashes {
        slot: Option<u64>,
    },

    // Returns the current state, including config, tasks and agents
    GetState {
        from_index: Option<u64>,
        limit: Option<u64>,
    },
}

依赖项

~6–14MB
~169K SLoC