@aomi-labs/client 0.1.7 → 0.1.8

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
@@ -644,6 +644,12 @@ interface AlchemyResolveOptions {
644
644
  modeOverride?: AAExecutionMode;
645
645
  publicOnly?: boolean;
646
646
  throwOnMissingConfig?: boolean;
647
+ /**
648
+ * Pre-resolved API key. Use this in Next.js client-side code where
649
+ * dynamic `process.env[name]` access doesn't work.
650
+ */
651
+ apiKey?: string;
652
+ gasPolicyId?: string;
647
653
  }
648
654
  interface AlchemyResolvedConfig {
649
655
  chainConfig: AAChainConfig;
@@ -664,6 +670,11 @@ interface PimlicoResolveOptions {
664
670
  modeOverride?: AAExecutionMode;
665
671
  publicOnly?: boolean;
666
672
  throwOnMissingConfig?: boolean;
673
+ /**
674
+ * Pre-resolved API key. Use this in Next.js client-side code where
675
+ * dynamic `process.env[name]` access doesn't work.
676
+ */
677
+ apiKey?: string;
667
678
  }
668
679
  interface PimlicoResolvedConfig {
669
680
  chainConfig: AAChainConfig;
@@ -675,10 +686,20 @@ interface PimlicoResolvedConfig {
675
686
  }
676
687
  declare function resolvePimlicoConfig(options: PimlicoResolveOptions): PimlicoResolvedConfig | null;
677
688
 
689
+ type CreateAAOwner = {
690
+ privateKey: `0x${string}`;
691
+ } | {
692
+ signer: unknown;
693
+ para: unknown;
694
+ address?: Hex;
695
+ } | {
696
+ para: unknown;
697
+ address?: Hex;
698
+ };
678
699
  interface CreateAAProviderStateOptions {
679
700
  provider: AAProvider;
680
701
  chain: Chain;
681
- privateKey: `0x${string}`;
702
+ owner: CreateAAOwner;
682
703
  rpcUrl: string;
683
704
  callList: WalletExecutionCall[];
684
705
  mode?: AAExecutionMode;
@@ -694,4 +715,4 @@ interface CreateAAProviderStateOptions {
694
715
  */
695
716
  declare function createAAProviderState(options: CreateAAProviderStateOptions): Promise<AAProviderState>;
696
717
 
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 };
718
+ 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 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 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
@@ -644,6 +644,12 @@ interface AlchemyResolveOptions {
644
644
  modeOverride?: AAExecutionMode;
645
645
  publicOnly?: boolean;
646
646
  throwOnMissingConfig?: boolean;
647
+ /**
648
+ * Pre-resolved API key. Use this in Next.js client-side code where
649
+ * dynamic `process.env[name]` access doesn't work.
650
+ */
651
+ apiKey?: string;
652
+ gasPolicyId?: string;
647
653
  }
648
654
  interface AlchemyResolvedConfig {
649
655
  chainConfig: AAChainConfig;
@@ -664,6 +670,11 @@ interface PimlicoResolveOptions {
664
670
  modeOverride?: AAExecutionMode;
665
671
  publicOnly?: boolean;
666
672
  throwOnMissingConfig?: boolean;
673
+ /**
674
+ * Pre-resolved API key. Use this in Next.js client-side code where
675
+ * dynamic `process.env[name]` access doesn't work.
676
+ */
677
+ apiKey?: string;
667
678
  }
668
679
  interface PimlicoResolvedConfig {
669
680
  chainConfig: AAChainConfig;
@@ -675,10 +686,20 @@ interface PimlicoResolvedConfig {
675
686
  }
676
687
  declare function resolvePimlicoConfig(options: PimlicoResolveOptions): PimlicoResolvedConfig | null;
677
688
 
689
+ type CreateAAOwner = {
690
+ privateKey: `0x${string}`;
691
+ } | {
692
+ signer: unknown;
693
+ para: unknown;
694
+ address?: Hex;
695
+ } | {
696
+ para: unknown;
697
+ address?: Hex;
698
+ };
678
699
  interface CreateAAProviderStateOptions {
679
700
  provider: AAProvider;
680
701
  chain: Chain;
681
- privateKey: `0x${string}`;
702
+ owner: CreateAAOwner;
682
703
  rpcUrl: string;
683
704
  callList: WalletExecutionCall[];
684
705
  mode?: AAExecutionMode;
@@ -694,4 +715,4 @@ interface CreateAAProviderStateOptions {
694
715
  */
695
716
  declare function createAAProviderState(options: CreateAAProviderStateOptions): Promise<AAProviderState>;
696
717
 
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 };
718
+ 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 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 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.js CHANGED
@@ -1404,7 +1404,9 @@ function resolveAlchemyConfig(options) {
1404
1404
  },
1405
1405
  modeOverride,
1406
1406
  publicOnly = false,
1407
- throwOnMissingConfig = false
1407
+ throwOnMissingConfig = false,
1408
+ apiKey: preResolvedApiKey,
1409
+ gasPolicyId: preResolvedGasPolicyId
1408
1410
  } = options;
1409
1411
  if (!calls || localPrivateKey) {
1410
1412
  return null;
@@ -1422,7 +1424,7 @@ function resolveAlchemyConfig(options) {
1422
1424
  }
1423
1425
  return null;
1424
1426
  }
1425
- const apiKey = readEnv(ALCHEMY_API_KEY_ENVS, { publicOnly });
1427
+ const apiKey = preResolvedApiKey != null ? preResolvedApiKey : readEnv(ALCHEMY_API_KEY_ENVS, { publicOnly });
1426
1428
  if (!apiKey) {
1427
1429
  if (throwOnMissingConfig) {
1428
1430
  throw new Error("Alchemy AA requires ALCHEMY_API_KEY.");
@@ -1433,7 +1435,7 @@ function resolveAlchemyConfig(options) {
1433
1435
  if (!chain) {
1434
1436
  return null;
1435
1437
  }
1436
- const gasPolicyId = readGasPolicyEnv(
1438
+ const gasPolicyId = preResolvedGasPolicyId != null ? preResolvedGasPolicyId : readGasPolicyEnv(
1437
1439
  chainConfig.chainId,
1438
1440
  chainSlugById,
1439
1441
  ALCHEMY_GAS_POLICY_ENVS,
@@ -1476,7 +1478,8 @@ function resolvePimlicoConfig(options) {
1476
1478
  rpcUrl,
1477
1479
  modeOverride,
1478
1480
  publicOnly = false,
1479
- throwOnMissingConfig = false
1481
+ throwOnMissingConfig = false,
1482
+ apiKey: preResolvedApiKey
1480
1483
  } = options;
1481
1484
  if (!calls || localPrivateKey) {
1482
1485
  return null;
@@ -1494,7 +1497,7 @@ function resolvePimlicoConfig(options) {
1494
1497
  }
1495
1498
  return null;
1496
1499
  }
1497
- const apiKey = readEnv(PIMLICO_API_KEY_ENVS, { publicOnly });
1500
+ const apiKey = preResolvedApiKey != null ? preResolvedApiKey : readEnv(PIMLICO_API_KEY_ENVS, { publicOnly });
1498
1501
  if (!apiKey) {
1499
1502
  if (throwOnMissingConfig) {
1500
1503
  throw new Error("Pimlico AA requires PIMLICO_API_KEY.");
@@ -1627,15 +1630,64 @@ import { createPimlicoSmartAccount } from "@getpara/aa-pimlico";
1627
1630
  import { privateKeyToAccount } from "viem/accounts";
1628
1631
  async function createAAProviderState(options) {
1629
1632
  if (options.provider === "alchemy") {
1630
- return createAlchemyAAState(options);
1633
+ return createAlchemyAAState({
1634
+ chain: options.chain,
1635
+ owner: options.owner,
1636
+ rpcUrl: options.rpcUrl,
1637
+ callList: options.callList,
1638
+ mode: options.mode,
1639
+ apiKey: options.apiKey,
1640
+ gasPolicyId: options.gasPolicyId,
1641
+ sponsored: options.sponsored
1642
+ });
1643
+ }
1644
+ return createPimlicoAAState({
1645
+ chain: options.chain,
1646
+ owner: options.owner,
1647
+ rpcUrl: options.rpcUrl,
1648
+ callList: options.callList,
1649
+ mode: options.mode,
1650
+ apiKey: options.apiKey
1651
+ });
1652
+ }
1653
+ function getOwnerParams(owner) {
1654
+ if (!owner) {
1655
+ return null;
1656
+ }
1657
+ if ("privateKey" in owner) {
1658
+ return {
1659
+ para: void 0,
1660
+ signer: privateKeyToAccount(owner.privateKey)
1661
+ };
1631
1662
  }
1632
- return createPimlicoAAState(options);
1663
+ if ("signer" in owner) {
1664
+ return __spreadValues({
1665
+ para: owner.para,
1666
+ signer: owner.signer
1667
+ }, owner.address ? { address: owner.address } : {});
1668
+ }
1669
+ if ("para" in owner) {
1670
+ return __spreadValues({
1671
+ para: owner.para
1672
+ }, owner.address ? { address: owner.address } : {});
1673
+ }
1674
+ return null;
1675
+ }
1676
+ function getMissingOwnerState(plan, provider) {
1677
+ return {
1678
+ plan,
1679
+ AA: null,
1680
+ isPending: false,
1681
+ error: new Error(
1682
+ `${provider} AA account creation requires a signer or Para session.`
1683
+ )
1684
+ };
1633
1685
  }
1634
1686
  async function createAlchemyAAState(options) {
1635
1687
  var _a, _b;
1636
1688
  const {
1637
1689
  chain,
1638
- privateKey,
1690
+ owner,
1639
1691
  rpcUrl,
1640
1692
  callList,
1641
1693
  mode,
@@ -1646,7 +1698,9 @@ async function createAlchemyAAState(options) {
1646
1698
  chainsById: { [chain.id]: chain },
1647
1699
  modeOverride: mode,
1648
1700
  throwOnMissingConfig: true,
1649
- getPreferredRpcUrl: () => rpcUrl
1701
+ getPreferredRpcUrl: () => rpcUrl,
1702
+ apiKey: options.apiKey,
1703
+ gasPolicyId: options.gasPolicyId
1650
1704
  });
1651
1705
  if (!resolved) {
1652
1706
  throw new Error("Alchemy AA config resolution failed.");
@@ -1657,17 +1711,18 @@ async function createAlchemyAAState(options) {
1657
1711
  sponsorship: gasPolicyId ? resolved.plan.sponsorship : "disabled",
1658
1712
  fallbackToEoa: false
1659
1713
  });
1660
- const signer = privateKeyToAccount(privateKey);
1714
+ const ownerParams = getOwnerParams(owner);
1715
+ if (!ownerParams) {
1716
+ return getMissingOwnerState(plan, "alchemy");
1717
+ }
1661
1718
  try {
1662
- const smartAccount = await createAlchemySmartAccount({
1663
- para: void 0,
1664
- signer,
1719
+ const smartAccount = await createAlchemySmartAccount(__spreadProps(__spreadValues({}, ownerParams), {
1665
1720
  apiKey,
1666
1721
  gasPolicyId,
1667
1722
  chain,
1668
1723
  rpcUrl,
1669
1724
  mode: plan.mode
1670
- });
1725
+ }));
1671
1726
  if (!smartAccount) {
1672
1727
  return {
1673
1728
  plan,
@@ -1695,7 +1750,7 @@ async function createPimlicoAAState(options) {
1695
1750
  var _a;
1696
1751
  const {
1697
1752
  chain,
1698
- privateKey,
1753
+ owner,
1699
1754
  rpcUrl,
1700
1755
  callList,
1701
1756
  mode
@@ -1705,7 +1760,8 @@ async function createPimlicoAAState(options) {
1705
1760
  chainsById: { [chain.id]: chain },
1706
1761
  rpcUrl,
1707
1762
  modeOverride: mode,
1708
- throwOnMissingConfig: true
1763
+ throwOnMissingConfig: true,
1764
+ apiKey: options.apiKey
1709
1765
  });
1710
1766
  if (!resolved) {
1711
1767
  throw new Error("Pimlico AA config resolution failed.");
@@ -1714,16 +1770,17 @@ async function createPimlicoAAState(options) {
1714
1770
  const plan = __spreadProps(__spreadValues({}, resolved.plan), {
1715
1771
  fallbackToEoa: false
1716
1772
  });
1717
- const signer = privateKeyToAccount(privateKey);
1773
+ const ownerParams = getOwnerParams(owner);
1774
+ if (!ownerParams) {
1775
+ return getMissingOwnerState(plan, "pimlico");
1776
+ }
1718
1777
  try {
1719
- const smartAccount = await createPimlicoSmartAccount({
1720
- para: void 0,
1721
- signer,
1778
+ const smartAccount = await createPimlicoSmartAccount(__spreadProps(__spreadValues({}, ownerParams), {
1722
1779
  apiKey,
1723
1780
  chain,
1724
1781
  rpcUrl,
1725
1782
  mode: plan.mode
1726
- });
1783
+ }));
1727
1784
  if (!smartAccount) {
1728
1785
  return {
1729
1786
  plan,