UNPKG

@opendatalabs/vana-sdk

Version:

A TypeScript library for interacting with Vana Network smart contracts.

121 lines (120 loc) 3.23 kB
export interface GatewayEnvelope<T> { data: T; proof: GatewayProof; } export interface GatewayProof { signature: string; timestamp: string; gatewayAddress: string; requestHash: string; responseHash: string; userSignature: string; status: string; chainBlockHeight: number; } export interface Builder { id: string; ownerAddress: string; granteeAddress: string; publicKey: string; appUrl: string; addedAt: string; } export interface Schema { id: string; ownerAddress: string; name: string; definitionUrl: string; scope: string; addedAt: string; } export interface ServerInfo { id: string; ownerAddress: string; serverAddress: string; publicKey: string; serverUrl: string; addedAt: string; } export interface GatewayGrantResponse { id: string; grantorAddress: string; granteeId: string; grant: string; fileIds: string[]; status: "pending" | "confirmed"; addedAt: string; revokedAt: string | null; revocationSignature: string | null; } export interface GrantListItem { id: string; grantorAddress: string; granteeId: string; grant: string; fileIds: string[]; status: "pending" | "confirmed"; addedAt: string; revokedAt: string | null; revocationSignature: string | null; } export interface FileRecord { fileId: string; owner: string; url: string; schemaId: string; createdAt: string; } export interface FileListResult { files: FileRecord[]; cursor: string | null; } export interface RegisterFileParams { ownerAddress: string; url: string; schemaId: string; signature: string; } export interface CreateGrantParams { grantorAddress: string; granteeId: string; grant: string; fileIds: string[]; signature: string; } export interface RevokeGrantParams { grantId: string; grantorAddress: string; signature: string; } export interface RegisterServerParams { ownerAddress: string; serverAddress: string; publicKey: string; serverUrl: string; signature: string; } export interface RegisterServerResult { serverId?: string; alreadyRegistered: boolean; } export interface GatewayClient { isRegisteredBuilder(address: string): Promise<boolean>; getBuilder(address: string): Promise<Builder | null>; getGrant(grantId: string): Promise<GatewayGrantResponse | null>; listGrantsByUser(userAddress: string): Promise<GrantListItem[]>; getSchemaForScope(scope: string): Promise<Schema | null>; getServer(address: string): Promise<ServerInfo | null>; getFile(fileId: string): Promise<FileRecord | null>; listFilesSince(owner: string, cursor: string | null): Promise<FileListResult>; getSchema(schemaId: string): Promise<Schema | null>; registerServer(params: RegisterServerParams): Promise<RegisterServerResult>; registerFile(params: RegisterFileParams): Promise<{ fileId?: string; }>; createGrant(params: CreateGrantParams): Promise<{ grantId?: string; }>; revokeGrant(params: RevokeGrantParams): Promise<void>; } export declare function createGatewayClient(baseUrl: string): GatewayClient;