Skip to content
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
6 changes: 6 additions & 0 deletions src/constants/vesting-contract-address.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** Vesting contract account. The account-type label special-cases this address. */
export const VESTING_CONTRACT_ADDRESS =
'qzmviwoPJR19XovVwUYUoUKb2MoBygYgwYAevj5Br8JeunxW7';

/** Account-type label shown for {@link VESTING_CONTRACT_ADDRESS}. */
export const VESTING_CONTRACT_TYPE_LABEL = 'Vesting Contract';
11 changes: 11 additions & 0 deletions src/utils/minting-address-display.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import {
MINTING_ADDRESS_FROM_LABEL,
MINTING_ADDRESS_TYPE_LABEL
} from '@/constants/minting-address';
import {
VESTING_CONTRACT_ADDRESS,
VESTING_CONTRACT_TYPE_LABEL
} from '@/constants/vesting-contract-address';
import { TRANSPARENT_ADDRESS_LABEL } from '@/utils/classify-account-address';

import {
Expand All @@ -27,6 +31,7 @@ describe('fromAddressPlainLabel', () => {

it('leaves every other address as a normal account cell', () => {
expect(fromAddressPlainLabel(`${MINTING_ADDRESS}x`)).toBeNull();
expect(fromAddressPlainLabel(VESTING_CONTRACT_ADDRESS)).toBeNull();
});
});

Expand All @@ -37,6 +42,12 @@ describe('accountAddressTypeLabel', () => {
);
});

it('names the vesting contract address as a vesting contract', () => {
expect(accountAddressTypeLabel(VESTING_CONTRACT_ADDRESS, transparent)).toBe(
VESTING_CONTRACT_TYPE_LABEL
);
});

it('keeps Transparent Address for any other standard account', () => {
expect(accountAddressTypeLabel(`${MINTING_ADDRESS}x`, transparent)).toBe(
TRANSPARENT_ADDRESS_LABEL
Expand Down
10 changes: 8 additions & 2 deletions src/utils/minting-address-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import {
MINTING_ADDRESS_FROM_LABEL,
MINTING_ADDRESS_TYPE_LABEL
} from '@/constants/minting-address';
import {
VESTING_CONTRACT_ADDRESS,
VESTING_CONTRACT_TYPE_LABEL
} from '@/constants/vesting-contract-address';
import {
type AccountAddressClassification,
classifyAccountAddress
Expand All @@ -15,13 +19,15 @@ export function fromAddressPlainLabel(address: string): string | null {
}

/**
* Display label for an account type. The minting address is labeled on its own;
* account-type filters still classify it from its flags.
* Display label for an account type. The minting address and the vesting
* contract are labeled on their own; account-type filters still classify
* them from their flags.
*/
export function accountAddressTypeLabel(
address: string,
classification: AccountAddressClassification
): string {
if (address === MINTING_ADDRESS) return MINTING_ADDRESS_TYPE_LABEL;
if (address === VESTING_CONTRACT_ADDRESS) return VESTING_CONTRACT_TYPE_LABEL;
return classifyAccountAddress(classification);
}
Loading