Skip to content

Commit

Permalink
feat(cw-storage): add ObjectData query
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamel committed Feb 23, 2023
1 parent f64bed1 commit a022a00
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions contracts/cw-storage/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum ExecuteMsg {
/// The object is referenced by the hash of its content and this value is returned.
/// If the object is already stored, this is a no-op.
/// If pin is true, the object is pinned for the sender.
StoreObject { object: Binary, pin: bool },
StoreObject { data: Binary, pin: bool },

/// # ForgetObject
/// ForgetObject first unpin the object from the bucket for the considered sender, then remove
Expand All @@ -51,18 +51,18 @@ pub enum ExecuteMsg {
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
/// # Object
/// Object returns the object information with the given id.
#[returns(ObjectResponse)]
Object {
/// # ObjectInfo
/// ObjectInfo returns the object information with the given id.
#[returns(ObjectInfoResponse)]
ObjectInfo {
/// The id of the object to get.
id: ObjectId,
},

/// # Objects
/// Objects returns the list of objects in the bucket with support for pagination.
#[returns(ObjectsResponse)]
Objects {
/// # ObjectsInfo
/// ObjectsInfo returns the list of objects in the bucket with support for pagination.
#[returns(ObjectsInfoResponse)]
ObjectsInfo {
/// The owner of the objects to get.
address: Option<String>,
/// The number of objects to return.
Expand All @@ -71,6 +71,14 @@ pub enum QueryMsg {
after: Option<Cursor>,
},

/// # ObjectData
/// ObjectData returns the content of the object with the given id.
#[returns(Binary)]
ObjectData {
/// The id of the object to get.
id: ObjectId,
},

/// # ObjectPins
/// ObjectPins returns the list of addresses that pinned the object with the given id with
/// support for pagination.
Expand All @@ -95,22 +103,22 @@ pub struct PageInfo {
pub end_cursor: Cursor,
}

/// # ObjectResponse
/// ObjectResponse is the response of the GetObject query.
/// # ObjectInfoResponse
/// ObjectInfoResponse is the response of the ObjectInfo query.
#[cw_serde]
pub struct ObjectResponse {
pub struct ObjectInfoResponse {
pub id: ObjectId,
pub owner: String,
pub is_pinned: bool,
pub size: Uint128,
}

/// # ObjectsResponse
/// GetObjectsResponse is the response of the GetObjects query.
/// # ObjectsInfoResponse
/// ObjectsInfoResponse is the response of the ObjectsInfo query.
#[cw_serde]
pub struct ObjectsResponse {
pub struct ObjectsInfoResponse {
/// The list of objects in the bucket.
pub data: Vec<ObjectResponse>,
pub data: Vec<ObjectInfoResponse>,
pub page_info: PageInfo,
}

Expand Down

0 comments on commit a022a00

Please sign in to comment.