From e812a3f3b04b8ddb4bdd010f383d3d1649bffdf6 Mon Sep 17 00:00:00 2001 From: Tim Schmidt Date: Wed, 11 Oct 2023 12:05:05 -0700 Subject: [PATCH 01/14] feat: add nft list and links from balances Signed-off-by: Tim Schmidt --- src/components/account/NftsTable.vue | 127 ++++++++++++++++++ src/components/account/NftsTableController.ts | 85 ++++++++++++ src/pages/AccountBalances.vue | 29 +++- tests/e2e/specs/AccountNavigation.cy.ts | 1 + 4 files changed, 238 insertions(+), 4 deletions(-) create mode 100644 src/components/account/NftsTable.vue create mode 100644 src/components/account/NftsTableController.ts diff --git a/src/components/account/NftsTable.vue b/src/components/account/NftsTable.vue new file mode 100644 index 000000000..1ee373513 --- /dev/null +++ b/src/components/account/NftsTable.vue @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/components/account/NftsTableController.ts b/src/components/account/NftsTableController.ts new file mode 100644 index 000000000..c9573172e --- /dev/null +++ b/src/components/account/NftsTableController.ts @@ -0,0 +1,85 @@ +/*- + * + * Hedera Mirror Node Explorer + * + * Copyright (C) 2021 - 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import { + Nft, + Nfts, + NftTransactionHistory, + TokenBalancesResponse, + TokenDistribution, + TokenRelationship +} from "@/schemas/HederaSchemas"; +import {ComputedRef, Ref} from "vue"; +import axios, {AxiosResponse} from "axios"; +import {KeyOperator, SortOrder, TableController} from "@/utils/table/TableController"; +import {Router} from "vue-router"; + +export class NftsTableController extends TableController { + + public readonly accountId: Ref + + // + // Public + // + + public constructor(router: Router, accountId: Ref, pageSize: ComputedRef) { + super(router, pageSize, 10 * pageSize.value, 5000, 10, 100) + this.accountId = accountId + } + + // + // TableController + // + + public async load(tokenId: string | null, operator: KeyOperator, order: SortOrder, limit: number): Promise { + if (this.accountId.value == null) { + return Promise.resolve(null) + } + + const params = {} as { + limit: number + "token.id": string | undefined + order: string + } + params.limit = limit + params.order = order + if (tokenId !== null) { + params["token.id"] = operator + ":" + tokenId + } + + const r = await axios.get( + `api/v1/accounts/${this.accountId.value}/nfts`, + {params: params}, + ) + return r.data.nfts ?? [] + } + + public keyFor(row: Nft): string { + return row.token_id ?? "" + } + + public stringFromKey(key: string): string { + return key; + } + + public keyFromString(s: string): string | null { + return s; + } +} diff --git a/src/pages/AccountBalances.vue b/src/pages/AccountBalances.vue index 9151d0add..0d032e142 100644 --- a/src/pages/AccountBalances.vue +++ b/src/pages/AccountBalances.vue @@ -36,6 +36,16 @@ + + + + +