Skip to content

Commit

Permalink
fix: fix infinite loading in custom network environments
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss committed Nov 10, 2024
1 parent 963805b commit 618aa53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/adena-extension/src/hooks/use-token-metainfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const useTokenMetainfo = (): UseTokenMetainfoReturn => {
}, [allTokenMetainfos]);

const initTokenMetainfos = async (withTransferEvents?: boolean): Promise<void> => {
if (!currentAccount || !currentNetwork.apiUrl) {
if (!currentAccount) {
return;
}

Expand Down
22 changes: 13 additions & 9 deletions packages/adena-extension/src/repositories/common/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
NativeTokenResponse,
} from './response/token-asset-response';

import { GNOT_TOKEN } from '@common/constants/token.constant';
import { GnoProvider } from '@common/provider/gno/gno-provider';
import { makeRPCRequest } from '@common/utils/fetch-utils';
import {
Expand Down Expand Up @@ -44,20 +45,20 @@ enum LocalValueType {
AccountTransferEventBlockHeight = 'ACCOUNT_TRANSFER_EVENT_BLOCK_HEIGHT',
}

const DEFAULT_TOKEN_NETWORK_ID = 'DEFAULT';
const DEFAULT_TOKEN_NETWORK_ID = '';

const DEFAULT_TOKEN_METAINFOS: NativeTokenModel[] = [
{
main: true,
tokenId: 'tokenId',
name: 'gno.land',
tokenId: GNOT_TOKEN.denom,
type: 'gno-native',
name: GNOT_TOKEN.name,
networkId: DEFAULT_TOKEN_NETWORK_ID,
symbol: GNOT_TOKEN.symbol,
denom: GNOT_TOKEN.denom,
decimals: GNOT_TOKEN.decimals,
image:
'https://raw.githubusercontent.com/onbloc/gno-token-resource/main/gno-native/images/gnot.svg',
symbol: 'GNOT',
denom: 'ugnot',
type: 'gno-native',
decimals: 6,
main: true,
display: true,
},
];
Expand Down Expand Up @@ -137,7 +138,10 @@ export class TokenRepository implements ITokenRepository {
[key in string]: TokenModel[];
}>(LocalValueType.AccountTokenMetainfos);

return accountTokenMetainfos[accountId] ?? [];
return (
accountTokenMetainfos[accountId] ??
DEFAULT_TOKEN_METAINFOS.map((token) => ({ ...token, networkId: this.networkId }))
);
};

public updateTokenMetainfos = async (
Expand Down

0 comments on commit 618aa53

Please sign in to comment.