Skip to content

Commit

Permalink
feat: Sp response add offchainstatus and SpAsDelegatedAgentDisabled
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 committed Apr 7, 2024
1 parent dff47d6 commit 159c01f
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/rare-vans-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bnb-chain/greenfield-js-sdk': patch
---

feat: SpResponse - bucketinfo add SpAsDelegatedAgentDisabled and offchainstatus field
102 changes: 101 additions & 1 deletion packages/js-sdk/src/types/sp/Common.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,58 @@
export type BucketMeta = {
/**
* defines the information of the bucket.
*/
BucketInfo: BucketInfo;

/**
* defines the creation transaction hash of bucket
*/
CreateTxHash: string;

/**
* defines the block number when the bucket deleted.
*/
DeleteAt: number;

/**
* defines the deleted reason of bucket
*/
DeleteReason: string;

/**
* defines the operator address of bucket
*/
Operator: string;

/**
* defines the bucket is deleted or not
*/
Removed: boolean;

/**
* defines the block number when the bucket updated
*/
UpdateAt: number;

/**
* defines the block number when the bucket updated
*/
UpdateTime: number;

/**
* defines the update transaction hash of bucket
*/
UpdateTxHash: string;

/**
* OffChainStatus represents the status of a bucket in the off-chain storage.
It is used to track the current state of the bucket with respect to off-chain operations,
1 means 0001 -> OffChainStatusIsLimited is true
0 means 0000 -> OffChainStatusIsLimited is false
For an explanation of the different OffChainStatus values, please visit:https://github.com/bnb-chain/greenfield-storage-provider/blob/9d7048ad33cf51a2f7eb347e2113c5d0cc45f970/modular/blocksyncer/modules/bucket/bucket_handle.go#L40
*/
OffChainStatus: number;
};

export type GlobalVirtualGroupFamily = {
Expand All @@ -18,6 +63,9 @@ export type GlobalVirtualGroupFamily = {
};

export interface BucketMetaWithVGF extends BucketMeta {
/**
* serve as a means of grouping global virtual groups.
*/
Vgf: GlobalVirtualGroupFamily;
}

Expand All @@ -31,23 +79,73 @@ export function formatVGF(vgf: GlobalVirtualGroupFamily): GlobalVirtualGroupFami
}

export interface BucketInfo {
// PrimarySpId: number;
/**
* globally unique name of bucket
*/
BucketName: string;

/**
* define the status of the bucket.
*/
BucketStatus: number;

/**
* charged_read_quota defines the traffic quota for read in bytes per month.
The available read data for each user is the sum of the free read data provided by SP and
the ChargeReadQuota specified here.
*/
ChargedReadQuota: number;

/**
* define the block timestamp when the bucket created.
*/
CreateAt: number;

/**
* defines the unique id of gvg family
*/
GlobalVirtualGroupFamilyId: number;

/**
* the unique identification for bucket.
*/
Id: string;

/**
* the account address of bucket creator, it is also the bucket owner.
*/
Owner: string;

/**
* the address of the payment account
*/
PaymentAddress: string;

/**
* defines which chain the user should send the bucket management transactions to
*/
SourceType: number;

/**
* defines the highest permissions for bucket. When a bucket is public, everyone can get storage objects in it.
*/
Visibility: number;

/**
* defines a list of tags the bucket has
*/
Tags: {
Tags: {
Key: string;
Value: string;
}[];
};

/**
* indicates that whether bucket owner disable SP as the upload agent.
when a bucket is created, by default, this is false, means SP is allowed to create object for delegator
*/
SpAsDelegatedAgentDisabled: string;
}

export interface StreamRecord {
Expand Down Expand Up @@ -114,6 +212,8 @@ export function formatBucketInfo(o: BucketInfo): BucketInfo {
GlobalVirtualGroupFamilyId: Number(o.GlobalVirtualGroupFamilyId),
SourceType: Number(o.SourceType),
Visibility: Number(o.Visibility),
// @ts-ignore
SpAsDelegatedAgentDisabled: convertStrToBool(o.SpAsDelegatedAgentDisabled),
Tags: {
Tags: tags,
},
Expand Down

0 comments on commit 159c01f

Please sign in to comment.