@aomi-labs/client 0.1.6 → 0.1.7
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/cli.js +1030 -97
- package/dist/index.cjs +769 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +249 -1
- package/dist/index.d.ts +249 -1
- package/dist/index.js +746 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Chain, Hex, TransactionReceipt } from 'viem';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Client-side user state synced with the backend.
|
|
3
5
|
* Typically wallet connection info, but can be any key-value data.
|
|
@@ -446,4 +448,250 @@ type UnwrappedEvent = {
|
|
|
446
448
|
*/
|
|
447
449
|
declare function unwrapSystemEvent(event: AomiSystemEvent): UnwrappedEvent | null;
|
|
448
450
|
|
|
449
|
-
|
|
451
|
+
type AAExecutionMode = "4337" | "7702";
|
|
452
|
+
type AASponsorshipMode = "disabled" | "optional" | "required";
|
|
453
|
+
type WalletExecutionCall = {
|
|
454
|
+
to: string;
|
|
455
|
+
value: string;
|
|
456
|
+
data?: string;
|
|
457
|
+
chainId: number;
|
|
458
|
+
};
|
|
459
|
+
type WalletAtomicCapability = {
|
|
460
|
+
atomic?: {
|
|
461
|
+
status?: string;
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
type WalletPrimitiveCall = {
|
|
465
|
+
to: Hex;
|
|
466
|
+
value: bigint;
|
|
467
|
+
data?: Hex;
|
|
468
|
+
};
|
|
469
|
+
interface AAChainConfig {
|
|
470
|
+
chainId: number;
|
|
471
|
+
enabled: boolean;
|
|
472
|
+
defaultMode: AAExecutionMode;
|
|
473
|
+
supportedModes: AAExecutionMode[];
|
|
474
|
+
allowBatching: boolean;
|
|
475
|
+
sponsorship: AASponsorshipMode;
|
|
476
|
+
}
|
|
477
|
+
interface AAConfig {
|
|
478
|
+
enabled: boolean;
|
|
479
|
+
provider: string;
|
|
480
|
+
fallbackToEoa: boolean;
|
|
481
|
+
chains: AAChainConfig[];
|
|
482
|
+
}
|
|
483
|
+
interface AAExecutionPlan {
|
|
484
|
+
provider: string;
|
|
485
|
+
chainId: number;
|
|
486
|
+
mode: AAExecutionMode;
|
|
487
|
+
batchingEnabled: boolean;
|
|
488
|
+
sponsorship: AASponsorshipMode;
|
|
489
|
+
fallbackToEoa: boolean;
|
|
490
|
+
}
|
|
491
|
+
interface AALike {
|
|
492
|
+
provider: string;
|
|
493
|
+
mode: string;
|
|
494
|
+
AAAddress?: Hex;
|
|
495
|
+
delegationAddress?: Hex;
|
|
496
|
+
sendTransaction: (call: WalletPrimitiveCall) => Promise<{
|
|
497
|
+
transactionHash: string;
|
|
498
|
+
}>;
|
|
499
|
+
sendBatchTransaction: (calls: WalletPrimitiveCall[]) => Promise<{
|
|
500
|
+
transactionHash: string;
|
|
501
|
+
}>;
|
|
502
|
+
}
|
|
503
|
+
interface AAProviderQuery<TAA extends AALike = AALike> {
|
|
504
|
+
AA?: TAA | null;
|
|
505
|
+
isPending?: boolean;
|
|
506
|
+
error?: Error | null;
|
|
507
|
+
}
|
|
508
|
+
interface AAProviderState<TAA extends AALike = AALike> {
|
|
509
|
+
plan: AAExecutionPlan | null;
|
|
510
|
+
AA?: TAA | null;
|
|
511
|
+
isPending: boolean;
|
|
512
|
+
error: Error | null;
|
|
513
|
+
query?: AAProviderQuery<TAA>;
|
|
514
|
+
}
|
|
515
|
+
interface TransactionExecutionResult {
|
|
516
|
+
txHash: string;
|
|
517
|
+
txHashes: string[];
|
|
518
|
+
executionKind: string;
|
|
519
|
+
batched: boolean;
|
|
520
|
+
sponsored: boolean;
|
|
521
|
+
AAAddress?: Hex;
|
|
522
|
+
delegationAddress?: Hex;
|
|
523
|
+
}
|
|
524
|
+
interface SendCallsSyncArgs {
|
|
525
|
+
calls: WalletPrimitiveCall[];
|
|
526
|
+
capabilities?: {
|
|
527
|
+
atomic?: {
|
|
528
|
+
required?: boolean;
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
interface ExecuteWalletCallsParams<TAA extends AALike = AALike> {
|
|
533
|
+
callList: WalletExecutionCall[];
|
|
534
|
+
currentChainId: number;
|
|
535
|
+
capabilities: Record<string, WalletAtomicCapability> | undefined;
|
|
536
|
+
localPrivateKey: `0x${string}` | null;
|
|
537
|
+
providerState: AAProviderState<TAA>;
|
|
538
|
+
sendCallsSyncAsync: (args: SendCallsSyncArgs) => Promise<unknown>;
|
|
539
|
+
sendTransactionAsync: (args: {
|
|
540
|
+
chainId: number;
|
|
541
|
+
to: Hex;
|
|
542
|
+
value: bigint;
|
|
543
|
+
data?: Hex;
|
|
544
|
+
}) => Promise<string>;
|
|
545
|
+
switchChainAsync: (params: {
|
|
546
|
+
chainId: number;
|
|
547
|
+
}) => Promise<unknown>;
|
|
548
|
+
chainsById: Record<number, Chain>;
|
|
549
|
+
getPreferredRpcUrl: (chain: Chain) => string;
|
|
550
|
+
}
|
|
551
|
+
declare function parseAAConfig(value: unknown): AAConfig;
|
|
552
|
+
declare function getAAChainConfig(config: AAConfig, calls: WalletExecutionCall[], chainsById: Record<number, Chain>): AAChainConfig | null;
|
|
553
|
+
declare function buildAAExecutionPlan(config: AAConfig, chainConfig: AAChainConfig): AAExecutionPlan;
|
|
554
|
+
declare function getWalletExecutorReady(providerState: AAProviderState): boolean;
|
|
555
|
+
declare const DEFAULT_AA_CONFIG: AAConfig;
|
|
556
|
+
declare function executeWalletCalls(params: ExecuteWalletCallsParams): Promise<TransactionExecutionResult>;
|
|
557
|
+
|
|
558
|
+
interface AlchemyHookParams {
|
|
559
|
+
enabled: boolean;
|
|
560
|
+
apiKey: string;
|
|
561
|
+
chain: Chain;
|
|
562
|
+
rpcUrl: string;
|
|
563
|
+
gasPolicyId?: string;
|
|
564
|
+
mode: AAExecutionMode;
|
|
565
|
+
}
|
|
566
|
+
type UseAlchemyAAHook<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> = (params?: AlchemyHookParams) => TQuery;
|
|
567
|
+
interface CreateAlchemyAAProviderOptions<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> {
|
|
568
|
+
accountAbstractionConfig?: AAConfig;
|
|
569
|
+
useAlchemyAA: UseAlchemyAAHook<TAA, TQuery>;
|
|
570
|
+
chainsById: Record<number, Chain>;
|
|
571
|
+
chainSlugById: Record<number, string>;
|
|
572
|
+
getPreferredRpcUrl: (chain: Chain) => string;
|
|
573
|
+
apiKeyEnvVar?: string;
|
|
574
|
+
gasPolicyEnvVar?: string;
|
|
575
|
+
}
|
|
576
|
+
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>;
|
|
577
|
+
|
|
578
|
+
interface PimlicoHookParams {
|
|
579
|
+
enabled: boolean;
|
|
580
|
+
apiKey: string;
|
|
581
|
+
chain: Chain;
|
|
582
|
+
mode: AAExecutionMode;
|
|
583
|
+
rpcUrl?: string;
|
|
584
|
+
}
|
|
585
|
+
type UsePimlicoAAHook<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> = (params?: PimlicoHookParams) => TQuery;
|
|
586
|
+
interface CreatePimlicoAAProviderOptions<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> {
|
|
587
|
+
accountAbstractionConfig?: AAConfig;
|
|
588
|
+
usePimlicoAA: UsePimlicoAAHook<TAA, TQuery>;
|
|
589
|
+
chainsById: Record<number, Chain>;
|
|
590
|
+
apiKeyEnvVar?: string;
|
|
591
|
+
rpcUrl?: string;
|
|
592
|
+
}
|
|
593
|
+
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>;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Reads the first non-empty env var from `candidates`.
|
|
597
|
+
* When `publicOnly` is true, only `NEXT_PUBLIC_*` names are considered.
|
|
598
|
+
*/
|
|
599
|
+
declare function readEnv(candidates: readonly string[], options?: {
|
|
600
|
+
publicOnly?: boolean;
|
|
601
|
+
}): string | undefined;
|
|
602
|
+
type AAProvider = "alchemy" | "pimlico";
|
|
603
|
+
/**
|
|
604
|
+
* Returns true if the given provider has a configured API key.
|
|
605
|
+
*/
|
|
606
|
+
declare function isProviderConfigured(provider: AAProvider, options?: {
|
|
607
|
+
publicOnly?: boolean;
|
|
608
|
+
}): boolean;
|
|
609
|
+
/**
|
|
610
|
+
* Picks the first configured provider (alchemy > pimlico).
|
|
611
|
+
* Throws if neither is configured.
|
|
612
|
+
*/
|
|
613
|
+
declare function resolveDefaultProvider(options?: {
|
|
614
|
+
publicOnly?: boolean;
|
|
615
|
+
}): AAProvider;
|
|
616
|
+
|
|
617
|
+
type ParaSmartAccountLike = {
|
|
618
|
+
provider: string;
|
|
619
|
+
mode: AAExecutionMode;
|
|
620
|
+
smartAccountAddress: Hex;
|
|
621
|
+
delegationAddress?: Hex;
|
|
622
|
+
sendTransaction: (call: WalletPrimitiveCall, options?: unknown) => Promise<TransactionReceipt>;
|
|
623
|
+
sendBatchTransaction: (calls: WalletPrimitiveCall[], options?: unknown) => Promise<TransactionReceipt>;
|
|
624
|
+
};
|
|
625
|
+
/**
|
|
626
|
+
* Bridges a `ParaSmartAccountLike` (from `@getpara/aa-*` SDKs) into
|
|
627
|
+
* the library's `AALike` interface:
|
|
628
|
+
* - Maps `smartAccountAddress` → `AAAddress`
|
|
629
|
+
* - Unwraps `TransactionReceipt` → `{ transactionHash }`
|
|
630
|
+
*/
|
|
631
|
+
declare function adaptSmartAccount(account: ParaSmartAccountLike): AALike;
|
|
632
|
+
/**
|
|
633
|
+
* Detects Alchemy gas sponsorship quota errors.
|
|
634
|
+
*/
|
|
635
|
+
declare function isAlchemySponsorshipLimitError(error: unknown): boolean;
|
|
636
|
+
|
|
637
|
+
interface AlchemyResolveOptions {
|
|
638
|
+
calls: WalletExecutionCall[] | null;
|
|
639
|
+
localPrivateKey?: `0x${string}` | null;
|
|
640
|
+
accountAbstractionConfig?: AAConfig;
|
|
641
|
+
chainsById: Record<number, Chain>;
|
|
642
|
+
chainSlugById?: Record<number, string>;
|
|
643
|
+
getPreferredRpcUrl?: (chain: Chain) => string;
|
|
644
|
+
modeOverride?: AAExecutionMode;
|
|
645
|
+
publicOnly?: boolean;
|
|
646
|
+
throwOnMissingConfig?: boolean;
|
|
647
|
+
}
|
|
648
|
+
interface AlchemyResolvedConfig {
|
|
649
|
+
chainConfig: AAChainConfig;
|
|
650
|
+
plan: AAExecutionPlan;
|
|
651
|
+
apiKey: string;
|
|
652
|
+
chain: Chain;
|
|
653
|
+
rpcUrl: string;
|
|
654
|
+
gasPolicyId?: string;
|
|
655
|
+
mode: AAExecutionMode;
|
|
656
|
+
}
|
|
657
|
+
declare function resolveAlchemyConfig(options: AlchemyResolveOptions): AlchemyResolvedConfig | null;
|
|
658
|
+
interface PimlicoResolveOptions {
|
|
659
|
+
calls: WalletExecutionCall[] | null;
|
|
660
|
+
localPrivateKey?: `0x${string}` | null;
|
|
661
|
+
accountAbstractionConfig?: AAConfig;
|
|
662
|
+
chainsById: Record<number, Chain>;
|
|
663
|
+
rpcUrl?: string;
|
|
664
|
+
modeOverride?: AAExecutionMode;
|
|
665
|
+
publicOnly?: boolean;
|
|
666
|
+
throwOnMissingConfig?: boolean;
|
|
667
|
+
}
|
|
668
|
+
interface PimlicoResolvedConfig {
|
|
669
|
+
chainConfig: AAChainConfig;
|
|
670
|
+
plan: AAExecutionPlan;
|
|
671
|
+
apiKey: string;
|
|
672
|
+
chain: Chain;
|
|
673
|
+
rpcUrl?: string;
|
|
674
|
+
mode: AAExecutionMode;
|
|
675
|
+
}
|
|
676
|
+
declare function resolvePimlicoConfig(options: PimlicoResolveOptions): PimlicoResolvedConfig | null;
|
|
677
|
+
|
|
678
|
+
interface CreateAAProviderStateOptions {
|
|
679
|
+
provider: AAProvider;
|
|
680
|
+
chain: Chain;
|
|
681
|
+
privateKey: `0x${string}`;
|
|
682
|
+
rpcUrl: string;
|
|
683
|
+
callList: WalletExecutionCall[];
|
|
684
|
+
mode?: AAExecutionMode;
|
|
685
|
+
apiKey?: string;
|
|
686
|
+
gasPolicyId?: string;
|
|
687
|
+
sponsored?: boolean;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Creates an `AAProviderState` by instantiating the appropriate smart account
|
|
691
|
+
* via `@getpara/aa-alchemy` or `@getpara/aa-pimlico`.
|
|
692
|
+
*
|
|
693
|
+
* This is the single entry-point for async (non-hook) AA provider state creation.
|
|
694
|
+
*/
|
|
695
|
+
declare function createAAProviderState(options: CreateAAProviderStateOptions): Promise<AAProviderState>;
|
|
696
|
+
|
|
697
|
+
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, AomiClient, type AomiClientOptions, type AomiCreateThreadResponse, type AomiInterruptResponse, type AomiMessage, type AomiSSEEvent, type AomiSSEEventType, type AomiStateResponse, type AomiSystemEvent, type AomiSystemResponse, type AomiThread, 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 WalletAtomicCapability, type WalletEip712Payload, type WalletExecutionCall, type WalletPrimitiveCall, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletTxPayload, adaptSmartAccount, buildAAExecutionPlan, createAAProviderState, createAlchemyAAProvider, createPimlicoAAProvider, executeWalletCalls, getAAChainConfig, getWalletExecutorReady, isAlchemySponsorshipLimitError, isAsyncCallback, isInlineCall, isProviderConfigured, isSystemError, isSystemNotice, normalizeEip712Payload, normalizeTxPayload, parseAAConfig, readEnv, resolveAlchemyConfig, resolveDefaultProvider, resolvePimlicoConfig, unwrapSystemEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Chain, Hex, TransactionReceipt } from 'viem';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Client-side user state synced with the backend.
|
|
3
5
|
* Typically wallet connection info, but can be any key-value data.
|
|
@@ -446,4 +448,250 @@ type UnwrappedEvent = {
|
|
|
446
448
|
*/
|
|
447
449
|
declare function unwrapSystemEvent(event: AomiSystemEvent): UnwrappedEvent | null;
|
|
448
450
|
|
|
449
|
-
|
|
451
|
+
type AAExecutionMode = "4337" | "7702";
|
|
452
|
+
type AASponsorshipMode = "disabled" | "optional" | "required";
|
|
453
|
+
type WalletExecutionCall = {
|
|
454
|
+
to: string;
|
|
455
|
+
value: string;
|
|
456
|
+
data?: string;
|
|
457
|
+
chainId: number;
|
|
458
|
+
};
|
|
459
|
+
type WalletAtomicCapability = {
|
|
460
|
+
atomic?: {
|
|
461
|
+
status?: string;
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
type WalletPrimitiveCall = {
|
|
465
|
+
to: Hex;
|
|
466
|
+
value: bigint;
|
|
467
|
+
data?: Hex;
|
|
468
|
+
};
|
|
469
|
+
interface AAChainConfig {
|
|
470
|
+
chainId: number;
|
|
471
|
+
enabled: boolean;
|
|
472
|
+
defaultMode: AAExecutionMode;
|
|
473
|
+
supportedModes: AAExecutionMode[];
|
|
474
|
+
allowBatching: boolean;
|
|
475
|
+
sponsorship: AASponsorshipMode;
|
|
476
|
+
}
|
|
477
|
+
interface AAConfig {
|
|
478
|
+
enabled: boolean;
|
|
479
|
+
provider: string;
|
|
480
|
+
fallbackToEoa: boolean;
|
|
481
|
+
chains: AAChainConfig[];
|
|
482
|
+
}
|
|
483
|
+
interface AAExecutionPlan {
|
|
484
|
+
provider: string;
|
|
485
|
+
chainId: number;
|
|
486
|
+
mode: AAExecutionMode;
|
|
487
|
+
batchingEnabled: boolean;
|
|
488
|
+
sponsorship: AASponsorshipMode;
|
|
489
|
+
fallbackToEoa: boolean;
|
|
490
|
+
}
|
|
491
|
+
interface AALike {
|
|
492
|
+
provider: string;
|
|
493
|
+
mode: string;
|
|
494
|
+
AAAddress?: Hex;
|
|
495
|
+
delegationAddress?: Hex;
|
|
496
|
+
sendTransaction: (call: WalletPrimitiveCall) => Promise<{
|
|
497
|
+
transactionHash: string;
|
|
498
|
+
}>;
|
|
499
|
+
sendBatchTransaction: (calls: WalletPrimitiveCall[]) => Promise<{
|
|
500
|
+
transactionHash: string;
|
|
501
|
+
}>;
|
|
502
|
+
}
|
|
503
|
+
interface AAProviderQuery<TAA extends AALike = AALike> {
|
|
504
|
+
AA?: TAA | null;
|
|
505
|
+
isPending?: boolean;
|
|
506
|
+
error?: Error | null;
|
|
507
|
+
}
|
|
508
|
+
interface AAProviderState<TAA extends AALike = AALike> {
|
|
509
|
+
plan: AAExecutionPlan | null;
|
|
510
|
+
AA?: TAA | null;
|
|
511
|
+
isPending: boolean;
|
|
512
|
+
error: Error | null;
|
|
513
|
+
query?: AAProviderQuery<TAA>;
|
|
514
|
+
}
|
|
515
|
+
interface TransactionExecutionResult {
|
|
516
|
+
txHash: string;
|
|
517
|
+
txHashes: string[];
|
|
518
|
+
executionKind: string;
|
|
519
|
+
batched: boolean;
|
|
520
|
+
sponsored: boolean;
|
|
521
|
+
AAAddress?: Hex;
|
|
522
|
+
delegationAddress?: Hex;
|
|
523
|
+
}
|
|
524
|
+
interface SendCallsSyncArgs {
|
|
525
|
+
calls: WalletPrimitiveCall[];
|
|
526
|
+
capabilities?: {
|
|
527
|
+
atomic?: {
|
|
528
|
+
required?: boolean;
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
interface ExecuteWalletCallsParams<TAA extends AALike = AALike> {
|
|
533
|
+
callList: WalletExecutionCall[];
|
|
534
|
+
currentChainId: number;
|
|
535
|
+
capabilities: Record<string, WalletAtomicCapability> | undefined;
|
|
536
|
+
localPrivateKey: `0x${string}` | null;
|
|
537
|
+
providerState: AAProviderState<TAA>;
|
|
538
|
+
sendCallsSyncAsync: (args: SendCallsSyncArgs) => Promise<unknown>;
|
|
539
|
+
sendTransactionAsync: (args: {
|
|
540
|
+
chainId: number;
|
|
541
|
+
to: Hex;
|
|
542
|
+
value: bigint;
|
|
543
|
+
data?: Hex;
|
|
544
|
+
}) => Promise<string>;
|
|
545
|
+
switchChainAsync: (params: {
|
|
546
|
+
chainId: number;
|
|
547
|
+
}) => Promise<unknown>;
|
|
548
|
+
chainsById: Record<number, Chain>;
|
|
549
|
+
getPreferredRpcUrl: (chain: Chain) => string;
|
|
550
|
+
}
|
|
551
|
+
declare function parseAAConfig(value: unknown): AAConfig;
|
|
552
|
+
declare function getAAChainConfig(config: AAConfig, calls: WalletExecutionCall[], chainsById: Record<number, Chain>): AAChainConfig | null;
|
|
553
|
+
declare function buildAAExecutionPlan(config: AAConfig, chainConfig: AAChainConfig): AAExecutionPlan;
|
|
554
|
+
declare function getWalletExecutorReady(providerState: AAProviderState): boolean;
|
|
555
|
+
declare const DEFAULT_AA_CONFIG: AAConfig;
|
|
556
|
+
declare function executeWalletCalls(params: ExecuteWalletCallsParams): Promise<TransactionExecutionResult>;
|
|
557
|
+
|
|
558
|
+
interface AlchemyHookParams {
|
|
559
|
+
enabled: boolean;
|
|
560
|
+
apiKey: string;
|
|
561
|
+
chain: Chain;
|
|
562
|
+
rpcUrl: string;
|
|
563
|
+
gasPolicyId?: string;
|
|
564
|
+
mode: AAExecutionMode;
|
|
565
|
+
}
|
|
566
|
+
type UseAlchemyAAHook<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> = (params?: AlchemyHookParams) => TQuery;
|
|
567
|
+
interface CreateAlchemyAAProviderOptions<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> {
|
|
568
|
+
accountAbstractionConfig?: AAConfig;
|
|
569
|
+
useAlchemyAA: UseAlchemyAAHook<TAA, TQuery>;
|
|
570
|
+
chainsById: Record<number, Chain>;
|
|
571
|
+
chainSlugById: Record<number, string>;
|
|
572
|
+
getPreferredRpcUrl: (chain: Chain) => string;
|
|
573
|
+
apiKeyEnvVar?: string;
|
|
574
|
+
gasPolicyEnvVar?: string;
|
|
575
|
+
}
|
|
576
|
+
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>;
|
|
577
|
+
|
|
578
|
+
interface PimlicoHookParams {
|
|
579
|
+
enabled: boolean;
|
|
580
|
+
apiKey: string;
|
|
581
|
+
chain: Chain;
|
|
582
|
+
mode: AAExecutionMode;
|
|
583
|
+
rpcUrl?: string;
|
|
584
|
+
}
|
|
585
|
+
type UsePimlicoAAHook<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> = (params?: PimlicoHookParams) => TQuery;
|
|
586
|
+
interface CreatePimlicoAAProviderOptions<TAA extends AALike = AALike, TQuery extends AAProviderQuery<TAA> = AAProviderQuery<TAA>> {
|
|
587
|
+
accountAbstractionConfig?: AAConfig;
|
|
588
|
+
usePimlicoAA: UsePimlicoAAHook<TAA, TQuery>;
|
|
589
|
+
chainsById: Record<number, Chain>;
|
|
590
|
+
apiKeyEnvVar?: string;
|
|
591
|
+
rpcUrl?: string;
|
|
592
|
+
}
|
|
593
|
+
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>;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Reads the first non-empty env var from `candidates`.
|
|
597
|
+
* When `publicOnly` is true, only `NEXT_PUBLIC_*` names are considered.
|
|
598
|
+
*/
|
|
599
|
+
declare function readEnv(candidates: readonly string[], options?: {
|
|
600
|
+
publicOnly?: boolean;
|
|
601
|
+
}): string | undefined;
|
|
602
|
+
type AAProvider = "alchemy" | "pimlico";
|
|
603
|
+
/**
|
|
604
|
+
* Returns true if the given provider has a configured API key.
|
|
605
|
+
*/
|
|
606
|
+
declare function isProviderConfigured(provider: AAProvider, options?: {
|
|
607
|
+
publicOnly?: boolean;
|
|
608
|
+
}): boolean;
|
|
609
|
+
/**
|
|
610
|
+
* Picks the first configured provider (alchemy > pimlico).
|
|
611
|
+
* Throws if neither is configured.
|
|
612
|
+
*/
|
|
613
|
+
declare function resolveDefaultProvider(options?: {
|
|
614
|
+
publicOnly?: boolean;
|
|
615
|
+
}): AAProvider;
|
|
616
|
+
|
|
617
|
+
type ParaSmartAccountLike = {
|
|
618
|
+
provider: string;
|
|
619
|
+
mode: AAExecutionMode;
|
|
620
|
+
smartAccountAddress: Hex;
|
|
621
|
+
delegationAddress?: Hex;
|
|
622
|
+
sendTransaction: (call: WalletPrimitiveCall, options?: unknown) => Promise<TransactionReceipt>;
|
|
623
|
+
sendBatchTransaction: (calls: WalletPrimitiveCall[], options?: unknown) => Promise<TransactionReceipt>;
|
|
624
|
+
};
|
|
625
|
+
/**
|
|
626
|
+
* Bridges a `ParaSmartAccountLike` (from `@getpara/aa-*` SDKs) into
|
|
627
|
+
* the library's `AALike` interface:
|
|
628
|
+
* - Maps `smartAccountAddress` → `AAAddress`
|
|
629
|
+
* - Unwraps `TransactionReceipt` → `{ transactionHash }`
|
|
630
|
+
*/
|
|
631
|
+
declare function adaptSmartAccount(account: ParaSmartAccountLike): AALike;
|
|
632
|
+
/**
|
|
633
|
+
* Detects Alchemy gas sponsorship quota errors.
|
|
634
|
+
*/
|
|
635
|
+
declare function isAlchemySponsorshipLimitError(error: unknown): boolean;
|
|
636
|
+
|
|
637
|
+
interface AlchemyResolveOptions {
|
|
638
|
+
calls: WalletExecutionCall[] | null;
|
|
639
|
+
localPrivateKey?: `0x${string}` | null;
|
|
640
|
+
accountAbstractionConfig?: AAConfig;
|
|
641
|
+
chainsById: Record<number, Chain>;
|
|
642
|
+
chainSlugById?: Record<number, string>;
|
|
643
|
+
getPreferredRpcUrl?: (chain: Chain) => string;
|
|
644
|
+
modeOverride?: AAExecutionMode;
|
|
645
|
+
publicOnly?: boolean;
|
|
646
|
+
throwOnMissingConfig?: boolean;
|
|
647
|
+
}
|
|
648
|
+
interface AlchemyResolvedConfig {
|
|
649
|
+
chainConfig: AAChainConfig;
|
|
650
|
+
plan: AAExecutionPlan;
|
|
651
|
+
apiKey: string;
|
|
652
|
+
chain: Chain;
|
|
653
|
+
rpcUrl: string;
|
|
654
|
+
gasPolicyId?: string;
|
|
655
|
+
mode: AAExecutionMode;
|
|
656
|
+
}
|
|
657
|
+
declare function resolveAlchemyConfig(options: AlchemyResolveOptions): AlchemyResolvedConfig | null;
|
|
658
|
+
interface PimlicoResolveOptions {
|
|
659
|
+
calls: WalletExecutionCall[] | null;
|
|
660
|
+
localPrivateKey?: `0x${string}` | null;
|
|
661
|
+
accountAbstractionConfig?: AAConfig;
|
|
662
|
+
chainsById: Record<number, Chain>;
|
|
663
|
+
rpcUrl?: string;
|
|
664
|
+
modeOverride?: AAExecutionMode;
|
|
665
|
+
publicOnly?: boolean;
|
|
666
|
+
throwOnMissingConfig?: boolean;
|
|
667
|
+
}
|
|
668
|
+
interface PimlicoResolvedConfig {
|
|
669
|
+
chainConfig: AAChainConfig;
|
|
670
|
+
plan: AAExecutionPlan;
|
|
671
|
+
apiKey: string;
|
|
672
|
+
chain: Chain;
|
|
673
|
+
rpcUrl?: string;
|
|
674
|
+
mode: AAExecutionMode;
|
|
675
|
+
}
|
|
676
|
+
declare function resolvePimlicoConfig(options: PimlicoResolveOptions): PimlicoResolvedConfig | null;
|
|
677
|
+
|
|
678
|
+
interface CreateAAProviderStateOptions {
|
|
679
|
+
provider: AAProvider;
|
|
680
|
+
chain: Chain;
|
|
681
|
+
privateKey: `0x${string}`;
|
|
682
|
+
rpcUrl: string;
|
|
683
|
+
callList: WalletExecutionCall[];
|
|
684
|
+
mode?: AAExecutionMode;
|
|
685
|
+
apiKey?: string;
|
|
686
|
+
gasPolicyId?: string;
|
|
687
|
+
sponsored?: boolean;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Creates an `AAProviderState` by instantiating the appropriate smart account
|
|
691
|
+
* via `@getpara/aa-alchemy` or `@getpara/aa-pimlico`.
|
|
692
|
+
*
|
|
693
|
+
* This is the single entry-point for async (non-hook) AA provider state creation.
|
|
694
|
+
*/
|
|
695
|
+
declare function createAAProviderState(options: CreateAAProviderStateOptions): Promise<AAProviderState>;
|
|
696
|
+
|
|
697
|
+
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, AomiClient, type AomiClientOptions, type AomiCreateThreadResponse, type AomiInterruptResponse, type AomiMessage, type AomiSSEEvent, type AomiSSEEventType, type AomiStateResponse, type AomiSystemEvent, type AomiSystemResponse, type AomiThread, 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 WalletAtomicCapability, type WalletEip712Payload, type WalletExecutionCall, type WalletPrimitiveCall, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletTxPayload, adaptSmartAccount, buildAAExecutionPlan, createAAProviderState, createAlchemyAAProvider, createPimlicoAAProvider, executeWalletCalls, getAAChainConfig, getWalletExecutorReady, isAlchemySponsorshipLimitError, isAsyncCallback, isInlineCall, isProviderConfigured, isSystemError, isSystemNotice, normalizeEip712Payload, normalizeTxPayload, parseAAConfig, readEnv, resolveAlchemyConfig, resolveDefaultProvider, resolvePimlicoConfig, unwrapSystemEvent };
|