Skip to content

Commit

Permalink
Merge pull request #749 from telosnetwork/master
Browse files Browse the repository at this point in the history
Merge Master into Dev.
  • Loading branch information
pmjanus authored May 21, 2024
2 parents aaa4f25 + bcb0d80 commit a71816a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 22 deletions.
5 changes: 3 additions & 2 deletions src/components/AddressField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const contractName = ref('');
const logo = ref<any>(null);
const tokenList = ref<any>(null);
const checksum = ref('');
const isToken = computed(() => contract.value?.isToken() ?? false);
const restart = async () => {
if (!props.address) {
Expand Down Expand Up @@ -103,7 +104,7 @@ const getDisplay = async () => {
? ''
: logo.value
;
const name = (contract.value.isToken() && contract.value.getProperties()?.symbol)
const name = (isToken.value && contract.value.getProperties()?.symbol)
? contract.value.getProperties().symbol
: contractName.value
;
Expand Down Expand Up @@ -136,7 +137,7 @@ const loadContract = async () => {
@mouseleave="setHighlightAddress('')"
>
<router-link
:to="`/address/${checksum}`"
:to="`/${isToken?'token':'address'}/${checksum}`"
:class="{
'c-address-field__link': true,
'c-address-field__link--highlight': highlightAddress === checksum && highlightAddress !== ''
Expand Down
39 changes: 22 additions & 17 deletions src/components/TransactionTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,17 @@ async function parseTransactions() {
}
}
loading.value = false;
rows.value = transactions;
// This converts the timestamp to a number regardless of the format it is in
rows.value = transactions.map((t) => {
if (typeof t.timestamp === 'number') {
return t;
} else {
const timestamp = new Date(t.timestamp).getTime();
const localZone = new Date().getTimezoneOffset() * 60000;
t.timestamp = timestamp - localZone;
return t;
}
});
} catch (e: any) {
$q.notify({
type: 'negative',
Expand Down Expand Up @@ -282,37 +292,32 @@ function addEmptyToCache(contracts: any, transaction: any){
async function getPath() {
const { page, key, rowsPerPage, descending } = pagination.value;
const prepend = props.accountAddress ? `address/${props.accountAddress}` : '';
let path = `${prepend}/transactions?limit=${
rowsPerPage === 0 ? 100 : Math.min(rowsPerPage, props.initialPageSize)
}`;
const limit = rowsPerPage === 0 ? 50 : Math.max(Math.min(rowsPerPage, props.initialPageSize), 10);
let path = '';
if (props.accountAddress) {
path = `address/${props.accountAddress}/transactions?limit=${limit}`;
path += `&offset=${(page - 1) * rowsPerPage}`;
path += `&sort=${descending ? 'desc' : 'asc'}`;
path += (pagination.value.rowsNumber === 0) ? '&includePagination=true' : ''; // We only need the count once
if (props.block) {
if (props.accountAddress) {
path += `&startBlock=${props.block}&endBlock=${props.block}`;
} else {
path += `&block=${props.block}`;
}
path += `&startBlock=${props.block}&endBlock=${props.block}`;
}
} else {
path = `transactions?limit=${limit}`;
if (pagination.value.initialKey === 0) {
// in the case of the first query, we need to get the initial key
let _aux_path = path.replace(/limit=\d+/, 'limit=1');
_aux_path += `&sort=${descending ? 'desc' : 'asc'}`;
_aux_path += '&includePagination=true';
_aux_path += '&key=0';
let response = await indexerApi.get(_aux_path);
let response = await indexerApi.get('transactions?includePagination=true&key=0');
const next = response.data.next;
pagination.value.initialKey = next + 1;
console.log('--->', { next, initialKey: pagination.value.initialKey });
}
path += `&sort=${descending ? 'desc' : 'asc'}`;
path += '&includePagination=true';
path += '&includeAbi=true';
path += `&key=${key}`;
if (props.block) {
path += `&block=${props.block}`;
} else {
path += `&key=${key}`;
}
}
return path;
}
Expand Down
10 changes: 7 additions & 3 deletions src/pages/AccountPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const initialLoadComplete = ref(false);
const accountAddress = computed(() => route.params.address as string ?? '');
const isLoggedIn = computed(() => store.getters['login/isLoggedIn']);
const address = computed(() => store.getters['login/address']);
const isToken = computed(() => contract.value?.isToken() ?? false);
watch(accountAddress, (newVal, oldVal) => {
if (newVal !== oldVal) {
Expand Down Expand Up @@ -122,6 +123,9 @@ async function loadAccount() {
});
}
title.value = $t('pages.contract');
if (isToken.value){
title.value = $t('components.token');
}
} else {
contractManager.addContractToCache(accountAddress.value, { address: accountAddress.value });
try {
Expand Down Expand Up @@ -222,7 +226,7 @@ async function loadAccount() {
:label="$t('components.nfts.collection')"
/>
<q-tab
v-if="contract && contract.isToken()"
v-if="isToken"
name="holders"
class="c-address__tabs-tab"
:to="{ query: {tab: 'holders' }}"
Expand Down Expand Up @@ -310,8 +314,8 @@ async function loadAccount() {
>
<NFTList :address="contract.address" filter="contract" />
</q-tab-panel>
<q-tab-panel v-if="contract && contract.isToken()" name="holders">
<HolderList :contract="contract" />
<q-tab-panel v-if="isToken" name="holders">
<HolderList v-if="contract" :contract="contract" />
</q-tab-panel>
<q-tab-panel v-else name="internaltx">
<InternalTransactionFlatTable
Expand Down
12 changes: 12 additions & 0 deletions src/router/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ const routes = [
component: () => import('pages/home/HomePage.vue'),
}],
},
{
path: '/token/:address',
component: () => import('layouts/MainLayout.vue'),
children: [
{
path: '',
name: 'token',
props: route => ({ page: route.query.page, pagesize: route.query.pagesize }),
component: () => import('pages/AccountPage.vue'),
},
],
},
{
path: '/address/:address/sourcify',
component: () => import('layouts/MainLayout.vue'),
Expand Down

0 comments on commit a71816a

Please sign in to comment.