Skip to content

Commit

Permalink
refactor: extract links to constants.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pstachel committed May 16, 2022
1 parent 490cb07 commit ebb9a73
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 18 deletions.
8 changes: 5 additions & 3 deletions src/popup/router/pages/About.vue
Expand Up @@ -5,7 +5,7 @@
<span class="version">
commit
<a
:href="`https://github.com/aeternity/superhero-wallet/commit/${commitHash}`"
:href="`${COMMIT_URL}${commitHash}`"
target="_blank"
>
{{ commitHash.slice(0, 7) }}</a>
Expand All @@ -15,7 +15,7 @@
<hr>
<div class="waellet-links">
<a
href="https://superhero.com/faq"
:href="`${AGGREGATOR_URL}faq`"
target="_blank"
>FAQ</a>
<router-link
Expand All @@ -40,7 +40,7 @@
<script>
import Button from '../components/Button.vue';
import Logo from '../../../icons/logo.svg?vue-component';
import { BUG_REPORT_URL } from '../../utils/constants';
import { BUG_REPORT_URL, AGGREGATOR_URL, COMMIT_URL } from '../../utils/constants';
export default {
components: { Button, Logo },
Expand All @@ -49,6 +49,8 @@ export default {
extensionVersion: `v.${process.env.npm_package_version}`,
commitHash: process.env.COMMIT_HASH,
BUG_REPORT_URL,
AGGREGATOR_URL,
COMMIT_URL,
};
},
};
Expand Down
8 changes: 5 additions & 3 deletions src/popup/router/pages/TermsOfService.vue
Expand Up @@ -156,7 +156,7 @@
<p>
The results of the donations and comments are published on the website
<a
href="https://superhero.com/"
:href="AGGREGATOR_URL"
target="_blank"
>superhero.com</a> .
</p>
Expand Down Expand Up @@ -281,7 +281,7 @@
<p>
After that, the website -
<a
href="https://superhero.com/"
:href="AGGREGATOR_URL"
target="_blank"
>superhero.com</a>, reflects the
<strong>USERS&rsquo;</strong> donations and comments and gives the possibility for other
Expand Down Expand Up @@ -478,7 +478,7 @@
<p>
The <strong>name</strong> can also be used as your profile name on the Superhero website
<a
href="https://superhero.com/"
:href="AGGREGATOR_URL"
target="_blank"
>superhero.com</a>.
</p>
Expand Down Expand Up @@ -947,6 +947,7 @@ import {
APP_LINK_FIREFOX,
APP_LINK_ANDROID,
APP_LINK_IOS,
AGGREGATOR_URL,
} from '../../utils/constants';
export default {
Expand All @@ -961,6 +962,7 @@ export default {
APP_LINK_FIREFOX,
APP_LINK_ANDROID,
APP_LINK_IOS,
AGGREGATOR_URL,
};
},
methods: {
Expand Down
4 changes: 3 additions & 1 deletion src/popup/router/pages/TipsClaim.vue
Expand Up @@ -7,7 +7,7 @@
:msg="$t('modals.verify.msg')"
:option="{
attrs: {
href: 'https://blog.aeternity.com/superhero-how-to-send-receive-superhero-tips-34971b18c919#024e',
href: BLOG_CLAIM_TIP_URL,
target: '_blank'
},
}"
Expand Down Expand Up @@ -36,6 +36,7 @@
<script>
import { mapGetters, mapState } from 'vuex';
import { aettosToAe, toURL, validateTipUrl } from '../../utils/helper';
import { BLOG_CLAIM_TIP_URL } from '../../utils/constants';
import InputField from '../components/InputField.vue';
import Button from '../components/Button.vue';
import HelpButton from '../components/HelpButton.vue';
Expand All @@ -45,6 +46,7 @@ export default {
data: () => ({
url: '',
loading: false,
BLOG_CLAIM_TIP_URL,
}),
computed: {
...mapState(['sdk', 'tippingV1']),
Expand Down
4 changes: 3 additions & 1 deletion src/popup/router/pages/TipsSend.vue
Expand Up @@ -6,7 +6,7 @@
class="header"
>
<a
href="https://superhero.com/"
:href="AGGREGATOR_URL"
target="_blank"
>
{{ $t('pages.notifications.superhero') }}
Expand Down Expand Up @@ -116,6 +116,7 @@ import UrlStatus from '../components/UrlStatus.vue';
import Button from '../components/Button.vue';
import TokenAmount from '../components/TokenAmount.vue';
import deeplinkApi from '../../../mixins/deeplinkApi';
import { AGGREGATOR_URL } from '../../utils/constants';
export default {
components: {
Expand All @@ -139,6 +140,7 @@ export default {
IS_EXTENSION: process.env.IS_EXTENSION,
tipFromPopup: false,
error: false,
AGGREGATOR_URL,
};
},
computed: {
Expand Down
11 changes: 11 additions & 0 deletions src/popup/utils/constants.js
Expand Up @@ -140,3 +140,14 @@ export const APP_LINK_ANDROID = 'https://play.google.com/store/apps/details?id=c
export const APP_LINK_IOS = 'https://apps.apple.com/us/app/superhero-wallet/id1502786641';

export const SIMPLEX_URL = 'https://aeternity.com/simplex-integration';

export const CURRENCIES_URL = 'https://api.coingecko.com/api/v3/simple/price?ids=aeternity&vs_currencies=usd,eur,aud,ron,brl,cad,chf,cny,czk,dkk,gbp,hkd,hrk,huf,idr,ils,inr,isk,jpy,krw,mxn,myr,nok,nzd,php,pln,ron,rub,sek,sgd,thb,try,zar,xau';
export const CURRENCY_URL = 'https://api.coingecko.com/api/v3/coins/markets?ids=aeternity&vs_currency=';

export const AVATAR_URL = 'https://avatars.z52da5wt.xyz/';

export const LEDGER_BRIDGE_URL = 'https://wallet.superhero.com/ledger-bridge';

export const BLOG_CLAIM_TIP_URL = 'https://blog.aeternity.com/superhero-how-to-send-receive-superhero-tips-34971b18c919#024e';

export const COMMIT_URL = 'https://github.com/aeternity/superhero-wallet/commit/';
5 changes: 2 additions & 3 deletions src/store/actions.js
Expand Up @@ -14,6 +14,7 @@ import {
isAccountNotFoundError,
} from '../popup/utils/helper';
import { i18n } from './plugins/languages';
import { CURRENCIES_URL } from '../popup/utils/constants';

export default {
switchNetwork({ commit }, payload) {
Expand Down Expand Up @@ -84,9 +85,7 @@ export default {
async getCurrencies({ state: { nextCurrenciesFetch }, commit }) {
if (!nextCurrenciesFetch || nextCurrenciesFetch <= new Date().getTime()) {
try {
const { aeternity } = await fetchJson(
'https://api.coingecko.com/api/v3/simple/price?ids=aeternity&vs_currencies=usd,eur,aud,ron,brl,cad,chf,cny,czk,dkk,gbp,hkd,hrk,huf,idr,ils,inr,isk,jpy,krw,mxn,myr,nok,nzd,php,pln,ron,rub,sek,sgd,thb,try,zar,xau',
);
const { aeternity } = await fetchJson(CURRENCIES_URL);
commit('setCurrencies', aeternity);
commit('setNextCurrencyFetch', new Date().getTime() + 3600000);
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions src/store/getters.js
Expand Up @@ -3,7 +3,7 @@ import { derivePathFromKey, getKeyPair } from '@aeternity/hd-wallet/src/hd-key';
import { generateHDWallet as generateHdWallet } from '@aeternity/hd-wallet/src';
import { mnemonicToSeed } from '@aeternity/bip39';
import { TxBuilderHelper, SCHEMA } from '@aeternity/aepp-sdk';
import { defaultNetworks, TX_TYPE_MDW } from '../popup/utils/constants';
import { AVATAR_URL, defaultNetworks, TX_TYPE_MDW } from '../popup/utils/constants';
import {
checkHashType,
convertToken,
Expand Down Expand Up @@ -67,7 +67,7 @@ export default {
return networks[network];
},
getProfileImage: (_, { activeNetwork }) => (address) => `${activeNetwork.backendUrl}/profile/image/${address}`,
getAvatar: () => (address) => `https://avatars.z52da5wt.xyz/${address}`,
getAvatar: () => (address) => `${AVATAR_URL}${address}`,
tippingSupported(state, { activeNetwork }) {
return (
['ae_mainnet', 'ae_uat'].includes(activeNetwork.networkId) || process.env.RUNNING_IN_TESTS
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/accounts/ledger.js
Expand Up @@ -4,6 +4,7 @@ import TransportU2F from '@ledgerhq/hw-transport-u2f';
import Ae from '@aeternity/ledger-app-api';
import { decode } from '@aeternity/aepp-sdk/es/tx/builder/helpers';
import LedgerBridge from './ledger-bridge';
import { LEDGER_BRIDGE_URL } from '../../../popup/utils/constants';

export default {
namespaced: true,
Expand All @@ -18,7 +19,7 @@ export default {
-1,
) + 1,
ledgerAppApi: () => new Ae(new TransportU2F()),
ledgerBridge: () => new LedgerBridge('https://wallet.superhero.com/ledger-bridge'),
ledgerBridge: () => new LedgerBridge(LEDGER_BRIDGE_URL),
},

actions: {
Expand Down
4 changes: 2 additions & 2 deletions src/store/plugins/fungibleTokens.js
Expand Up @@ -3,7 +3,7 @@ import FUNGIBLE_TOKEN_CONTRACT from 'aeternity-fungible-token/FungibleTokenFullI
import BigNumber from 'bignumber.js';
import { unionBy, isEqual, isEmpty } from 'lodash-es';
import { convertToken, fetchJson, handleUnknownError } from '../../popup/utils/helper';
import { ZEIT_TOKEN_INTERFACE } from '../../popup/utils/constants';
import { CURRENCY_URL, ZEIT_TOKEN_INTERFACE } from '../../popup/utils/constants';

export default (store) => {
store.registerModule('fungibleTokens', {
Expand Down Expand Up @@ -121,7 +121,7 @@ export default (store) => {
},
async getAeternityData({ rootState: { current }, commit }) {
const [aeternityData] = await fetchJson(
`https://api.coingecko.com/api/v3/coins/markets?ids=aeternity&vs_currency=${current.currency}`,
`${CURRENCY_URL}${current.currency}`,
).catch((e) => {
handleUnknownError(e);
return [];
Expand Down
5 changes: 3 additions & 2 deletions src/store/plugins/observables.js
Expand Up @@ -12,6 +12,7 @@ import {
setBalanceLocalStorage,
getBalanceLocalStorage,
} from '../../popup/utils/helper';
import { AGGREGATOR_URL } from '../../popup/utils/constants';

export default (store) => {
// eslint-disable-next-line no-underscore-dangle
Expand Down Expand Up @@ -82,8 +83,8 @@ export default (store) => {
chainName: store.state.chainNames?.[sender],
path:
entityType === 'TIP'
? `https://superhero.com/tip/${entityId}`
: `https://superhero.com/tip/${sourceId}/comment/${entityId}`,
? `${AGGREGATOR_URL}tip/${entityId}`
: `${AGGREGATOR_URL}tip/${sourceId}/comment/${entityId}`,
});

const notifications$ = createSdkObservable(
Expand Down

0 comments on commit ebb9a73

Please sign in to comment.