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: hide decimals in coin balances
* also sort sui-objects by id
- Loading branch information
1 parent
b272e79
commit 8a572af
Showing
4 changed files
with
40 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { isSuiMoveObject } from '@mysten/sui.js'; | ||
|
||
import type { SuiObject, SuiMoveObject } from '@mysten/sui.js'; | ||
|
||
const COIN_TYPE = '0x2::Coin::Coin'; | ||
const COIN_TYPE_ARG_REGEX = /^0x2::Coin::Coin<(.+)>$/; | ||
|
||
// TODO use sdk | ||
export class Coin { | ||
public static isCoin(obj: SuiObject) { | ||
return isSuiMoveObject(obj.data) && obj.data.type.startsWith(COIN_TYPE); | ||
} | ||
|
||
public static getCoinTypeArg(obj: SuiMoveObject) { | ||
const res = obj.type.match(COIN_TYPE_ARG_REGEX); | ||
return res ? res[1] : null; | ||
} | ||
|
||
public static getCoinSymbol(coinTypeArg: string) { | ||
return coinTypeArg.substring(coinTypeArg.lastIndexOf(':') + 1); | ||
} | ||
} |
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