@signumjs/wallets
Version:
Wallets communication package for DApps in the Signum Network
123 lines (122 loc) • 4.66 kB
TypeScript
export type ExtensionMessage = ExtensionRequestArgs | ExtensionResponse;
export type ExtensionRequestArgs = ExtensionGetCurrentPermissionRequest | ExtensionPermissionRequest | ExtensionSignRequest | ExtensionSendEncryptedMessageRequest;
export type ExtensionResponse = ExtensionGetCurrentPermissionResponse | ExtensionPermissionResponse | ExtensionSignResponse | ExtensionSendEncryptedMessageResponse;
interface ExtensionMessageBase {
type: ExtensionMessageType;
}
export declare enum ExtensionMessageType {
GetCurrentPermissionRequest = "GET_CURRENT_PERMISSION_REQUEST",
GetCurrentPermissionResponse = "GET_CURRENT_PERMISSION_RESPONSE",
PermissionRequest = "PERMISSION_REQUEST",
PermissionResponse = "PERMISSION_RESPONSE",
SignRequest = "SIGN_REQUEST",
SignResponse = "SIGN_RESPONSE",
SendEncryptedMessageRequest = "SEND_ENCRYPTED_MSG_REQUEST",
SendEncryptedMessageResponse = "SEND_ENCRYPTED_MSG_RESPONSE"
}
export interface ExtensionGetCurrentPermissionRequest extends ExtensionMessageBase {
type: ExtensionMessageType.GetCurrentPermissionRequest;
}
export interface ExtensionGetCurrentPermissionResponse extends ExtensionMessageBase {
type: ExtensionMessageType.GetCurrentPermissionResponse;
permission: ExtensionPermission;
}
export interface ExtensionPermissionRequest extends ExtensionMessageBase {
type: ExtensionMessageType.PermissionRequest;
network: string;
appMeta: ExtensionDAppMetadata;
force?: boolean;
}
export interface ExtensionPermissionResponse extends ExtensionMessageBase {
type: ExtensionMessageType.PermissionResponse;
accountId: string;
publicKey: string;
availableNodeHosts: string[];
currentNodeHost: string;
watchOnly: boolean;
}
export interface ExtensionSignRequest extends ExtensionMessageBase {
type: ExtensionMessageType.SignRequest;
payload: string;
}
export interface ExtensionSignResponse extends ExtensionMessageBase {
type: ExtensionMessageType.SignResponse;
transactionId: string;
fullHash: string;
}
export interface ExtensionSendEncryptedMessageRequest extends ExtensionMessageBase {
type: ExtensionMessageType.SendEncryptedMessageRequest;
plainMessage: string;
messageIsText: boolean;
recipientPublicKey: string;
feeSigna?: string;
}
export interface ExtensionSendEncryptedMessageResponse extends ExtensionMessageBase {
type: ExtensionMessageType.SendEncryptedMessageResponse;
transactionId: string;
fullHash: string;
}
export declare enum ExtensionErrorType {
NotGranted = "NOT_GRANTED",
NotFound = "NOT_FOUND",
InvalidParams = "INVALID_PARAMS",
InvalidNetwork = "INVALID_NETWORK"
}
export type ExtensionPermission = {
currentNodeHost: string;
availableNodeHosts: string[];
accountId: string;
publicKey: string;
watchOnly: boolean;
} | null;
export type ExtensionSigned = {
transactionId: string;
fullHash: string;
} | null;
export type ExtensionSentEncryptedMessage = {
transactionId: string;
fullHash: string;
} | null;
export interface ExtensionDAppMetadata {
name: string;
}
export interface PageMessage {
type: PageMessageType;
payload: any;
reqId?: string | number;
}
export declare enum PageMessageType {
Request = "SIGNUM_PAGE_REQUEST",
Response = "SIGNUM_PAGE_RESPONSE",
ErrorResponse = "SIGNUM_PAGE_ERROR_RESPONSE"
}
export declare enum ExtensionNotificationType {
NetworkChanged = "XT_DAPP_NETWORK_CHANGED",
AccountChanged = "XT_DAPP_ACCOUNT_CHANGED",
PermissionRemoved = "XT_DAPP_PERMISSION_REMOVED",
AccountRemoved = "XT_DAPP_ACCOUNT_REMOVED"
}
interface ExtensionNotificationBase {
type: ExtensionNotificationType;
}
export type ExtensionNotification = ExtensionNotificationNetworkChanged | ExtensionNotificationPermissionRemoved | ExtensionNotificationAccountRemoved | ExtensionNotificationAccountChanged;
export interface ExtensionNotificationNetworkChanged extends ExtensionNotificationBase {
type: ExtensionNotificationType.NetworkChanged;
networkName: string;
networkHost: string;
}
export interface ExtensionNotificationPermissionRemoved extends ExtensionNotificationBase {
type: ExtensionNotificationType.PermissionRemoved;
url: string;
}
export interface ExtensionNotificationAccountRemoved extends ExtensionNotificationBase {
type: ExtensionNotificationType.AccountRemoved;
accountId: string;
}
export interface ExtensionNotificationAccountChanged extends ExtensionNotificationBase {
type: ExtensionNotificationType.AccountChanged;
accountId: string;
accountPublicKey: string;
watchOnly: boolean;
}
export {};