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: Bucket headBucketExtra api #324

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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