Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply bugfixes to production #719

Merged
merged 21 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1791946
hide erc20 transfers when is empty
Viterbo Apr 19, 2024
bcf60af
reparing value display in transfers table
Viterbo Apr 20, 2024
0bc5491
adding direction column to transactions table
Viterbo Apr 20, 2024
4dd4667
adding TLOS Transfers section to Transaction Page
Viterbo Apr 20, 2024
02a3a6d
Merge pull request #710 from telosnetwork/700-dont-show-erc20-transfe…
pmjanus Apr 23, 2024
7bf41e8
Merge pull request #713 from telosnetwork/657-restore-inout-fields-on…
pmjanus Apr 23, 2024
55b30f2
Merge pull request #712 from telosnetwork/708-erc20-transfer-amount-d…
pmjanus Apr 23, 2024
ac85e4b
resolvking conflicts
Viterbo Apr 23, 2024
c7822ff
reparing the code
Viterbo Apr 24, 2024
a7222d2
saving the code viewr state to local storage
Viterbo Apr 25, 2024
456f820
saving wip
Viterbo Apr 25, 2024
3872b30
Merge pull request #714 from telosnetwork/709-wtlos-balance-incorrect…
pmjanus Apr 25, 2024
1f06c0c
redesign of transaction action field
Viterbo Apr 26, 2024
a4a8555
remember the new default when collapse or expand all
Viterbo Apr 26, 2024
1c57d6d
removing non-used imports
Viterbo Apr 26, 2024
d025132
Merge pull request #718 from telosnetwork/717-remember-the-state-of-t…
pmjanus Apr 26, 2024
6942654
Merge pull request #720 from telosnetwork/564-improve-tx-route-page-t…
pmjanus Apr 26, 2024
353658f
saving wip
Viterbo Apr 26, 2024
e873c73
Merge branch 'dev' of https://github.com/telosnetwork/teloscan into 7…
Viterbo Apr 26, 2024
da4c732
incorporating ValueField Component
Viterbo Apr 27, 2024
83ba7f6
Merge pull request #721 from telosnetwork/716-display-amounts-with-cu…
rozzaswap Apr 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/boot/fathom.js

This file was deleted.

116 changes: 73 additions & 43 deletions src/components/ContractTab/ContractSource.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- eslint-disable @typescript-eslint/no-explicit-any -->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { onMounted, ref, watch } from 'vue';
import axios from 'axios';
import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css';
Expand Down Expand Up @@ -32,11 +32,75 @@ const loading = ref(true);
const sources = ref(false);
const metaData = ref<MetaData>({});

const expanded = ref({} as {[key:string]: boolean});
// expand / collapse ------
interface ExpandedCollapsed {
[key: string]: boolean;
}
const expanded = ref({} as ExpandedCollapsed);
const enableSave = ref(false);
const defaultState = ref<boolean | null>(null);

const saveDefaultState = () => {
localStorage.setItem('expanded-default', JSON.stringify(defaultState.value));
};

const loadDefaultState = () => {
const defaultStateData = localStorage.getItem('expanded-default');
if (defaultStateData) {
const parsed = JSON.parse(defaultStateData);
defaultState.value = parsed;
return true;
} else {
return false;
}
};
loadDefaultState();

const expandAll = () => {
for (const key in expanded.value) {
expanded.value[key] = true;
}
defaultState.value = true;
enableSave.value = true;
saveDefaultState();
};

const collapseAll = () => {
for (const key in expanded.value) {
expanded.value[key] = false;
}
defaultState.value = false;
enableSave.value = true;
saveDefaultState();
};

// this function saves expanded content to local storage
const saveExpanded = () => {
if (enableSave.value) {
localStorage.setItem(`expanded-${props.contract.address}`, JSON.stringify(expanded.value));
}
};

// this function loads expanded content from local storage
const loadExpanded = () => {
const expandedData = localStorage.getItem(`expanded-${props.contract.address}`);
if (expandedData) {
const parsed = JSON.parse(expandedData);
for (const key in parsed) {
expanded.value[key] = parsed[key];
}
return true;
} else {
return false;
}
};

const getFileKey = (index: number) => `viewer-${index}`;

watch(expanded.value, () => {
saveExpanded();
});

