Skip to content

Commit

Permalink
fix(dcellar-web-ui): delegateCreateFolder type error
Browse files Browse the repository at this point in the history
  • Loading branch information
devinxl committed May 9, 2024
1 parent a19c2a1 commit e87f441
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
7 changes: 0 additions & 7 deletions apps/dcellar-web-ui/src/facade/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ import { TempAccountEntity } from '@/store/slices/accounts';

export const resolve = <R>(r: R): [R, null] => [r, null];

export const resolveSpRequest = <R>(r: SpResponse<R>) => {
if (r.code !== 0) {
return [null, r.message || UNKNOWN_ERROR];
}
return [r.body, null];
};

export type DeliverTxResponse = Awaited<ReturnType<TxResponse['broadcast']>>;

export const getObjectInfoAndBucketQuota = async ({
Expand Down
13 changes: 10 additions & 3 deletions apps/dcellar-web-ui/src/facade/object.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GROUP_ID } from '@/constants/legacy';
import { quotaRemains } from '@/facade/bucket';
import { getObjectInfoAndBucketQuota, resolve, resolveSpRequest } from '@/facade/common';
import { getObjectInfoAndBucketQuota, resolve } from '@/facade/common';
import {
E_NOT_FOUND,
E_NO_QUOTA,
Expand Down Expand Up @@ -41,6 +41,7 @@ import {
} from '@bnb-chain/greenfield-cosmos-types/greenfield/storage/types';
import {
AuthType,
DelegateCreateFolderRepsonse,
DelegatedCreateFolderRequest,
GRNToString,
IQuotaProps,
Expand Down Expand Up @@ -698,8 +699,14 @@ export const updateObjectTags = async (params: UpdateObjectTagsParams, connector
export const delegateCreateFolder = async (
request: DelegatedCreateFolderRequest,
auth: AuthType,
) => {
): Promise<ErrorResponse | [DelegateCreateFolderRepsonse, null]> => {
const client = await getClient();
const [result, error] = await client.object
.delegateCreateFolder(request, auth)
.then(resolve, commonFault);

if (!result || error) return [null, error];
if (result.code !== 0 || !result.body) return [null, result.message ?? ''];

return client.object.delegateCreateFolder(request, auth).then(resolveSpRequest, commonFault);
return [result.body, null];
};

0 comments on commit e87f441

Please sign in to comment.