Skip to content

Commit

Permalink
fix(interface): removed filters and added base records types
Browse files Browse the repository at this point in the history
  • Loading branch information
atticusofsparta committed Feb 22, 2024
1 parent 789d100 commit 849834d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 32 deletions.
38 changes: 10 additions & 28 deletions src/types/arns-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
import { EvalStateResult, EvaluationOptions } from 'warp-contracts';

import {
ArNSRecord,
ArNSNameData,
Balances,
Gateway,
WieghtedObserver,
} from './arns-state.js';
import { WalletAddress } from './common.js';

export type EvaluatedContractState<ContractState> =
EvalStateResult<ContractState> & {
Expand All @@ -46,7 +45,7 @@ export type GatewaysResponse = ArNSStateResponse<

export type RecordsResponse = ArNSStateResponse<
'records',
Record<string | number, ArNSRecord>
Record<string | number, ArNSNameData>
>;

export type BalancesResponse = ArNSStateResponse<'balances', Balances>;
Expand All @@ -57,33 +56,14 @@ export type ObserversResponse = ArNSStateResponse<
>;

export type ArNSFilters = {
domains?: string[];
owners?: WalletAddress[];
contractTxIds?: string[];
fqdns?: string[];
observerWallets?: WalletAddress[];
blockHeight?: number;
sortKey?: string;
};
export interface ArIONetworkContract {
gateways({
filters,
}: {
filters?: Pick<ArNSFilters, 'fqdns' | 'owners' | 'observerWallets'>;
}): Promise<Pick<GatewaysResponse, 'gateways'>>;
records({
filters,
}: {
filters?: Pick<ArNSFilters, 'contractTxIds' | 'owners' | 'domains'>;
}): Promise<Pick<RecordsResponse, 'records'>>;
balance({
filters,
}: {
filters?: Pick<ArNSFilters, 'owners'>;
}): Promise<Pick<BalancesResponse, 'balances'>>;
observers({
filters,
}: {
filters?: Pick<ArNSFilters, 'owners'>;
}): Promise<Pick<ObserversResponse, 'result'>>;
gateways(): Promise<Pick<GatewaysResponse, 'gateways'>>;
records(): Promise<Pick<RecordsResponse, 'records'>>;
balance(): Promise<Pick<BalancesResponse, 'balances'>>;
observers(): Promise<Pick<ObserversResponse, 'result'>>;
}

export interface ContractCache {
Expand All @@ -92,7 +72,9 @@ export interface ContractCache {
*/
getContractState<ContractState>({
contractTxId,
filters,
}: {
contractTxId: string;
filters: Pick<ArNSFilters, 'blockHeight' | 'sortKey'>;
}): Promise<ContractState>;
}
19 changes: 15 additions & 4 deletions src/types/arns-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,25 @@ export type ObserverWeights = {

// Records
export type RegistrationType = 'lease' | 'permabuy';
export type ArNSRecord = {
contractTxId: string;
endTimestamp: number;
startTimestamp: number;
export type ArNSBaseNameData = {
contractTxId: string; // The ANT Contract used to manage this name
startTimestamp: number; // At what unix time (seconds since epoch) the lease starts
type: RegistrationType;
undernames: number;
purchasePrice: number;
};

export type ArNSPermabuyData = ArNSBaseNameData & {
type: 'permabuy';
};

export type ArNSLeaseData = ArNSBaseNameData & {
type: 'lease';
endTimestamp: number; // At what unix time (seconds since epoch) the lease ends
};

export type ArNSNameData = ArNSPermabuyData | ArNSLeaseData;

// Vaults

export type VaultData = {
Expand Down

0 comments on commit 849834d

Please sign in to comment.