onMounted(async () => {
let sourceData;
try {
Expand All @@ -55,32 +119,6 @@ onMounted(async () => {
loading.value = false;
}

try {
const bytecodeResponse = await axios.post('/evm', {
jsonrpc: '2.0',
id: 1,
method: 'eth_getCode',
params: [props.contract.address],
});

if (bytecodeResponse.data?.result) {
(files.value as any[]).unshift({
content: bytecodeResponse.data.result,
name: 'bytecode',
expanded: false,
fullscreen: false,
raw: bytecodeResponse.data.result,
contract: false,
});
}

(files.value as any[]).forEach((file, index) => {
expanded.value[getFileKey(index)] = true;
});
} catch (e) {
console.error(e);
}

loading.value = false;
});

Expand Down Expand Up @@ -111,9 +149,12 @@ const sortFiles = (filesToSort: any[]) => {
}
}

(files.value as any[]).forEach((file, index) => {
expanded.value[getFileKey(index)] = true;
});
const loaded = loadExpanded();
if (!loaded) {
(files.value as any[]).forEach((file, index) => {
expanded.value[getFileKey(index)] = defaultState.value === null ? true : defaultState.value;
});
}
};

const isContract = (fileName: string) => {
Expand All @@ -134,18 +175,6 @@ const setMetaData = (data: any) => {
};
};

const expandAll = () => {
for (const key in expanded.value) {
expanded.value[key] = true;
}
};

const collapseAll = () => {
for (const key in expanded.value) {
expanded.value[key] = false;
}
};

</script>

