@aomi-labs/react 0.3.13 → 0.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { AomiClient, SessionOptions, Session, UserState, WalletRequest, WalletRequestResult } from '@aomi-labs/client';
2
- export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, DISABLED_PROVIDER_STATE, UserState, WalletEip712Payload, WalletRequest, WalletRequestResult, WalletTxPayload, aaModeFromExecutionKind, executeWalletCalls, hydrateTxPayloadFromUserState, parseChainId, toAAWalletCall, toAAWalletCalls, toViemSignTypedDataArgs } from '@aomi-labs/client';
1
+ import { AomiClient, SessionOptions, Session, UserState, WalletRequest, WalletRequestResult, AomiSimulateResponse } from '@aomi-labs/client';
2
+ export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, DISABLED_PROVIDER_STATE, MAX_AUTO_FEE_WEI, UserState, WalletEip712Payload, WalletRequest, WalletRequestResult, WalletTxPayload, aaModeFromExecutionKind, appendFeeCallToPayload, buildFeeAAWalletCall, executeWalletCalls, hydrateTxPayloadFromUserState, normalizeSimulatedFee, parseChainId, toAAWalletCall, toAAWalletCalls, toViemSignTypedDataArgs } from '@aomi-labs/client';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { ReactNode, SetStateAction } from 'react';
5
5
  import { ThreadMessageLike } from '@assistant-ui/react';
@@ -213,6 +213,18 @@ type AomiRuntimeApi = {
213
213
  resolveWalletRequest: (id: string, result: WalletRequestResult) => Promise<void>;
214
214
  /** Fail a wallet request after the backend acknowledges the error */
215
215
  rejectWalletRequest: (id: string, error?: string) => Promise<void>;
216
+ /** Simulate a batch against the current thread session context. */
217
+ simulateBatchTransactions: (transactions: Array<{
218
+ to: string;
219
+ value?: string;
220
+ data?: string;
221
+ label?: string;
222
+ chain_id?: number;
223
+ chainId?: number;
224
+ }>, options?: {
225
+ from?: string;
226
+ chainId?: number;
227
+ }) => Promise<AomiSimulateResponse["result"]>;
216
228
  /** Subscribe to inbound events by type. Returns unsubscribe function. */
217
229
  subscribe: (type: string, callback: EventSubscriber) => () => void;
218
230
  /** Send a system command to the backend */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { AomiClient, SessionOptions, Session, UserState, WalletRequest, WalletRequestResult } from '@aomi-labs/client';
2
- export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, DISABLED_PROVIDER_STATE, UserState, WalletEip712Payload, WalletRequest, WalletRequestResult, WalletTxPayload, aaModeFromExecutionKind, executeWalletCalls, hydrateTxPayloadFromUserState, parseChainId, toAAWalletCall, toAAWalletCalls, toViemSignTypedDataArgs } from '@aomi-labs/client';
1
+ import { AomiClient, SessionOptions, Session, UserState, WalletRequest, WalletRequestResult, AomiSimulateResponse } from '@aomi-labs/client';
2
+ export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, DISABLED_PROVIDER_STATE, MAX_AUTO_FEE_WEI, UserState, WalletEip712Payload, WalletRequest, WalletRequestResult, WalletTxPayload, aaModeFromExecutionKind, appendFeeCallToPayload, buildFeeAAWalletCall, executeWalletCalls, hydrateTxPayloadFromUserState, normalizeSimulatedFee, parseChainId, toAAWalletCall, toAAWalletCalls, toViemSignTypedDataArgs } from '@aomi-labs/client';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { ReactNode, SetStateAction } from 'react';
5
5
  import { ThreadMessageLike } from '@assistant-ui/react';
