Skip to content

Commit

Permalink
Merge pull request #409 from telosnetwork/develop
Browse files Browse the repository at this point in the history
v1.0.1-rc
  • Loading branch information
karynemayer authored Nov 10, 2022
2 parents 8f8d596 + 75d641c commit dc54124
Show file tree
Hide file tree
Showing 29 changed files with 268 additions and 141 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ NETWORK_EVM_ENDPOINT=https://testnet.telos.caleos.io
NETWORK_EVM_CONTRACT=eosio.evm
NETWORK_EVM_CHAIN_ID=41
HYPERION_ENDPOINT=https://testnet.telos.caleos.io
TELOS_API_ENDPOINT=http://app-dev.telos.net
TELOS_API_ENDPOINT=http://api-dev.telos.net/v1

# TELOS_API_ENDPOINT=localhost:9999/v1
APP_NAME=OBE
Expand All @@ -25,7 +25,7 @@ PRODUCER_BUCKET_URL=https://telos-producer-validation.s3.amazonaws.com
# NETWORK_EVM_CONTRACT=eosio.evm
# NETWORK_EVM_CHAIN_ID=40
# HYPERION_ENDPOINT=https://telos.caleos.io
# TELOS_API_ENDPOINT=http://app.telos.net
# TELOS_API_ENDPOINT=http://api.telos.net/v1

SHOW_SIDEBAR=true #default sidebar state
CHAIN_NAME=telos #default chain
CHAIN_NAME=telos #default chain
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn test
35 changes: 18 additions & 17 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,31 @@ module.exports = {
'<rootDir>/src/**/*.tsx'
],
coveragePathIgnorePatterns: ['/node_modules/', '.d.ts$'],
//TODO increase thresholds as coverage increases as testing will be enforced
coverageThreshold: {
global: {
branches: 50,
functions: 50,
lines: 50,
statements: 50
branches: 0,
functions: 0,
lines: 0,
statements: 0
},
'./src/components/': {
statements: 100,
branches: 100,
functions: 100,
lines: 100
statements: 0,
branches: 0,
functions: 0,
lines: 0
},
'./src/pages/': {
statements: 100,
branches: 100,
functions: 100,
lines: 100
statements: 0,
branches: 0,
functions: 0,
lines: 0
},
'./src/layouts/': {
statements: 100,
branches: 100,
functions: 100,
lines: 100
statements: 0,
branches: 0,
functions: 0,
lines: 0
}
},
testMatch: [
Expand Down Expand Up @@ -95,6 +96,6 @@ module.exports = {
'jest-transform-stub'
},
transformIgnorePatterns: [`node_modules/(?!(${esModules}))`],
setupFiles: ['<rootDir>/jest.init.js'],
setupFiles: ['<rootDir>/jest.init.js', '<rootDir>/test/jest/setEnvVars.ts'],
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue']
};
10 changes: 8 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from = "/*"
to = "/"
status = 200

[build]
publish = "dist/spa"
command = "quasar build"
Expand All @@ -22,6 +22,8 @@
PRODUCER_BUCKET_URL="https://telos-producer-validation.s3.amazonaws.com"
# SHOW_SIDEBAR = "true"
CHAIN_NAME = "telos"
TELOS_API_ENDPOINT="http://api.telos.net/v1"


[context.develop.environment]
APP_NAME = "Telos Testnet Block Explorer"
Expand All @@ -38,7 +40,9 @@
PRODUCER_BUCKET_URL="https://telos-producer-validation.s3.amazonaws.com"
# SHOW_SIDEBAR = "true"
CHAIN_NAME = "telos-testnet"

TELOS_API_ENDPOINT="http://api-dev.telos.net/v1"


