diff --git a/src/pages/AccountDetails.vue b/src/pages/AccountDetails.vue index 8a3420b52..9a044762a 100644 --- a/src/pages/AccountDetails.vue +++ b/src/pages/AccountDetails.vue @@ -193,10 +193,11 @@ - + @@ -351,6 +352,7 @@ import TransactionDownloadDialog from "@/components/download/TransactionDownload import {NameQuery} from "@/utils/name_service/NameQuery"; import EntityIOL from "@/components/values/link/EntityIOL.vue"; import InfoTooltip from "@/components/InfoTooltip.vue"; +import {labelForAutomaticTokenAssociation} from "@/schemas/HederaUtils"; export default defineComponent({ @@ -423,6 +425,11 @@ export default defineComponent({ onMounted(() => accountLocParser.mount()) onBeforeUnmount(() => accountLocParser.unmount()) + const maxAutoAssociationValue = computed(() => + labelForAutomaticTokenAssociation( + accountLocParser.accountInfo.value?.max_automatic_token_associations ?? 0 + )) + // // BalanceAnalyzer // @@ -544,6 +551,7 @@ export default defineComponent({ notification: accountLocParser.errorNotification, isInactiveEvmAddress: accountLocParser.isInactiveEvmAddress, account: accountLocParser.accountInfo, + maxAutoAssociationValue, normalizedAccountId: accountLocParser.accountId, accountChecksum: accountLocParser.accountChecksum, accountInfo: accountLocParser.accountDescription, @@ -571,6 +579,7 @@ export default defineComponent({ onDateCleared, domainName: nameQuery.name, domainProviderName: nameQuery.providerName, + labelForAutomaticTokenAssociation, } } }); diff --git a/src/pages/ContractDetails.vue b/src/pages/ContractDetails.vue index b4ec82c06..a3f5bcbaa 100644 --- a/src/pages/ContractDetails.vue +++ b/src/pages/ContractDetails.vue @@ -132,10 +132,11 @@ - + @@ -230,6 +231,7 @@ import MirrorLink from "@/components/MirrorLink.vue"; import {NameQuery} from "@/utils/name_service/NameQuery"; import EntityIOL from "@/components/values/link/EntityIOL.vue"; import InfoTooltip from "@/components/InfoTooltip.vue"; +import {labelForAutomaticTokenAssociation} from "@/schemas/HederaUtils"; export default defineComponent({ @@ -285,6 +287,10 @@ export default defineComponent({ onBeforeUnmount(() => contractLocParser.unmount()) const displayNonce = computed(() => contractLocParser.entity.value?.nonce != undefined) + const maxAutoAssociationValue = computed(() => + labelForAutomaticTokenAssociation( + contractLocParser.entity.value?.max_automatic_token_associations ?? 0 + )) const autoRenewAccount = computed(() => { return contractLocParser.entity.value?.auto_renew_account ?? null @@ -347,6 +353,7 @@ export default defineComponent({ isMediumScreen, isTouchDevice, contract: contractLocParser.entity, + maxAutoAssociationValue, balanceAnalyzer, ethereumAddress: contractLocParser.ethereumAddress, displayNonce, diff --git a/src/schemas/HederaUtils.ts b/src/schemas/HederaUtils.ts index b48890a00..11523a1e9 100644 --- a/src/schemas/HederaUtils.ts +++ b/src/schemas/HederaUtils.ts @@ -377,6 +377,22 @@ export async function isOwnedSerials(accountId: string | null, tokenId: string | return Promise.resolve(result) } +export function labelForAutomaticTokenAssociation(rawProperty: number): string { + let result: string + console.log(`labelForAutomaticTokenAssociation - property: ${rawProperty}`) + switch (rawProperty) { + case -1: + result = 'Unlimited Auto Associations' + break + case 0: + result = 'No Auto Association' + break + default: + result = rawProperty.toString() + } + return result +} + export async function waitForTransactionRefresh(transactionId: string, attemptIndex: number, polling = 3000) { let result: Promise diff --git a/tests/unit/Mocks.ts b/tests/unit/Mocks.ts index 26863b9f1..bedb0d704 100644 --- a/tests/unit/Mocks.ts +++ b/tests/unit/Mocks.ts @@ -2320,7 +2320,7 @@ export const SAMPLE_ACCOUNT_DUDE = { "deleted": false, "expiry_timestamp": "1649648001.410978000", "key": {"_type": "ED25519", "key": "38f1ea460e95d97eea13aefac760eaf990154b80a3608ab01d4a264944d68746"}, - "max_automatic_token_associations": 10, + "max_automatic_token_associations": -1, "memo": "Account Dude Memo in clear", "receiver_sig_required": true, "evm_address": null, @@ -2541,7 +2541,7 @@ export const SAMPLE_CONTRACT = { "evm_address": "0x00000000000000000000000000000000000b70cf", "expiration_timestamp": null, "file_id": "0.0.749773", - "max_automatic_token_associations": 0, + "max_automatic_token_associations": -1, "memo": "Mirror Node acceptance test: 2022-03-07T15:09:15.228564328Z Create contract", "nonce": 1, "obtainer_id": null, diff --git a/tests/unit/account/AccountDetails.spec.ts b/tests/unit/account/AccountDetails.spec.ts index e89318a4f..7fb794606 100644 --- a/tests/unit/account/AccountDetails.spec.ts +++ b/tests/unit/account/AccountDetails.spec.ts @@ -129,7 +129,7 @@ describe("AccountDetails.vue", () => { expect(wrapper.get("#expiresAtValue").text()).toBe("None") expect(wrapper.get("#autoRenewPeriodValue").text()).toBe("90 days") - expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("0") + expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("No Auto Association") expect(wrapper.get("#receiverSigRequiredValue").text()).toBe("false") expect(wrapper.get("#evmAddress").text()).toBe( @@ -243,7 +243,7 @@ describe("AccountDetails.vue", () => { expect(wrapper.find("#aliasValue").exists()).toBe(false) expect(wrapper.get("#expiresAtValue").text()).toBe("3:33:21.4109 AMApr 11, 2022, UTC") expect(wrapper.get("#autoRenewPeriodValue").text()).toBe("77d 3h 40min") - expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("10") + expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("Unlimited Auto Associations") expect(wrapper.get("#receiverSigRequiredValue").text()).toBe("true") mock.restore() diff --git a/tests/unit/contract/ContractDetails.spec.ts b/tests/unit/contract/ContractDetails.spec.ts index 1e90f3896..03a80bfa4 100644 --- a/tests/unit/contract/ContractDetails.spec.ts +++ b/tests/unit/contract/ContractDetails.spec.ts @@ -107,7 +107,7 @@ describe("ContractDetails.vue", () => { expect(wrapper.get("#expiresAtValue").text()).toBe("None") expect(wrapper.get("#autoRenewPeriodValue").text()).toBe("90 days") expect(wrapper.get("#autoRenewAccountValue").text()).toBe("0.0.730632") - expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("0") + expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("Unlimited Auto Associations") expect(wrapper.get("#obtainerValue").text()).toBe("None") expect(wrapper.get("#proxyAccountValue").text()).toBe("None") expect(wrapper.get("#validFromValue").text()).toBe("3:09:15.9474 PMMar 7, 2022, UTC") @@ -199,7 +199,7 @@ describe("ContractDetails.vue", () => { expect(wrapper.get("#expiresAtValue").text()).toBe("None") expect(wrapper.get("#autoRenewPeriodValue").text()).toBe("90 days") expect(wrapper.get("#autoRenewAccountValue").text()).toBe("0.0.730632") - expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("0") + expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("Unlimited Auto Associations") expect(wrapper.get("#obtainerValue").text()).toBe("None") expect(wrapper.get("#proxyAccountValue").text()).toBe("None") expect(wrapper.get("#validFromValue").text()).toBe("3:09:15.9474 PMMar 7, 2022, UTC") @@ -376,7 +376,7 @@ describe("ContractDetails.vue", () => { expect(wrapper.text()).toMatch(RegExp("Contract " + "Show associated account" + "Contract ID:" + SAMPLE_CONTRACT_DUDE.contract_id)) expect(wrapper.get("#keyValue").text()).toBe("None") - expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("None") + expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("No Auto Association") expect(wrapper.get("#memoValue").text()).toBe("None") expect(wrapper.find("#nonce").exists()).toBe(false) expect(wrapper.get("#fileValue").text()).toBe("0.0.803267") diff --git a/tests/unit/node/NodeDetails.spec.ts b/tests/unit/node/NodeDetails.spec.ts index 5173fbf7e..bc70716ab 100644 --- a/tests/unit/node/NodeDetails.spec.ts +++ b/tests/unit/node/NodeDetails.spec.ts @@ -20,17 +20,20 @@ * */ -import {describe, it, expect} from 'vitest' +import {describe, expect, it} from 'vitest' import {flushPromises, mount} from "@vue/test-utils" import router from "@/router"; import axios from "axios"; import AccountDetails from "@/pages/AccountDetails.vue"; import { SAMPLE_ACCOUNT, - SAMPLE_ACCOUNT_BALANCES, SAMPLE_ACCOUNT_DUDE, - SAMPLE_NETWORK_NODES, SAMPLE_NETWORK_STAKE, + SAMPLE_ACCOUNT_BALANCES, + SAMPLE_ACCOUNT_DUDE, + SAMPLE_NETWORK_NODES, + SAMPLE_NETWORK_STAKE, SAMPLE_NONFUNGIBLE, - SAMPLE_TOKEN, SAMPLE_TOKEN_DUDE, + SAMPLE_TOKEN, + SAMPLE_TOKEN_DUDE, SAMPLE_TRANSACTIONS } from "../Mocks"; import MockAdapter from "axios-mock-adapter"; @@ -185,7 +188,7 @@ describe("NodeDetails.vue", () => { expect(wrapper.find("#aliasValue").exists()).toBe(false) expect(wrapper.get("#expiresAtValue").text()).toBe("3:33:21.4109 AMApr 11, 2022, UTC") expect(wrapper.get("#autoRenewPeriodValue").text()).toBe("77d 3h 40min") - expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("10") + expect(wrapper.get("#maxAutoAssociationValue").text()).toBe("Unlimited Auto Associations") expect(wrapper.get("#receiverSigRequiredValue").text()).toBe("true") mock.restore()