@dfinity/oisy-wallet-signer
Version:
A library designed to facilitate communication between a dApp and the OISY Wallet on the Internet Computer.
103 lines (102 loc) • 3.98 kB
TypeScript
import * as z from 'zod';
export declare const JSON_RPC_VERSION_2 = "2.0";
export declare const RpcIdSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
export type RpcId = z.infer<typeof RpcIdSchema>;
export declare const RpcRequestSchema: z.ZodObject<{
jsonrpc: z.ZodLiteral<"2.0">;
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
method: z.ZodString;
params: z.ZodOptional<z.ZodAny>;
}, z.core.$strict>;
export declare const inferRpcRequestWithoutParamsSchema: <M extends string>({ method }: {
method: M;
}) => z.ZodObject<{
jsonrpc: z.ZodLiteral<"2.0">;
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
method: z.ZodLiteral<M>;
}, z.core.$strict>;
export declare const inferRpcRequestWithParamsSchema: <T extends z.ZodTypeAny, M extends string>({ params, method }: {
params: T;
method: M;
}) => z.ZodObject<{
jsonrpc: z.ZodLiteral<"2.0">;
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
method: z.ZodLiteral<M>;
params: T;
}, z.core.$strip>;
export declare const RpcNotificationSchema: z.ZodObject<{
method: z.ZodString;
params: z.ZodOptional<z.ZodAny>;
jsonrpc: z.ZodLiteral<"2.0">;
}, z.core.$strict>;
export declare enum RpcErrorCode {
/**
* Invalid JSON was received by the server.
* An error occurred on the server while parsing the JSON text.
*/
PARSE_ERROR = -32700,
/**
* The JSON sent is not a valid Request object.
*/
INVALID_REQUEST = -32600,
/**
* The method does not exist / is not available.
*/
METHOD_NOT_FOUND = -32601,
/**
* Invalid method parameter(s).
*/
INVALID_PARAMS = -32602,
/**
* Internal JSON-RPC error.
*/
INTERNAL_ERROR = -32603,
/**
* Reserved for implementation-defined server-errors.
*/
SERVER_ERROR = -32000
}
declare const RpcResponseErrorCodeSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodEnum<typeof RpcErrorCode>]>;
export type RpcResponseErrorCode = z.infer<typeof RpcResponseErrorCodeSchema>;
declare const RpcResponseErrorSchema: z.ZodObject<{
code: z.ZodUnion<readonly [z.ZodNumber, z.ZodEnum<typeof RpcErrorCode>]>;
message: z.ZodString;
data: z.ZodOptional<z.ZodNever>;
}, z.core.$strip>;
export type RpcResponseError = z.infer<typeof RpcResponseErrorSchema>;
declare const RpcResponseSchema: z.ZodObject<{
jsonrpc: z.ZodLiteral<"2.0">;
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
}, z.core.$strip>;
export type RpcResponse = z.infer<typeof RpcResponseSchema>;
export declare const RpcResponseWithErrorSchema: z.ZodObject<{
jsonrpc: z.ZodLiteral<"2.0">;
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
error: z.ZodObject<{
code: z.ZodUnion<readonly [z.ZodNumber, z.ZodEnum<typeof RpcErrorCode>]>;
message: z.ZodString;
data: z.ZodOptional<z.ZodNever>;
}, z.core.$strip>;
}, z.core.$strict>;
export type RpcResponseWithError = z.infer<typeof RpcResponseWithErrorSchema>;
export declare const inferRpcResponseSchema: <T extends z.ZodTypeAny>(result: T) => z.ZodObject<{
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
jsonrpc: z.ZodLiteral<"2.0">;
result: z.ZodOptional<T>;
error: z.ZodOptional<z.ZodObject<{
code: z.ZodUnion<readonly [z.ZodNumber, z.ZodEnum<typeof RpcErrorCode>]>;
message: z.ZodString;
data: z.ZodOptional<z.ZodNever>;
}, z.core.$strip>>;
}, z.core.$strict>;
export declare const RpcResponseWithResultOrErrorSchema: z.ZodObject<{
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
jsonrpc: z.ZodLiteral<"2.0">;
result: z.ZodOptional<z.ZodAny>;
error: z.ZodOptional<z.ZodObject<{
code: z.ZodUnion<readonly [z.ZodNumber, z.ZodEnum<typeof RpcErrorCode>]>;
message: z.ZodString;
data: z.ZodOptional<z.ZodNever>;
}, z.core.$strip>>;
}, z.core.$strict>;
export {};