diff --git a/contracts/cw-storage/src/msg.rs b/contracts/cw-storage/src/msg.rs index bdd1d0f2..536b3048 100644 --- a/contracts/cw-storage/src/msg.rs +++ b/contracts/cw-storage/src/msg.rs @@ -1,6 +1,7 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::Binary; use cosmwasm_std::Uint128; +use crate::state::BucketLimits; /// ObjectId is the type of identifier of an object in the bucket. type ObjectId = String; @@ -8,21 +9,6 @@ type ObjectId = String; /// Cursor is the opaque type of cursor used for pagination. type Cursor = String; -/// BucketLimits is the type of the limits of a bucket. -/// -/// The limits are optional and if not set, there is no limit. -#[cw_serde] -pub struct BucketLimits { - /// The maximum total size of the objects in the bucket. - pub max_total_size: Option, - /// The maximum number of objects in the bucket. - pub max_objects: Option, - /// The maximum size of the objects in the bucket. - pub max_object_size: Option, - /// The maximum number of pins in the bucket for an object. - pub max_object_pins: Option, -} - /// Instantiate messages #[cw_serde] pub struct InstantiateMsg { diff --git a/contracts/cw-storage/src/state.rs b/contracts/cw-storage/src/state.rs index 8b137891..8e787a8e 100644 --- a/contracts/cw-storage/src/state.rs +++ b/contracts/cw-storage/src/state.rs @@ -1 +1,31 @@ +use schemars::JsonSchema; +use cosmwasm_std::Uint128; +use cw_storage_plus::Item; +use serde::{Deserialize, Serialize}; +use cosmwasm_schema::cw_serde; +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct Bucket { + /// The name of the bucket. + pub name: String, + /// The limits of the bucket. + pub limits: BucketLimits, +} + +/// BucketLimits is the type of the limits of a bucket. +/// +/// The limits are optional and if not set, there is no limit. +#[cw_serde] +#[derive(Eq)] +pub struct BucketLimits { + /// The maximum total size of the objects in the bucket. + pub max_total_size: Option, + /// The maximum number of objects in the bucket. + pub max_objects: Option, + /// The maximum size of the objects in the bucket. + pub max_object_size: Option, + /// The maximum number of pins in the bucket for an object. + pub max_object_pins: Option, +} + +pub const BUCKET: Item<'_, Bucket> = Item::new("bucket");