From b19388086ec0932c54f601a6e1489b016de4ebd8 Mon Sep 17 00:00:00 2001 From: Deveus Date: Thu, 15 Dec 2022 00:12:37 +0200 Subject: [PATCH 01/12] fix: create_task response data --- contracts/cw-croncat/src/tasks.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/cw-croncat/src/tasks.rs b/contracts/cw-croncat/src/tasks.rs index fa95c72f..af5103a7 100644 --- a/contracts/cw-croncat/src/tasks.rs +++ b/contracts/cw-croncat/src/tasks.rs @@ -411,6 +411,7 @@ impl<'a> CwCroncat<'a> { }; Ok(Response::new() + .set_data(format!("task_hash {}", hash).into_bytes()) .add_attribute("method", "create_task") .add_attribute("slot_id", next_id.to_string()) .add_attribute("slot_kind", format!("{:?}", slot_kind)) From 9af9db6e4e0481898f0f9421045959b8b3979a5f Mon Sep 17 00:00:00 2001 From: Deveus Date: Thu, 15 Dec 2022 00:55:51 +0200 Subject: [PATCH 02/12] fix: checksum --- checksum | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checksum b/checksum index 36487034..1f2d424b 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -efc374eee9ede4a11ec6c344db13de10afdfd10510cb70f39611e2c67c20a58b cw_croncat.wasm -5863a5417a530690c765c9ca4f3943c96071b1ee7faecfc408fce01da08aec56 cw_rules.wasm +500f80325636853036a753570a7f50f4626ea6b601ba302167488fb3e8072a61 cw_croncat.wasm +38b2f5bf5a0b9db2ea2dbfeb9dcfa1c25cd1705df665e9d6f45ee5e2832a971c cw_rules.wasm From 0003e3136d2276f6050d949253df475b718d5a60 Mon Sep 17 00:00:00 2001 From: Deveus Date: Thu, 15 Dec 2022 01:16:29 +0200 Subject: [PATCH 03/12] fix: checksum --- checksum | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checksum b/checksum index 1f2d424b..f0ad4673 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -500f80325636853036a753570a7f50f4626ea6b601ba302167488fb3e8072a61 cw_croncat.wasm -38b2f5bf5a0b9db2ea2dbfeb9dcfa1c25cd1705df665e9d6f45ee5e2832a971c cw_rules.wasm +aa78f414bb3a10e445feb82ab6e5a3dc6c706d7e0532b83e74327e0ea935fb7e cw_croncat.wasm +5863a5417a530690c765c9ca4f3943c96071b1ee7faecfc408fce01da08aec56 cw_rules.wasm From 2021c48d1fac24fbee412cdbd24c404e5a1b9bc7 Mon Sep 17 00:00:00 2001 From: Deveus Date: Fri, 16 Dec 2022 08:48:34 +0200 Subject: [PATCH 04/12] fix: checksum conflict --- checksum | 5 ----- 1 file changed, 5 deletions(-) diff --git a/checksum b/checksum index 8646b07e..f0ad4673 100644 --- a/checksum +++ b/checksum @@ -1,7 +1,2 @@ -<<<<<<< HEAD aa78f414bb3a10e445feb82ab6e5a3dc6c706d7e0532b83e74327e0ea935fb7e cw_croncat.wasm 5863a5417a530690c765c9ca4f3943c96071b1ee7faecfc408fce01da08aec56 cw_rules.wasm -======= -de7f6716cf0380e7eaff2440d24dada99fe054aaf51e190b80c5a8ebf35c97d5 cw_croncat.wasm -de2d1a0c648e41760020dd261f818da085c358240059acf85128f60eb0e05db2 cw_rules.wasm ->>>>>>> main From 70594c48be7189fb126123d96293ad2389505f1b Mon Sep 17 00:00:00 2001 From: Deveus Date: Fri, 16 Dec 2022 16:11:40 +0200 Subject: [PATCH 05/12] fix: checksum --- checksum | 4 +- contracts/cw-croncat/src/contract.rs | 1 - contracts/cw-croncat/src/tasks.rs | 5 - contracts/cw-croncat/src/tests/tasks.rs | 52 - .../cw-croncat-core/schema/query_msg.json | 1337 +---------------- packages/cw-croncat-core/src/msg.rs | 5 +- .../cw-croncat-core/CwCroncatCore.client.ts | 17 - .../cw-croncat-core/CwCroncatCore.types.ts | 5 - 8 files changed, 23 insertions(+), 1403 deletions(-) diff --git a/checksum b/checksum index f0ad4673..fa506645 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -aa78f414bb3a10e445feb82ab6e5a3dc6c706d7e0532b83e74327e0ea935fb7e cw_croncat.wasm -5863a5417a530690c765c9ca4f3943c96071b1ee7faecfc408fce01da08aec56 cw_rules.wasm +a5b8881b2b365260939a6f9e59ac8d00f8ecb7b138ad2ff2d79cfa5c7dd2e4fc cw_croncat.wasm +de2d1a0c648e41760020dd261f818da085c358240059acf85128f60eb0e05db2 cw_rules.wasm diff --git a/contracts/cw-croncat/src/contract.rs b/contracts/cw-croncat/src/contract.rs index e05a3cf2..3945dd5f 100644 --- a/contracts/cw-croncat/src/contract.rs +++ b/contracts/cw-croncat/src/contract.rs @@ -201,7 +201,6 @@ impl<'a> CwCroncat<'a> { to_binary(&self.query_get_tasks_by_owner(deps, owner_id)?) } QueryMsg::GetTask { task_hash } => to_binary(&self.query_get_task(deps, task_hash)?), - QueryMsg::GetTaskHash { task } => to_binary(&self.query_get_task_hash(*task)?), QueryMsg::ValidateInterval { interval } => { to_binary(&self.query_validate_interval(interval)?) } diff --git a/contracts/cw-croncat/src/tasks.rs b/contracts/cw-croncat/src/tasks.rs index af5103a7..79e7d428 100644 --- a/contracts/cw-croncat/src/tasks.rs +++ b/contracts/cw-croncat/src/tasks.rs @@ -94,11 +94,6 @@ impl<'a> CwCroncat<'a> { Ok(res.map(Into::into)) } - /// Returns a hash computed by the input task data - pub(crate) fn query_get_task_hash(&self, task: Task) -> StdResult { - Ok(task.to_hash()) - } - /// Check if interval params are valid by attempting to parse pub(crate) fn query_validate_interval(&self, interval: Interval) -> StdResult { Ok(interval.is_valid()) diff --git a/contracts/cw-croncat/src/tests/tasks.rs b/contracts/cw-croncat/src/tests/tasks.rs index 7983bca1..e791d3d9 100644 --- a/contracts/cw-croncat/src/tests/tasks.rs +++ b/contracts/cw-croncat/src/tests/tasks.rs @@ -16,58 +16,6 @@ use cw_multi_test::Executor; use cw_rules_core::types::{CroncatQuery, HasBalanceGte}; use std::convert::TryInto; -#[test] -fn query_task_hash_success() { - let (app, cw_template_contract, _) = proper_instantiate(); - let contract_addr = cw_template_contract.addr(); - - let to_address = String::from("you"); - let amount = coins(1015, "earth"); - let bank = BankMsg::Send { to_address, amount }; - let msg: CosmosMsg = bank.clone().into(); - let version = ContractVersion { - version: "0.0.1".to_string(), - contract: "nobidy".to_string(), - }; - - let task = Task { - owner_id: Addr::unchecked("nobody".to_string()), - interval: Interval::Immediate, - boundary: BoundaryValidated { - start: None, - end: None, - }, - stop_on_fail: false, - total_deposit: GenericBalance { - native: coins(37, NATIVE_DENOM), - cw20: Default::default(), - }, - amount_for_one_task: Default::default(), - actions: vec![Action { - msg, - gas_limit: Some(150_000), - }], - queries: None, - transforms: None, - version: version.version, - }; - - // HASH CHECK! - let task_hash: String = app - .wrap() - .query_wasm_smart( - &contract_addr.clone(), - &QueryMsg::GetTaskHash { - task: Box::new(task), - }, - ) - .unwrap(); - assert_eq!( - "69217dd2b6334abe2544a12fcb89588f9cc5c62a298b8720706d9befa3d736d3", - task_hash - ); -} - #[test] fn query_validate_interval_success() { let (app, cw_template_contract, _) = proper_instantiate(); diff --git a/packages/cw-croncat-core/schema/query_msg.json b/packages/cw-croncat-core/schema/query_msg.json index 269736a3..bcf12e73 100644 --- a/packages/cw-croncat-core/schema/query_msg.json +++ b/packages/cw-croncat-core/schema/query_msg.json @@ -178,26 +178,6 @@ }, "additionalProperties": false }, - { - "type": "object", - "required": [ - "get_task_hash" - ], - "properties": { - "get_task_hash": { - "type": "object", - "required": [ - "task" - ], - "properties": { - "task": { - "$ref": "#/definitions/Task" - } - } - } - }, - "additionalProperties": false - }, { "type": "object", "required": [ @@ -304,753 +284,43 @@ } ], "definitions": { - "Action_for_Empty": { - "type": "object", - "required": [ - "msg" - ], - "properties": { - "gas_limit": { - "description": "The gas needed to safely process the execute msg", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "msg": { - "description": "Supported CosmosMsgs only!", - "allOf": [ - { - "$ref": "#/definitions/CosmosMsg_for_Empty" - } - ] - } - } - }, - "Addr": { - "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", - "type": "string" - }, - "Balance": { - "oneOf": [ - { - "type": "object", - "required": [ - "native" - ], - "properties": { - "native": { - "$ref": "#/definitions/NativeBalance" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "cw20" - ], - "properties": { - "cw20": { - "$ref": "#/definitions/Cw20CoinVerified" - } - }, - "additionalProperties": false - } - ] - }, - "BankMsg": { - "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", - "oneOf": [ - { - "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "send" - ], - "properties": { - "send": { - "type": "object", - "required": [ - "amount", - "to_address" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "to_address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", - "type": "object", - "required": [ - "burn" - ], - "properties": { - "burn": { - "type": "object", - "required": [ - "amount" - ], - "properties": { - "amount": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Binary": { - "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", - "type": "string" - }, - "BoundaryValidated": { - "type": "object", - "properties": { - "end": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "start": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - }, - "CheckOwnerOfNft": { - "type": "object", - "required": [ - "address", - "nft_address", - "token_id" - ], - "properties": { - "address": { - "type": "string" - }, - "nft_address": { - "type": "string" - }, - "token_id": { - "type": "string" - } - } - }, - "CheckProposalStatus": { - "type": "object", - "required": [ - "dao_address", - "proposal_id", - "status" - ], - "properties": { - "dao_address": { - "type": "string" - }, - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "status": { - "$ref": "#/definitions/Status" - } - } - }, - "Coin": { - "type": "object", - "required": [ - "amount", - "denom" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "denom": { - "type": "string" - } - } - }, - "CosmosMsg_for_Empty": { - "oneOf": [ - { - "type": "object", - "required": [ - "bank" - ], - "properties": { - "bank": { - "$ref": "#/definitions/BankMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "custom" - ], - "properties": { - "custom": { - "$ref": "#/definitions/Empty" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "staking" - ], - "properties": { - "staking": { - "$ref": "#/definitions/StakingMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "distribution" - ], - "properties": { - "distribution": { - "$ref": "#/definitions/DistributionMsg" - } - }, - "additionalProperties": false - }, - { - "description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", - "type": "object", - "required": [ - "stargate" - ], - "properties": { - "stargate": { - "type": "object", - "required": [ - "type_url", - "value" - ], - "properties": { - "type_url": { - "type": "string" - }, - "value": { - "$ref": "#/definitions/Binary" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "ibc" - ], - "properties": { - "ibc": { - "$ref": "#/definitions/IbcMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "wasm" - ], - "properties": { - "wasm": { - "$ref": "#/definitions/WasmMsg" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "gov" - ], - "properties": { - "gov": { - "$ref": "#/definitions/GovMsg" - } - }, - "additionalProperties": false - } - ] - }, - "CroncatQuery": { + "Interval": { + "description": "Defines the spacing of execution NOTES: - Block Height Based: Once, Immediate, Block - Timestamp Based: Cron - No Epoch support directly, advised to use block heights instead", "oneOf": [ { - "type": "object", - "required": [ - "query" - ], - "properties": { - "query": { - "type": "object", - "required": [ - "contract_addr", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "$ref": "#/definitions/Binary" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "has_balance_gte" - ], - "properties": { - "has_balance_gte": { - "$ref": "#/definitions/HasBalanceGte" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "check_owner_of_nft" - ], - "properties": { - "check_owner_of_nft": { - "$ref": "#/definitions/CheckOwnerOfNft" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "check_proposal_status" - ], - "properties": { - "check_proposal_status": { - "$ref": "#/definitions/CheckProposalStatus" - } - }, - "additionalProperties": false + "description": "For when this is a non-recurring future scheduled TXN", + "type": "string", + "enum": [ + "Once" + ] }, { - "type": "object", - "required": [ - "generic_query" - ], - "properties": { - "generic_query": { - "$ref": "#/definitions/GenericQuery" - } - }, - "additionalProperties": false + "description": "The ugly batch schedule type, in case you need to exceed single TXN gas limits, within fewest block(s)", + "type": "string", + "enum": [ + "Immediate" + ] }, { + "description": "Allows timing based on block intervals rather than timestamps", "type": "object", "required": [ - "smart_query" + "Block" ], "properties": { - "smart_query": { - "$ref": "#/definitions/SmartQueryHead" + "Block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 } }, "additionalProperties": false - } - ] - }, - "Cw20CoinVerified": { - "type": "object", - "required": [ - "address", - "amount" - ], - "properties": { - "address": { - "$ref": "#/definitions/Addr" }, - "amount": { - "$ref": "#/definitions/Uint128" - } - } - }, - "DistributionMsg": { - "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", - "oneOf": [ { - "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "description": "Crontab Spec String", "type": "object", "required": [ - "set_withdraw_address" - ], - "properties": { - "set_withdraw_address": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "description": "The `withdraw_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "withdraw_delegator_reward" - ], - "properties": { - "withdraw_delegator_reward": { - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "The `validator_address`", - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Empty": { - "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", - "type": "object" - }, - "GenericBalance": { - "type": "object", - "required": [ - "cw20", - "native" - ], - "properties": { - "cw20": { - "type": "array", - "items": { - "$ref": "#/definitions/Cw20CoinVerified" - } - }, - "native": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - } - }, - "GenericQuery": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "ordering", - "path_to_value", - "value" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "ordering": { - "$ref": "#/definitions/ValueOrdering" - }, - "path_to_value": { - "$ref": "#/definitions/PathToValue" - }, - "value": { - "$ref": "#/definitions/Binary" - } - } - }, - "GovMsg": { - "oneOf": [ - { - "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", - "type": "object", - "required": [ - "vote" - ], - "properties": { - "vote": { - "type": "object", - "required": [ - "proposal_id", - "vote" - ], - "properties": { - "proposal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "vote": { - "$ref": "#/definitions/VoteOption" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "HasBalanceGte": { - "type": "object", - "required": [ - "address", - "required_balance" - ], - "properties": { - "address": { - "type": "string" - }, - "required_balance": { - "$ref": "#/definitions/Balance" - } - } - }, - "IbcMsg": { - "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", - "oneOf": [ - { - "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", - "type": "object", - "required": [ - "transfer" - ], - "properties": { - "transfer": { - "type": "object", - "required": [ - "amount", - "channel_id", - "timeout", - "to_address" - ], - "properties": { - "amount": { - "description": "packet data only supports one coin https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", - "allOf": [ - { - "$ref": "#/definitions/Coin" - } - ] - }, - "channel_id": { - "description": "exisiting channel to send the tokens over", - "type": "string" - }, - "timeout": { - "description": "when packet times out, measured on remote chain", - "allOf": [ - { - "$ref": "#/definitions/IbcTimeout" - } - ] - }, - "to_address": { - "description": "address on the remote chain to receive these tokens", - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", - "type": "object", - "required": [ - "send_packet" - ], - "properties": { - "send_packet": { - "type": "object", - "required": [ - "channel_id", - "data", - "timeout" - ], - "properties": { - "channel_id": { - "type": "string" - }, - "data": { - "$ref": "#/definitions/Binary" - }, - "timeout": { - "description": "when packet times out, measured on remote chain", - "allOf": [ - { - "$ref": "#/definitions/IbcTimeout" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port", - "type": "object", - "required": [ - "close_channel" - ], - "properties": { - "close_channel": { - "type": "object", - "required": [ - "channel_id" - ], - "properties": { - "channel_id": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "IbcTimeout": { - "description": "In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set.", - "type": "object", - "properties": { - "block": { - "anyOf": [ - { - "$ref": "#/definitions/IbcTimeoutBlock" - }, - { - "type": "null" - } - ] - }, - "timestamp": { - "anyOf": [ - { - "$ref": "#/definitions/Timestamp" - }, - { - "type": "null" - } - ] - } - } - }, - "IbcTimeoutBlock": { - "description": "IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)", - "type": "object", - "required": [ - "height", - "revision" - ], - "properties": { - "height": { - "description": "block height after which the packet times out. the height within the given revision", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "revision": { - "description": "the version that the client is currently on (eg. after reseting the chain this could increment 1 as height drops to 0)", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - }, - "Interval": { - "description": "Defines the spacing of execution NOTES: - Block Height Based: Once, Immediate, Block - Timestamp Based: Cron - No Epoch support directly, advised to use block heights instead", - "oneOf": [ - { - "description": "For when this is a non-recurring future scheduled TXN", - "type": "string", - "enum": [ - "Once" - ] - }, - { - "description": "The ugly batch schedule type, in case you need to exceed single TXN gas limits, within fewest block(s)", - "type": "string", - "enum": [ - "Immediate" - ] - }, - { - "description": "Allows timing based on block intervals rather than timestamps", - "type": "object", - "required": [ - "Block" - ], - "properties": { - "Block": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - }, - { - "description": "Crontab Spec String", - "type": "object", - "required": [ - "Cron" + "Cron" ], "properties": { "Cron": { @@ -1060,573 +330,6 @@ "additionalProperties": false } ] - }, - "NativeBalance": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "PathToValue": { - "type": "array", - "items": { - "$ref": "#/definitions/ValueIndex" - } - }, - "SmartQueries": { - "type": "array", - "items": { - "$ref": "#/definitions/SmartQuery" - } - }, - "SmartQuery": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "path_to_msg_value", - "path_to_query_value" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "$ref": "#/definitions/Binary" - }, - "path_to_msg_value": { - "description": "Replace value inside this query", - "allOf": [ - { - "$ref": "#/definitions/PathToValue" - } - ] - }, - "path_to_query_value": { - "description": "Value passed to the next iteration", - "allOf": [ - { - "$ref": "#/definitions/PathToValue" - } - ] - } - } - }, - "SmartQueryHead": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "ordering", - "path_to_query_value", - "queries", - "value" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "First query without placeholder!", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "ordering": { - "$ref": "#/definitions/ValueOrdering" - }, - "path_to_query_value": { - "description": "Value from this message", - "allOf": [ - { - "$ref": "#/definitions/PathToValue" - } - ] - }, - "queries": { - "$ref": "#/definitions/SmartQueries" - }, - "value": { - "$ref": "#/definitions/Binary" - } - } - }, - "StakingMsg": { - "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", - "oneOf": [ - { - "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "delegate" - ], - "properties": { - "delegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "undelegate" - ], - "properties": { - "undelegate": { - "type": "object", - "required": [ - "amount", - "validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "redelegate" - ], - "properties": { - "redelegate": { - "type": "object", - "required": [ - "amount", - "dst_validator", - "src_validator" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Coin" - }, - "dst_validator": { - "type": "string" - }, - "src_validator": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] - }, - "Status": { - "oneOf": [ - { - "type": "string", - "enum": [ - "execution_failed" - ] - }, - { - "description": "The proposal is open for voting.", - "type": "string", - "enum": [ - "open" - ] - }, - { - "description": "The proposal has been rejected.", - "type": "string", - "enum": [ - "rejected" - ] - }, - { - "description": "The proposal has been passed but has not been executed.", - "type": "string", - "enum": [ - "passed" - ] - }, - { - "description": "The proposal has been passed and executed.", - "type": "string", - "enum": [ - "executed" - ] - }, - { - "description": "The proposal has failed or expired and has been closed. A proposal deposit refund has been issued if applicable.", - "type": "string", - "enum": [ - "closed" - ] - } - ] - }, - "Task": { - "type": "object", - "required": [ - "actions", - "amount_for_one_task", - "boundary", - "interval", - "owner_id", - "stop_on_fail", - "total_deposit", - "version" - ], - "properties": { - "actions": { - "description": "The cosmos message to call, if time or rules are met", - "type": "array", - "items": { - "$ref": "#/definitions/Action_for_Empty" - } - }, - "amount_for_one_task": { - "$ref": "#/definitions/GenericBalance" - }, - "boundary": { - "$ref": "#/definitions/BoundaryValidated" - }, - "interval": { - "description": "Scheduling definitions", - "allOf": [ - { - "$ref": "#/definitions/Interval" - } - ] - }, - "owner_id": { - "description": "Entity responsible for this task, can change task details", - "allOf": [ - { - "$ref": "#/definitions/Addr" - } - ] - }, - "queries": { - "description": "A prioritized list of messages that can be chained decision matrix required to complete before task action Rules MUST return the ResolverResponse type", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/CroncatQuery" - } - }, - "stop_on_fail": { - "description": "Defines if this task can continue until balance runs out", - "type": "boolean" - }, - "total_deposit": { - "description": "NOTE: Only tally native balance here, manager can maintain token/balances outside of tasks", - "allOf": [ - { - "$ref": "#/definitions/GenericBalance" - } - ] - }, - "transforms": { - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/Transform" - } - }, - "version": { - "type": "string" - } - } - }, - "Timestamp": { - "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", - "allOf": [ - { - "$ref": "#/definitions/Uint64" - } - ] - }, - "Transform": { - "type": "object", - "required": [ - "action_idx", - "action_path", - "query_idx", - "query_response_path" - ], - "properties": { - "action_idx": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "action_path": { - "$ref": "#/definitions/PathToValue" - }, - "query_idx": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "query_response_path": { - "$ref": "#/definitions/PathToValue" - } - } - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uint64": { - "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", - "type": "string" - }, - "ValueIndex": { - "oneOf": [ - { - "type": "object", - "required": [ - "key" - ], - "properties": { - "key": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "index" - ], - "properties": { - "index": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - ] - }, - "ValueOrdering": { - "type": "string", - "enum": [ - "unit_above", - "unit_above_equal", - "unit_below", - "unit_below_equal", - "equal", - "not_equal" - ] - }, - "VoteOption": { - "type": "string", - "enum": [ - "yes", - "no", - "abstain", - "no_with_veto" - ] - }, - "WasmMsg": { - "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", - "oneOf": [ - { - "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "execute" - ], - "properties": { - "execute": { - "type": "object", - "required": [ - "contract_addr", - "funds", - "msg" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "msg": { - "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "instantiate" - ], - "properties": { - "instantiate": { - "type": "object", - "required": [ - "code_id", - "funds", - "label", - "msg" - ], - "properties": { - "admin": { - "type": [ - "string", - "null" - ] - }, - "code_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "funds": { - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - }, - "label": { - "description": "A human-readbale label for the contract", - "type": "string" - }, - "msg": { - "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", - "type": "object", - "required": [ - "migrate" - ], - "properties": { - "migrate": { - "type": "object", - "required": [ - "contract_addr", - "msg", - "new_code_id" - ], - "properties": { - "contract_addr": { - "type": "string" - }, - "msg": { - "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", - "allOf": [ - { - "$ref": "#/definitions/Binary" - } - ] - }, - "new_code_id": { - "description": "the code_id of the new logic to place in the given contract", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "update_admin" - ], - "properties": { - "update_admin": { - "type": "object", - "required": [ - "admin", - "contract_addr" - ], - "properties": { - "admin": { - "type": "string" - }, - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", - "type": "object", - "required": [ - "clear_admin" - ], - "properties": { - "clear_admin": { - "type": "object", - "required": [ - "contract_addr" - ], - "properties": { - "contract_addr": { - "type": "string" - } - } - } - }, - "additionalProperties": false - } - ] } } } diff --git a/packages/cw-croncat-core/src/msg.rs b/packages/cw-croncat-core/src/msg.rs index 8e48b06d..a0a59b3b 100644 --- a/packages/cw-croncat-core/src/msg.rs +++ b/packages/cw-croncat-core/src/msg.rs @@ -125,7 +125,7 @@ pub enum ExecuteMsg { Tick {}, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { GetConfig {}, @@ -151,9 +151,6 @@ pub enum QueryMsg { GetTask { task_hash: String, }, - GetTaskHash { - task: Box, - }, ValidateInterval { interval: Interval, }, diff --git a/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts b/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts index befe9a5f..6d900467 100644 --- a/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts +++ b/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts @@ -46,11 +46,6 @@ export interface CwCroncatCoreReadOnlyInterface { }: { taskHash: string; }) => Promise; - getTaskHash: ({ - task - }: { - task: Task; - }) => Promise; validateInterval: ({ interval }: { @@ -91,7 +86,6 @@ export class CwCroncatCoreQueryClient implements CwCroncatCoreReadOnlyInterface this.getTasksWithQueries = this.getTasksWithQueries.bind(this); this.getTasksByOwner = this.getTasksByOwner.bind(this); this.getTask = this.getTask.bind(this); - this.getTaskHash = this.getTaskHash.bind(this); this.validateInterval = this.validateInterval.bind(this); this.getSlotHashes = this.getSlotHashes.bind(this); this.getSlotIds = this.getSlotIds.bind(this); @@ -186,17 +180,6 @@ export class CwCroncatCoreQueryClient implements CwCroncatCoreReadOnlyInterface } }); }; - getTaskHash = async ({ - task - }: { - task: Task; - }): Promise => { - return this.client.queryContractSmart(this.contractAddress, { - get_task_hash: { - task - } - }); - }; validateInterval = async ({ interval }: { diff --git a/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts b/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts index 8785d9c1..4d1f446e 100644 --- a/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts +++ b/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts @@ -605,11 +605,6 @@ export type QueryMsg = { task_hash: string; [k: string]: unknown; }; -} | { - get_task_hash: { - task: Task; - [k: string]: unknown; - }; } | { validate_interval: { interval: Interval; From 71bedd1f1b86b0f560abd81fa432fbc5c69adb84 Mon Sep 17 00:00:00 2001 From: Deveus Date: Fri, 16 Dec 2022 16:14:44 +0200 Subject: [PATCH 06/12] fix: codegen --- .../contracts/cw-croncat-core/CwCroncatCore.client.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js b/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js index e7ff693c..03df3ea9 100644 --- a/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js +++ b/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js @@ -76,13 +76,6 @@ class CwCroncatCoreQueryClient { } }); }); - this.getTaskHash = ({ task }) => __awaiter(this, void 0, void 0, function* () { - return this.client.queryContractSmart(this.contractAddress, { - get_task_hash: { - task - } - }); - }); this.validateInterval = ({ interval }) => __awaiter(this, void 0, void 0, function* () { return this.client.queryContractSmart(this.contractAddress, { validate_interval: { @@ -128,7 +121,6 @@ class CwCroncatCoreQueryClient { this.getTasksWithQueries = this.getTasksWithQueries.bind(this); this.getTasksByOwner = this.getTasksByOwner.bind(this); this.getTask = this.getTask.bind(this); - this.getTaskHash = this.getTaskHash.bind(this); this.validateInterval = this.validateInterval.bind(this); this.getSlotHashes = this.getSlotHashes.bind(this); this.getSlotIds = this.getSlotIds.bind(this); From c4969bb80b0cafd9d772e9f633789b768ec57ce7 Mon Sep 17 00:00:00 2001 From: Deveus Date: Sat, 17 Dec 2022 02:26:13 +0200 Subject: [PATCH 07/12] fix: bring get_hash back --- checksum | 2 +- contracts/cw-croncat/src/contract.rs | 1 + contracts/cw-croncat/src/tasks.rs | 5 +++ contracts/cw-croncat/src/tests/tasks.rs | 52 +++++++++++++++++++++++++ justfile | 3 ++ packages/cw-croncat-core/src/msg.rs | 5 ++- 6 files changed, 66 insertions(+), 2 deletions(-) diff --git a/checksum b/checksum index fa506645..597fc7a8 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -a5b8881b2b365260939a6f9e59ac8d00f8ecb7b138ad2ff2d79cfa5c7dd2e4fc cw_croncat.wasm +c2a55d2ae7f05aa3535c90fa9e8cae289ef23bc7d92163322ab5caf7bb084337 cw_croncat.wasm de2d1a0c648e41760020dd261f818da085c358240059acf85128f60eb0e05db2 cw_rules.wasm diff --git a/contracts/cw-croncat/src/contract.rs b/contracts/cw-croncat/src/contract.rs index 3945dd5f..62efb809 100644 --- a/contracts/cw-croncat/src/contract.rs +++ b/contracts/cw-croncat/src/contract.rs @@ -212,6 +212,7 @@ impl<'a> CwCroncat<'a> { QueryMsg::GetState { from_index, limit } => { to_binary(&self.get_state(deps, env, from_index, limit)?) } + QueryMsg::GetTaskHash { task } => to_binary(&self.query_get_task_hash(*task)?), } } diff --git a/contracts/cw-croncat/src/tasks.rs b/contracts/cw-croncat/src/tasks.rs index 79e7d428..af5103a7 100644 --- a/contracts/cw-croncat/src/tasks.rs +++ b/contracts/cw-croncat/src/tasks.rs @@ -94,6 +94,11 @@ impl<'a> CwCroncat<'a> { Ok(res.map(Into::into)) } + /// Returns a hash computed by the input task data + pub(crate) fn query_get_task_hash(&self, task: Task) -> StdResult { + Ok(task.to_hash()) + } + /// Check if interval params are valid by attempting to parse pub(crate) fn query_validate_interval(&self, interval: Interval) -> StdResult { Ok(interval.is_valid()) diff --git a/contracts/cw-croncat/src/tests/tasks.rs b/contracts/cw-croncat/src/tests/tasks.rs index e791d3d9..7983bca1 100644 --- a/contracts/cw-croncat/src/tests/tasks.rs +++ b/contracts/cw-croncat/src/tests/tasks.rs @@ -16,6 +16,58 @@ use cw_multi_test::Executor; use cw_rules_core::types::{CroncatQuery, HasBalanceGte}; use std::convert::TryInto; +#[test] +fn query_task_hash_success() { + let (app, cw_template_contract, _) = proper_instantiate(); + let contract_addr = cw_template_contract.addr(); + + let to_address = String::from("you"); + let amount = coins(1015, "earth"); + let bank = BankMsg::Send { to_address, amount }; + let msg: CosmosMsg = bank.clone().into(); + let version = ContractVersion { + version: "0.0.1".to_string(), + contract: "nobidy".to_string(), + }; + + let task = Task { + owner_id: Addr::unchecked("nobody".to_string()), + interval: Interval::Immediate, + boundary: BoundaryValidated { + start: None, + end: None, + }, + stop_on_fail: false, + total_deposit: GenericBalance { + native: coins(37, NATIVE_DENOM), + cw20: Default::default(), + }, + amount_for_one_task: Default::default(), + actions: vec![Action { + msg, + gas_limit: Some(150_000), + }], + queries: None, + transforms: None, + version: version.version, + }; + + // HASH CHECK! + let task_hash: String = app + .wrap() + .query_wasm_smart( + &contract_addr.clone(), + &QueryMsg::GetTaskHash { + task: Box::new(task), + }, + ) + .unwrap(); + assert_eq!( + "69217dd2b6334abe2544a12fcb89588f9cc5c62a298b8720706d9befa3d736d3", + task_hash + ); +} + #[test] fn query_validate_interval_success() { let (app, cw_template_contract, _) = proper_instantiate(); diff --git a/justfile b/justfile index 315885e4..7790c230 100644 --- a/justfile +++ b/justfile @@ -40,6 +40,9 @@ download-deps: wget https://github.com/CosmWasm/cw-plus/releases/latest/download/cw20_base.wasm -O artifacts/cw20_base.wasm # TODO?: test dao-contracts +all: build test check optimize checksum + print "Done!\n"; + gas-benchmark: juno-local download-deps optimize #!/usr/bin/env bash sleep 1 diff --git a/packages/cw-croncat-core/src/msg.rs b/packages/cw-croncat-core/src/msg.rs index a0a59b3b..8e48b06d 100644 --- a/packages/cw-croncat-core/src/msg.rs +++ b/packages/cw-croncat-core/src/msg.rs @@ -125,7 +125,7 @@ pub enum ExecuteMsg { Tick {}, } -#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { GetConfig {}, @@ -151,6 +151,9 @@ pub enum QueryMsg { GetTask { task_hash: String, }, + GetTaskHash { + task: Box, + }, ValidateInterval { interval: Interval, }, From 46e112a7bcf1c40555bb0107a747239423f2b46f Mon Sep 17 00:00:00 2001 From: Deveus Date: Sat, 17 Dec 2022 02:42:08 +0200 Subject: [PATCH 08/12] fix: types --- justfile | 4 +- .../cw-croncat-core/schema/query_msg.json | 1341 ++++++++++++++++- 2 files changed, 1321 insertions(+), 24 deletions(-) diff --git a/justfile b/justfile index 7790c230..a527da86 100644 --- a/justfile +++ b/justfile @@ -40,8 +40,8 @@ download-deps: wget https://github.com/CosmWasm/cw-plus/releases/latest/download/cw20_base.wasm -O artifacts/cw20_base.wasm # TODO?: test dao-contracts -all: build test check optimize checksum - print "Done!\n"; +all: build test check schema optimize checksum + gas-benchmark: juno-local download-deps optimize #!/usr/bin/env bash diff --git a/packages/cw-croncat-core/schema/query_msg.json b/packages/cw-croncat-core/schema/query_msg.json index bcf12e73..269736a3 100644 --- a/packages/cw-croncat-core/schema/query_msg.json +++ b/packages/cw-croncat-core/schema/query_msg.json @@ -178,6 +178,26 @@ }, "additionalProperties": false }, + { + "type": "object", + "required": [ + "get_task_hash" + ], + "properties": { + "get_task_hash": { + "type": "object", + "required": [ + "task" + ], + "properties": { + "task": { + "$ref": "#/definitions/Task" + } + } + } + }, + "additionalProperties": false + }, { "type": "object", "required": [ @@ -284,47 +304,1324 @@ } ], "definitions": { - "Interval": { - "description": "Defines the spacing of execution NOTES: - Block Height Based: Once, Immediate, Block - Timestamp Based: Cron - No Epoch support directly, advised to use block heights instead", + "Action_for_Empty": { + "type": "object", + "required": [ + "msg" + ], + "properties": { + "gas_limit": { + "description": "The gas needed to safely process the execute msg", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + }, + "msg": { + "description": "Supported CosmosMsgs only!", + "allOf": [ + { + "$ref": "#/definitions/CosmosMsg_for_Empty" + } + ] + } + } + }, + "Addr": { + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", + "type": "string" + }, + "Balance": { "oneOf": [ { - "description": "For when this is a non-recurring future scheduled TXN", - "type": "string", - "enum": [ - "Once" - ] + "type": "object", + "required": [ + "native" + ], + "properties": { + "native": { + "$ref": "#/definitions/NativeBalance" + } + }, + "additionalProperties": false }, { - "description": "The ugly batch schedule type, in case you need to exceed single TXN gas limits, within fewest block(s)", - "type": "string", - "enum": [ - "Immediate" - ] + "type": "object", + "required": [ + "cw20" + ], + "properties": { + "cw20": { + "$ref": "#/definitions/Cw20CoinVerified" + } + }, + "additionalProperties": false + } + ] + }, + "BankMsg": { + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "oneOf": [ + { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28). `from_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "send" + ], + "properties": { + "send": { + "type": "object", + "required": [ + "amount", + "to_address" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "to_address": { + "type": "string" + } + } + } + }, + "additionalProperties": false }, { - "description": "Allows timing based on block intervals rather than timestamps", + "description": "This will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.", "type": "object", "required": [ - "Block" + "burn" ], "properties": { - "Block": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 + "burn": { + "type": "object", + "required": [ + "amount" + ], + "properties": { + "amount": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", + "type": "string" + }, + "BoundaryValidated": { + "type": "object", + "properties": { + "end": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + }, + "start": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + }, + "CheckOwnerOfNft": { + "type": "object", + "required": [ + "address", + "nft_address", + "token_id" + ], + "properties": { + "address": { + "type": "string" + }, + "nft_address": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + }, + "CheckProposalStatus": { + "type": "object", + "required": [ + "dao_address", + "proposal_id", + "status" + ], + "properties": { + "dao_address": { + "type": "string" + }, + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "status": { + "$ref": "#/definitions/Status" + } + } + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CosmosMsg_for_Empty": { + "oneOf": [ + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/definitions/BankMsg" } }, "additionalProperties": false }, { - "description": "Crontab Spec String", "type": "object", "required": [ - "Cron" + "custom" ], "properties": { - "Cron": { - "type": "string" + "custom": { + "$ref": "#/definitions/Empty" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "staking" + ], + "properties": { + "staking": { + "$ref": "#/definitions/StakingMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "distribution" + ], + "properties": { + "distribution": { + "$ref": "#/definitions/DistributionMsg" + } + }, + "additionalProperties": false + }, + { + "description": "A Stargate message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "object", + "required": [ + "stargate" + ], + "properties": { + "stargate": { + "type": "object", + "required": [ + "type_url", + "value" + ], + "properties": { + "type_url": { + "type": "string" + }, + "value": { + "$ref": "#/definitions/Binary" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "ibc" + ], + "properties": { + "ibc": { + "$ref": "#/definitions/IbcMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "wasm" + ], + "properties": { + "wasm": { + "$ref": "#/definitions/WasmMsg" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "gov" + ], + "properties": { + "gov": { + "$ref": "#/definitions/GovMsg" + } + }, + "additionalProperties": false + } + ] + }, + "CroncatQuery": { + "oneOf": [ + { + "type": "object", + "required": [ + "query" + ], + "properties": { + "query": { + "type": "object", + "required": [ + "contract_addr", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "$ref": "#/definitions/Binary" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "has_balance_gte" + ], + "properties": { + "has_balance_gte": { + "$ref": "#/definitions/HasBalanceGte" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "check_owner_of_nft" + ], + "properties": { + "check_owner_of_nft": { + "$ref": "#/definitions/CheckOwnerOfNft" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "check_proposal_status" + ], + "properties": { + "check_proposal_status": { + "$ref": "#/definitions/CheckProposalStatus" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "generic_query" + ], + "properties": { + "generic_query": { + "$ref": "#/definitions/GenericQuery" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "smart_query" + ], + "properties": { + "smart_query": { + "$ref": "#/definitions/SmartQueryHead" + } + }, + "additionalProperties": false + } + ] + }, + "Cw20CoinVerified": { + "type": "object", + "required": [ + "address", + "amount" + ], + "properties": { + "address": { + "$ref": "#/definitions/Addr" + }, + "amount": { + "$ref": "#/definitions/Uint128" + } + } + }, + "DistributionMsg": { + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "set_withdraw_address" + ], + "properties": { + "set_withdraw_address": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "description": "The `withdraw_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "withdraw_delegator_reward" + ], + "properties": { + "withdraw_delegator_reward": { + "type": "object", + "required": [ + "validator" + ], + "properties": { + "validator": { + "description": "The `validator_address`", + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "GenericBalance": { + "type": "object", + "required": [ + "cw20", + "native" + ], + "properties": { + "cw20": { + "type": "array", + "items": { + "$ref": "#/definitions/Cw20CoinVerified" + } + }, + "native": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + }, + "GenericQuery": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "ordering", + "path_to_value", + "value" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "$ref": "#/definitions/Binary" + }, + "ordering": { + "$ref": "#/definitions/ValueOrdering" + }, + "path_to_value": { + "$ref": "#/definitions/PathToValue" + }, + "value": { + "$ref": "#/definitions/Binary" + } + } + }, + "GovMsg": { + "oneOf": [ + { + "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", + "type": "object", + "required": [ + "vote" + ], + "properties": { + "vote": { + "type": "object", + "required": [ + "proposal_id", + "vote" + ], + "properties": { + "proposal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "vote": { + "$ref": "#/definitions/VoteOption" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "HasBalanceGte": { + "type": "object", + "required": [ + "address", + "required_balance" + ], + "properties": { + "address": { + "type": "string" + }, + "required_balance": { + "$ref": "#/definitions/Balance" + } + } + }, + "IbcMsg": { + "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", + "oneOf": [ + { + "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", + "type": "object", + "required": [ + "transfer" + ], + "properties": { + "transfer": { + "type": "object", + "required": [ + "amount", + "channel_id", + "timeout", + "to_address" + ], + "properties": { + "amount": { + "description": "packet data only supports one coin https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", + "allOf": [ + { + "$ref": "#/definitions/Coin" + } + ] + }, + "channel_id": { + "description": "exisiting channel to send the tokens over", + "type": "string" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + }, + "to_address": { + "description": "address on the remote chain to receive these tokens", + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", + "type": "object", + "required": [ + "send_packet" + ], + "properties": { + "send_packet": { + "type": "object", + "required": [ + "channel_id", + "data", + "timeout" + ], + "properties": { + "channel_id": { + "type": "string" + }, + "data": { + "$ref": "#/definitions/Binary" + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "allOf": [ + { + "$ref": "#/definitions/IbcTimeout" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port", + "type": "object", + "required": [ + "close_channel" + ], + "properties": { + "close_channel": { + "type": "object", + "required": [ + "channel_id" + ], + "properties": { + "channel_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "IbcTimeout": { + "description": "In IBC each package must set at least one type of timeout: the timestamp or the block height. Using this rather complex enum instead of two timeout fields we ensure that at least one timeout is set.", + "type": "object", + "properties": { + "block": { + "anyOf": [ + { + "$ref": "#/definitions/IbcTimeoutBlock" + }, + { + "type": "null" + } + ] + }, + "timestamp": { + "anyOf": [ + { + "$ref": "#/definitions/Timestamp" + }, + { + "type": "null" + } + ] + } + } + }, + "IbcTimeoutBlock": { + "description": "IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)", + "type": "object", + "required": [ + "height", + "revision" + ], + "properties": { + "height": { + "description": "block height after which the packet times out. the height within the given revision", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "revision": { + "description": "the version that the client is currently on (eg. after reseting the chain this could increment 1 as height drops to 0)", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + }, + "Interval": { + "description": "Defines the spacing of execution NOTES: - Block Height Based: Once, Immediate, Block - Timestamp Based: Cron - No Epoch support directly, advised to use block heights instead", + "oneOf": [ + { + "description": "For when this is a non-recurring future scheduled TXN", + "type": "string", + "enum": [ + "Once" + ] + }, + { + "description": "The ugly batch schedule type, in case you need to exceed single TXN gas limits, within fewest block(s)", + "type": "string", + "enum": [ + "Immediate" + ] + }, + { + "description": "Allows timing based on block intervals rather than timestamps", + "type": "object", + "required": [ + "Block" + ], + "properties": { + "Block": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "Crontab Spec String", + "type": "object", + "required": [ + "Cron" + ], + "properties": { + "Cron": { + "type": "string" + } + }, + "additionalProperties": false + } + ] + }, + "NativeBalance": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "PathToValue": { + "type": "array", + "items": { + "$ref": "#/definitions/ValueIndex" + } + }, + "SmartQueries": { + "type": "array", + "items": { + "$ref": "#/definitions/SmartQuery" + } + }, + "SmartQuery": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "path_to_msg_value", + "path_to_query_value" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "$ref": "#/definitions/Binary" + }, + "path_to_msg_value": { + "description": "Replace value inside this query", + "allOf": [ + { + "$ref": "#/definitions/PathToValue" + } + ] + }, + "path_to_query_value": { + "description": "Value passed to the next iteration", + "allOf": [ + { + "$ref": "#/definitions/PathToValue" + } + ] + } + } + }, + "SmartQueryHead": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "ordering", + "path_to_query_value", + "queries", + "value" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "First query without placeholder!", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "ordering": { + "$ref": "#/definitions/ValueOrdering" + }, + "path_to_query_value": { + "description": "Value from this message", + "allOf": [ + { + "$ref": "#/definitions/PathToValue" + } + ] + }, + "queries": { + "$ref": "#/definitions/SmartQueries" + }, + "value": { + "$ref": "#/definitions/Binary" + } + } + }, + "StakingMsg": { + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "oneOf": [ + { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "delegate" + ], + "properties": { + "delegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "undelegate" + ], + "properties": { + "undelegate": { + "type": "object", + "required": [ + "amount", + "validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105). `delegator_address` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "redelegate" + ], + "properties": { + "redelegate": { + "type": "object", + "required": [ + "amount", + "dst_validator", + "src_validator" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Coin" + }, + "dst_validator": { + "type": "string" + }, + "src_validator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] + }, + "Status": { + "oneOf": [ + { + "type": "string", + "enum": [ + "execution_failed" + ] + }, + { + "description": "The proposal is open for voting.", + "type": "string", + "enum": [ + "open" + ] + }, + { + "description": "The proposal has been rejected.", + "type": "string", + "enum": [ + "rejected" + ] + }, + { + "description": "The proposal has been passed but has not been executed.", + "type": "string", + "enum": [ + "passed" + ] + }, + { + "description": "The proposal has been passed and executed.", + "type": "string", + "enum": [ + "executed" + ] + }, + { + "description": "The proposal has failed or expired and has been closed. A proposal deposit refund has been issued if applicable.", + "type": "string", + "enum": [ + "closed" + ] + } + ] + }, + "Task": { + "type": "object", + "required": [ + "actions", + "amount_for_one_task", + "boundary", + "interval", + "owner_id", + "stop_on_fail", + "total_deposit", + "version" + ], + "properties": { + "actions": { + "description": "The cosmos message to call, if time or rules are met", + "type": "array", + "items": { + "$ref": "#/definitions/Action_for_Empty" + } + }, + "amount_for_one_task": { + "$ref": "#/definitions/GenericBalance" + }, + "boundary": { + "$ref": "#/definitions/BoundaryValidated" + }, + "interval": { + "description": "Scheduling definitions", + "allOf": [ + { + "$ref": "#/definitions/Interval" + } + ] + }, + "owner_id": { + "description": "Entity responsible for this task, can change task details", + "allOf": [ + { + "$ref": "#/definitions/Addr" + } + ] + }, + "queries": { + "description": "A prioritized list of messages that can be chained decision matrix required to complete before task action Rules MUST return the ResolverResponse type", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/CroncatQuery" + } + }, + "stop_on_fail": { + "description": "Defines if this task can continue until balance runs out", + "type": "boolean" + }, + "total_deposit": { + "description": "NOTE: Only tally native balance here, manager can maintain token/balances outside of tasks", + "allOf": [ + { + "$ref": "#/definitions/GenericBalance" + } + ] + }, + "transforms": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Transform" + } + }, + "version": { + "type": "string" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Transform": { + "type": "object", + "required": [ + "action_idx", + "action_path", + "query_idx", + "query_response_path" + ], + "properties": { + "action_idx": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "action_path": { + "$ref": "#/definitions/PathToValue" + }, + "query_idx": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "query_response_path": { + "$ref": "#/definitions/PathToValue" + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + }, + "ValueIndex": { + "oneOf": [ + { + "type": "object", + "required": [ + "key" + ], + "properties": { + "key": { + "type": "string" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "index" + ], + "properties": { + "index": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + } + ] + }, + "ValueOrdering": { + "type": "string", + "enum": [ + "unit_above", + "unit_above_equal", + "unit_below", + "unit_below_equal", + "equal", + "not_equal" + ] + }, + "VoteOption": { + "type": "string", + "enum": [ + "yes", + "no", + "abstain", + "no_with_veto" + ] + }, + "WasmMsg": { + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "oneOf": [ + { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "execute" + ], + "properties": { + "execute": { + "type": "object", + "required": [ + "contract_addr", + "funds", + "msg" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.16.0-alpha1/x/wasm/internal/types/tx.proto#L47-L61). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "instantiate" + ], + "properties": { + "instantiate": { + "type": "object", + "required": [ + "code_id", + "funds", + "label", + "msg" + ], + "properties": { + "admin": { + "type": [ + "string", + "null" + ] + }, + "code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "funds": { + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "label": { + "description": "A human-readbale label for the contract", + "type": "string" + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.", + "type": "object", + "required": [ + "migrate" + ], + "properties": { + "migrate": { + "type": "object", + "required": [ + "contract_addr", + "msg", + "new_code_id" + ], + "properties": { + "contract_addr": { + "type": "string" + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "allOf": [ + { + "$ref": "#/definitions/Binary" + } + ] + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "update_admin" + ], + "properties": { + "update_admin": { + "type": "object", + "required": [ + "admin", + "contract_addr" + ], + "properties": { + "admin": { + "type": "string" + }, + "contract_addr": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract.", + "type": "object", + "required": [ + "clear_admin" + ], + "properties": { + "clear_admin": { + "type": "object", + "required": [ + "contract_addr" + ], + "properties": { + "contract_addr": { + "type": "string" + } + } } }, "additionalProperties": false From 3ba8537c95efe5da7ef177d82521d27b013ee011 Mon Sep 17 00:00:00 2001 From: Deveus Date: Sat, 17 Dec 2022 03:07:50 +0200 Subject: [PATCH 09/12] fix: types --- justfile | 14 ++++++++++---- .../cw-croncat-core/CwCroncatCore.client.ts | 17 +++++++++++++++++ .../cw-croncat-core/CwCroncatCore.types.ts | 5 +++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/justfile b/justfile index a527da86..b14228c7 100644 --- a/justfile +++ b/justfile @@ -1,17 +1,23 @@ test_addrs := env_var_or_default('TEST_ADDR', `jq -r '.[].address' ci/test_accounts.json | tr '\n' ' '`) set export check: - cargo fmt && cargo clippy -- -D warnings + cargo fmt --all && cargo clippy -- -D warnings test: ./scripts/test.sh build: - ./scripts/build.sh + #!/bin/bash + cargo build --release --lib --target wasm32-unknown-unknown deploy: ./scripts/uni-testnet/start.sh -c -w checksum: ./scripts/update-checksum.sh schema: ./scripts/schema.sh +gen: + #!/usr/bin/env bash + cd typescript + yarn --cwd ./typescript install --frozen-lockfile + yarn --cwd ./typescript codegen juno-local: docker kill cosmwasm || true docker volume rm -f junod_data @@ -40,8 +46,8 @@ download-deps: wget https://github.com/CosmWasm/cw-plus/releases/latest/download/cw20_base.wasm -O artifacts/cw20_base.wasm # TODO?: test dao-contracts -all: build test check schema optimize checksum - +all: build test check schema gen optimize checksum + #!/usr/bin/env bash gas-benchmark: juno-local download-deps optimize #!/usr/bin/env bash diff --git a/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts b/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts index 6d900467..befe9a5f 100644 --- a/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts +++ b/typescript/contracts/cw-croncat-core/CwCroncatCore.client.ts @@ -46,6 +46,11 @@ export interface CwCroncatCoreReadOnlyInterface { }: { taskHash: string; }) => Promise; + getTaskHash: ({ + task + }: { + task: Task; + }) => Promise; validateInterval: ({ interval }: { @@ -86,6 +91,7 @@ export class CwCroncatCoreQueryClient implements CwCroncatCoreReadOnlyInterface this.getTasksWithQueries = this.getTasksWithQueries.bind(this); this.getTasksByOwner = this.getTasksByOwner.bind(this); this.getTask = this.getTask.bind(this); + this.getTaskHash = this.getTaskHash.bind(this); this.validateInterval = this.validateInterval.bind(this); this.getSlotHashes = this.getSlotHashes.bind(this); this.getSlotIds = this.getSlotIds.bind(this); @@ -180,6 +186,17 @@ export class CwCroncatCoreQueryClient implements CwCroncatCoreReadOnlyInterface } }); }; + getTaskHash = async ({ + task + }: { + task: Task; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + get_task_hash: { + task + } + }); + }; validateInterval = async ({ interval }: { diff --git a/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts b/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts index 4d1f446e..8785d9c1 100644 --- a/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts +++ b/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts @@ -605,6 +605,11 @@ export type QueryMsg = { task_hash: string; [k: string]: unknown; }; +} | { + get_task_hash: { + task: Task; + [k: string]: unknown; + }; } | { validate_interval: { interval: Interval; From 260ee9f9cb09f8d678ddbe6ba798c1a1d34532d8 Mon Sep 17 00:00:00 2001 From: Deveus Date: Sat, 17 Dec 2022 03:12:34 +0200 Subject: [PATCH 10/12] fix: types --- justfile | 14 +++++++++++--- .../cw-croncat-core/CwCroncatCore.client.js | 8 ++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/justfile b/justfile index b14228c7..3acd01b8 100644 --- a/justfile +++ b/justfile @@ -3,16 +3,24 @@ set export check: cargo fmt --all && cargo clippy -- -D warnings test: - ./scripts/test.sh + #!/bin/bash + set -e + export RUSTFLAGS='-C link-arg=-s' + cargo unit-test + cargo wasm build: #!/bin/bash cargo build --release --lib --target wasm32-unknown-unknown deploy: ./scripts/uni-testnet/start.sh -c -w checksum: - ./scripts/update-checksum.sh + #!/bin/bash + cat artifacts/checksums.txt | grep -e cw_croncat.wasm -e cw_rules.wasm > checksum schema: - ./scripts/schema.sh + #!/bin/bash + set -e + cargo run --example schema + cargo run --example rules_schema gen: #!/usr/bin/env bash cd typescript diff --git a/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js b/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js index 03df3ea9..e7ff693c 100644 --- a/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js +++ b/typescript/build/contracts/cw-croncat-core/CwCroncatCore.client.js @@ -76,6 +76,13 @@ class CwCroncatCoreQueryClient { } }); }); + this.getTaskHash = ({ task }) => __awaiter(this, void 0, void 0, function* () { + return this.client.queryContractSmart(this.contractAddress, { + get_task_hash: { + task + } + }); + }); this.validateInterval = ({ interval }) => __awaiter(this, void 0, void 0, function* () { return this.client.queryContractSmart(this.contractAddress, { validate_interval: { @@ -121,6 +128,7 @@ class CwCroncatCoreQueryClient { this.getTasksWithQueries = this.getTasksWithQueries.bind(this); this.getTasksByOwner = this.getTasksByOwner.bind(this); this.getTask = this.getTask.bind(this); + this.getTaskHash = this.getTaskHash.bind(this); this.validateInterval = this.validateInterval.bind(this); this.getSlotHashes = this.getSlotHashes.bind(this); this.getSlotIds = this.getSlotIds.bind(this); From 5e2424d785d080c893604ec35d8461dd688250dd Mon Sep 17 00:00:00 2001 From: Deveus Date: Sun, 18 Dec 2022 00:13:38 +0200 Subject: [PATCH 11/12] fix: minor fix --- checksum | 2 +- contracts/cw-croncat/src/tasks.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/checksum b/checksum index 597fc7a8..334d6949 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -c2a55d2ae7f05aa3535c90fa9e8cae289ef23bc7d92163322ab5caf7bb084337 cw_croncat.wasm +b36530635cc8449969b10873825144a3c15fc45aa72f435d1f04f2132948ae55 cw_croncat.wasm de2d1a0c648e41760020dd261f818da085c358240059acf85128f60eb0e05db2 cw_rules.wasm diff --git a/contracts/cw-croncat/src/tasks.rs b/contracts/cw-croncat/src/tasks.rs index af5103a7..9d2769ae 100644 --- a/contracts/cw-croncat/src/tasks.rs +++ b/contracts/cw-croncat/src/tasks.rs @@ -411,7 +411,7 @@ impl<'a> CwCroncat<'a> { }; Ok(Response::new() - .set_data(format!("task_hash {}", hash).into_bytes()) + .set_data(hash.as_bytes()) .add_attribute("method", "create_task") .add_attribute("slot_id", next_id.to_string()) .add_attribute("slot_kind", format!("{:?}", slot_kind)) From 0795183fba1e398987f79bf167a32582c45297c7 Mon Sep 17 00:00:00 2001 From: Deveus Date: Sun, 18 Dec 2022 00:27:35 +0200 Subject: [PATCH 12/12] fix: checksum --- checksum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checksum b/checksum index 597fc7a8..f311d653 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -c2a55d2ae7f05aa3535c90fa9e8cae289ef23bc7d92163322ab5caf7bb084337 cw_croncat.wasm +e841b8f67c8209ade26674edd432bb1d7dc9dcaa470651ebf379c62d41c294c8 cw_croncat.wasm de2d1a0c648e41760020dd261f818da085c358240059acf85128f60eb0e05db2 cw_rules.wasm