Skip to content

Commit

Permalink
Check for missing object result in search (MystenLabs#1755)
Browse files Browse the repository at this point in the history
* check return value of object query

* lint changes
  • Loading branch information
Stella Cannefax authored May 3, 2022
1 parent 10bdb1c commit f2b37b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions explorer/client/src/utils/api/searchUtil.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { isObjectNotExistsInfo, isObjectRef } from 'sui.js';

import { DefaultRpcClient as rpc } from './DefaultRpcClient';

export const navigateWithUnknown = async (
Expand All @@ -15,10 +17,17 @@ export const navigateWithUnknown = async (
data: data,
};
});
const objInfoPromise = rpc.getObjectInfo(input).then((data) => ({
category: 'objects',
data: data,
}));
const objInfoPromise = rpc.getObjectInfo(input).then((data) => {
const deets = data.details;
if (isObjectNotExistsInfo(deets) && !isObjectRef(deets)) {
throw new Error('no object found');
}

return {
category: 'objects',
data: data,
};
});

const txDetailsPromise = rpc.getTransaction(input).then((data) => ({
category: 'transactions',
Expand Down
1 change: 1 addition & 0 deletions sdk/typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export * from './signers/raw-signer';
export * from './signers/signer-with-provider';

export * from './types';
export * from './index.guard';

export * as BCS from './bcs';

0 comments on commit f2b37b5

Please sign in to comment.