From a022a00435bf65d015f4c720453d70b58571cf07 Mon Sep 17 00:00:00 2001 From: ccamel Date: Thu, 23 Feb 2023 13:20:56 +0100 Subject: [PATCH] feat(cw-storage): add ObjectData query --- contracts/cw-storage/src/msg.rs | 40 ++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/contracts/cw-storage/src/msg.rs b/contracts/cw-storage/src/msg.rs index 482e0ede..e22e7aeb 100644 --- a/contracts/cw-storage/src/msg.rs +++ b/contracts/cw-storage/src/msg.rs @@ -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 @@ -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, /// The number of objects to return. @@ -71,6 +71,14 @@ pub enum QueryMsg { after: Option, }, + /// # 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. @@ -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, + pub data: Vec, pub page_info: PageInfo, }