@metamask/eip-5792-middleware
Version:
Implements the JSON-RPC methods for sending multiple calls from the user's wallet, and checking their status, as referenced in EIP-5792
91 lines • 4.12 kB
text/typescript
import type { AccountsControllerGetSelectedAccountAction, AccountsControllerGetStateAction } from "@metamask/accounts-controller";
import type { Messenger } from "@metamask/base-controller";
import type { NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetStateAction } from "@metamask/network-controller";
import type { PreferencesControllerGetStateAction } from "@metamask/preferences-controller";
import type { Infer } from "@metamask/superstruct";
import type { TransactionControllerGetStateAction } from "@metamask/transaction-controller";
import type { Hex, Json, JsonRpcRequest } from "@metamask/utils";
type Actions = AccountsControllerGetStateAction | AccountsControllerGetSelectedAccountAction | NetworkControllerGetNetworkClientByIdAction | TransactionControllerGetStateAction | PreferencesControllerGetStateAction | NetworkControllerGetStateAction;
export type EIP5792Messenger = Messenger<Actions, never>;
export type GetCallsStatusParams = Infer<typeof GetCallsStatusStruct>;
export type GetCallsStatusResult = {
version: string;
id: Hex;
chainId: Hex;
status: number;
atomic: boolean;
receipts?: {
logs: {
address: Hex;
data: Hex;
topics: Hex[];
}[];
status: '0x0' | '0x1';
blockHash: Hex;
blockNumber: Hex;
gasUsed: Hex;
transactionHash: Hex;
}[];
capabilities?: Record<string, Json>;
};
export type GetCallsStatusHook = (id: GetCallsStatusParams[0], req: JsonRpcRequest) => Promise<GetCallsStatusResult>;
export type GetCapabilitiesParams = Infer<typeof GetCapabilitiesStruct>;
export type GetCapabilitiesResult = Record<Hex, Record<string, Json>>;
export type GetCapabilitiesHook = (address: GetCapabilitiesParams[0], chainIds: GetCapabilitiesParams[1], req: JsonRpcRequest) => Promise<GetCapabilitiesResult>;
export type SendCallsParams = Infer<typeof SendCallsStruct>;
export type SendCallsPayload = SendCallsParams[0];
export type SendCallsRequiredAssetsParam = Infer<typeof RequiredAssetStruct>;
export type SendCallsResult = {
id: Hex;
capabilities?: Record<string, Json>;
};
export type ProcessSendCallsHook = (sendCalls: SendCallsPayload, req: JsonRpcRequest) => Promise<SendCallsResult>;
export declare const GetCallsStatusStruct: import("@metamask/superstruct").Struct<[`0x${string}`], null>;
export declare const GetCapabilitiesStruct: import("@metamask/superstruct").Struct<[`0x${string}`, `0x${string}`[] | undefined], null>;
declare const RequiredAssetStruct: import("@metamask/superstruct").Struct<{
address: `0x${string}`;
standard: string;
amount: `0x${string}`;
}, {
address: import("@metamask/superstruct").Struct<`0x${string}`, null>;
amount: import("@metamask/superstruct").Struct<`0x${string}`, null>;
standard: import("@metamask/superstruct").Struct<string, null>;
}>;
export declare const CapabilitiesStruct: import("@metamask/superstruct").Struct<Record<string, {
optional?: boolean | undefined;
requiredAssets?: {
address: `0x${string}`;
standard: string;
amount: `0x${string}`;
}[] | undefined;
}>, null>;
export declare const SendCallsStruct: import("@metamask/superstruct").Struct<[{
version: string;
chainId: `0x${string}`;
atomicRequired: boolean;
calls: {
data?: `0x${string}` | undefined;
value?: `0x${string}` | undefined;
to?: `0x${string}` | undefined;
capabilities?: Record<string, {
optional?: boolean | undefined;
requiredAssets?: {
address: `0x${string}`;
standard: string;
amount: `0x${string}`;
}[] | undefined;
}> | undefined;
}[];
id?: `0x${string}` | undefined;
from?: `0x${string}` | undefined;
capabilities?: Record<string, {
optional?: boolean | undefined;
requiredAssets?: {
address: `0x${string}`;
standard: string;
amount: `0x${string}`;
}[] | undefined;
}> | undefined;
}], null>;
export {};
//# sourceMappingURL=types.d.mts.map