<template>
Expand Down Expand Up @@ -200,6 +229,7 @@ const collapseAll = () => {
v-model="expanded[getFileKey(index)]"
:default-opened="true"
class="shadow-2 q-mb-md"
@update:model-value="enableSave = true; expanded[getFileKey(index)] = $event;"
>
<template v-slot:header>
<div class="flex items-center justify-between">
Expand Down
19 changes: 18 additions & 1 deletion src/components/MethodField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const props = defineProps({
type: Boolean,
default: false,
},
separateWords: {
type: Boolean,
default: false,
},
contract: {
type: Object,
default: () => null,
Expand All @@ -49,7 +53,7 @@ const methodSignature = computed(() => {

return '';
});
const displayText = computed(() => {
const methodNameOrSignature = computed(() => {
if (methodName.value) {
return methodName.value;
}
Expand All @@ -60,6 +64,19 @@ const displayText = computed(() => {

return '';
});
const displayText = computed(() => {
try {
let method = methodNameOrSignature.value;
if (method && props.separateWords) {
method = method.replace(/([A-Z])/g, ' $1').trim();
method = method[0].toUpperCase() + method.slice(1);
}
return method;
} catch (e) {
console.error(e);
}
return '';
});
const propValue = computed(() => +(props.trx.value || '0x0'));

onMounted(async () => {
Expand Down
54 changes: 23 additions & 31 deletions src/components/NftTransfersTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useI18n } from 'vue-i18n';
import { indexerApi } from 'src/boot/telosApi';

import TransactionField from 'components/TransactionField.vue';
import ValueField from 'components/ValueField.vue';
import MethodField from 'components/MethodField.vue';
import AddressField from 'components/AddressField.vue';
import NftItemField from 'components/NftItemField.vue';
Expand All @@ -14,12 +15,12 @@ import { formatWei, toChecksumAddress } from 'src/lib/utils';
import { NftTransferProps, NftTransferData } from 'src/types';

import { loadTransaction, getDirection } from 'src/lib/transaction-utils';
import { WEI_PRECISION } from 'src/antelope/wallets/utils';
import { BigNumber } from 'ethers';
import { prettyPrintCurrency } from 'src/antelope/wallets/utils/currency-utils';
import { Pagination } from 'src/types';
import { useStore } from 'vuex';

const { t: $t } = useI18n();
const $store = useStore();
const toggleDisplayDecimals = () => $store.dispatch('general/toggleDisplayDecimals');

// ---------------------
interface TransfersResponse {
Expand Down Expand Up @@ -236,29 +237,6 @@ const onRequest = async (settings: { pagination: Pagination}) => {
loading.value = false;
};

const locale = useI18n().locale.value;
function getValueDisplay(value: string, symbol: string, decimals: number) {
const _decimals = typeof decimals === 'number' ? decimals : parseInt(decimals ?? WEI_PRECISION);
console.log('getValueDisplay', value, symbol, decimals, '[', _decimals, ']');
try {
return prettyPrintCurrency(
BigNumber.from(value.split('.').join('')),
4,
locale,
false,
symbol ?? 'UNKNOWN',
false,
_decimals,
false,
);
} catch (e) {
console.error('getValueDisplay', e);
}

return truncatedId(value);
}


const convertToEpoch = (dateString: string | number) => {
if (typeof dateString === 'number'){
return dateString / 1000;
Expand Down Expand Up @@ -364,6 +342,17 @@ onMounted(() => {
</q-tooltip>
</q-icon>
</div>
<div
v-else-if="col.name==='value'"
class="u-flex--center-y"
@click="toggleDisplayDecimals"
>
<a>{{ col.label }}</a>
<q-icon class="info-icon q-ml-xs" name="far fa-question-circle"/>
<q-tooltip anchor="bottom middle" self="bottom middle">
{{ $t('components.click_to_change_format') }}
</q-tooltip>
</div>
<div v-else class="u-flex--center-y">
{{ col.label }}
</div>
Expand All @@ -375,7 +364,9 @@ onMounted(() => {
<template v-slot:body="props">
<q-tr :props="props">
<q-td key="hash" :props="props">
<TransactionField :transaction-hash="props.row.hash"/>
<TransactionField
:transaction-hash="props.row.hash"
/>
</q-td>
<q-td key="method" :props="props">
<MethodField
Expand Down Expand Up @@ -430,10 +421,11 @@ onMounted(() => {
</span>
</q-td>
<q-td key="value" :props="props">
<span class="value">
{{ getValueDisplay(props.row.value, props.row.contract.symbol, props.row.contract.decimals) }}
<q-tooltip>{{ props.row.value }}</q-tooltip>
</span>
<ValueField
:value="props.row.value"
:symbol="props.row.contract.symbol"
:decimals="props.row.contract.decimals"
/>
</q-td>
<q-td key="token" :props="props" class="flex items-center">
<AddressField
Expand Down
31 changes: 24 additions & 7 deletions src/components/Token/TokenTable.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script>
import AddressField from 'src/components/AddressField';
import AddToWallet from 'src/components/AddToWallet';
import ValueField from 'components/ValueField.vue';
import { mapActions } from 'vuex';

export default {
name: 'TokenTable',
components: { AddressField, AddToWallet },
components: { AddressField, AddToWallet, ValueField },
props: {
tokens: {
type: Array,
Expand Down Expand Up @@ -50,6 +52,12 @@ export default {
columns,
};
},
methods: {
...mapActions('general', ['toggleDisplayDecimals']),
async showEntry(token) {
console.log('showEntry', token);
},
},
};
</script>

Expand All @@ -69,15 +77,24 @@ export default {
:key="col.name"
:props="props"
>
<div class="u-flex--center-y">
{{ col.label }}
<div v-if="col.name==='balance'" class="u-flex--center-y" @click="toggleDisplayDecimals">
<a>{{ col.label }}</a>
<q-icon class="info-icon q-ml-xs" name="far fa-question-circle"/>
<q-tooltip anchor="bottom middle" self="bottom middle">
{{ $t('components.click_to_change_format') }}
</q-tooltip>
</div>
<template v-else>
<div class="u-flex--center-y">
{{ col.label }}
</div>
</template>
</q-th>
</q-tr>
</template>

<template v-slot:body="props">
<q-tr :props="props">
<q-tr :props="props" @click="showEntry(props.row)">
<q-td key="icon" :props="props">
<q-img :src="props.row.logoURI" class="c-token-icon" />
</q-td>
Expand All @@ -88,9 +105,9 @@ export default {
{{ props.row.symbol }}
</q-td>
<q-td key="balance" :props="props">
<span v-if="props.row.balance === '0.0000'">{{ '< 0.0001' }}</span>
<span v-else>{{ props.row.balance }}</span>
<q-tooltip>{{ props.row.fullBalance }}</q-tooltip>
<ValueField
:value="props.row.fullBalance"
/>
</q-td>
<q-td key="usd" :props="props">
<span v-if="props.row.price > 0">
Expand Down
Loading
Loading