Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable querying bucket, object and group by id. #83

Merged
merged 16 commits into from
Mar 8, 2023

Conversation

alexgao001
Copy link
Collaborator

@alexgao001 alexgao001 commented Mar 1, 2023

Description

  1. enable querying bucket, object and group by id.
  2. add apis to query bucket, object and group NFT following standard.

Rationale

tell us why we need these changes...

Example


bucket NFT response:

{
  "meta_data": {
    "description": "",
    "external_url": "",
    "bucket_name": "fstdy",
    "image": "",
    "attributes": [
      {
        "trait_type": "Owner",
        "value": "0xD85BCc033402AbCb818fe2fCC0c9685A29948d59"
      },
      {
        "trait_type": "BucketName",
        "value": "fstdy"
      },
      {
        "trait_type": "IsPublic",
        "value": "false"
      },
      {
        "trait_type": "Id",
        "value": "1"
      },
      {
        "trait_type": "SourceType",
        "value": "SOURCE_TYPE_ORIGIN"
      },
      {
        "trait_type": "CreateAt",
        "value": "72"
      },
      {
        "trait_type": "PaymentAddress",
        "value": "0xD85BCc033402AbCb818fe2fCC0c9685A29948d59"
      },
      {
        "trait_type": "PrimarySpAddress",
        "value": "0xD4e091cF947E25B6Ca92895b6D55781447866d07"
      },
      {
        "trait_type": "ReadQuota",
        "value": "READ_QUOTA_FREE"
      },
      {
        "trait_type": "PaymentPriceTime",
        "value": "0"
      }
    ]
  }
}


object NFT response:

{
  "meta_data": {
    "description": "",
    "external_url": "",
    "object_name": "svmxowgyb9",
    "image": "",
    "attributes": [
      {
        "trait_type": "Owner",
        "value": "0xD85BCc033402AbCb818fe2fCC0c9685A29948d59"
      },
      {
        "trait_type": "BucketName",
        "value": "fstdy"
      },
      {
        "trait_type": "ObjectName",
        "value": "svmxowgyb9"
      },
      {
        "trait_type": "Id",
        "value": "1"
      },
      {
        "trait_type": "PayloadSize",
        "value": "1067008"
      },
      {
        "trait_type": "IsPublic",
        "value": "false"
      },
      {
        "trait_type": "ContentType",
        "value": "text/event-stream"
      },
      {
        "trait_type": "CreateAt",
        "value": "73"
      },
      {
        "trait_type": "ObjectStatus",
        "value": "OBJECT_STATUS_IN_SERVICE"
      },
      {
        "trait_type": "RedundancyType",
        "value": "REDUNDANCY_EC_TYPE"
      },
      {
        "trait_type": "SourceType",
        "value": "SOURCE_TYPE_ORIGIN"
      },
   
      {
        "trait_type": "SecondarySpAddresses",
        "value": "[0xD4e091cF947E25B6Ca92895b6D55781447866d07 0xD4e091cF947E25B6Ca92895b6D55781447866d07 0xD4e091cF947E25B6Ca92895b6D55781447866d07 0xD4e091cF947E25B6Ca92895b6D55781447866d07 0xD4e091cF947E25B6Ca92895b6D55781447866d07 0xD4e091cF947E25B6Ca92895b6D55781447866d07]"
      },
      {
        "trait_type": "LockedBalance",
        "value": "<nil>"
      }
    ]
  }
}

Changes

Notable changes:

  1. enable querying bucket, object and group by id.
  2. add apis to query bucket, object and group NFT following standard.

@fynnss
Copy link
Contributor

fynnss commented Mar 1, 2023

Use make proto-format to fix the protobuf-check failure.

Copy link
Collaborator

@unclezoro unclezoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some API that match the NFT metadata standard.

if !found {
return nil, types.ErrNoSuchObject
}
attributes := make([]types.Trait, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have a generic function to convert struct to NFT metadata standard.

Copy link
Contributor

@fynnss fynnss Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it's better to add an interface (e.g ToNFTMetadata) to bucket/object/group info struct.

@@ -1327,6 +1327,117 @@ paths:
type: string
tags:
- Query
/bnb-chain/greenfield/sp/storage_provider/{spAddress}:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will sp/storage_provider such a path be verbose? since sp is already short for storage_provider.

@fynnss @alexgao001 what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is auto-generated by ignite. sp means the sp module.

I think we can make this more simple by remove the sp.

docs/static/swagger.yaml Outdated Show resolved Hide resolved
docs/static/swagger.yaml Outdated Show resolved Hide resolved
docs/static/swagger.yaml Outdated Show resolved Hide resolved
docs/static/swagger.yaml Outdated Show resolved Hide resolved
docs/static/swagger.yaml Outdated Show resolved Hide resolved
type: string
format: byte
parameters:
- name: spAddress
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name spAddress is too generic, which address is it exactly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as the validatorAddress that we use the operator address of it as the ValAddress.

Any other advice?

docs/static/swagger.yaml Outdated Show resolved Hide resolved
the object is public, everyone can access it.
content_type:
type: string
description: >-
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: make it an enum.

Copy link
Contributor

@fynnss fynnss Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is generally represented by a string for content-type in minio or ceph or s3

create_at:
type: string
format: int64
title: create_at define the block number when the object created
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you double check all create_at? I think some are not clear, we may think it is a unix timestamp.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we can rename it to create_height.

It will be associated with some system parameters, such as redundant parameters.

'200':
description: A successful response.
schema:
type: object
Copy link
Collaborator

@unclezoro unclezoro Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swagger is expected to define the object and reuse it. I think we redefine the bucket, storage object in many places, any idea to improve that?

x/storage/keeper/query.go Outdated Show resolved Hide resolved
@alexgao001 alexgao001 added the r4r label Mar 3, 2023
@unclezoro unclezoro merged commit aa875b7 into develop Mar 8, 2023
@unclezoro unclezoro deleted the feat-storage-indexed-by-id branch April 18, 2023 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants