From a030dc6023a7f645c664af4d57314770714f089c Mon Sep 17 00:00:00 2001 From: Gamaliel Padillo Date: Wed, 20 Nov 2024 10:42:14 -0800 Subject: [PATCH] devop: add code rabbit suggestions --- .../components/network-assets-item.vue | 15 ++++++++++----- .../src/ui/action/views/network-assets/index.vue | 6 ++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/extension/src/ui/action/views/network-assets/components/network-assets-item.vue b/packages/extension/src/ui/action/views/network-assets/components/network-assets-item.vue index 8365fd959..a23da895c 100644 --- a/packages/extension/src/ui/action/views/network-assets/components/network-assets-item.vue +++ b/packages/extension/src/ui/action/views/network-assets/components/network-assets-item.vue @@ -134,11 +134,15 @@ const customTokens = ref([]); const tokenState = new TokensState(); const fetchCustomTokens = async () => { - return await tokenState.getTokensByNetwork(props.network.name).then(res => { - customTokens.value = res.filter( - (token): token is CustomErc20Token => 'address' in token, - ); - }); + try { + return await tokenState.getTokensByNetwork(props.network.name).then(res => { + customTokens.value = res.filter( + (token): token is CustomErc20Token => 'address' in token, + ); + }); + } catch { + customTokens.value = []; + } }; onMounted(async () => { @@ -146,6 +150,7 @@ onMounted(async () => { }); const isCustomToken = computed(() => { + if (!props.token.contract) return false; return customTokens.value.some( token => token.address.toLowerCase() === props.token.contract?.toLowerCase(), diff --git a/packages/extension/src/ui/action/views/network-assets/index.vue b/packages/extension/src/ui/action/views/network-assets/index.vue index 4aad72e73..87811e70c 100644 --- a/packages/extension/src/ui/action/views/network-assets/index.vue +++ b/packages/extension/src/ui/action/views/network-assets/index.vue @@ -147,11 +147,9 @@ const addCustomAsset = (asset: AssetsType) => { }); if (!existingAsset) { - assets.value = [...assets.value, asset]; + // refetches assets to update the custom token + updateAssets(); } - - // refetches assets to update the custom token - updateAssets(); };