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
7 changes: 6 additions & 1 deletion src/core/services/mirrornode/hedera-mirrornode-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { handleMirrorNodeErrorResponse } from '@/core/utils/handle-mirror-node-e

import {
AccountAPIResponseSchema,
ContractInfoSchema,
GetAccountsAPIResponseSchema,
NftInfoSchema,
TokenAirdropsResponseSchema,
Expand Down Expand Up @@ -479,7 +480,11 @@ export class HederaMirrornodeServiceDefaultImpl implements HederaMirrornodeServi
);
}

return (await response.json()) as ContractInfo;
return parseWithSchema(
ContractInfoSchema,
await response.json(),
`Mirror Node GET /contracts/${contractId}`,
);
} catch (error) {
if (error instanceof CliError) throw error;
throw new NetworkError(
Expand Down
22 changes: 22 additions & 0 deletions src/core/services/mirrornode/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
type AccountListItemAPIResponse,
type AccountListItemBalance,
type AccountListItemTokenBalance,
type ContractInfo,
type GetAccountsAPIResponse,
MirrorNodeKeyType,
type NftInfo,
Expand Down Expand Up @@ -209,6 +210,27 @@ export const TopicInfoSchema: z.ZodType<TopicInfo> = z.object({
deleted: z.boolean(),
});

export const ContractInfoSchema: z.ZodType<ContractInfo> = z.object({
contract_id: z.string(),
account: z.string().optional(),
created_timestamp: z.string(),
deleted: z.boolean(),
memo: z.string(),
evm_address: z.string().optional(),
admin_key: optionalKeyRef,
auto_renew_account: nullableStringKey,
auto_renew_period: z.number(),
expiration_timestamp: nullableStringKey,
file_id: nullableStringKey,
max_automatic_token_associations: z.number(),
obtainer_id: nullableStringKey,
permanent_removal: z.union([z.boolean(), z.null()]).optional(),
proxy_account_id: nullableStringKey,
staked_account_id: nullableStringKey,
staked_node_id: z.union([z.number(), z.null()]).optional(),
stake_period_start: nullableStringKey,
});

const transactionTransferItemSchema: z.ZodType<TransactionTransferItem> =
z.object({
account: z.string(),
Expand Down
25 changes: 11 additions & 14 deletions src/core/services/mirrornode/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,26 +209,23 @@ export interface TransactionDetailsResponse {
// Contract Info
export interface ContractInfo {
contract_id: string;
account: string;
account?: string;
created_timestamp: string;
deleted: boolean;
memo: string;
evm_address?: string;
admin_key?: {
_type: string;
key: string;
};
auto_renew_account?: string;
admin_key?: MirrorNodeKey | null;
auto_renew_account?: string | null;
auto_renew_period: number;
expiration_timestamp?: string;
file_id?: string;
expiration_timestamp?: string | null;
file_id?: string | null;
max_automatic_token_associations: number;
obtainer_id?: string;
permanent_removal?: boolean;
proxy_account_id?: string;
staked_account_id?: string;
staked_node_id?: number;
stake_period_start?: string;
obtainer_id?: string | null;
permanent_removal?: boolean | null;
proxy_account_id?: string | null;
staked_account_id?: string | null;
staked_node_id?: number | null;
stake_period_start?: string | null;
}

// Token Airdrops
Expand Down
Loading