Skip to content

Commit

Permalink
feat: + is_core for total_balance (#2621)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvvvvv1vvvvvv authored Nov 13, 2024
1 parent 63e4cdf commit b61f228
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@rabby-wallet/gnosis-sdk": "1.3.9",
"@rabby-wallet/page-provider": "0.4.2",
"@rabby-wallet/rabby-action": "0.1.4",
"@rabby-wallet/rabby-api": "0.8.4",
"@rabby-wallet/rabby-api": "0.8.5",
"@rabby-wallet/rabby-security-engine": "2.0.7",
"@rabby-wallet/rabby-swap": "0.0.42",
"@rabby-wallet/widgets": "1.0.9",
Expand Down
13 changes: 12 additions & 1 deletion src/background/controller/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
KEYRING_CLASS,
DBK_CHAIN_ID,
DBK_NFT_CONTRACT_ADDRESS,
CORE_KEYRING_TYPES,
} from 'consts';
import { ERC20ABI } from 'consts/abi';
import { Account, IHighlightedAddress } from '../service/preference';
Expand Down Expand Up @@ -1562,7 +1563,17 @@ export class WalletController extends BaseController {
private getTotalBalanceCached = cached(
'getTotalBalanceCached',
async (address: string) => {
const data = await openapiService.getTotalBalance(address);
const addresses = await keyringService.getAllAdresses();
const filtered = addresses.filter((item) =>
isSameAddress(item.address, address)
);
let core = false;
if (
filtered.some((item) => CORE_KEYRING_TYPES.includes(item.type as any))
) {
core = true;
}
const data = await openapiService.getTotalBalance(address, core);
preferenceService.updateBalanceAboutCache(address, {
totalBalance: data,
});
Expand Down
6 changes: 6 additions & 0 deletions src/constant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ export const KEYRING_CLASS = {
Coinbase: 'Coinbase',
} as const;

export const CORE_KEYRING_TYPES = [
KEYRING_CLASS.MNEMONIC,
KEYRING_CLASS.PRIVATE_KEY,
...Object.values(KEYRING_CLASS.HARDWARE),
];

export const KEYRING_WITH_INDEX = [
KEYRING_CLASS.HARDWARE.LEDGER,
KEYRING_CLASS.HARDWARE.GRIDPLUS,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4781,10 +4781,10 @@
resolved "https://registry.yarnpkg.com/@rabby-wallet/rabby-action/-/rabby-action-0.1.4.tgz#c82e7c8b538b7dfd94506c4f89f78aca7ca880ef"
integrity sha512-6ttnlpGHcO2v/qyYo8epBbSutfS9OZXfXr9mfapuveoBvzqUwvE6ej3bsmdtc+qFhFeH7HeiwASpY6xaTM4E1w==

"@rabby-wallet/[email protected].4":
version "0.8.4"
resolved "https://registry.yarnpkg.com/@rabby-wallet/rabby-api/-/rabby-api-0.8.4.tgz#ef1979eea94eb5fe4e07fe123444a7213178ce15"
integrity sha512-pN6fL6YHhmW7MTmtJEftfvkljYdgcEtJKk2hX2uBfHJQVRXU+jiGOPhSHPE1yfKV4LNwptdV1jtBv3KaYyKa8Q==
"@rabby-wallet/[email protected].5":
version "0.8.5"
resolved "https://registry.yarnpkg.com/@rabby-wallet/rabby-api/-/rabby-api-0.8.5.tgz#b2c7820c52ffe2aa8cb3226304593eaca1231b88"
integrity sha512-yykwK/pZA/5eCn/QCRwgP6uDQQhOdG3Zl1CAjFqK5AVNyc5DE1BCcZWkABWzXjt63KJHePVcAX7rP8rhzbmsTQ==
dependencies:
"@rabby-wallet/rabby-sign" "0.4.0"
axios "^0.27.2"
Expand Down

0 comments on commit b61f228

Please sign in to comment.