forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wallet-ext: sui-object link to explorer
- Loading branch information
1 parent
3642552
commit 16f4be0
Showing
4 changed files
with
90 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { API_ENV, DEFAULT_API_ENV } from '_app/ApiProvider'; | ||
|
||
import type { ObjectId } from '@mysten/sui.js'; | ||
|
||
const API_ENV_TO_EXPLORER_URL: Record<API_ENV, string | undefined> = { | ||
[API_ENV.local]: process.env.EXPLORER_URL_LOCAL, | ||
[API_ENV.devNet]: process.env.EXPLORER_URL_DEV_NET, | ||
}; | ||
|
||
function getDefaultUrl() { | ||
const url = API_ENV_TO_EXPLORER_URL[DEFAULT_API_ENV]; | ||
if (!url) { | ||
throw new Error(`Url for API_ENV ${DEFAULT_API_ENV} is not defined`); | ||
} | ||
return url; | ||
} | ||
|
||
const DEFAULT_EXPLORER_URL = getDefaultUrl(); | ||
|
||
export class Explorer { | ||
private static _url = DEFAULT_EXPLORER_URL; | ||
|
||
public static getObjectUrl(objectID: ObjectId) { | ||
return new URL(`/objects/${objectID}`, Explorer._url).href; | ||
} | ||
} |