0.1.17 • Published 3 months ago

brahma-builder-playground v0.1.17

Weekly downloads
-
License
-
Repository
-
Last release
3 months ago

Brahma Account Deployment Flow

This document outlines the process for managing assets and deploying a Brahma Account using a pre-computed address. The flow involves several steps, from fetching assets to deploying the account and checking the deployment status.

flowchart TD;
    A[Start] --> B[Fetch EOA Assets]
    B --> C[User Selection]
    C --> D[Fetch Pre-Computed Address]
    D --> E{Is Deposit Sufficient?}
    E -- Yes --> F[Deploy Brahma Account]
    E -- No --> G[Request Additional Deposit]
    G --> C
    F --> H[Poll for Deployment Status]
    H --> I[End]

Flow Overview

  1. Fetch EOA Assets: Retrieve the balances of assets for a given Externally Owned Account (EOA). See the implementation in fetchEoaAssets.
  2. User Selection: Users select the amount they want to transfer to the pre-computed address.
  3. Fetch Pre-Computed Address: Obtain the pre-computed address and related data such as fee estimates. See the implementation in fetchPreComputedConsoleAddress.
  4. Check Deposit Against Gas Cost: Ensure the deposited amount covers the gas cost for deploying the Brahma Account.
  5. Request Additional Deposit: If necessary, prompt the user to deposit more funds.
  6. Deploy Brahma Account: Generate and deploy the Brahma Account once the deposit is sufficient. See the implementation in generateAndDeploySubAccount.
  7. Poll for Deployment Status: Continuously check the deployment status until completion. See the implementation in fetchDeploymentStatus.

Detailed Steps

1. Fetch EOA Assets

  • Use the fetchEoaAssets function to call fetchAssetsBalanceMultiCall and retrieve asset balances. See the API call in fetchAssetsBalanceMultiCall.

2. User Selection

  • Users interact with the UI to select the amount to transfer.

3. Fetch Pre-Computed Address

  • Call fetchPreComputedConsoleAddress to get the pre-computed address, fee estimate, and signature.

4. Check Deposit Against Gas Cost

  • Compare the deposited amount with the feeEstimate to ensure sufficient funds.

5. Request Additional Deposit

  • If the deposit is insufficient, prompt the user to add more funds.

6. Deploy Brahma Account

  • Use generateAndDeploySubAccount to generate and deploy the account using the public deployer from brahma-templates-sdk calling the functions generateAutomationSubAccount and deployConsoleAndSubAccount.

7. Poll for Deployment Status

  • Use fetchDeploymentStatus to poll the deployment status using the fetchTaskStatus from the brahma-templates-sdk's public deployer.

Error Handling

  • Ensure proper error handling at each step, especially when interacting with APIs.
  • Use dispatchToast to notify users of errors or status updates. See the implementation in dispatchToast.

Conclusion

This flow ensures a seamless process for deploying Brahma Accounts, leveraging pre-computed addresses and efficient asset management.

Running the app

This is a RainbowKit + wagmi + Next.js project bootstrapped with create-rainbowkit.

Getting Started

First, run the development server:

npm run dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.tsx. The page auto-updates as you edit the file.

Learn More

To learn more about this stack, take a look at the following resources:

You can check out the RainbowKit GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out the Next.js deployment documentation for more details