[context.deploy-preview.environment]
APP_NAME = "Telos Block Explorer"
NODE_VERSION = "14"
Expand All @@ -54,3 +58,5 @@
PRODUCER_BUCKET_URL="https://telos-producer-validation.s3.amazonaws.com"
# SHOW_SIDEBAR = "true"
CHAIN_NAME = "telos"
TELOS_API_ENDPOINT="http://api.telos.net/v1"

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"build": "quasar clean && quasar build",
"lint": "eslint --ext .js,.ts,.vue ./",
"test": "jest --coverage",
"test:coverage": "quasar serve test/jest/coverage/lcov-report/ --port 8788"
"test:coverage": "quasar serve test/jest/coverage/lcov-report/ --port 8788",
"postinstall": "husky install"
},
"dependencies": {
"@greymass/eosio": "^0.5.4",
Expand Down Expand Up @@ -48,6 +49,7 @@
"eslint-plugin-jest": "^25.2.2",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^7.0.0",
"husky": "^8.0.2",
"node-polyfill-webpack-plugin": "^1.1.4",
"prettier": "^2.5.1",
"pug": "^3.0.2",
Expand Down
3 changes: 2 additions & 1 deletion quasar.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ module.exports = configure(function (ctx) {
// Quasar plugins
plugins: [
'Notify',
'Dialog'
'Dialog',
'LocalStorage'
]
},

Expand Down
2 changes: 0 additions & 2 deletions src/api/hyperion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import { Chain } from 'src/types/Chain';
import { getChain } from 'src/config/ConfigManager';

const chain: Chain = getChain();
console.dir(chain);

const hyperion = axios.create({ baseURL: chain.getHyperionEndpoint() });
const controller = new AbortController();

Expand Down
6 changes: 5 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ import {
getKeyAccounts,
getProducerSchedule
} from './hyperion'; // e.g. './new-service' method name stays the same

import {
getTableRows,
getTokenBalances,
deserializeActionData,
serializeActionData
} from './eosio_core';

import { getApy } from './telosApi';

export const api = {
getAccount,
getCreator,
Expand All @@ -53,5 +56,6 @@ export const api = {
getKeyAccounts,
deserializeActionData,
serializeActionData,
getProducerSchedule
getProducerSchedule,
getApy
};
42 changes: 42 additions & 0 deletions src/api/telosApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import axios from 'axios';
import { Chain } from 'src/types/Chain';
import { getChain } from 'src/config/ConfigManager';

const MAX_REQUESTS_COUNT = 5;
const INTERVAL_MS = 10;
let PENDING_REQUESTS = 0;

const chain: Chain = getChain();

const telosApi = axios.create({ baseURL: chain.getApiEndpoint() });

telosApi.interceptors.request.use(function (config) {
return new Promise((resolve) => {
const interval = setInterval(() => {
if (PENDING_REQUESTS < MAX_REQUESTS_COUNT) {
PENDING_REQUESTS++;
clearInterval(interval);
resolve(config);
}
}, INTERVAL_MS);
});
});

/**
* Axios Response Interceptor
*/
telosApi.interceptors.response.use(
function (response) {
PENDING_REQUESTS = Math.max(0, PENDING_REQUESTS - 1);
return Promise.resolve(response);
},
function (error) {
PENDING_REQUESTS = Math.max(0, PENDING_REQUESTS - 1);
return Promise.reject(error);
}
);

export const getApy = async function (): Promise<string> {
const response = await telosApi.get('apy/native');
return response.data as string;
};
27 changes: 16 additions & 11 deletions src/components/HeaderSearch.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { defineComponent, ref, toRaw, watch } from 'vue';
import { defineComponent, ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import { OptionsObj } from 'src/types';
import { api } from 'src/api';
Expand Down Expand Up @@ -141,19 +141,26 @@ export default defineComponent({
}
}
async function handleGoTo() {
const optionsRaw = toRaw(options.value);
async function handleGoTo(path?: string) {
if (!inputValue.value) {
return;
}
// if clicked/selected from dropdown search results
if (typeof path === 'string') {
await router.push(path);
router.go(0);
}
// transaction validation
if (isValidHex(inputValue.value) && inputValue.value.length == 64) {
await router.push({
name: 'transaction',
params: { transaction: inputValue.value }
});
router.go(0);
// key validation
} else if (
(inputValue.value.length == 53 && inputValue.value.startsWith('EOS')) ||
(inputValue.value.length == 57 && inputValue.value.startsWith('PUB_K1'))
Expand All @@ -163,7 +170,9 @@ export default defineComponent({
params: { key: inputValue.value }
});
router.go(0);
} else if (inputValue.value.length <= 12) {
// default to 'account'
} else if (inputValue.value.length <= 13) {
try {
await api.getAccount(inputValue.value.toLowerCase());
await router.push({
Expand All @@ -173,15 +182,11 @@ export default defineComponent({
}
});
router.go(0);
return;
} catch (error) {
$q.notify(`account ${inputValue.value} not found!`);
}
}
const option = optionsRaw.find((item) => item.label === inputValue.value);
const to = option ? option.to : optionsRaw[1].to;
await router.push(to);
router.go(0);
}
return {
Expand Down Expand Up @@ -223,7 +228,7 @@ q-select(

template(#option="scope")
q-item-label(v-if="scope.opt.isHeader" header) {{ scope.opt.label }}
q-item(v-else v-bind="scope.itemProps" exact @click="handleGoTo" clickable)
q-item(v-else v-bind="scope.itemProps" exact @click="handleGoTo(scope.opt.to)" clickable)
q-item-section
q-item-label {{ scope.opt.label }}
</template>
Expand Down
1 change: 0 additions & 1 deletion src/components/KeyAccountsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default defineComponent({
const Key = ref(props.pubkey);
const Accounts = computed(() => props.accounts);
const $q = useQuasar();
console.log(chain.getSmallLogoPath());
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
const tokenLogo = computed(() => chain.getSmallLogoPath());
function copy(value: string) {
Expand Down
10 changes: 5 additions & 5 deletions src/components/PercentCircle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,23 @@ export default defineComponent({
<template lang="pug">
div.chart-container
svg.circular-chart(:style="{ 'max-width': containerWidth }" :viewBox="`${-offset * 6} ${-offset / 2} ${containerWidth} ${containerWidth}`" )
path.circle-bg(
path.circle-bg(
:d="`M18 2 a ${radius} ${radius} 0 0 1 0 88 a ${radius} ${radius} 0 0 1 0 ${-diameter}`"
)
path.circle(
path.circle(
:stroke-dasharray="dashArray"
:d="`M18 2 a ${radius} ${radius} 0 0 1 0 88 a ${radius} ${radius} 0 0 1 0 ${-diameter}`"
:stroke='strokeColor'
:style="{ 'stroke-opacity' : Number.isNaN(formatResourcePercent) ? 0 : 1, 'stroke' : !Number.isNaN(formatResourcePercent) && Number(formatResourcePercent) > 80 ? 'red' : 'white' }"
)
text.text.label(
text.text.label(
x="18"
:y="radius - offset"
) {{ label }}
) {{ label }}
text.text.percentage(
v-if='!Number.isNaN(formatResourcePercent)'
x="20"
:y="radius + 12"
:y="radius + 12"
) {{ formatResourcePercent }}%
p.text.usage USED: {{ this.fraction }} {{ this.unit }}
p.text.usage TOTAL: {{ this.total }} {{ this.unit }}
Expand Down
15 changes: 14 additions & 1 deletion src/components/Staking/StakingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export default defineComponent({
amount: 0,
contract: 'eosio.token'
} as Token,
sendDialog: false
sendDialog: false,
apy: '--'
};
},
props: {
Expand Down Expand Up @@ -127,6 +128,12 @@ export default defineComponent({
}
},
async mounted() {
try {
const apyValue = await this.$api.getApy();
this.apy = `${apyValue}%`;
} catch (e) {
console.error(e);
}
await this.loadAccountData();
}
});
Expand All @@ -141,6 +148,7 @@ q-dialog( @show='setDefaults' :persistent='true' @hide='resetForm' maximized)
.col-xs-12.col-sm-10.col-md-7.col-lg-7.maxSize
.row.q-pl-sm
.text-h4.q-pb-md.inline-block.color-grey-3.inline Staking (REX)
.text-h5.q-pb-md.inline-block.color-grey-3.inline.float-right APY: {{ apy }}
.q-pa-sm
StakingInfo
.q-pt-lg.q-pl-lg(v-if='rexfund > 0')
Expand Down Expand Up @@ -233,4 +241,9 @@ q-dialog( @show='setDefaults' :persistent='true' @hide='resetForm' maximized)
.q-tab-panel
padding-left: 0 !important
padding-right: 0 !important
.float-right
margin-left: auto
margin-top: auto
padding-right: 8px
</style>
Loading

0 comments on commit dc54124

Please sign in to comment.