🚂Execution Engine Controller

The execution engine is designed to take transaction queues and execute them in a sequential manner. It's functionality is to have all breakpoint status updated in the queue about each txn, notify UI.

Create an instance
// Pass the walletController and solanaWallet instance here 
// it internally used evm broadcast txn, solana signAndSendTxn
const engine = new ExecutionEngine({
    walletController,
    transactions,
    solanaWallet,
});

// Either pass the txn queue in the constructor or use this function
engine.createTransactionQueue(transactions: Transaction[]);

// To push any new txn to the txn queue
engine.pushToTransactionQueue(transaction: Transaction);

// Start execution once the transaction queue is added
await engine.startExecution();

// Use this to check the latest status of the transactions
await engine.checkStatus();
startExecution

This is to start the sequential execution of the transactions added in the queue based on their status.

await engine.startExecution();
checkStatus
await engine.checkStatus();
onStatusUpdate

Event handler or callback to be set by the UI.

Override this function to add the logic here for UI to execute for each notification they want in between of the transaction execution process.

This is called internally, after each transaction in queue is executed. This is meant to be used for the progress bar in the UI.

Types
export interface Transaction {
  id: string;
  chainName: string;
  status: "pending" | "success" | "failed" | "cancelled"; // can add more status as needed
  type: OperationType | string;
  selectedWallet?: "EOA" | "AA"; // only needed for EVMs
  data: {
    solana?: string; // encodedTransaction // before signing we update the recentBlockHash and anything dependent on time expiry
    evm?: ITxnObject; // Evm txn object // we estimate gasLimit for the txnObject before broadcasting
  };
  cost?: number; // this can be regarding any payable transaction value
  fee: number; // gas fee estimated
  txHash?: string; // Transaction hash populated after success
  userOpHash?: string; // Transaction hash populated after success // in case of AA txns
  viewInExplorerUrl?: string; // we can add this for link to be clicked on each progress in the progress bar on FE side
  errorMessage?: string; // Error message populated if the transaction fails
}
export type ITxnObject = {
  from?: string;
  to?: string;
  value?: any;
  data?: string;
  gasLimit?: any;
  gasPrice?: any;
  chainId?: any;
};
export type ExecutionResult = {
  success: boolean;
  transaction?: Transaction; // this should return the updated transaction with updated status, and txnHash
  error?: any;
};

Integrations to be done:

  • So the UI is expected to receive a base path, as in a transaction queue to be executed for a user's operation

  • This basePath/queue is to be stored in the local storage of auth, to not lose it if user reloads in middle

  • For any user session check if there is a pending queue in user's local storage, and execute it passing the queue to the execution engine.

    • this is a fail safe in case the user drops in middle of a transaction queue execution

  • When the user is doing an operation, and tria creates a base path for their operation, we get a transaction queue from the basePath provider to be executed using the execution engine, and execution engine starts to execute the complete queue with one user click, returns the breakpoint status to the UI for display/progress bar purpose.

To enable debridge (spooncat minting via debridge) with Tria wallet:

  • create a transaction queue on auth side, for the required transactions to be done for spooncat minting specifically, i.e. approve + debridge txn (like done in metamask integration)

    • Check for token allowance - use the checkTokenAllowance function from the connect sdk - refer metamask integration for spooncat minting

    • Approve txn object - use getApproveTxnObject in fee controller to get the txnObject for approve and add it to the data: {evm: txnObject} field in the transaction to add to the queue, and add it as pending to the queue

    • Debridge Txn object - use the getBridgeQuote function from the connect sdk with the same params passed in metamask integration

Last updated