@perawallet/connect
Version:
JavaScript SDK for integrating Pera Wallet to web applications.
83 lines (82 loc) • 3.38 kB
TypeScript
export type PERA_CONNECT_MODAL_VIEWS = "default" | "download-pera";
export interface PeraWalletModalConfig {
isWebWalletAvailable: boolean;
shouldDisplayNewBadge: boolean;
shouldUseSound: boolean;
promoteMobile?: boolean;
compactMode?: boolean;
singleAccount?: boolean;
selectedAccount?: string;
isInWebview?: boolean;
}
declare const PERA_WALLET_CONNECT_MODAL_ID = "pera-wallet-connect-modal-wrapper";
declare const PERA_WALLET_REDIRECT_MODAL_ID = "pera-wallet-redirect-modal-wrapper";
declare const PERA_WALLET_SIGN_TXN_TOAST_ID = "pera-wallet-sign-txn-toast-wrapper";
declare const PERA_WALLET_SIGN_TXN_MODAL_ID = "pera-wallet-sign-txn-modal-wrapper";
declare const PERA_WALLET_IFRAME_ID = "pera-wallet-iframe";
declare const PERA_WALLET_MODAL_CLASSNAME = "pera-wallet-modal";
declare const PERA_WALLET_WEB_WALLET_IFRAME_CLASSNAME = "pera-wallet-connect-modal-desktop-mode__web-wallet-iframe";
/**
* Creates a modal wrapper on the DOM and renders a PeraWalletConnectModal instance on it.
* @param modalConfig PeraWalletModalConfig
*
* @returns VoidFunction
*/
declare function openPeraWalletConnectModal(modalConfig: PeraWalletModalConfig): (uri: string) => void;
/**
* Adds a listener to the close button of the given modal.
*
* @param modalId string
* @param onClose VoidFunction
*
* @returns {void}
*/
declare function setupPeraWalletConnectModalCloseListener(modalId: string, onClose: VoidFunction): void;
/**
* Creates a PeraWalletRedirectModal instance and renders it on the DOM.
*
* @returns {void}
*/
declare function openPeraWalletRedirectModal(): void;
/**
* Creates a PeraWalletSignTxnModal instance and renders it on the DOM.
*
* @returns {Promise<Element>}
*/
declare function openPeraWalletSignTxnModal({ isCompactMode }: {
isCompactMode?: boolean;
}): Promise<Element>;
/**
* Close the PeraWalletSignTxnModal instance and remove it from the DOM.
* @param rejectPromise
*
* @returns {void}
*/
declare function closePeraWalletSignTxnModal(rejectPromise?: (error: any) => void): void;
/**
* Creates a PeraWalletSignTxnToast instance and renders it on the DOM.
*
* @returns {void}
*/
declare function openPeraWalletSignTxnToast(): void;
/**
* Close the PeraWalletSignTxnToast instance and remove it from the DOM.
*
* @returns {void}
*/
declare function closePeraWalletSignTxnToast(): void;
/**
* Removes the modal wrapper with given ID from the DOM.
* @param modalId string
*
* @returns {void}
*/
declare function removeModalWrapperFromDOM(modalId: string): void;
/**
* Return the close button element in the header as a result
* @param type "connect" | "sign-txn"
*
* @returns HTMLElement | null | undefined
*/
declare function getHeaderCloseButton(type: "connect" | "sign-txn"): HTMLElement | null | undefined;
export { PERA_WALLET_CONNECT_MODAL_ID, PERA_WALLET_REDIRECT_MODAL_ID, PERA_WALLET_SIGN_TXN_TOAST_ID, PERA_WALLET_SIGN_TXN_MODAL_ID, PERA_WALLET_MODAL_CLASSNAME, PERA_WALLET_WEB_WALLET_IFRAME_CLASSNAME, PERA_WALLET_IFRAME_ID, openPeraWalletConnectModal, setupPeraWalletConnectModalCloseListener, openPeraWalletRedirectModal, openPeraWalletSignTxnToast, closePeraWalletSignTxnToast, removeModalWrapperFromDOM, openPeraWalletSignTxnModal, closePeraWalletSignTxnModal, getHeaderCloseButton };