@aomi-labs/client 0.1.21 → 0.1.22

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
@@ -565,9 +565,31 @@ type UnwrappedEvent = {
565
565
  */
566
566
  declare function unwrapSystemEvent(event: AomiSystemEvent): UnwrappedEvent | null;
567
567
 
568
- type AAExecutionMode = "4337" | "7702";
569
- type AASponsorshipMode = "disabled" | "optional" | "required";
570
- type WalletExecutionCall = {
568
+ /**
569
+ * Reads the first non-empty env var from `candidates`.
570
+ * When `publicOnly` is true, only `NEXT_PUBLIC_*` names are considered.
571
+ */
572
+ declare function readEnv(candidates: readonly string[], options?: {
573
+ publicOnly?: boolean;
574
+ }): string | undefined;
575
+ type AAProvider = "alchemy" | "pimlico";
576
+ /**
577
+ * Returns true if the given provider has a configured API key.
578
+ */
579
+ declare function isProviderConfigured(provider: AAProvider, options?: {
580
+ publicOnly?: boolean;
581
+ }): boolean;
582
+ /**
583
+ * Picks the first configured provider (alchemy > pimlico).
584
+ * Throws if neither is configured.
585
+ */
586
+ declare function resolveDefaultProvider(options?: {
587
+ publicOnly?: boolean;
588
+ }): AAProvider;
589
+
590
+ type AAMode = "4337" | "7702";
591
+ type AASponsorship = "disabled" | "optional" | "required";
592
+ type WalletCall = {
571
593
  to: string;
572
594
  value: string;
573
595
  data?: string;
@@ -586,26 +608,26 @@ type WalletPrimitiveCall = {
586
608
  interface AAChainConfig {
587
609
  chainId: number;
588
610
  enabled: boolean;
589
- defaultMode: AAExecutionMode;
590
- supportedModes: AAExecutionMode[];
611
+ defaultMode: AAMode;
612
+ supportedModes: AAMode[];
591
613
  allowBatching: boolean;
592
- sponsorship: AASponsorshipMode;
614
+ sponsorship: AASponsorship;
593
615
  }
594
616
  interface AAConfig {
595
617
  enabled: boolean;
596
- provider: string;
618
+ provider: AAProvider;
597
619
  fallbackToEoa: boolean;
598
620
  chains: AAChainConfig[];
599
621
  }
600
- interface AAExecutionPlan {
601
- provider: string;
622
+ interface AAResolvedConfig {
623
+ provider: AAProvider;
602
624
  chainId: number;
603
- mode: AAExecutionMode;
625
+ mode: AAMode;
604
626
  batchingEnabled: boolean;
605
- sponsorship: AASponsorshipMode;
627
+ sponsorship: AASponsorship;
606
628
  fallbackToEoa: boolean;
607
629
  }
608
- interface AALike {
630
+ interface SmartAccount {
609
631
  provider: string;
610
632
  mode: string;
611
633
  AAAddress?: Hex;
@@ -617,19 +639,13 @@ interface AALike {
617
639
  transactionHash: string;
618
640
  }>;
619
641
  }
620
- interface AAProviderQuery<TAA extends AALike = AALike> {
621
- AA?: TAA | null;
622
- isPending?: boolean;
623
- error?: Error | null;
624
- }
625
- interface AAProviderState<TAA extends AALike = AALike> {
626
- plan: AAExecutionPlan | null;
627
- AA?: TAA | null;
628
- isPending: boolean;
642
+ interface AAState<TAccount extends SmartAccount = SmartAccount> {
643
+ resolved: AAResolvedConfig | null;
644
+ account?: TAccount | null;
645
+ pending: boolean;
629
646
  error: Error | null;
630
- query?: AAProviderQuery<TAA>;
631
647
  }
632
- interface TransactionExecutionResult {
648
+ interface ExecutionResult {
633
649
  txHash: string;
634
650
  txHashes: string[];
635
651
  executionKind: string;
@@ -638,7 +654,7 @@ interface TransactionExecutionResult {
638
654
  AAAddress?: Hex;
639
655
  delegationAddress?: Hex;
640
656
  }
641
- interface SendCallsSyncArgs {
657
+ interface AtomicBatchArgs {
642
658
  calls: WalletPrimitiveCall[];
643
659
  capabilities?: {
644
660
  atomic?: {
@@ -646,13 +662,13 @@ interface SendCallsSyncArgs {
646
662
  };
647
663
  };
648
664
  }
649
- interface ExecuteWalletCallsParams<TAA extends AALike = AALike> {
650
- callList: WalletExecutionCall[];
665
+ interface ExecuteWalletCallsParams<TAccount extends SmartAccount = SmartAccount> {
666
+ callList: WalletCall[];
651
667
  currentChainId: number;
652
668
  capabilities: Record<string, WalletAtomicCapability> | undefined;
653
669
  localPrivateKey: `0x${string}` | null;
654
- providerState: AAProviderState<TAA>;
655
- sendCallsSyncAsync: (args: SendCallsSyncArgs) => Promise<unknown>;
670
+ providerState: AAState<TAccount>;
671
+ sendCallsSyncAsync: (args: AtomicBatchArgs) => Promise<unknown>;
656
672
  sendTransactionAsync: (args: {
657
673
  chainId: number;
658
674
  to: Hex;
@@ -666,11 +682,32 @@ interface ExecuteWalletCallsParams<TAA extends AALike = AALike> {
666
682
  getPreferredRpcUrl: (chain: Chain) => string;
667
683
  }
668
684
  declare function parseAAConfig(value: unknown): AAConfig;
669
- declare function getAAChainConfig(config: AAConfig, calls: WalletExecutionCall[], chainsById: Record<number, Chain>): AAChainConfig | null;
670
- declare function buildAAExecutionPlan(config: AAConfig, chainConfig: AAChainConfig): AAExecutionPlan;
671
- declare function getWalletExecutorReady(providerState: AAProviderState): boolean;
685
+ declare function getAAChainConfig(config: AAConfig, calls: WalletCall[], chainsById: Record<number, Chain>): AAChainConfig | null;
686
+ declare function buildAAExecutionPlan(config: AAConfig, chainConfig: AAChainConfig): AAResolvedConfig;
687
+ declare function getWalletExecutorReady(providerState: AAState): boolean;
672
688
  declare const DEFAULT_AA_CONFIG: AAConfig;
673
- declare function executeWalletCalls(params: ExecuteWalletCallsParams): Promise<TransactionExecutionResult>;
689
+ declare function executeWalletCalls(params: ExecuteWalletCallsParams): Promise<ExecutionResult>;
690
+
691
+ interface AlchemyResolveOptions {
692
+ calls: WalletCall[] | null;
693
+ localPrivateKey?: `0x${string}` | null;
694
+ accountAbstractionConfig?: AAConfig;
695
+ chainsById: Record<number, Chain>;
696
+ chainSlugById?: Record<number, string>;
697
+ getPreferredRpcUrl?: (chain: Chain) => string;
698
+ modeOverride?: AAMode;
699
+ publicOnly?: boolean;
700
+ throwOnMissingConfig?: boolean;
701
+ apiKey?: string;
702
+ gasPolicyId?: string;
703
+ }
704
+ interface AlchemyResolvedConfig extends AAResolvedConfig {
705
+ apiKey: string;
706
+ chain: Chain;
707
+ rpcUrl: string;
708
+ gasPolicyId?: string;
709
+ }
710
+ declare function resolveAlchemyConfig(options: AlchemyResolveOptions): AlchemyResolvedConfig | null;
674
711
 
675
712
  interface AlchemyHookParams {
676
713
  enabled: boolean;
@@ -678,158 +715,111 @@ interface AlchemyHookParams {
678
715
  chain: Chain;
679
716
  rpcUrl: string;
680
717
  gasPolicyId?: string;
681
- mode: AAExecutionMode;
718
+ mode: AAMode;
682
719
  }
683
- type UseAlchemyAAHook<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> = (params?: AlchemyHookParams) => TQuery;
684
- interface CreateAlchemyAAProviderOptions<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> {
720
+ type AlchemyHookState<TAccount extends SmartAccount = SmartAccount> = {
721
+ account?: TAccount | null;
722
+ pending?: boolean;
723
+ error?: Error | null;
724
+ };
725
+ type UseAlchemyAAHook<TAccount extends SmartAccount = SmartAccount> = (params?: AlchemyHookParams) => AlchemyHookState<TAccount>;
726
+ interface CreateAlchemyAAProviderOptions<TAccount extends SmartAccount = SmartAccount> {
685
727
  accountAbstractionConfig?: AAConfig;
686
- useAlchemyAA: UseAlchemyAAHook<TAA, TQuery>;
728
+ useAlchemyAA: UseAlchemyAAHook<TAccount>;
687
729
  chainsById: Record<number, Chain>;
688
730
  chainSlugById: Record<number, string>;
689
731
  getPreferredRpcUrl: (chain: Chain) => string;
690
732
  apiKeyEnvVar?: string;
691
733
  gasPolicyEnvVar?: string;
692
734
  }
693
- declare function createAlchemyAAProvider<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>>({ accountAbstractionConfig, useAlchemyAA, chainsById, chainSlugById, getPreferredRpcUrl, }: CreateAlchemyAAProviderOptions<TAA, TQuery>): (calls: WalletExecutionCall[] | null, localPrivateKey: `0x${string}` | null) => AAProviderState<TAA>;
735
+ declare function createAlchemyAAProvider<TAccount extends SmartAccount = SmartAccount>({ accountAbstractionConfig, useAlchemyAA, chainsById, chainSlugById, getPreferredRpcUrl, }: CreateAlchemyAAProviderOptions<TAccount>): (calls: WalletCall[] | null, localPrivateKey: `0x${string}` | null) => AAState<TAccount>;
736
+
737
+ type AAOwner = {
738
+ kind: "direct";
739
+ privateKey: `0x${string}`;
740
+ } | {
741
+ kind: "session";
742
+ adapter: string;
743
+ session: unknown;
744
+ signer?: unknown;
745
+ address?: Hex;
746
+ };
747
+
748
+ interface PimlicoResolveOptions {
749
+ calls: WalletCall[] | null;
750
+ localPrivateKey?: `0x${string}` | null;
751
+ accountAbstractionConfig?: AAConfig;
752
+ chainsById: Record<number, Chain>;
753
+ rpcUrl?: string;
754
+ modeOverride?: AAMode;
755
+ publicOnly?: boolean;
756
+ throwOnMissingConfig?: boolean;
757
+ apiKey?: string;
758
+ }
759
+ interface PimlicoResolvedConfig extends AAResolvedConfig {
760
+ apiKey: string;
761
+ chain: Chain;
762
+ rpcUrl?: string;
763
+ }
764
+ declare function resolvePimlicoConfig(options: PimlicoResolveOptions): PimlicoResolvedConfig | null;
694
765
 
695
766
  interface PimlicoHookParams {
696
767
  enabled: boolean;
697
768
  apiKey: string;
698
769
  chain: Chain;
699
- mode: AAExecutionMode;
770
+ mode: AAMode;
700
771
  rpcUrl?: string;
701
772
  }
702
- type UsePimlicoAAHook<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> = (params?: PimlicoHookParams) => TQuery;
703
- interface CreatePimlicoAAProviderOptions<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> {
773
+ type PimlicoHookState<TAccount extends SmartAccount = SmartAccount> = {
774
+ account?: TAccount | null;
775
+ pending?: boolean;
776
+ error?: Error | null;
777
+ };
778
+ type UsePimlicoAAHook<TAccount extends SmartAccount = SmartAccount> = (params?: PimlicoHookParams) => PimlicoHookState<TAccount>;
779
+ interface CreatePimlicoAAProviderOptions<TAccount extends SmartAccount = SmartAccount> {
704
780
  accountAbstractionConfig?: AAConfig;
705
- usePimlicoAA: UsePimlicoAAHook<TAA, TQuery>;
781
+ usePimlicoAA: UsePimlicoAAHook<TAccount>;
706
782
  chainsById: Record<number, Chain>;
707
783
  apiKeyEnvVar?: string;
708
784
  rpcUrl?: string;
709
785
  }
710
- declare function createPimlicoAAProvider<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>>({ accountAbstractionConfig, usePimlicoAA, chainsById, rpcUrl, }: CreatePimlicoAAProviderOptions<TAA, TQuery>): (calls: WalletExecutionCall[] | null, localPrivateKey: `0x${string}` | null) => AAProviderState<TAA>;
711
-
712
- /**
713
- * Reads the first non-empty env var from `candidates`.
714
- * When `publicOnly` is true, only `NEXT_PUBLIC_*` names are considered.
715
- */
716
- declare function readEnv(candidates: readonly string[], options?: {
717
- publicOnly?: boolean;
718
- }): string | undefined;
719
- type AAProvider = "alchemy" | "pimlico";
720
- /**
721
- * Returns true if the given provider has a configured API key.
722
- */
723
- declare function isProviderConfigured(provider: AAProvider, options?: {
724
- publicOnly?: boolean;
725
- }): boolean;
726
- /**
727
- * Picks the first configured provider (alchemy > pimlico).
728
- * Throws if neither is configured.
729
- */
730
- declare function resolveDefaultProvider(options?: {
731
- publicOnly?: boolean;
732
- }): AAProvider;
786
+ declare function createPimlicoAAProvider<TAccount extends SmartAccount = SmartAccount>({ accountAbstractionConfig, usePimlicoAA, chainsById, rpcUrl, }: CreatePimlicoAAProviderOptions<TAccount>): (calls: WalletCall[] | null, localPrivateKey: `0x${string}` | null) => AAState<TAccount>;
733
787
 
734
- type ParaSmartAccountLike = {
788
+ type SdkSmartAccount = {
735
789
  provider: string;
736
- mode: AAExecutionMode;
790
+ mode: AAMode;
737
791
  smartAccountAddress: Hex;
738
792
  delegationAddress?: Hex;
739
793
  sendTransaction: (call: WalletPrimitiveCall, options?: unknown) => Promise<TransactionReceipt>;
740
794
  sendBatchTransaction: (calls: WalletPrimitiveCall[], options?: unknown) => Promise<TransactionReceipt>;
741
795
  };
742
796
  /**
743
- * Bridges a `ParaSmartAccountLike` (from `@getpara/aa-*` SDKs) into
744
- * the library's `AALike` interface:
797
+ * Bridges the provider SDK smart-account shape into the library's
798
+ * SmartAccount interface:
745
799
  * - Maps `smartAccountAddress` → `AAAddress`
746
800
  * - Unwraps `TransactionReceipt` → `{ transactionHash }`
747
801
  */
748
- declare function adaptSmartAccount(account: ParaSmartAccountLike): AALike;
802
+ declare function adaptSmartAccount(account: SdkSmartAccount): SmartAccount;
749
803
  /**
750
804
  * Detects Alchemy gas sponsorship quota errors.
751
805
  */
752
806
  declare function isAlchemySponsorshipLimitError(error: unknown): boolean;
753
807
 
754
- interface AlchemyResolveOptions {
755
- calls: WalletExecutionCall[] | null;
756
- localPrivateKey?: `0x${string}` | null;
757
- accountAbstractionConfig?: AAConfig;
758
- chainsById: Record<number, Chain>;
759
- chainSlugById?: Record<number, string>;
760
- getPreferredRpcUrl?: (chain: Chain) => string;
761
- modeOverride?: AAExecutionMode;
762
- publicOnly?: boolean;
763
- throwOnMissingConfig?: boolean;
764
- /**
765
- * Pre-resolved API key. Use this in Next.js client-side code where
766
- * dynamic `process.env[name]` access doesn't work.
767
- */
768
- apiKey?: string;
769
- gasPolicyId?: string;
770
- }
771
- interface AlchemyResolvedConfig {
772
- chainConfig: AAChainConfig;
773
- plan: AAExecutionPlan;
774
- apiKey: string;
775
- chain: Chain;
776
- rpcUrl: string;
777
- gasPolicyId?: string;
778
- mode: AAExecutionMode;
779
- }
780
- declare function resolveAlchemyConfig(options: AlchemyResolveOptions): AlchemyResolvedConfig | null;
781
- interface PimlicoResolveOptions {
782
- calls: WalletExecutionCall[] | null;
783
- localPrivateKey?: `0x${string}` | null;
784
- accountAbstractionConfig?: AAConfig;
785
- chainsById: Record<number, Chain>;
786
- rpcUrl?: string;
787
- modeOverride?: AAExecutionMode;
788
- publicOnly?: boolean;
789
- throwOnMissingConfig?: boolean;
790
- /**
791
- * Pre-resolved API key. Use this in Next.js client-side code where
792
- * dynamic `process.env[name]` access doesn't work.
793
- */
794
- apiKey?: string;
795
- }
796
- interface PimlicoResolvedConfig {
797
- chainConfig: AAChainConfig;
798
- plan: AAExecutionPlan;
799
- apiKey: string;
800
- chain: Chain;
801
- rpcUrl?: string;
802
- mode: AAExecutionMode;
803
- }
804
- declare function resolvePimlicoConfig(options: PimlicoResolveOptions): PimlicoResolvedConfig | null;
805
-
806
- type CreateAAOwner = {
807
- kind: "direct";
808
- privateKey: `0x${string}`;
809
- } | {
810
- kind: "session";
811
- adapter: string;
812
- session: unknown;
813
- signer?: unknown;
814
- address?: Hex;
815
- };
816
- interface CreateAAProviderStateOptions {
808
+ interface CreateAAStateOptions {
817
809
  provider: AAProvider;
818
810
  chain: Chain;
819
- owner: CreateAAOwner;
811
+ owner: AAOwner;
820
812
  rpcUrl: string;
821
- callList: WalletExecutionCall[];
822
- mode?: AAExecutionMode;
813
+ callList: WalletCall[];
814
+ mode?: AAMode;
823
815
  apiKey?: string;
824
816
  gasPolicyId?: string;
825
817
  sponsored?: boolean;
826
818
  }
827
819
  /**
828
- * Creates an `AAProviderState` by instantiating the appropriate smart account
829
- * via `@getpara/aa-alchemy` or `@getpara/aa-pimlico`.
830
- *
831
- * This is the single entry-point for async (non-hook) AA provider state creation.
820
+ * Creates an AA state by instantiating the appropriate smart account via
821
+ * `@getpara/aa-alchemy` or `@getpara/aa-pimlico`.
832
822
  */
833
- declare function createAAProviderState(options: CreateAAProviderStateOptions): Promise<AAProviderState>;
823
+ declare function createAAProviderState(options: CreateAAStateOptions): Promise<AAState>;
834
824
 
835
- export { type AAChainConfig, type AAConfig, type AAExecutionMode, type AAExecutionPlan, type AALike, type AAProvider, type AAProviderQuery, type AAProviderState, type AASponsorshipMode, type AlchemyHookParams, type AlchemyResolveOptions, type AlchemyResolvedConfig, type AomiChatResponse, type AomiClearSecretsResponse, AomiClient, type AomiClientOptions, type AomiClientType, type AomiCreateThreadResponse, type AomiIngestSecretsResponse, type AomiInterruptResponse, type AomiMessage, type AomiSSEEvent, type AomiSSEEventType, type AomiSimulateFee, type AomiSimulateResponse, type AomiStateResponse, type AomiSystemEvent, type AomiSystemResponse, type AomiThread, CLIENT_TYPE_TS_CLI, CLIENT_TYPE_WEB_UI, type CreateAAOwner, type CreateAAProviderStateOptions, type CreateAlchemyAAProviderOptions, type CreatePimlicoAAProviderOptions, DEFAULT_AA_CONFIG, type ExecuteWalletCallsParams, type Logger, type ParaSmartAccountLike, type PimlicoHookParams, type PimlicoResolveOptions, type PimlicoResolvedConfig, type SendCallsSyncArgs, type SendResult, ClientSession as Session, type SessionEventMap, type SessionOptions, type TransactionExecutionResult, TypedEventEmitter, type UnwrappedEvent, type UseAlchemyAAHook, type UsePimlicoAAHook, type UserState, type ViemSignTypedDataArgs, type WalletAtomicCapability, type WalletEip712Payload, type WalletExecutionCall, type WalletPrimitiveCall, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletTxPayload, adaptSmartAccount, addUserStateExt, buildAAExecutionPlan, createAAProviderState, createAlchemyAAProvider, createPimlicoAAProvider, executeWalletCalls, getAAChainConfig, getWalletExecutorReady, isAlchemySponsorshipLimitError, isAsyncCallback, isInlineCall, isProviderConfigured, isSystemError, isSystemNotice, normalizeEip712Payload, normalizeTxPayload, parseAAConfig, readEnv, resolveAlchemyConfig, resolveDefaultProvider, resolvePimlicoConfig, toViemSignTypedDataArgs, unwrapSystemEvent };
825
+ export { type AAChainConfig, type AAConfig, type AAMode, type AAOwner, type AAProvider, type AAResolvedConfig, type AASponsorship, type AAState, type AlchemyHookParams, type AlchemyResolveOptions, type AlchemyResolvedConfig, type AomiChatResponse, type AomiClearSecretsResponse, AomiClient, type AomiClientOptions, type AomiClientType, type AomiCreateThreadResponse, type AomiIngestSecretsResponse, type AomiInterruptResponse, type AomiMessage, type AomiSSEEvent, type AomiSSEEventType, type AomiSimulateFee, type AomiSimulateResponse, type AomiStateResponse, type AomiSystemEvent, type AomiSystemResponse, type AomiThread, type AtomicBatchArgs, CLIENT_TYPE_TS_CLI, CLIENT_TYPE_WEB_UI, type CreateAAStateOptions, type CreateAlchemyAAProviderOptions, type CreatePimlicoAAProviderOptions, DEFAULT_AA_CONFIG, type ExecuteWalletCallsParams, type ExecutionResult, type Logger, type PimlicoHookParams, type PimlicoResolveOptions, type PimlicoResolvedConfig, type SendResult, ClientSession as Session, type SessionEventMap, type SessionOptions, type SmartAccount, TypedEventEmitter, type UnwrappedEvent, type UseAlchemyAAHook, type UsePimlicoAAHook, type UserState, type ViemSignTypedDataArgs, type WalletAtomicCapability, type WalletCall, type WalletEip712Payload, type WalletPrimitiveCall, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletTxPayload, adaptSmartAccount, addUserStateExt, buildAAExecutionPlan, createAAProviderState, createAlchemyAAProvider, createPimlicoAAProvider, executeWalletCalls, getAAChainConfig, getWalletExecutorReady, isAlchemySponsorshipLimitError, isAsyncCallback, isInlineCall, isProviderConfigured, isSystemError, isSystemNotice, normalizeEip712Payload, normalizeTxPayload, parseAAConfig, readEnv, resolveAlchemyConfig, resolveDefaultProvider, resolvePimlicoConfig, toViemSignTypedDataArgs, unwrapSystemEvent };