runtime-tx-handler
aomi/runtime-tx-handlerFreeComponent
Executes wallet transaction and EIP-712 signing requests from the AI backend through the active wallet kit.
Install it
npx shadcn@latest add https://aomi.dev/r/runtime-tx-handler.jsonSource
1"use client";23import { useEffect, useRef, useState } from "react";4import { ShieldCheck } from "lucide-react";5import { Connection as SolanaConnection } from "@solana/web3.js";6import { normalizeSolanaCluster } from "@aomi-labs/client";7import {8 UserState,9 appendFeeCallToPayload,10 hydrateTxPayloadFromUserState,11 parseChainId,12 toViemSignMessageArgs,13 toViemSignTypedDataArgs,14 useAomiRuntime,15 type WalletRequest,16 type WalletTxPayload,17} from "@aomi-labs/react";18import { useAomiWalletKit } from "../lib/wallet-kit";19import { walletDebug } from "../lib/wallet-kit/wallet-debug";20import { Button } from "./ui/button";21import {22 Dialog,23 DialogContent,24 DialogDescription,25 DialogFooter,26 DialogHeader,27 DialogTitle,28} from "./ui/dialog";2930function hasHydratedCalls(payload: WalletTxPayload): boolean {31 return Array.isArray(payload.calls) && payload.calls.length > 0;32}3334function decodeBase64(value: string): Uint8Array {35 if (typeof Buffer !== "undefined") {36 return new Uint8Array(Buffer.from(value, "base64"));37 }38 return Uint8Array.from(atob(value), (char) => char.charCodeAt(0));39}4041function toSimulationTransactions(payload: WalletTxPayload): Array<{42 to: string;43 value?: string;44 data?: string;45 label?: string;46 chain_id?: number;47}> {48 if (Array.isArray(payload.calls) && payload.calls.length > 0) {49 return payload.calls.map((call) => ({50 to: call.to,51 value: call.value,52 data: call.data,53 label: call.description,54 chain_id: call.chainId,55 }));56 }5758 if (!payload.to) {59 throw new Error("pending_transaction_missing_call_data");60 }6162 return [63 {64 to: payload.to,65 value: payload.value,66 data: payload.data,67 chain_id: payload.chainId,68 },69 ];70}7172/**73 * Invisible bridge component that processes wallet transaction and EIP-71274 * signing requests from the AI backend through the active Aomi wallet kit.75 *76 * Auto-mounted inside AomiFrame.Root.77 */78export function RuntimeTxHandler() {79 const {80 user,81 pendingWalletRequests,82 startWalletRequest,83 resolveWalletRequest,84 rejectWalletRequest,85 simulateBatchTransactions,86 showNotification,87 } = useAomiRuntime();88 const adapter = useAomiWalletKit();89 const { chainId: currentChainId } = adapter.identity;90 const processingRef = useRef(false);91 const [isSigningAa, setIsSigningAa] = useState(false);92 const aaRequest =93 pendingWalletRequests[0]?.kind === "aa_sign"94 ? pendingWalletRequests[0]95 : null;96// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from aomi
All 34 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | aomi | Components | Free | 2 deps | |
| alertalert | aomi | Components | Free | 1 dep | |
| aomi-frameaomi-frame | aomi | Components | Free | 1 dep | |
| aomi-para-provideraomi-para-provider | aomi | Components | Free | 9 deps · 27 files | |
| aomi-privy-provideraomi-privy-provider | aomi | Components | Free | 7 deps · 15 files | |
| aomi-wallet-kitaomi-wallet-kit | aomi | Components | Free | 8 deps · 59 files | |
| aomi-widgetaomi-widget | aomi | Components | Free | 2 deps | |
| assistant-threadassistant-thread | aomi | Components | Free | 6 deps · 23 files |
