Skip to content

Commit 75eaa49

Browse files
authored
Merge pull request #851 from telosnetwork/develop
Update Production
2 parents 51c3f3b + 1507a93 commit 75eaa49

92 files changed

Lines changed: 2450 additions & 2847 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module.exports = {
4646
// https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-file
4747
// required to lint *.vue files
4848
'vue',
49+
'unused-imports',
4950
],
5051

5152
globals: {
@@ -145,5 +146,16 @@ module.exports = {
145146
'vue/component-options-name-casing': ['error', 'PascalCase'],
146147
'vue/component-definition-name-casing': ['error', 'PascalCase'],
147148
'vue/component-name-in-template-casing': ['error', 'PascalCase'],
149+
'no-unused-vars': 'off',
150+
'unused-imports/no-unused-imports': 'error',
151+
'unused-imports/no-unused-vars': [
152+
'warn',
153+
{
154+
'vars': 'all',
155+
'varsIgnorePattern': '^_',
156+
'args': 'after-used',
157+
'argsIgnorePattern': '^_'
158+
}
159+
],
148160
}
149161
}

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424
"highcharts-vue": "^1.4.0",
2525
"moment": "^2.29.4",
2626
"ol": "^6.14.1",
27+
"pinia": "^2.1.6",
2728
"quasar": "^2.6.2",
2829
"ual-anchor": "1.3.0",
2930
"universal-authenticator-library": "^0.3.0",
30-
"vue": "^3.0.0",
31-
"vue-class-component": "^7.2.6",
31+
"vue": "^3.3.0",
3232
"vue-json-viewer": "^3.0.4",
3333
"vue-router": "^4.0.0",
34-
"vue3-openlayers": "^0.1.63",
35-
"vuex": "^4.0.1"
34+
"vue3-openlayers": "^0.1.63"
3635
},
3736
"devDependencies": {
3837
"@babel/eslint-parser": "^7.13.14",
38+
"@pinia/testing": "^0.1.3",
3939
"@quasar/app-webpack": "^3.5.3",
4040
"@quasar/quasar-app-extension-testing-unit-jest": "^3.0.0-alpha.10",
4141
"@types/jest": "^27.4.0",
@@ -45,6 +45,7 @@
4545
"dotenv": "^14.3.0",
4646
"eslint": "^7.14.0",
4747
"eslint-plugin-jest": "^25.2.2",
48+
"eslint-plugin-unused-imports": "^3.0.0",
4849
"eslint-plugin-vue": "^9.0.0",
4950
"node-polyfill-webpack-plugin": "^1.1.4",
5051
"vue-property-decorator": "^9.1.2"

quasar.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = configure(function (ctx) {
3030
// app boot file (/src/boot)
3131
// --> boot files are part of "main.js"
3232
// https://quasar.dev/quasar-cli/boot-files
33-
boot: ['config', 'axios', 'fathom', 'api', 'ual', 'fuel'],
33+
boot: ['config', 'fathom', 'api', 'ual', 'fuel'],
3434

3535
// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css
3636
css: ['app.sass'],

src/api/hyperion.ts

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ const name = chain.getName();
3838
const url =
3939
`https://raw.githubusercontent.com/telosnetwork/token-list/main/tokens.${name}.json`;
4040

41-
const tokenListPromise = fetch(url)
42-
.then(response => response.text())
43-
.then((fileContent: string) => JSON.parse(fileContent) as { account: string }[])
44-
.then(originals => originals.map(token => token as unknown as Token))
45-
.catch((error) => {
46-
console.error(error);
47-
return [];
48-
});
49-
5041
const MAX_REQUESTS_COUNT = 5;
5142
const INTERVAL_MS = 10;
5243
let PENDING_REQUESTS = 0;
@@ -97,23 +88,30 @@ export const getCreator = async function (address: string): Promise<AccountCreat
9788
};
9889

9990
export const getTokens = async function (address?: string): Promise<Token[]> {
100-
if (address) {
101-
const response = await hyperion.get('v2/state/get_tokens', {
102-
params: { account: address },
103-
});
104-
const tokens = await tokenListPromise;
105-
const balances = (response.data as {tokens:Token[]}).tokens;
106-
return balances.map((token:Token) => {
107-
const tk = tokens.find((t:Token) => t.symbol === token.symbol) as Token;
108-
if (tk && tk.logo) {
109-
token.logo = tk?.logo;
110-
} else {
111-
token.logo = DEFAULT_ICON;
112-
}
113-
return token;
114-
});
115-
} else {
116-
return await tokenListPromise;
91+
try {
92+
const tokens = await axios.get(url).then(response => response.data as Token[]);
93+
94+
if (address) {
95+
const response = await hyperion.get('v2/state/get_tokens', {
96+
params: { account: address },
97+
});
98+
99+
const balances = (response.data as {tokens:Token[]}).tokens;
100+
// return tokens;
101+
return balances.map((token:Token) => {
102+
const tk = tokens.find((t:Token) => t.symbol === token.symbol);
103+
if (tk && tk.logo) {
104+
token.logo = tk?.logo;
105+
} else {
106+
token.logo = DEFAULT_ICON;
107+
}
108+
return token;
109+
});
110+
} else {
111+
return tokens;
112+
}
113+
} catch(e) {
114+
console.error(e);
117115
}
118116
};
119117

src/boot/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { boot } from 'quasar/wrappers';
22
import { ApiClient } from 'src/types/Api';
33
import { api } from 'src/api';
44

5-
declare module '@vue/runtime-core' {
5+
declare module 'vue' {
66
interface ComponentCustomProperties {
77
$api: ApiClient;
88
}

src/boot/axios.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/components/AccountCard.vue

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<script lang="ts">
22
import { Token, GetTableRowsParams, RexbalRows, RexPoolRows } from 'src/types';
33
import { defineComponent, computed, ref, onMounted, watch } from 'vue';
4-
import { useAntelopeStore } from 'src/store/antelope.store';
54
import PercentCircle from 'src/components/PercentCircle.vue';
65
import SendDialog from 'src/components/SendDialog.vue';
76
import ResourcesDialog from 'src/components/resources/ResourcesDialog.vue';
87
import StakingDialog from 'src/components/staking/StakingDialog.vue';
98
import DateField from 'src/components/DateField.vue';
10-
import { date, useQuasar } from 'quasar';
11-
import { copyToClipboard } from 'quasar';
9+
import { date, useQuasar, copyToClipboard } from 'quasar';
1210
import { getChain } from 'src/config/ConfigManager';
1311
import { api } from 'src/api';
1412
import { useRouter } from 'vue-router';
@@ -17,6 +15,9 @@ import { API, UInt64 } from '@greymass/eosio';
1715
import { formatCurrency } from 'src/utils/string-utils';
1816
import ConfigManager from 'src/config/ConfigManager';
1917
import { isSystemAccount } from 'src/utils/systemAccount';
18+
import { useResourceStore } from 'src/stores/resources';
19+
import { useChainStore } from 'src/stores/chain';
20+
import { useAccountStore } from 'src/stores/account';
2021
2122
const chain = getChain();
2223
export default defineComponent({
@@ -37,7 +38,9 @@ export default defineComponent({
3738
setup(props) {
3839
const $q = useQuasar();
3940
const router = useRouter();
40-
const store = useAntelopeStore();
41+
const resourceStore = useResourceStore();
42+
const chainStore = useChainStore();
43+
const accountStore = useAccountStore();
4144
4245
const accountPageSettings = computed(() => ConfigManager.get().getCurrentChain().getUiCustomization().accountPageSettings);
4346
@@ -55,9 +58,7 @@ export default defineComponent({
5558
const ramUnit = ref<string>('kb');
5659
const resources = ref<number>(0);
5760
const delegatedByOthers = ref<number>(0.0);
58-
const delegatedToOthers = computed(
59-
(): number => store.resources.getDelegatedToOthersAggregated(),
60-
);
61+
const delegatedToOthers = computed(() => resourceStore.getDelegatedToOthersAggregated);
6162
const rexStaked = ref<number>(0);
6263
const rexProfits = ref<number>(0);
6364
const rexDeposits = ref<number>(0);
@@ -93,7 +94,7 @@ export default defineComponent({
9394
9495
const staked = computed((): number => stakedRefund.value + stakedNET.value + stakedCPU.value);
9596
96-
const token = computed((): Token => store.state.chain.token);
97+
const token = computed((): Token => chainStore.token);
9798
9899
const liquidNative = computed((): number => accountData.value?.core_liquid_balance?.value
99100
? accountData.value.core_liquid_balance.value
@@ -118,14 +119,14 @@ export default defineComponent({
118119
return result;
119120
});
120121
121-
const isAccount = computed((): boolean => store.state.account.accountName === props.account);
122+
const isAccount = computed((): boolean => accountStore.accountName === props.account);
122123
123124
const createTimeFormat = computed((): string =>
124125
date.formatDate(createTime.value, 'DD MMMM YYYY @ hh:mm A'),
125126
);
126127
127128
const setToken = (value: Token) => {
128-
void store.commit('chain/setToken', value);
129+
void chainStore.setToken(value);
129130
};
130131
131132
const loadAccountData = async (): Promise<void> => {
@@ -258,8 +259,7 @@ export default defineComponent({
258259
}
259260
};
260261
261-
const updateResources = (payload: {account:string, force: boolean}) =>
262-
store.resources.updateResources(payload);
262+
const updateResources = (payload: {account:string, force: boolean}) => resourceStore.updateResources(payload);
263263
264264
const getRexFund = async () => {
265265
const paramsrexfund = {
@@ -393,26 +393,25 @@ export default defineComponent({
393393
onMounted(async () => {
394394
usdPrice.value = await chain.getUsdPrice();
395395
await loadAccountData();
396-
await store.dispatch('account/updateRexData', {
396+
await accountStore.updateRexData({
397397
account: props.account,
398398
});
399399
loadSystemToken();
400-
void store.dispatch('chain/updateRamPrice');
400+
void chainStore.updateRamPrice();
401401
});
402402
403403
watch(
404404
() => props.account,
405405
async () => {
406406
resetBalances();
407407
await loadAccountData();
408-
await store.dispatch('account/updateRexData', {
408+
await accountStore.updateRexData({
409409
account: props.account,
410410
});
411411
},
412412
);
413-
414413
watch(
415-
() => store.resources.getDelegatedToOthersAggregated(),
414+
(): number => resourceStore.getDelegatedToOthersAggregated,
416415
() => {
417416
setTotalBalance();
418417
},

src/components/Header.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import LoginHandler from 'components/LoginHandler.vue';
55
import HeaderSearch from 'components/HeaderSearch.vue';
66
import ChainsMenu from 'components/ChainsMenu.vue';
77
import ConfigManager, { getChain } from 'src/config/ConfigManager';
8-
import { useStore } from 'src/store';
98
import { useRouteDataNetwork } from 'src/router';
109
import { HeaderSettings } from 'src/types/UiCustomization';
10+
import { useAccountStore } from 'src/stores/account';
1111
1212
export default defineComponent({
1313
name: 'AppHeader',
@@ -18,11 +18,11 @@ export default defineComponent({
1818
},
1919
setup() {
2020
const $q = useQuasar();
21-
const store = useStore();
22-
const headerSettings = computed(() : HeaderSettings => ConfigManager.get().getCurrentChain().getUiCustomization().headerSettings);
21+
const accountStore = useAccountStore();
22+
const headerSettings = computed((): HeaderSettings => ConfigManager.get().getCurrentChain().getUiCustomization().headerSettings);
2323
24-
const account = computed(() => store.state.account.accountName);
25-
const isLarge = computed((): boolean => $q.screen.gt.sm);
24+
const account = computed(() => accountStore.accountName);
25+
const isLarge = computed((): boolean => $q.screen.gt.md);
2626
const showMultichainSelector = computed(() => process.env.SHOW_MULTICHAIN_SELECTOR === 'true');
2727
2828
const isTestnet = ref(getChain().isTestnet());

src/components/LoginHandler.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ import { defineComponent, ref, onMounted, computed } from 'vue';
33
import LoginHandlerDropdown from 'src/components/LoginHandlerDropdown.vue';
44
import WalletModal from 'src/components/WalletModal.vue';
55
import { Authenticator } from 'universal-authenticator-library';
6-
import { useStore } from 'src/store';
76
import { getAuthenticators } from 'src/boot/ual';
87
import { getChain } from 'src/config/ConfigManager';
8+
import { useAccountStore } from 'src/stores/account';
99
1010
export default defineComponent({
1111
name: 'LoginHandler',
1212
components: { LoginHandlerDropdown, WalletModal },
1313
setup() {
1414
const authenticators = getAuthenticators();
15-
const store = useStore();
15+
const accountStore = useAccountStore();
1616
1717
const showDropdown = ref(false);
1818
const showModal = ref(false);
19-
const account = computed(() => store.state.account.accountName);
19+
const account = computed(() => accountStore.accountName);
2020
2121
onMounted(() => {
2222
const storedAccount = localStorage.getItem('account_' + getChain().getChainId());
2323
if (storedAccount) {
24-
void store.commit('account/setAccountName', storedAccount);
24+
void accountStore.setAccountName(storedAccount);
2525
const ualName = localStorage.getItem('autoLogin_' + getChain().getChainId());
2626
const ual: Authenticator = authenticators.find(
2727
a => a.getName() === ualName,
2828
);
29-
void store.dispatch('account/login', {
29+
void accountStore.login({
3030
account: storedAccount,
3131
authenticator: ual,
3232
});

src/components/LoginHandlerDropdown.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
<script lang="ts">
2-
import { defineComponent, ref, computed } from 'vue';
2+
import { computed, defineComponent, ref } from 'vue';
33
import WalletModal from 'src/components/WalletModal.vue';
4-
import { useStore } from 'src/store';
54
import { getAuthenticators } from 'src/boot/ual';
65
import { Authenticator } from 'universal-authenticator-library';
76
import { getChain } from 'src/config/ConfigManager';
7+
import { useAccountStore } from 'src/stores/account';
88
99
export default defineComponent({
1010
name: 'LoginHandlerDropdown',
1111
components: { WalletModal },
1212
setup() {
1313
const authenticators = getAuthenticators();
14-
const store = useStore();
15-
const account = computed(() => store.state.account.accountName);
14+
const accountStore = useAccountStore();
15+
const account = computed(() => accountStore.accountName);
1616
const showModal = ref(false);
1717
1818
const getAuthenticator = (): Authenticator => {
1919
const wallet = localStorage.getItem('autoLogin_' + getChain().getChainId());
20-
const authenticator = authenticators.find(
20+
return authenticators.find(
2121
auth => auth.getName() === wallet,
2222
);
23-
return authenticator;
2423
};
2524
2625
const onLogout = async (): Promise<void> => {
@@ -35,7 +34,7 @@ export default defineComponent({
3534
};
3635
3736
const clearAccount = (): void => {
38-
void store.dispatch('account/logout');
37+
void accountStore.logout();
3938
};
4039
return {
4140
account,

0 commit comments

Comments
 (0)