Skip to content

Commit

Permalink
[explorer] Add DefaultRpcClient (MystenLabs#1658)
Browse files Browse the repository at this point in the history
  • Loading branch information
666lcz authored Apr 29, 2022
1 parent ca9046f commit ca72f7c
Show file tree
Hide file tree
Showing 6 changed files with 8,281 additions and 8,110 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/explorer-client-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
outputs:
isClient: ${{ steps.diff.outputs.isExplorerClient }}
steps:
- uses: actions/checkout@v3
- name: Detect Changes
uses: './.github/actions/diffs'
id: diff
- uses: actions/checkout@v3
- name: Detect Changes
uses: "./.github/actions/diffs"
id: diff
client_checks:
name: Lint, Test & Build
needs: diff
Expand All @@ -21,12 +21,15 @@ jobs:
- name: Install Nodejs
uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'yarn'
node-version: "16"
cache: "yarn"
cache-dependency-path: ./explorer/client/yarn.lock
- name: Build TS sdk
working-directory: ./sdk/typescript
run: yarn install; yarn build
- name: Install yarn dependencies
working-directory: ./explorer/client
run: yarn install
run: yarn install
- name: Lint
working-directory: ./explorer/client
run: yarn lint
Expand Down
1 change: 1 addition & 0 deletions explorer/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"react-ace": "^9.5.0",
"react-dom": "^17.0.2",
"react-router-dom": "^6.2.1",
"sui.js": "file:../../sdk/typescript",
"swr": "^1.2.2",
"web-vitals": "^2.1.4"
},
Expand Down
18 changes: 18 additions & 0 deletions explorer/client/src/utils/api/DefaultRpcClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { JsonRpcProvider } from 'sui.js';

import { tryGetRpcSetting } from './rpcSetting';

export type AddressBytes = number[];
export type AddressOwner = { AddressOwner: AddressBytes };

export type AnyVec = { vec: any[] };
export type JsonBytes = { bytes: number[] };

const rpcUrl = tryGetRpcSetting() ?? 'http://127.0.0.1:5001';

export const DefaultRpcClient = new JsonRpcProvider(rpcUrl);

console.log(DefaultRpcClient);
1 change: 1 addition & 0 deletions explorer/client/src/utils/api/SuiRpcClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

// TODO: Remove this file after we finish the migration to use sui.js SDK
import { tryGetRpcSetting } from './rpcSetting';

export class SuiRpcClient {
Expand Down
1 change: 1 addition & 0 deletions explorer/client/src/utils/api/searchUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const navigateWithUnknown = async (
};
});

// TODO:(Chirs) replace this after we can fetch `getObjectInfo` with the SDK
const objInfoPromise = rpc.getObjectInfo(input).then((data) => ({
category: 'objects',
data: data,
Expand Down
Loading

0 comments on commit ca72f7c

Please sign in to comment.