@nfps.dev/runtime
Version:
Runtime library for NFPs
86 lines (85 loc) • 2.61 kB
TypeScript
import type { HexMixed, JsonObject, JsonValue, Uint128 } from '@blake.regalia/belt';
import type { Key as KeplrKey, StdSignDoc } from '@keplr-wallet/types';
import type { HttpsUrl, SlimAuthInfo } from '@solar-republic/neutrino';
export declare const XC_CMD_CONNECT = 1;
export declare const XC_CMD_DISCONNECT = 2;
export declare const XC_CMD_ACCOUNT_CHANGED = 3;
export declare const XC_CMD_SIGN_AUTO = 4;
export declare const XC_CMD_EXEC_CONTRACT = 5;
export declare const XC_CMD_SECRET_ENCRYPT = 6;
export declare const XC_CMD_SECRET_DECRYPT = 7;
export declare const XC_CMD_STORE_DATA = 8;
export declare const XC_CMD_FETCH_DATA = 9;
export type Serializable = JsonValue<ArrayBuffer | ArrayBufferView | DataView | Date | Error | Map<Serializable, Serializable> | RegExp | Set<Serializable> | String>;
type CommandDef<h_def extends Record<number, {
req: any;
res: any;
}>> = h_def;
export type ComcCommands = CommandDef<{
[XC_CMD_CONNECT]: {
req: [
p_origin: string,
si_chain: string
];
res: KeplrKey;
};
[XC_CMD_DISCONNECT]: {
req: void;
res: void;
};
[XC_CMD_ACCOUNT_CHANGED]: {
req: void;
res: KeplrKey;
};
[XC_CMD_SIGN_AUTO]: {
req: [
atu8_msg: Uint8Array,
sg_limit: Uint128,
a_auth: SlimAuthInfo
];
res: [
g_signed: StdSignDoc,
atu8_signature: Uint8Array
];
};
[XC_CMD_EXEC_CONTRACT]: {
req: [
sb16_code_hash: HexMixed,
h_msg: JsonObject
];
res: Uint8Array;
};
[XC_CMD_SECRET_ENCRYPT]: {
req: [
sb16_code_hash: HexMixed,
h_msg: JsonObject
];
res: Uint8Array;
};
[XC_CMD_SECRET_DECRYPT]: {
req: [
atu8_ciphertext: Uint8Array,
atu8_nonce: Uint8Array
];
res: Uint8Array;
};
[XC_CMD_STORE_DATA]: {
req: [
w_data: JsonValue
];
res: string;
};
[XC_CMD_FETCH_DATA]: {
req: [
s_key: string
];
res: JsonValue;
};
}>;
export type ComcCommand = keyof ComcCommands;
export interface ComcClient {
post<xc_cmd extends ComcCommand, g_cmd extends ComcCommands[xc_cmd] = ComcCommands[xc_cmd]>(xc_cmd: xc_cmd, w_arg: g_cmd['req']): Promise<g_cmd['res']>;
}
export declare const comcPortal: (p_host: HttpsUrl, dm_root: Element) => Promise<HTMLIFrameElement>;
export declare const comcClient: (dm_iframe: HTMLIFrameElement) => ComcClient;
export {};