Migration to Lit and AA
  • Overview
  • Getting Started
    • Installation
    • Deployment
    • FAQ
  • Reference
    • Onboarding and Wallet SDK
      • Concepts
      • Wagmi config
      • @tria-sdk/core
        • Auth Controller [INTERNAL]
        • User Controller
      • @tria-sdk/web [INTERNAL]
        • Lit Controller
        • Keyring Controller
        • Wallet Controller
        • Gas Abstraction Wallet Controller ⛽️
        • Fee Controller
        • Solana Wallet
        • WalletConnect Controller
        • 🚂Execution Engine Controller
      • @tria-sdk/connect
        • TriaProvider
        • Actions
        • Hooks
          • Internal hooks
        • Constants [Internal]
      • @tria-sdk/authenticate
        • Application
      • @tria-sdk/authenticate-web
    • Supported Networks
    • How to create Debridge Solana Calldata
    • New concepts [Internal]
    • Gas Abstraction Integrations [Internal]
  • EIP1193 - Provider (WIP)
Powered by GitBook
On this page
  • Create an instance
  • Initialize
  • Listen to events
  1. Reference
  2. Onboarding and Wallet SDK
  3. @tria-sdk/web [INTERNAL]

WalletConnect Controller

WalletConnect controller handles the connections and transactions with dapps.

Create an instance

const wcController = new WCController({
        baseUrl,
        walletType,
        selectedChainName,
        environment = "mainnet",
        sessionSignatures,
        currentAccount,
        customAuthMethod,
        accessToken,
        sentryDns,
        aa,
        selectedWallet,
}: TriaArgs);

export type TriaArgs = {
  baseUrl: string;
  sentryDns?: string;
  walletType?: WalletType;
  selectedChainName?: ChainName;
  environment?: ENV;
  currentAccount?: IRelayPKP;
  sessionSignatures?: string;
  customAuthMethod?: LitCustomAuthMethod;
  accessToken?: string;
  aa?: AaDetails;
  selectedWallet?: "EOA" | "AA";
};

Initialize

This function initializes WalletConnect and start listening to the events.

await wcController.initialize();

Listen to events

Listen to connection event:

This event will be triggered when any dApp initiates a connection request.

// Listen to the connection request
wcController.onConnectionRequest(connectionReqCB);

// Sample connectionReqCB
function connectionReqCB({ id, params }) {
    const dAppName = params.proposer.metadata.name;
    const dAppIcon = params.proposer.metadata.icons[0];
    
    // ...show the connect wallet UI
}

// Accept the connection request
await wcController.acceptSessionProposal({ id, params });

// Reject the connection request
await wcController.rejectSessionProposal({ id });

Listen to dApp function calls:

This event will be triggered when any dApp initiates any function call

// Listen to the function call event
wcController.onFunctionRequest(functionReqCB);

// Sample functionReqCB
function functionReqCB({ topic, params, id }) {
    const method = params.request.method;
    const args = params.request.params;
    const chainId = params.chainId;
    
    // The screen to be displayed will depend on the value of method parameter.
    if (method === 'eth_sign') {
        const message === args[1];
        
        // Open the message sign UI with the message
    } else if (method === 'personal_sign') {
        const message === args[0];
        
        // Open the message sign UI with the message
    } else if (method === 'eth_sendTransaction') {
        const { to, value, data, from, gas } = args[0];
    
        const transaction = { to, value, data, from, gasLimit };
        
        // Use the above parameters to populate the transaction screen
    }
}

To execute the function calls,

const response = await wcController.executeFunction({ id, method, params: args, chainIdNamespace: chainId });
PreviousSolana WalletNextExecution Engine Controller

Last updated 9 months ago