@coinmeca/wallet-sdk
Version:
151 lines • 7.29 kB
TypeScript
import type { Box, Chain, Kdf } from "./types";
export declare const pattern: {
chainId: RegExp;
address: RegExp;
hex: RegExp;
hash: RegExp;
};
export declare const walletRequestMethods: readonly ["erc20_approve", "eth_requestAccounts", "eth_sendTransaction", "eth_signTransaction", "eth_signTypedData", "eth_signTypedData_v4", "personal_sign", "wallet_addEthereumChain", "wallet_switchEthereumChain", "wallet_watchAsset"];
export declare const walletProxyRequestMethods: readonly ["eth_accounts"];
export declare const isRequestMethod: (value?: string, shell?: "request" | "proxy") => boolean;
export declare const requestRoute: (value?: string, shell?: "request" | "proxy") => string | undefined;
export declare const routePath: (value?: string, base?: string) => boolean;
export declare const isBridgePath: (value?: string) => boolean;
export declare const encode: {
string: (value: string) => Buffer;
uint: (type: string, value: string | number | bigint) => Buffer;
int: (type: string, value: string | number | bigint) => Buffer;
address: (value: string) => Buffer;
bytes: (type: string, value: Buffer) => Buffer;
array: (type: string, value: Array<any>) => Buffer;
};
export declare function encodeParameter(type: string, value: any): Buffer;
export declare function flattenMessage(types: any, message: any, primaryType: string): any[];
export declare const toBytes: (value: string | number | bigint, pad?: number | {
start?: number;
end?: number;
}) => Uint8Array;
export declare const enable: (...checks: boolean[]) => boolean;
export declare const valid: {
chainId: (...chainId: (number | string | undefined)[]) => boolean;
address: (...address: (string | undefined)[]) => boolean;
hash: (...hash: (string | undefined)[]) => boolean;
bigint: (value: string | number | bigint, type?: string) => bigint | false;
};
export declare const objectToUrlParams: (obj: {
[x: string | number | symbol]: any;
}) => string;
export declare const getAppName: () => string;
export declare const getFaviconUrl: () => string;
export declare const getFaviconUri: () => Promise<string | null>;
export declare const openWindow: (target: string, size?: number | {
width?: number;
height?: number;
}) => any;
export declare function parseChainId(chain: number | string | Chain): number;
export declare function formatChainId(chain: number | string | Chain): string;
export declare const quantityHex: (value?: any) => string | undefined;
export declare const dataHex: (value?: any) => string | undefined;
export declare const transactionRequest: (value?: any) => any;
export declare const personalSignRequest: (params?: any) => {
address: string | undefined;
message: string | undefined;
params: any[];
} | undefined;
export declare const typedDataRequest: (params?: any) => {
address: string | undefined;
data: any;
params: any[];
} | undefined;
export declare const isMobile: () => boolean;
export declare const chainUrl: (value?: any, kind?: "rpc" | "explorer" | "icon") => string | undefined;
export declare const chainUrls: (value?: any, kind?: "rpc" | "explorer" | "icon") => string[] | undefined;
export declare const erc20ApproveCall: (value?: any) => {
data: string;
spender: string;
amount: bigint;
} | undefined;
type DeviceBindingKind = "device" | "platform";
type DeviceBindingResult = {
data: Uint8Array;
kind: DeviceBindingKind;
};
export declare const deviceBindingProvision: (scope?: string) => Promise<Uint8Array | undefined>;
export declare const deviceBinding: (scope?: string, kinds?: DeviceBindingKind[]) => Promise<DeviceBindingResult | undefined>;
export declare const deviceBindingCandidates: (scope?: string, kinds?: DeviceBindingKind[]) => Promise<Uint8Array[]>;
export declare const deviceAttest: (scope: string, payload: string, options?: {
binding?: BufferSource;
kinds?: ("device" | "platform")[];
}) => Promise<string | undefined>;
export declare const deviceAttestationMatches: (scope: string, payload: string, attestation?: string, kinds?: ("device" | "platform")[], bindings?: BufferSource[]) => Promise<boolean | undefined>;
export declare const random: (size?: number) => Uint8Array<ArrayBuffer>;
export declare const hash: (value: string) => Promise<string>;
export declare const derive: (value: string, input?: Uint8Array | string, kdf?: Omit<Kdf, "name" | "salt">) => Promise<{
kdf: {
name: "argon2id";
iterations: number;
parallelism: number;
memorySize: number;
hashLength: number;
salt: string;
};
data: Uint8Array<ArrayBufferLike>;
}>;
export declare const sealWith: (value: string, secret: BufferSource, kdf: Kdf, options?: {
binding?: BufferSource;
bindingKind?: "device" | "platform";
}) => Promise<Box>;
export declare const seal: (value: string, password: string, kdf?: Omit<Kdf, "name" | "salt">) => Promise<Box>;
export declare const openWith: (box?: Box | null, secret?: BufferSource, binding?: BufferSource) => Promise<string | undefined>;
export declare const open: (box?: Box | null, password?: string) => Promise<string | undefined>;
export declare const format: (value?: any) => string | undefined;
export declare const parse: (value?: string | null) => any;
export interface StorageController {
get: (key: string) => any;
gets: (keys: string[]) => Record<string, any>;
getAll: () => Record<string, any>;
set: (key: string, value: any) => void;
sets: (map: string[][]) => void;
remove: (key: string) => void;
removes: (keys: string[]) => void;
clear: () => void;
}
export declare const loadStorage: (prefix: string, storage?: CloudStorage | Storage, isTelegram?: boolean) => StorageController;
export interface TelegramController {
telegram: Telegram["WebApp"] | undefined;
user: Telegram["WebApp"]["initDataUnsafe"]["user"] | undefined;
isInApp?: boolean;
isExpanded?: boolean;
isVerticalSwipe?: boolean;
isCloseConfirm?: boolean;
storage?: CloudStorage;
send: (text: string) => void | undefined;
enable: {
vertical: () => void | undefined;
closeConfirm: () => void | undefined;
};
disable: {
vertical: () => void | undefined;
closeConfirm: () => void | undefined;
};
bio: {
request: (reason?: string) => BiometricManager | undefined;
auth: (reason?: string) => BiometricManager | undefined;
};
show: {
alert: (message: string, callback?: () => void) => void | undefined;
confirm: (title: string, callback?: (ok: boolean) => void) => void | undefined;
popup: (popup: PopupParams, callback?: ((button_id: string) => void) | undefined) => void | undefined;
scanQR: (text: string, callback?: (data: string) => void) => void | undefined;
};
open: {
internal: (url: string, callback?: Function) => void;
external: (url: string, try_instant_view?: boolean, callback?: Function) => void;
};
expand: (callback?: Function) => void;
exit: (callback?: Function) => void;
}
export declare const loadTelegram: (telegram?: Telegram["WebApp"]) => TelegramController;
export declare const favicon: () => string;
export {};
//# sourceMappingURL=utils.d.ts.map