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
88 changes: 57 additions & 31 deletions src/__generated__/gql.ts

Large diffs are not rendered by default.

1,619 changes: 816 additions & 803 deletions src/__generated__/graphql.ts

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions src/api/accounts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { print } from 'graphql';

import {
GET_ACCOUNT_BY_ID,
GET_ACCOUNTS,
GET_FILTERED_ACCOUNTS
} from './accounts';

describe('account queries', () => {
it.each([
['GetAccounts', GET_ACCOUNTS],
['GetFilteredAccounts', GET_FILTERED_ACCOUNTS],
['GetAccountById', GET_ACCOUNT_BY_ID]
] as const)(
'%s reads has_mined_blocks instead of peeking minedBlocks',
(_name, document) => {
const query = print(document);

expect(query).toContain('has_mined_blocks');
expect(query).not.toContain('minedBlocks');
}
);
});
8 changes: 2 additions & 6 deletions src/api/accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ const ACCOUNT_LIST_FIELDS = `
is_high_security
is_guardian
is_multisig
minedBlocks(limit: 1) {
height
}
has_mined_blocks
`;

export const GET_ACCOUNTS = gql`
Expand Down Expand Up @@ -71,9 +69,7 @@ export const GET_ACCOUNT_BY_ID = gql`
frozen
reserved
is_deposit_only
minedBlocks(limit: 1) {
height
}
has_mined_blocks
}
accountStats: account_stats_by_pk(id: $id) {
total_cancelled_transfers
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/table-columns/ACCOUNT_COLUMNS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const ACCOUNT_COLUMNS = [
is_guardian: isGuardian,
is_multisig: isMultisig,
is_deposit_only: isDepositOnly,
minedBlocks
has_mined_blocks: hasMinedBlocks
} = props.row.original;
const hasFlags = isHighSec || isGuardian || isMultisig;
const addressLabel = (
Expand All @@ -40,7 +40,7 @@ export const ACCOUNT_COLUMNS = [
isGuardian={isGuardian}
isMultisig={isMultisig}
isDepositOnly={isDepositOnly}
hasMinedBlocks={minedBlocks.length > 0}
hasMinedBlocks={hasMinedBlocks}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const AccountInformation: React.FC<AccountInformationProps> = ({
isGuardian,
isMultisig,
isDepositOnly: account?.is_deposit_only ?? null,
hasMinedBlocks: (account?.minedBlocks.length ?? 0) > 0
hasMinedBlocks: account?.has_mined_blocks ?? false
}
];

Expand Down
10 changes: 3 additions & 7 deletions src/schemas/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ export type Account = Pick<
'id' | 'free' | 'frozen' | 'reserved' | 'is_deposit_only'
>;

/** At most one mined block, fetched only to tell whether the account has ever mined. */
export interface AccountMinedBlocksPeek {
minedBlocks: { height: number }[];
}

/** Listing row: flags are denormalized onto `account` by the indexer (no nested event lookups). */
export interface AccountListItem extends Account, AccountMinedBlocksPeek {
export interface AccountListItem extends Account {
is_high_security: boolean;
is_guardian: boolean;
is_multisig: boolean;
has_mined_blocks: boolean;
}

export interface AccountListPageResponse {
Expand All @@ -32,7 +28,7 @@ export interface AccountStats {
}

export interface AccountResponse {
account: (Account & AccountMinedBlocksPeek) | null;
account: (Account & Pick<gql.Account, 'has_mined_blocks'>) | null;
accountStats: AccountStats;
multisig?: { id: string } | null;
beneficiaries: {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/account-type-filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ describe('accountTypeWhere', () => {
expect(accountTypeWhere('potential_encrypted')).toEqual({
...STANDARD,
is_deposit_only: { _eq: true },
_not: { minedBlocks: {} }
has_mined_blocks: { _eq: false }
});
});

it('matches unflagged deposit-only accounts with mined blocks as encrypted', () => {
expect(accountTypeWhere('encrypted')).toEqual({
...STANDARD,
is_deposit_only: { _eq: true },
minedBlocks: {}
has_mined_blocks: { _eq: true }
});
});

Expand Down
4 changes: 2 additions & 2 deletions src/utils/account-type-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ export function accountTypeWhere(type: AccountType): Account_Bool_Exp {
return {
...STANDARD_ACCOUNT,
is_deposit_only: { _eq: true },
_not: { minedBlocks: {} }
has_mined_blocks: { _eq: false }
};
case 'encrypted':
return {
...STANDARD_ACCOUNT,
is_deposit_only: { _eq: true },
minedBlocks: {}
has_mined_blocks: { _eq: true }
};
case 'high_security':
return { is_high_security: { _eq: true } };
Expand Down
Loading