From f3a7ce8f06d6bedf5e07bccccc4ada7676e79f2a Mon Sep 17 00:00:00 2001 From: rrr523 <59029880+rrr523@users.noreply.github.com> Date: Tue, 12 Sep 2023 17:37:16 +0800 Subject: [PATCH] feat: Bucket headBucketExtra api (#324) --- .changeset/big-actors-divide.md | 5 ++ packages/chain-sdk/src/api/bucket.ts | 90 +++++++++++++++------------- 2 files changed, 55 insertions(+), 40 deletions(-) create mode 100644 .changeset/big-actors-divide.md diff --git a/.changeset/big-actors-divide.md b/.changeset/big-actors-divide.md new file mode 100644 index 00000000..c292e2d5 --- /dev/null +++ b/.changeset/big-actors-divide.md @@ -0,0 +1,5 @@ +--- +'@bnb-chain/greenfield-js-sdk': patch +--- + +feat: New Bucket API: `headBucketExtra` diff --git a/packages/chain-sdk/src/api/bucket.ts b/packages/chain-sdk/src/api/bucket.ts index c94e5877..c0a3c5d6 100644 --- a/packages/chain-sdk/src/api/bucket.ts +++ b/packages/chain-sdk/src/api/bucket.ts @@ -42,6 +42,7 @@ import { import { visibilityTypeFromJSON } from '@bnb-chain/greenfield-cosmos-types/greenfield/storage/common'; import { QueryBucketNFTResponse, + QueryHeadBucketExtraResponse, QueryHeadBucketResponse, QueryNFTRequest, QueryPolicyForAccountRequest, @@ -95,30 +96,43 @@ import { Sp } from './sp'; import { Storage } from './storage'; export interface IBucket { - /** - * returns the signature info for the approval of preCreating resources - */ - getCreateBucketApproval( - configParam: CreateBucketApprovalRequest, - authType: AuthType, - ): Promise>; - /** * get approval of creating bucket and send createBucket txn to greenfield chain */ createBucket(params: CreateBucketApprovalRequest, authType: AuthType): Promise; + deleteBucket(msg: MsgDeleteBucket): Promise; + + deleteBucketPolicy( + operator: string, + bucketName: string, + principalAddr: string, + ): Promise; + + getBucketMeta(params: GetBucketMetaRequest): Promise>; + + getBucketPolicy(request: QueryPolicyForAccountRequest): Promise; + /** - * query the bucketInfo on chain, return the bucket info if exists + * return quota info of bucket of current month, include chain quota, free quota and consumed quota */ - headBucket(bucketName: string): Promise; + getBucketReadQuota( + configParam: ReadQuotaRequest, + authType: AuthType, + ): Promise>; /** - * query the bucketInfo on chain by bucketId, return the bucket info if exists + * returns the signature info for the approval of preCreating resources */ - headBucketById(bucketId: string): Promise; + getCreateBucketApproval( + configParam: CreateBucketApprovalRequest, + authType: AuthType, + ): Promise>; - headBucketNFT(request: QueryNFTRequest): Promise; + getMigrateBucketApproval( + params: MigrateBucketApprovalRequest, + authType: AuthType, + ): Promise>; /** * check if the permission of bucket is allowed to the user. @@ -130,37 +144,18 @@ export interface IBucket { ): Promise; /** - * return quota info of bucket of current month, include chain quota, free quota and consumed quota + * query the bucketInfo on chain, return the bucket info if exists */ - getBucketReadQuota( - configParam: ReadQuotaRequest, - authType: AuthType, - ): Promise>; - - deleteBucket(msg: MsgDeleteBucket): Promise; - - updateBucketInfo( - srcMsg: Omit & { chargedReadQuota?: string }, - ): Promise; - - putBucketPolicy(bucketName: string, srcMsg: Omit): Promise; - - deleteBucketPolicy( - operator: string, - bucketName: string, - principalAddr: string, - ): Promise; - - getBucketPolicy(request: QueryPolicyForAccountRequest): Promise; + headBucket(bucketName: string): Promise; - getMigrateBucketApproval( - params: MigrateBucketApprovalRequest, - authType: AuthType, - ): Promise>; + /** + * query the bucketInfo on chain by bucketId, return the bucket info if exists + */ + headBucketById(bucketId: string): Promise; - migrateBucket(params: MigrateBucketApprovalRequest, authType: AuthType): Promise; + headBucketExtra(bucketName: string): Promise; - getBucketMeta(params: GetBucketMetaRequest): Promise>; + headBucketNFT(request: QueryNFTRequest): Promise; listBucketReadRecords( params: ListBucketReadRecordRequest, @@ -179,6 +174,14 @@ export interface IBucket { listBucketsByPaymentAccount( params: ListBucketsByPaymentAccountRequest, ): Promise>; + + migrateBucket(params: MigrateBucketApprovalRequest, authType: AuthType): Promise; + + putBucketPolicy(bucketName: string, srcMsg: Omit): Promise; + + updateBucketInfo( + srcMsg: Omit & { chargedReadQuota?: string }, + ): Promise; } @injectable() @@ -328,6 +331,13 @@ export class Bucket implements IBucket { }); } + public async headBucketExtra(bucketName: string) { + const rpc = await this.queryClient.getBucketQueryClient(); + return await rpc.HeadBucketExtra({ + bucketName, + }); + } + public async headBucketNFT(request: QueryNFTRequest) { const rpc = await this.queryClient.getStorageQueryClient(); return await rpc.HeadBucketNFT(request);