Skip to content

Commit

Permalink
Fix/sp tag type (#444)
Browse files Browse the repository at this point in the history
* fix: Sp types

* fix: Sp types
  • Loading branch information
rrr523 authored Dec 21, 2023
1 parent 5e277f6 commit eb75e4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 42 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-meals-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bnb-chain/greenfield-js-sdk': patch
---

fix: Sp tag types
42 changes: 0 additions & 42 deletions packages/js-sdk/src/types/sp/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ export interface BucketInfo {
PaymentAddress: string;
SourceType: number;
Visibility: number;
Tags: {
Tags: {
Key: string;
Value: string;
}[];
};
}

export interface StreamRecord {
Expand Down Expand Up @@ -91,20 +85,9 @@ export interface ObjectInfo {
RedundancyType: number;
SourceType: number;
Visibility: number;
Tags: {
Tags: {
Key: string;
Value: string;
}[];
};
}

export function formatBucketInfo(o: BucketInfo): BucketInfo {
let tags = o.Tags.Tags || [];
if (!Array.isArray(tags)) {
tags = [tags];
}

return {
...o,
// PrimarySpId: Number(item.BucketInfo.PrimarySpId),
Expand All @@ -114,18 +97,10 @@ export function formatBucketInfo(o: BucketInfo): BucketInfo {
GlobalVirtualGroupFamilyId: Number(o.GlobalVirtualGroupFamilyId),
SourceType: Number(o.SourceType),
Visibility: Number(o.Visibility),
Tags: {
Tags: tags,
},
};
}

export function formatObjectInfo(o: ObjectInfo): ObjectInfo {
let tags = o.Tags.Tags || [];
if (!Array.isArray(tags)) {
tags = [tags];
}

return {
...o,
CreateAt: Number(o.CreateAt),
Expand All @@ -136,9 +111,6 @@ export function formatObjectInfo(o: ObjectInfo): ObjectInfo {
RedundancyType: Number(o.RedundancyType),
SourceType: Number(o.SourceType),
Visibility: Number(o.Visibility),
Tags: {
Tags: tags,
},
};
}

Expand Down Expand Up @@ -168,27 +140,13 @@ export interface GroupInfo {
SourceType: number;
Id: number;
Extra: string;
Tags: {
Tags: {
Key: string;
Value: string;
}[];
};
}

export function formatGroupInfo(o: GroupInfo): GroupInfo {
let tags = o.Tags.Tags || [];
if (!Array.isArray(tags)) {
tags = [tags];
}

return {
...o,
SourceType: Number(o.SourceType),
Id: Number(o.Id),
Tags: {
Tags: tags,
},
};
}

Expand Down

0 comments on commit eb75e4d

Please sign in to comment.