@@ -213,6 +213,18 @@ type AomiRuntimeApi = {
213
213
  resolveWalletRequest: (id: string, result: WalletRequestResult) => Promise<void>;
214
214
  /** Fail a wallet request after the backend acknowledges the error */
215
215
  rejectWalletRequest: (id: string, error?: string) => Promise<void>;
216
+ /** Simulate a batch against the current thread session context. */
217
+ simulateBatchTransactions: (transactions: Array<{
218
+ to: string;
219
+ value?: string;
220
+ data?: string;
221
+ label?: string;
222
+ chain_id?: number;
223
+ chainId?: number;
224
+ }>, options?: {
225
+ from?: string;
226
+ chainId?: number;
227
+ }) => Promise<AomiSimulateResponse["result"]>;
216
228
  /** Subscribe to inbound events by type. Returns unsubscribe function. */
217
229
  subscribe: (type: string, callback: EventSubscriber) => () => void;
218
230
  /** Send a system command to the backend */
package/dist/index.js CHANGED
@@ -38,6 +38,10 @@ import {
38
38
  hydrateTxPayloadFromUserState,
39
39
  toAAWalletCalls,
40
40
  toAAWalletCall,
41
+ appendFeeCallToPayload,
42
+ buildFeeAAWalletCall,
43
+ normalizeSimulatedFee,
44
+ MAX_AUTO_FEE_WEI,
41
45
  executeWalletCalls,
42
46
  DISABLED_PROVIDER_STATE,
43
47
  parseChainId,
@@ -1908,6 +1912,22 @@ function AomiRuntimeCore({
1908
1912
  },
1909
1913
  [threadContext.allThreadsMetadata, threadListAdapter]
1910
1914
  );
1915
+ const simulateBatchTransactions = useCallback7(
1916
+ async (transactions, options) => {
1917
+ var _a, _b;
1918
+ const session = (_b = (_a = sessionManagerRef.current) == null ? void 0 : _a.get(threadContext.currentThreadId)) != null ? _b : getSession(threadContext.currentThreadId);
1919
+ if (!session) {
1920
+ throw new Error("runtime_session_unavailable");
1921
+ }
1922
+ const response = await session.client.simulateBatch(
1923
+ session.sessionId,
1924
+ transactions,
1925
+ options
1926
+ );
1927
+ return response.result;
1928
+ },
1929
+ [getSession, threadContext.currentThreadId]
1930
+ );
1911
1931
  const aomiRuntimeApi = useMemo2(
1912
1932
  () => ({
1913
1933
  // User API
@@ -1942,6 +1962,7 @@ function AomiRuntimeCore({
1942
1962
  startWalletRequest: walletHandler.startRequest,
1943
1963
  resolveWalletRequest: walletHandler.resolveRequest,
1944
1964
  rejectWalletRequest: walletHandler.rejectRequest,
1965
+ simulateBatchTransactions,
1945
1966
  // Event API
1946
1967
  subscribe: eventContext.subscribe,
1947
1968
  sendSystemCommand: eventContext.sendOutboundSystem,
@@ -1964,6 +1985,7 @@ function AomiRuntimeCore({
1964
1985
  cancelGeneration,
1965
1986
  notificationContext,
1966
1987
  walletHandler,
1988
+ simulateBatchTransactions,
1967
1989
  eventContext
1968
1990
  ]
1969
1991
  );
@@ -2061,12 +2083,15 @@ export {
2061
2083
  ControlContextProvider,
2062
2084
  DISABLED_PROVIDER_STATE,
2063
2085
  EventContextProvider,
2086
+ MAX_AUTO_FEE_WEI,
2064
2087
  NotificationContextProvider,
2065
2088
  RuntimeUserStateProvider,
2066
2089
  SUPPORTED_CHAINS,
2067
2090
  ThreadContextProvider,
2068
2091
  UserContextProvider,
2069
2092
  aaModeFromExecutionKind,
2093
+ appendFeeCallToPayload,
2094
+ buildFeeAAWalletCall,
2070
2095
  cn,
2071
2096
  executeWalletCalls,
2072
2097
  formatAddress,
@@ -2074,6 +2099,7 @@ export {
2074
2099
  getNetworkName,
2075
2100
  hydrateTxPayloadFromUserState,
2076
2101
  initThreadControl,
2102
+ normalizeSimulatedFee,
2077
2103
  parseChainId,
2078
2104
  toAAWalletCall,
2079
2105
  toAAWalletCalls,