Skip to content

Commit

Permalink
feat: Bucket headBucketExtra api (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 authored Sep 12, 2023
1 parent 837d8f4 commit f3a7ce8
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-actors-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bnb-chain/greenfield-js-sdk': patch
---

feat: New Bucket API: `headBucketExtra`
90 changes: 50 additions & 40 deletions packages/chain-sdk/src/api/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
import { visibilityTypeFromJSON } from '@bnb-chain/greenfield-cosmos-types/greenfield/storage/common';
import {
QueryBucketNFTResponse,
QueryHeadBucketExtraResponse,
QueryHeadBucketResponse,
QueryNFTRequest,
QueryPolicyForAccountRequest,
Expand Down Expand Up @@ -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<SpResponse<string>>;

/**
* get approval of creating bucket and send createBucket txn to greenfield chain
*/
createBucket(params: CreateBucketApprovalRequest, authType: AuthType): Promise<TxResponse>;

deleteBucket(msg: MsgDeleteBucket): Promise<TxResponse>;

deleteBucketPolicy(
operator: string,
bucketName: string,
principalAddr: string,
): Promise<TxResponse>;

getBucketMeta(params: GetBucketMetaRequest): Promise<SpResponse<GetBucketMetaResponse>>;

getBucketPolicy(request: QueryPolicyForAccountRequest): Promise<QueryPolicyForAccountResponse>;

/**
* 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<QueryHeadBucketResponse>;
getBucketReadQuota(
configParam: ReadQuotaRequest,
authType: AuthType,
): Promise<SpResponse<IQuotaProps>>;

/**
* 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<QueryHeadBucketResponse>;
getCreateBucketApproval(
configParam: CreateBucketApprovalRequest,
authType: AuthType,
): Promise<SpResponse<string>>;

headBucketNFT(request: QueryNFTRequest): Promise<QueryBucketNFTResponse>;
getMigrateBucketApproval(
params: MigrateBucketApprovalRequest,
authType: AuthType,
): Promise<SpResponse<string>>;

/**
* check if the permission of bucket is allowed to the user.
Expand All @@ -130,37 +144,18 @@ export interface IBucket {
): Promise<QueryVerifyPermissionResponse>;

/**
* 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<SpResponse<IQuotaProps>>;

deleteBucket(msg: MsgDeleteBucket): Promise<TxResponse>;

updateBucketInfo(
srcMsg: Omit<MsgUpdateBucketInfo, 'chargedReadQuota'> & { chargedReadQuota?: string },
): Promise<TxResponse>;

putBucketPolicy(bucketName: string, srcMsg: Omit<MsgPutPolicy, 'resource'>): Promise<TxResponse>;

deleteBucketPolicy(
operator: string,
bucketName: string,
principalAddr: string,
): Promise<TxResponse>;

getBucketPolicy(request: QueryPolicyForAccountRequest): Promise<QueryPolicyForAccountResponse>;
headBucket(bucketName: string): Promise<QueryHeadBucketResponse>;

getMigrateBucketApproval(
params: MigrateBucketApprovalRequest,
authType: AuthType,
): Promise<SpResponse<string>>;
/**
* query the bucketInfo on chain by bucketId, return the bucket info if exists
*/
headBucketById(bucketId: string): Promise<QueryHeadBucketResponse>;

migrateBucket(params: MigrateBucketApprovalRequest, authType: AuthType): Promise<TxResponse>;
headBucketExtra(bucketName: string): Promise<QueryHeadBucketExtraResponse>;

getBucketMeta(params: GetBucketMetaRequest): Promise<SpResponse<GetBucketMetaResponse>>;
headBucketNFT(request: QueryNFTRequest): Promise<QueryBucketNFTResponse>;

listBucketReadRecords(
params: ListBucketReadRecordRequest,
Expand All @@ -179,6 +174,14 @@ export interface IBucket {
listBucketsByPaymentAccount(
params: ListBucketsByPaymentAccountRequest,
): Promise<SpResponse<ListBucketsByPaymentAccountResponse>>;

migrateBucket(params: MigrateBucketApprovalRequest, authType: AuthType): Promise<TxResponse>;

putBucketPolicy(bucketName: string, srcMsg: Omit<MsgPutPolicy, 'resource'>): Promise<TxResponse>;

updateBucketInfo(
srcMsg: Omit<MsgUpdateBucketInfo, 'chargedReadQuota'> & { chargedReadQuota?: string },
): Promise<TxResponse>;
}

@injectable()
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f3a7ce8

Please sign in to comment.