@aomi-labs/client 0.1.20 → 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.js CHANGED
@@ -1272,6 +1272,9 @@ function parseAAConfig(value) {
1272
1272
  if (typeof value.provider !== "string" || !value.provider) {
1273
1273
  throw new Error("Invalid AA config: provider must be a non-empty string");
1274
1274
  }
1275
+ if (value.provider !== "alchemy" && value.provider !== "pimlico") {
1276
+ throw new Error('Invalid AA config: provider must be either "alchemy" or "pimlico"');
1277
+ }
1275
1278
  if (typeof value.fallbackToEoa !== "boolean") {
1276
1279
  throw new Error("Invalid AA config: fallbackToEoa must be a boolean");
1277
1280
  }
@@ -1322,7 +1325,7 @@ function buildAAExecutionPlan(config, chainConfig) {
1322
1325
  };
1323
1326
  }
1324
1327
  function getWalletExecutorReady(providerState) {
1325
- return !providerState.plan || !providerState.isPending && (Boolean(providerState.AA) || Boolean(providerState.error) || providerState.plan.fallbackToEoa);
1328
+ return !providerState.resolved || !providerState.pending && (Boolean(providerState.account) || Boolean(providerState.error) || providerState.resolved.fallbackToEoa);
1326
1329
  }
1327
1330
  function mapCall(call) {
1328
1331
  return {
@@ -1391,10 +1394,10 @@ async function executeWalletCalls(params) {
1391
1394
  chainsById,
1392
1395
  getPreferredRpcUrl
1393
1396
  } = params;
1394
- if (providerState.plan && providerState.AA) {
1397
+ if (providerState.resolved && providerState.account) {
1395
1398
  return executeViaAA(callList, providerState);
1396
1399
  }
1397
- if (providerState.plan && providerState.error && !providerState.plan.fallbackToEoa) {
1400
+ if (providerState.resolved && providerState.error && !providerState.resolved.fallbackToEoa) {
1398
1401
  throw providerState.error;
1399
1402
  }
1400
1403
  return executeViaEoa({
@@ -1411,26 +1414,26 @@ async function executeWalletCalls(params) {
1411
1414
  }
1412
1415
  async function executeViaAA(callList, providerState) {
1413
1416
  var _a;
1414
- const AA = providerState.AA;
1415
- const plan = providerState.plan;
1416
- if (!AA || !plan) {
1417
+ const account = providerState.account;
1418
+ const resolved = providerState.resolved;
1419
+ if (!account || !resolved) {
1417
1420
  throw (_a = providerState.error) != null ? _a : new Error("smart_account_unavailable");
1418
1421
  }
1419
1422
  const callsPayload = callList.map(mapCall);
1420
- const receipt = callList.length > 1 ? await AA.sendBatchTransaction(callsPayload) : await AA.sendTransaction(callsPayload[0]);
1423
+ const receipt = callList.length > 1 ? await account.sendBatchTransaction(callsPayload) : await account.sendTransaction(callsPayload[0]);
1421
1424
  const txHash = receipt.transactionHash;
1422
- const providerPrefix = AA.provider.toLowerCase();
1423
- let delegationAddress = AA.mode === "7702" ? AA.delegationAddress : void 0;
1424
- if (AA.mode === "7702" && !delegationAddress) {
1425
+ const providerPrefix = account.provider.toLowerCase();
1426
+ let delegationAddress = account.mode === "7702" ? account.delegationAddress : void 0;
1427
+ if (account.mode === "7702" && !delegationAddress) {
1425
1428
  delegationAddress = await resolve7702Delegation(txHash, callList);
1426
1429
  }
1427
1430
  return {
1428
1431
  txHash,
1429
1432
  txHashes: [txHash],
1430
- executionKind: `${providerPrefix}_${AA.mode}`,
1433
+ executionKind: `${providerPrefix}_${account.mode}`,
1431
1434
  batched: callList.length > 1,
1432
- sponsored: plan.sponsorship !== "disabled",
1433
- AAAddress: AA.AAAddress,
1435
+ sponsored: resolved.sponsorship !== "disabled",
1436
+ AAAddress: account.AAAddress,
1434
1437
  delegationAddress
1435
1438
  };
1436
1439
  }
@@ -1474,7 +1477,7 @@ async function executeViaEoa({
1474
1477
  }) {
1475
1478
  var _a, _b;
1476
1479
  const { createPublicClient, createWalletClient, http } = await import("viem");
1477
- const { privateKeyToAccount: privateKeyToAccount2 } = await import("viem/accounts");
1480
+ const { privateKeyToAccount: privateKeyToAccount3 } = await import("viem/accounts");
1478
1481
  const hashes = [];
1479
1482
  if (localPrivateKey) {
1480
1483
  for (const call of callList) {
@@ -1486,7 +1489,7 @@ async function executeViaEoa({
1486
1489
  if (!rpcUrl) {
1487
1490
  throw new Error(`No RPC for chain ${call.chainId}`);
1488
1491
  }
1489
- const account = privateKeyToAccount2(localPrivateKey);
1492
+ const account = privateKeyToAccount3(localPrivateKey);
1490
1493
  const walletClient = createWalletClient({
1491
1494
  account,
1492
1495
  chain,
@@ -1559,7 +1562,7 @@ async function executeViaEoa({
1559
1562
  };
1560
1563
  }
1561
1564
 
1562
- // src/aa/env.ts
1565
+ // src/aa/alchemy/env.ts
1563
1566
  var ALCHEMY_API_KEY_ENVS = [
1564
1567
  "ALCHEMY_API_KEY",
1565
1568
  "NEXT_PUBLIC_ALCHEMY_API_KEY"
@@ -1568,10 +1571,14 @@ var ALCHEMY_GAS_POLICY_ENVS = [
1568
1571
  "ALCHEMY_GAS_POLICY_ID",
1569
1572
  "NEXT_PUBLIC_ALCHEMY_GAS_POLICY_ID"
1570
1573
  ];
1574
+
1575
+ // src/aa/pimlico/env.ts
1571
1576
  var PIMLICO_API_KEY_ENVS = [
1572
1577
  "PIMLICO_API_KEY",
1573
1578
  "NEXT_PUBLIC_PIMLICO_API_KEY"
1574
1579
  ];
1580
+
1581
+ // src/aa/env.ts
1575
1582
  function readEnv(candidates, options = {}) {
1576
1583
  var _a;
1577
1584
  const { publicOnly = false } = options;
@@ -1606,7 +1613,7 @@ function resolveDefaultProvider(options = {}) {
1606
1613
  );
1607
1614
  }
1608
1615
 
1609
- // src/aa/resolve.ts
1616
+ // src/aa/alchemy/resolve.ts
1610
1617
  function resolveAlchemyConfig(options) {
1611
1618
  const {
1612
1619
  calls,
@@ -1674,77 +1681,17 @@ function resolveAlchemyConfig(options) {
1674
1681
  return null;
1675
1682
  }
1676
1683
  const resolvedChainConfig = modeOverride ? __spreadProps(__spreadValues({}, chainConfig), { defaultMode: modeOverride }) : chainConfig;
1677
- const plan = buildAAExecutionPlan(config, resolvedChainConfig);
1678
- return {
1679
- chainConfig: resolvedChainConfig,
1680
- plan,
1684
+ const resolved = buildAAExecutionPlan(config, resolvedChainConfig);
1685
+ return __spreadProps(__spreadValues({}, resolved), {
1681
1686
  apiKey,
1682
1687
  chain,
1683
1688
  rpcUrl: getPreferredRpcUrl(chain),
1684
1689
  gasPolicyId,
1685
1690
  mode: resolvedChainConfig.defaultMode
1686
- };
1687
- }
1688
- function resolvePimlicoConfig(options) {
1689
- const {
1690
- calls,
1691
- localPrivateKey,
1692
- accountAbstractionConfig = DEFAULT_AA_CONFIG,
1693
- chainsById,
1694
- rpcUrl,
1695
- modeOverride,
1696
- publicOnly = false,
1697
- throwOnMissingConfig = false,
1698
- apiKey: preResolvedApiKey
1699
- } = options;
1700
- if (!calls || localPrivateKey) {
1701
- return null;
1702
- }
1703
- const config = __spreadProps(__spreadValues({}, accountAbstractionConfig), {
1704
- provider: "pimlico"
1705
1691
  });
1706
- const chainConfig = getAAChainConfig(config, calls, chainsById);
1707
- if (!chainConfig) {
1708
- if (throwOnMissingConfig) {
1709
- const chainIds = Array.from(new Set(calls.map((c) => c.chainId)));
1710
- throw new Error(
1711
- `AA is not configured for chain ${chainIds[0]}, or batching is disabled for that chain.`
1712
- );
1713
- }
1714
- return null;
1715
- }
1716
- const apiKey = preResolvedApiKey != null ? preResolvedApiKey : readEnv(PIMLICO_API_KEY_ENVS, { publicOnly });
1717
- if (!apiKey) {
1718
- if (throwOnMissingConfig) {
1719
- throw new Error("Pimlico AA requires PIMLICO_API_KEY.");
1720
- }
1721
- return null;
1722
- }
1723
- const chain = chainsById[chainConfig.chainId];
1724
- if (!chain) {
1725
- return null;
1726
- }
1727
- if (modeOverride && !chainConfig.supportedModes.includes(modeOverride)) {
1728
- if (throwOnMissingConfig) {
1729
- throw new Error(
1730
- `AA mode "${modeOverride}" is not supported on chain ${chainConfig.chainId}.`
1731
- );
1732
- }
1733
- return null;
1734
- }
1735
- const resolvedChainConfig = modeOverride ? __spreadProps(__spreadValues({}, chainConfig), { defaultMode: modeOverride }) : chainConfig;
1736
- const plan = buildAAExecutionPlan(config, resolvedChainConfig);
1737
- return {
1738
- chainConfig: resolvedChainConfig,
1739
- plan,
1740
- apiKey,
1741
- chain,
1742
- rpcUrl,
1743
- mode: resolvedChainConfig.defaultMode
1744
- };
1745
1692
  }
1746
1693
 
1747
- // src/aa/alchemy.ts
1694
+ // src/aa/alchemy/provider.ts
1748
1695
  function createAlchemyAAProvider({
1749
1696
  accountAbstractionConfig = DEFAULT_AA_CONFIG,
1750
1697
  useAlchemyAA,
@@ -1753,7 +1700,7 @@ function createAlchemyAAProvider({
1753
1700
  getPreferredRpcUrl
1754
1701
  }) {
1755
1702
  return function useAlchemyAAProvider(calls, localPrivateKey) {
1756
- var _a, _b;
1703
+ var _a;
1757
1704
  const resolved = resolveAlchemyConfig({
1758
1705
  calls,
1759
1706
  localPrivateKey,
@@ -1773,49 +1720,16 @@ function createAlchemyAAProvider({
1773
1720
  } : void 0;
1774
1721
  const query = useAlchemyAA(params);
1775
1722
  return {
1776
- plan: (_a = resolved == null ? void 0 : resolved.plan) != null ? _a : null,
1777
- query,
1778
- AA: query.AA,
1779
- isPending: Boolean(resolved && query.isPending),
1780
- error: (_b = query.error) != null ? _b : null
1723
+ resolved: resolved != null ? resolved : null,
1724
+ account: query.account,
1725
+ pending: Boolean(resolved && query.pending),
1726
+ error: (_a = query.error) != null ? _a : null
1781
1727
  };
1782
1728
  };
1783
1729
  }
1784
1730
 
1785
- // src/aa/pimlico.ts
1786
- function createPimlicoAAProvider({
1787
- accountAbstractionConfig = DEFAULT_AA_CONFIG,
1788
- usePimlicoAA,
1789
- chainsById,
1790
- rpcUrl
1791
- }) {
1792
- return function usePimlicoAAProvider(calls, localPrivateKey) {
1793
- var _a, _b;
1794
- const resolved = resolvePimlicoConfig({
1795
- calls,
1796
- localPrivateKey,
1797
- accountAbstractionConfig,
1798
- chainsById,
1799
- rpcUrl,
1800
- publicOnly: true
1801
- });
1802
- const params = resolved ? {
1803
- enabled: true,
1804
- apiKey: resolved.apiKey,
1805
- chain: resolved.chain,
1806
- mode: resolved.mode,
1807
- rpcUrl: resolved.rpcUrl
1808
- } : void 0;
1809
- const query = usePimlicoAA(params);
1810
- return {
1811
- plan: (_a = resolved == null ? void 0 : resolved.plan) != null ? _a : null,
1812
- query,
1813
- AA: query.AA,
1814
- isPending: Boolean(resolved && query.isPending),
1815
- error: (_b = query.error) != null ? _b : null
1816
- };
1817
- };
1818
- }
1731
+ // src/aa/alchemy/create.ts
1732
+ import { privateKeyToAccount as privateKeyToAccount2 } from "viem/accounts";
1819
1733
 
1820
1734
  // src/aa/adapt.ts
1821
1735
  function adaptSmartAccount(account) {
@@ -1841,32 +1755,8 @@ function isAlchemySponsorshipLimitError(error) {
1841
1755
  return normalized.includes("gas sponsorship limit") || normalized.includes("put your team over your gas sponsorship limit") || normalized.includes("buy gas credits in your gas manager dashboard");
1842
1756
  }
1843
1757
 
1844
- // src/aa/create.ts
1845
- import { createAlchemySmartAccount } from "@getpara/aa-alchemy";
1846
- import { createPimlicoSmartAccount } from "@getpara/aa-pimlico";
1758
+ // src/aa/owner.ts
1847
1759
  import { privateKeyToAccount } from "viem/accounts";
1848
- async function createAAProviderState(options) {
1849
- if (options.provider === "alchemy") {
1850
- return createAlchemyAAState({
1851
- chain: options.chain,
1852
- owner: options.owner,
1853
- rpcUrl: options.rpcUrl,
1854
- callList: options.callList,
1855
- mode: options.mode,
1856
- apiKey: options.apiKey,
1857
- gasPolicyId: options.gasPolicyId,
1858
- sponsored: options.sponsored
1859
- });
1860
- }
1861
- return createPimlicoAAState({
1862
- chain: options.chain,
1863
- owner: options.owner,
1864
- rpcUrl: options.rpcUrl,
1865
- callList: options.callList,
1866
- mode: options.mode,
1867
- apiKey: options.apiKey
1868
- });
1869
- }
1870
1760
  function getDirectOwnerParams(owner) {
1871
1761
  return {
1872
1762
  kind: "ready",
@@ -1912,24 +1802,27 @@ function getOwnerParams(owner) {
1912
1802
  return getSessionOwnerParams(owner);
1913
1803
  }
1914
1804
  }
1915
- function getMissingOwnerState(plan, provider) {
1805
+ function getMissingOwnerState(resolved, provider) {
1916
1806
  return {
1917
- plan,
1918
- AA: null,
1919
- isPending: false,
1807
+ resolved,
1808
+ account: null,
1809
+ pending: false,
1920
1810
  error: new Error(
1921
1811
  `${provider} AA account creation requires a direct owner or a supported session owner.`
1922
1812
  )
1923
1813
  };
1924
1814
  }
1925
- function getUnsupportedAdapterState(plan, adapter) {
1815
+ function getUnsupportedAdapterState(resolved, adapter) {
1926
1816
  return {
1927
- plan,
1928
- AA: null,
1929
- isPending: false,
1817
+ resolved,
1818
+ account: null,
1819
+ pending: false,
1930
1820
  error: new Error(`Session adapter "${adapter}" is not implemented.`)
1931
1821
  };
1932
1822
  }
1823
+
1824
+ // src/aa/alchemy/create.ts
1825
+ var ALCHEMY_7702_DELEGATION_ADDRESS = "0x69007702764179f14F51cdce752f4f775d74E139";
1933
1826
  async function createAlchemyAAState(options) {
1934
1827
  var _a, _b;
1935
1828
  const {
@@ -1954,70 +1847,71 @@ async function createAlchemyAAState(options) {
1954
1847
  }
1955
1848
  const apiKey = (_a = options.apiKey) != null ? _a : resolved.apiKey;
1956
1849
  const gasPolicyId = sponsored ? (_b = options.gasPolicyId) != null ? _b : readEnv(ALCHEMY_GAS_POLICY_ENVS) : void 0;
1957
- const plan = __spreadProps(__spreadValues({}, resolved.plan), {
1958
- sponsorship: gasPolicyId ? resolved.plan.sponsorship : "disabled",
1850
+ const execution = __spreadProps(__spreadValues({}, resolved), {
1851
+ sponsorship: gasPolicyId ? resolved.sponsorship : "disabled",
1959
1852
  fallbackToEoa: false
1960
1853
  });
1961
1854
  const ownerParams = getOwnerParams(owner);
1962
1855
  if (ownerParams.kind === "missing") {
1963
- return getMissingOwnerState(plan, "alchemy");
1856
+ return getMissingOwnerState(execution, "alchemy");
1964
1857
  }
1965
1858
  if (ownerParams.kind === "unsupported_adapter") {
1966
- return getUnsupportedAdapterState(plan, ownerParams.adapter);
1859
+ return getUnsupportedAdapterState(execution, ownerParams.adapter);
1967
1860
  }
1968
1861
  if (owner.kind === "direct") {
1969
1862
  try {
1970
1863
  return await createAlchemyWalletApisState({
1971
- plan,
1864
+ resolved: execution,
1972
1865
  chain,
1973
1866
  privateKey: owner.privateKey,
1974
1867
  apiKey,
1975
1868
  gasPolicyId,
1976
- mode: plan.mode
1869
+ mode: execution.mode
1977
1870
  });
1978
1871
  } catch (error) {
1979
1872
  return {
1980
- plan,
1981
- AA: null,
1982
- isPending: false,
1873
+ resolved: execution,
1874
+ account: null,
1875
+ pending: false,
1983
1876
  error: error instanceof Error ? error : new Error(String(error))
1984
1877
  };
1985
1878
  }
1986
1879
  }
1987
1880
  try {
1881
+ const { createAlchemySmartAccount } = await import("@getpara/aa-alchemy");
1988
1882
  const smartAccount = await createAlchemySmartAccount(__spreadProps(__spreadValues({}, ownerParams.ownerParams), {
1989
1883
  apiKey,
1990
1884
  gasPolicyId,
1991
1885
  chain,
1992
1886
  rpcUrl,
1993
- mode: plan.mode
1887
+ mode: execution.mode
1994
1888
  }));
1995
1889
  if (!smartAccount) {
1996
1890
  return {
1997
- plan,
1998
- AA: null,
1999
- isPending: false,
1891
+ resolved: execution,
1892
+ account: null,
1893
+ pending: false,
2000
1894
  error: new Error("Alchemy AA account could not be initialized.")
2001
1895
  };
2002
1896
  }
2003
1897
  return {
2004
- plan,
2005
- AA: adaptSmartAccount(smartAccount),
2006
- isPending: false,
1898
+ resolved: execution,
1899
+ account: adaptSmartAccount(smartAccount),
1900
+ pending: false,
2007
1901
  error: null
2008
1902
  };
2009
1903
  } catch (error) {
2010
1904
  return {
2011
- plan,
2012
- AA: null,
2013
- isPending: false,
1905
+ resolved: execution,
1906
+ account: null,
1907
+ pending: false,
2014
1908
  error: error instanceof Error ? error : new Error(String(error))
2015
1909
  };
2016
1910
  }
2017
1911
  }
2018
1912
  async function createAlchemyWalletApisState(params) {
2019
1913
  const { createSmartWalletClient, alchemyWalletTransport } = await import("@alchemy/wallet-apis");
2020
- const signer = privateKeyToAccount(params.privateKey);
1914
+ const signer = privateKeyToAccount2(params.privateKey);
2021
1915
  const walletClient = createSmartWalletClient(__spreadValues({
2022
1916
  transport: alchemyWalletTransport({ apiKey: params.apiKey }),
2023
1917
  chain: params.chain,
@@ -2025,8 +1919,8 @@ async function createAlchemyWalletApisState(params) {
2025
1919
  }, params.gasPolicyId ? { paymaster: { policyId: params.gasPolicyId } } : {}));
2026
1920
  let accountAddress = signer.address;
2027
1921
  if (params.mode === "4337") {
2028
- const account = await walletClient.requestAccount();
2029
- accountAddress = account.address;
1922
+ const account2 = await walletClient.requestAccount();
1923
+ accountAddress = account2.address;
2030
1924
  }
2031
1925
  const sendCalls = async (calls) => {
2032
1926
  var _a, _b;
@@ -2040,21 +1934,115 @@ async function createAlchemyWalletApisState(params) {
2040
1934
  }
2041
1935
  return { transactionHash };
2042
1936
  };
2043
- const AA = {
1937
+ const account = {
2044
1938
  provider: "alchemy",
2045
1939
  mode: params.mode,
2046
1940
  AAAddress: accountAddress,
2047
- delegationAddress: params.mode === "7702" ? signer.address : void 0,
1941
+ delegationAddress: params.mode === "7702" ? ALCHEMY_7702_DELEGATION_ADDRESS : void 0,
2048
1942
  sendTransaction: async (call) => sendCalls([call]),
2049
1943
  sendBatchTransaction: async (calls) => sendCalls(calls)
2050
1944
  };
2051
1945
  return {
2052
- plan: params.plan,
2053
- AA,
2054
- isPending: false,
1946
+ resolved: params.resolved,
1947
+ account,
1948
+ pending: false,
2055
1949
  error: null
2056
1950
  };
2057
1951
  }
1952
+
1953
+ // src/aa/pimlico/resolve.ts
1954
+ function resolvePimlicoConfig(options) {
1955
+ const {
1956
+ calls,
1957
+ localPrivateKey,
1958
+ accountAbstractionConfig = DEFAULT_AA_CONFIG,
1959
+ chainsById,
1960
+ rpcUrl,
1961
+ modeOverride,
1962
+ publicOnly = false,
1963
+ throwOnMissingConfig = false,
1964
+ apiKey: preResolvedApiKey
1965
+ } = options;
1966
+ if (!calls || localPrivateKey) {
1967
+ return null;
1968
+ }
1969
+ const config = __spreadProps(__spreadValues({}, accountAbstractionConfig), {
1970
+ provider: "pimlico"
1971
+ });
1972
+ const chainConfig = getAAChainConfig(config, calls, chainsById);
1973
+ if (!chainConfig) {
1974
+ if (throwOnMissingConfig) {
1975
+ const chainIds = Array.from(new Set(calls.map((c) => c.chainId)));
1976
+ throw new Error(
1977
+ `AA is not configured for chain ${chainIds[0]}, or batching is disabled for that chain.`
1978
+ );
1979
+ }
1980
+ return null;
1981
+ }
1982
+ const apiKey = preResolvedApiKey != null ? preResolvedApiKey : readEnv(PIMLICO_API_KEY_ENVS, { publicOnly });
1983
+ if (!apiKey) {
1984
+ if (throwOnMissingConfig) {
1985
+ throw new Error("Pimlico AA requires PIMLICO_API_KEY.");
1986
+ }
1987
+ return null;
1988
+ }
1989
+ const chain = chainsById[chainConfig.chainId];
1990
+ if (!chain) {
1991
+ return null;
1992
+ }
1993
+ if (modeOverride && !chainConfig.supportedModes.includes(modeOverride)) {
1994
+ if (throwOnMissingConfig) {
1995
+ throw new Error(
1996
+ `AA mode "${modeOverride}" is not supported on chain ${chainConfig.chainId}.`
1997
+ );
1998
+ }
1999
+ return null;
2000
+ }
2001
+ const resolvedChainConfig = modeOverride ? __spreadProps(__spreadValues({}, chainConfig), { defaultMode: modeOverride }) : chainConfig;
2002
+ const resolved = buildAAExecutionPlan(config, resolvedChainConfig);
2003
+ return __spreadProps(__spreadValues({}, resolved), {
2004
+ apiKey,
2005
+ chain,
2006
+ rpcUrl,
2007
+ mode: resolvedChainConfig.defaultMode
2008
+ });
2009
+ }
2010
+
2011
+ // src/aa/pimlico/provider.ts
2012
+ function createPimlicoAAProvider({
2013
+ accountAbstractionConfig = DEFAULT_AA_CONFIG,
2014
+ usePimlicoAA,
2015
+ chainsById,
2016
+ rpcUrl
2017
+ }) {
2018
+ return function usePimlicoAAProvider(calls, localPrivateKey) {
2019
+ var _a;
2020
+ const resolved = resolvePimlicoConfig({
2021
+ calls,
2022
+ localPrivateKey,
2023
+ accountAbstractionConfig,
2024
+ chainsById,
2025
+ rpcUrl,
2026
+ publicOnly: true
2027
+ });
2028
+ const params = resolved ? {
2029
+ enabled: true,
2030
+ apiKey: resolved.apiKey,
2031
+ chain: resolved.chain,
2032
+ mode: resolved.mode,
2033
+ rpcUrl: resolved.rpcUrl
2034
+ } : void 0;
2035
+ const query = usePimlicoAA(params);
2036
+ return {
2037
+ resolved: resolved != null ? resolved : null,
2038
+ account: query.account,
2039
+ pending: Boolean(resolved && query.pending),
2040
+ error: (_a = query.error) != null ? _a : null
2041
+ };
2042
+ };
2043
+ }
2044
+
2045
+ // src/aa/pimlico/create.ts
2058
2046
  async function createPimlicoAAState(options) {
2059
2047
  var _a;
2060
2048
  const {
@@ -2076,46 +2064,71 @@ async function createPimlicoAAState(options) {
2076
2064
  throw new Error("Pimlico AA config resolution failed.");
2077
2065
  }
2078
2066
  const apiKey = (_a = options.apiKey) != null ? _a : resolved.apiKey;
2079
- const plan = __spreadProps(__spreadValues({}, resolved.plan), {
2067
+ const execution = __spreadProps(__spreadValues({}, resolved), {
2080
2068
  fallbackToEoa: false
2081
2069
  });
2082
2070
  const ownerParams = getOwnerParams(owner);
2083
2071
  if (ownerParams.kind === "missing") {
2084
- return getMissingOwnerState(plan, "pimlico");
2072
+ return getMissingOwnerState(execution, "pimlico");
2085
2073
  }
2086
2074
  if (ownerParams.kind === "unsupported_adapter") {
2087
- return getUnsupportedAdapterState(plan, ownerParams.adapter);
2075
+ return getUnsupportedAdapterState(execution, ownerParams.adapter);
2088
2076
  }
2089
2077
  try {
2078
+ const { createPimlicoSmartAccount } = await import("@getpara/aa-pimlico");
2090
2079
  const smartAccount = await createPimlicoSmartAccount(__spreadProps(__spreadValues({}, ownerParams.ownerParams), {
2091
2080
  apiKey,
2092
2081
  chain,
2093
2082
  rpcUrl,
2094
- mode: plan.mode
2083
+ mode: execution.mode
2095
2084
  }));
2096
2085
  if (!smartAccount) {
2097
2086
  return {
2098
- plan,
2099
- AA: null,
2100
- isPending: false,
2087
+ resolved: execution,
2088
+ account: null,
2089
+ pending: false,
2101
2090
  error: new Error("Pimlico AA account could not be initialized.")
2102
2091
  };
2103
2092
  }
2104
2093
  return {
2105
- plan,
2106
- AA: adaptSmartAccount(smartAccount),
2107
- isPending: false,
2094
+ resolved: execution,
2095
+ account: adaptSmartAccount(smartAccount),
2096
+ pending: false,
2108
2097
  error: null
2109
2098
  };
2110
2099
  } catch (error) {
2111
2100
  return {
2112
- plan,
2113
- AA: null,
2114
- isPending: false,
2101
+ resolved: execution,
2102
+ account: null,
2103
+ pending: false,
2115
2104
  error: error instanceof Error ? error : new Error(String(error))
2116
2105
  };
2117
2106
  }
2118
2107
  }
2108
+
2109
+ // src/aa/create.ts
2110
+ async function createAAProviderState(options) {
2111
+ if (options.provider === "alchemy") {
2112
+ return createAlchemyAAState({
2113
+ chain: options.chain,
2114
+ owner: options.owner,
2115
+ rpcUrl: options.rpcUrl,
2116
+ callList: options.callList,
2117
+ mode: options.mode,
2118
+ apiKey: options.apiKey,
2119
+ gasPolicyId: options.gasPolicyId,
2120
+ sponsored: options.sponsored
2121
+ });
2122
+ }
2123
+ return createPimlicoAAState({
2124
+ chain: options.chain,
2125
+ owner: options.owner,
2126
+ rpcUrl: options.rpcUrl,
2127
+ callList: options.callList,
2128
+ mode: options.mode,
2129
+ apiKey: options.apiKey
2130
+ });
2131
+ }
2119
2132
  export {
2120
2133
  AomiClient,
2121
2134
  CLIENT_TYPE_TS_CLI,