Skip to content

Commit 7832b3a

Browse files
committed
fix: be able to receive ethereum related info
1 parent 2fee398 commit 7832b3a

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
env:
77
APP_NAME: wallet
8+
ETHERSCAN_API_KEY: "${{ github.ref == 'refs/heads/master' && secrets.ETHERSCAN_API_KEY_PROD || secrets.ETHERSCAN_API_KEY_DEV }}"
89
WALLET_CONNECT_PROJECT_ID: ${{ secrets.WALLET_CONNECT_PROJECT_ID }}
910
TOKEN_SALES_URL_MAINNET: ${{ secrets.TOKEN_SALES_URL_MAINNET }}
1011
TOKEN_SALES_URL_TESTNET: ${{ secrets.TOKEN_SALES_URL_TESTNET }}

src/composables/connectionStatus.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { StatusIconType } from '@/types';
1212
import { ROUTE_ACCOUNT } from '@/popup/router/routeNames';
1313
import { useAeMiddleware, useAeTippingBackend } from '@/protocols/aeternity/composables';
14+
import { isEtherscanUnavailable } from '@/protocols/ethereum/libs/EtherscanService';
1415
import { tg as t } from '@/popup/plugins/i18n';
1516

1617
interface StatusType {
@@ -38,14 +39,7 @@ export function useConnectionStatus() {
3839
const showMultisigError = computed(
3940
() => route.name === ROUTE_ACCOUNT && isMultisigBackendUnavailable.value,
4041
);
41-
const isError = computed(() => (
42-
!isOnline.value
43-
|| isAeNodeError.value
44-
|| isMiddlewareUnavailable.value
45-
|| (middlewareStatus.value && !middlewareStatus.value.mdwSynced)
46-
|| showMultisigError.value
47-
|| isBackendUnavailable.value
48-
));
42+
const isError = computed(() => !isAeNodeConnecting.value && !justBeenConnected.value);
4943

5044
// Display "Connected" message for a while after connecting to node.
5145
watch(isAeNodeReady, (val) => {
@@ -97,6 +91,13 @@ export function useConnectionStatus() {
9791
description: t('connectionStatus.backend.description'),
9892
icon: 'critical',
9993
};
94+
case isEtherscanUnavailable.value:
95+
return {
96+
statusMessage: t('connectionStatus.etherscan.statusMessage'),
97+
title: t('connectionStatus.etherscan.title'),
98+
description: t('connectionStatus.etherscan.description'),
99+
icon: 'critical',
100+
};
100101
case showMultisigError.value:
101102
return {
102103
statusMessage: t('connectionStatus.multisig.statusMessage'),

src/popup/components/ConnectionStatus.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
:icon="status.icon"
1717
warning
1818
class="btn-help"
19-
:class="{
20-
'is-error': isError,
21-
}"
2219
/>
2320
</div>
2421
</transition>

src/popup/locales/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@
104104
"title": "Multisig backend failure",
105105
"description": "Multisig vaults may not be accessible at the moment due to temporary backend failure. <p> If you are trying to access your multisig vaults please try again later. </p>"
106106
},
107+
"etherscan": {
108+
"statusMessage": "Etherscan services are down.",
109+
"title": "Etherscan services are down",
110+
"description": "Some features such as fetching transaction history and transaction details on Ethereum network may not be functioning properly at the moment."
111+
},
107112
"backend": {
108113
"statusMessage": "Temporary backend failure.",
109114
"title": "Backend failure",

src/protocols/ethereum/libs/EtherscanService.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { ref } from 'vue';
12
import { fromWei } from 'web3-utils';
3+
24
import type { AccountAddress, AssetContractId, ITransaction } from '@/types';
35
import { ETHERSCAN_API_KEY, PROTOCOLS, TXS_PER_PAGE } from '@/constants';
46
import { fetchJson, removeObjectUndefinedProperties, sleep } from '@/utils';
@@ -21,14 +23,16 @@ interface EtherscanApiCallParams {
2123

2224
let lastCallTime: number;
2325

26+
export const isEtherscanUnavailable = ref(false);
27+
2428
/**
2529
* @see docs.etherscan.io
2630
*/
2731
export class EtherscanService {
2832
apiUrl: string;
2933

3034
// TODO - update delay if we use paid API key
31-
freeVersionTimeDelay = ETHERSCAN_API_KEY ? 250 : 5300;
35+
freeVersionTimeDelay = 5300;
3236

3337
constructor(apiUrl: string) {
3438
this.apiUrl = apiUrl;
@@ -40,7 +44,6 @@ export class EtherscanService {
4044
apikey: ETHERSCAN_API_KEY,
4145
}).toString();
4246

43-
// Without API key amount of calls are limited to one per every 5 seconds.
4447
// With free API key we can make 5 calls per second.
4548
// We're adding delays between calls to avoid getting empty results.
4649
// TODO: Use own node or paid version
@@ -50,8 +53,14 @@ export class EtherscanService {
5053
if (timeToWait > 0) {
5154
await sleep(timeToWait);
5255
}
53-
54-
return fetchJson<T>(`${this.apiUrl}?${query}`);
56+
try {
57+
const response = await fetchJson<T>(`${this.apiUrl}?${query}`);
58+
isEtherscanUnavailable.value = false;
59+
return response;
60+
} catch (e) {
61+
isEtherscanUnavailable.value = true;
62+
throw e;
63+
}
5564
}
5665

5766
/**

0 commit comments

Comments
 (0)