displayModal
displayModal<
T>(client,args,placement?):Promise<ModalRpcStepsResultType<T>>
Defined in: actions/displayModal.ts:111
Function used to display a modal
Type Parameters
Section titled “Type Parameters”T extends ModalStepTypes[] = ModalStepTypes[]
Parameters
Section titled “Parameters”client
Section titled “client”The current Frak Client
placement?
Section titled “placement?”string
Optional placement ID to associate with this modal display
Returns
Section titled “Returns”Promise<ModalRpcStepsResultType<T>>
The result of each modal steps
Description
Section titled “Description”This function will display a modal to the user with the provided steps and metadata.
Remarks
Section titled “Remarks”- The UI of the displayed modal can be configured with the
customCssproperty in thecustomizations.cssfield of the top-level config. - The
loginstep will be automatically skipped if the user is already logged in. It’s safe to include this step in all cases to ensure proper user state. - Steps are automatically reordered in the following sequence:
login(if needed)- All other steps in the order specified
success(if included, always last)
Examples
Section titled “Examples”Simple sharing modal with steps:
- Login (Skipped if already logged in)
- Display a success message with sharing link option
const results = await displayModal(frakConfig, { steps: { // Simple login with no SSO, nor customization login: { allowSso: false }, // Success message final: { action: { key: "reward" }, // Skip this step, it will be only displayed in the stepper within the modal autoSkip: true, }, },});
console.log("Login step - wallet", results.login.wallet);A full modal example, with a few customization options, with the steps:
- Login (Skipped if already logged in)
- Authenticate via SIWE
- Send a transaction
- Display a success message with sharing link options
const results = await displayModal(frakConfig, { steps: { // Login step login: { allowSso: true, ssoMetadata: { logoUrl: "https://my-app.com/logo.png", homepageLink: "https://my-app.com", }, }, // Siwe authentication siweAuthenticate: { siwe: { domain: "my-app.com", uri: "https://my-app.com/", nonce: generateSiweNonce(), version: "1", }, }, // Send batched transaction sendTransaction: { tx: [ { to: "0xdeadbeef", data: "0xdeadbeef" }, { to: "0xdeadbeef", data: "0xdeadbeef" }, ], }, // Success message with sharing options final: { action: { key: "sharing", options: { popupTitle: "Share the app", text: "Discover my super app website", link: "https://my-app.com", }, }, dismissedMetadata: { title: "Dismiss", description: "You won't be rewarded for this sharing action", }, }, }, metadata: { // Header of desktop modals header: { title: "My-App", icon: "https://my-app.com/logo.png", }, // Context that will be present in every modal steps context: "My-app overkill flow", },});