Skip to content

Commit

Permalink
feat(storage): create bucket state
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Feb 24, 2023
1 parent bf06a6d commit 53e2b8c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
16 changes: 1 addition & 15 deletions contracts/cw-storage/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
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;

/// 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<Uint128>,
/// The maximum number of objects in the bucket.
pub max_objects: Option<Uint128>,
/// The maximum size of the objects in the bucket.
pub max_object_size: Option<Uint128>,
/// The maximum number of pins in the bucket for an object.
pub max_object_pins: Option<Uint128>,
}

/// Instantiate messages
#[cw_serde]
pub struct InstantiateMsg {
Expand Down
30 changes: 30 additions & 0 deletions contracts/cw-storage/src/state.rs
Original file line number Diff line number Diff line change
@@ -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<Uint128>,
/// The maximum number of objects in the bucket.
pub max_objects: Option<Uint128>,
/// The maximum size of the objects in the bucket.
pub max_object_size: Option<Uint128>,
/// The maximum number of pins in the bucket for an object.
pub max_object_pins: Option<Uint128>,
}

pub const BUCKET: Item<'_, Bucket> = Item::new("bucket");

0 comments on commit 53e2b8c

Please sign in to comment.