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

feat: display max automatic token associations #1284

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 11 additions & 2 deletions src/pages/AccountDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,11 @@
<DurationValue v-bind:number-value="account?.auto_renew_period ?? undefined"/>
</template>
</Property>
<Property id="maxAutoAssociation">
<Property id="maxAutoAssociation"
tooltip="Number of auto association slots for token airdrops. Unlimited (-1), Limited (>0), No auto association slots (0).">
<template v-slot:name>Max. Auto. Association</template>
<template v-slot:value>
<StringValue :string-value="account?.max_automatic_token_associations?.toString()"/>
<StringValue :string-value="maxAutoAssociationValue"/>
</template>
</Property>
<Property id="receiverSigRequired">
Expand Down Expand Up @@ -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({

Expand Down Expand Up @@ -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
//
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -571,6 +579,7 @@ export default defineComponent({
onDateCleared,
domainName: nameQuery.name,
domainProviderName: nameQuery.providerName,
labelForAutomaticTokenAssociation,
}
}
});
Expand Down
11 changes: 9 additions & 2 deletions src/pages/ContractDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@
<AccountLink :account-id="autoRenewAccount"/>
</template>
</Property>
<Property id="maxAutoAssociation">
<Property id="maxAutoAssociation"
tooltip="Number of auto association slots for token airdrops. Unlimited (-1), Limited (>0), No auto association slots (0).">
<template v-slot:name>Max. Auto. Association</template>
<template v-slot:value>
<StringValue :string-value="contract?.max_automatic_token_associations?.toString()"/>
<StringValue :string-value="maxAutoAssociationValue"/>
</template>
</Property>
</template>
Expand Down Expand Up @@ -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({

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -347,6 +353,7 @@ export default defineComponent({
isMediumScreen,
isTouchDevice,
contract: contractLocParser.entity,
maxAutoAssociationValue,
balanceAnalyzer,
ethereumAddress: contractLocParser.ethereumAddress,
displayNonce,
Expand Down
16 changes: 16 additions & 0 deletions src/schemas/HederaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Transaction | string>

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/account/AccountDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/contract/ContractDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
13 changes: 8 additions & 5 deletions tests/unit/node/NodeDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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()
Expand Down