refactor: migrate interfaces to dedicated directory
Reorganizes TypeScript interfaces into a modular structure: - Create dedicated interfaces directory with specialized files - Split interfaces by domain (claims, common, limits, records, user) - Update imports in endorserServer.ts to use new interface locations - Replace 'any' types with 'unknown' for better type safety - Add proper type imports and exports This improves code organization and maintainability by: - Centralizing interface definitions - Reducing file size of endorserServer.ts - Making interface relationships more explicit - Improving type safety with stricter types
This commit is contained in:
47
src/interfaces/claims-result.ts
Normal file
47
src/interfaces/claims-result.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { AxiosResponse } from "axios";
|
||||
import { GiverReceiverInputInfo } from "../libs/util";
|
||||
import { ErrorResult, ResultWithType } from "./common";
|
||||
|
||||
export interface GiverOutputInfo {
|
||||
action: string;
|
||||
giver?: GiverReceiverInputInfo;
|
||||
description?: string;
|
||||
amount?: number;
|
||||
unitCode?: string;
|
||||
}
|
||||
|
||||
export interface ClaimResult {
|
||||
success: { claimId: string; handleId: string };
|
||||
error: { code: string; message: string };
|
||||
}
|
||||
|
||||
export interface VerifiableCredential {
|
||||
exp?: number;
|
||||
iat: number;
|
||||
iss: string;
|
||||
vc: {
|
||||
"@context": string[];
|
||||
type: string[];
|
||||
credentialSubject: VerifiableCredentialSubject;
|
||||
};
|
||||
}
|
||||
|
||||
export interface VerifiableCredentialSubject {
|
||||
"@context": string;
|
||||
"@type": string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface WorldProperties {
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
}
|
||||
|
||||
// Type for createAndSubmitClaim result
|
||||
export type CreateAndSubmitClaimResult = SuccessResult | ErrorResult;
|
||||
|
||||
// Update SuccessResult to use ClaimResult
|
||||
export interface SuccessResult extends ResultWithType {
|
||||
type: "success";
|
||||
response: AxiosResponse<ClaimResult>;
|
||||
}
|
||||
Reference in New Issue
Block a user