@nfps.dev/runtime
Version:
Runtime library for NFPs
59 lines (58 loc) • 2.04 kB
TypeScript
import type { A, O } from 'ts-toolbelt';
import type { HexMixed, JsonObject, JsonValue } from '@blake.regalia/belt';
import type { Key as KeplrKey, StdSignDoc } from '@keplr-wallet/types';
import type { HttpsUrl } from '@solar-republic/neutrino';
export declare const XC_CMD_CONNECT = 1;
export declare const XC_CMD_DISCONNECT = 2;
export declare const XC_CMD_SIGN_AMINO_INFERRED = 3;
export declare const XC_CMD_SECRET_ENCRYPT = 4;
export declare const XC_CMD_SECRET_DECRYPT = 5;
export type Serializable = JsonValue<ArrayBuffer | ArrayBufferView | DataView | Date | Error | Map<Serializable, Serializable> | RegExp | Set<Serializable> | String>;
type CommandDef<h_def extends Record<number, {
req: Serializable;
res: Serializable;
}>> = h_def;
type WritableSignDoc = O.Writable<StdSignDoc, A.Key, 'deep'>;
export type ComcCommands = CommandDef<{
[XC_CMD_CONNECT]: {
req: [
p_origin: string,
si_chain: string
];
res: O.Writable<KeplrKey>;
};
[XC_CMD_DISCONNECT]: {
req: [];
res: [];
};
[XC_CMD_SIGN_AMINO_INFERRED]: {
req: [
g_doc: WritableSignDoc
];
res: [
g_signed: WritableSignDoc,
atu8_signature: 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;
};
}>;
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 {};