@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/cli.js +3717 -2775
- package/dist/index.cjs +208 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +131 -141
- package/dist/index.d.ts +131 -141
- package/dist/index.js +206 -193
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/skills/aomi-transact/SKILL.md +239 -109
package/dist/index.cjs
CHANGED
|
@@ -1334,6 +1334,9 @@ function parseAAConfig(value) {
|
|
|
1334
1334
|
if (typeof value.provider !== "string" || !value.provider) {
|
|
1335
1335
|
throw new Error("Invalid AA config: provider must be a non-empty string");
|
|
1336
1336
|
}
|
|
1337
|
+
if (value.provider !== "alchemy" && value.provider !== "pimlico") {
|
|
1338
|
+
throw new Error('Invalid AA config: provider must be either "alchemy" or "pimlico"');
|
|
1339
|
+
}
|
|
1337
1340
|
if (typeof value.fallbackToEoa !== "boolean") {
|
|
1338
1341
|
throw new Error("Invalid AA config: fallbackToEoa must be a boolean");
|
|
1339
1342
|
}
|
|
@@ -1384,7 +1387,7 @@ function buildAAExecutionPlan(config, chainConfig) {
|
|
|
1384
1387
|
};
|
|
1385
1388
|
}
|
|
1386
1389
|
function getWalletExecutorReady(providerState) {
|
|
1387
|
-
return !providerState.
|
|
1390
|
+
return !providerState.resolved || !providerState.pending && (Boolean(providerState.account) || Boolean(providerState.error) || providerState.resolved.fallbackToEoa);
|
|
1388
1391
|
}
|
|
1389
1392
|
function mapCall(call) {
|
|
1390
1393
|
return {
|
|
@@ -1453,10 +1456,10 @@ async function executeWalletCalls(params) {
|
|
|
1453
1456
|
chainsById,
|
|
1454
1457
|
getPreferredRpcUrl
|
|
1455
1458
|
} = params;
|
|
1456
|
-
if (providerState.
|
|
1459
|
+
if (providerState.resolved && providerState.account) {
|
|
1457
1460
|
return executeViaAA(callList, providerState);
|
|
1458
1461
|
}
|
|
1459
|
-
if (providerState.
|
|
1462
|
+
if (providerState.resolved && providerState.error && !providerState.resolved.fallbackToEoa) {
|
|
1460
1463
|
throw providerState.error;
|
|
1461
1464
|
}
|
|
1462
1465
|
return executeViaEoa({
|
|
@@ -1473,26 +1476,26 @@ async function executeWalletCalls(params) {
|
|
|
1473
1476
|
}
|
|
1474
1477
|
async function executeViaAA(callList, providerState) {
|
|
1475
1478
|
var _a;
|
|
1476
|
-
const
|
|
1477
|
-
const
|
|
1478
|
-
if (!
|
|
1479
|
+
const account = providerState.account;
|
|
1480
|
+
const resolved = providerState.resolved;
|
|
1481
|
+
if (!account || !resolved) {
|
|
1479
1482
|
throw (_a = providerState.error) != null ? _a : new Error("smart_account_unavailable");
|
|
1480
1483
|
}
|
|
1481
1484
|
const callsPayload = callList.map(mapCall);
|
|
1482
|
-
const receipt = callList.length > 1 ? await
|
|
1485
|
+
const receipt = callList.length > 1 ? await account.sendBatchTransaction(callsPayload) : await account.sendTransaction(callsPayload[0]);
|
|
1483
1486
|
const txHash = receipt.transactionHash;
|
|
1484
|
-
const providerPrefix =
|
|
1485
|
-
let delegationAddress =
|
|
1486
|
-
if (
|
|
1487
|
+
const providerPrefix = account.provider.toLowerCase();
|
|
1488
|
+
let delegationAddress = account.mode === "7702" ? account.delegationAddress : void 0;
|
|
1489
|
+
if (account.mode === "7702" && !delegationAddress) {
|
|
1487
1490
|
delegationAddress = await resolve7702Delegation(txHash, callList);
|
|
1488
1491
|
}
|
|
1489
1492
|
return {
|
|
1490
1493
|
txHash,
|
|
1491
1494
|
txHashes: [txHash],
|
|
1492
|
-
executionKind: `${providerPrefix}_${
|
|
1495
|
+
executionKind: `${providerPrefix}_${account.mode}`,
|
|
1493
1496
|
batched: callList.length > 1,
|
|
1494
|
-
sponsored:
|
|
1495
|
-
AAAddress:
|
|
1497
|
+
sponsored: resolved.sponsorship !== "disabled",
|
|
1498
|
+
AAAddress: account.AAAddress,
|
|
1496
1499
|
delegationAddress
|
|
1497
1500
|
};
|
|
1498
1501
|
}
|
|
@@ -1536,7 +1539,7 @@ async function executeViaEoa({
|
|
|
1536
1539
|
}) {
|
|
1537
1540
|
var _a, _b;
|
|
1538
1541
|
const { createPublicClient, createWalletClient, http } = await import("viem");
|
|
1539
|
-
const { privateKeyToAccount:
|
|
1542
|
+
const { privateKeyToAccount: privateKeyToAccount3 } = await import("viem/accounts");
|
|
1540
1543
|
const hashes = [];
|
|
1541
1544
|
if (localPrivateKey) {
|
|
1542
1545
|
for (const call of callList) {
|
|
@@ -1548,7 +1551,7 @@ async function executeViaEoa({
|
|
|
1548
1551
|
if (!rpcUrl) {
|
|
1549
1552
|
throw new Error(`No RPC for chain ${call.chainId}`);
|
|
1550
1553
|
}
|
|
1551
|
-
const account =
|
|
1554
|
+
const account = privateKeyToAccount3(localPrivateKey);
|
|
1552
1555
|
const walletClient = createWalletClient({
|
|
1553
1556
|
account,
|
|
1554
1557
|
chain,
|
|
@@ -1621,7 +1624,7 @@ async function executeViaEoa({
|
|
|
1621
1624
|
};
|
|
1622
1625
|
}
|
|
1623
1626
|
|
|
1624
|
-
// src/aa/env.ts
|
|
1627
|
+
// src/aa/alchemy/env.ts
|
|
1625
1628
|
var ALCHEMY_API_KEY_ENVS = [
|
|
1626
1629
|
"ALCHEMY_API_KEY",
|
|
1627
1630
|
"NEXT_PUBLIC_ALCHEMY_API_KEY"
|
|
@@ -1630,10 +1633,14 @@ var ALCHEMY_GAS_POLICY_ENVS = [
|
|
|
1630
1633
|
"ALCHEMY_GAS_POLICY_ID",
|
|
1631
1634
|
"NEXT_PUBLIC_ALCHEMY_GAS_POLICY_ID"
|
|
1632
1635
|
];
|
|
1636
|
+
|
|
1637
|
+
// src/aa/pimlico/env.ts
|
|
1633
1638
|
var PIMLICO_API_KEY_ENVS = [
|
|
1634
1639
|
"PIMLICO_API_KEY",
|
|
1635
1640
|
"NEXT_PUBLIC_PIMLICO_API_KEY"
|
|
1636
1641
|
];
|
|
1642
|
+
|
|
1643
|
+
// src/aa/env.ts
|
|
1637
1644
|
function readEnv(candidates, options = {}) {
|
|
1638
1645
|
var _a;
|
|
1639
1646
|
const { publicOnly = false } = options;
|
|
@@ -1668,7 +1675,7 @@ function resolveDefaultProvider(options = {}) {
|
|
|
1668
1675
|
);
|
|
1669
1676
|
}
|
|
1670
1677
|
|
|
1671
|
-
// src/aa/resolve.ts
|
|
1678
|
+
// src/aa/alchemy/resolve.ts
|
|
1672
1679
|
function resolveAlchemyConfig(options) {
|
|
1673
1680
|
const {
|
|
1674
1681
|
calls,
|
|
@@ -1736,77 +1743,17 @@ function resolveAlchemyConfig(options) {
|
|
|
1736
1743
|
return null;
|
|
1737
1744
|
}
|
|
1738
1745
|
const resolvedChainConfig = modeOverride ? __spreadProps(__spreadValues({}, chainConfig), { defaultMode: modeOverride }) : chainConfig;
|
|
1739
|
-
const
|
|
1740
|
-
return {
|
|
1741
|
-
chainConfig: resolvedChainConfig,
|
|
1742
|
-
plan,
|
|
1746
|
+
const resolved = buildAAExecutionPlan(config, resolvedChainConfig);
|
|
1747
|
+
return __spreadProps(__spreadValues({}, resolved), {
|
|
1743
1748
|
apiKey,
|
|
1744
1749
|
chain,
|
|
1745
1750
|
rpcUrl: getPreferredRpcUrl(chain),
|
|
1746
1751
|
gasPolicyId,
|
|
1747
1752
|
mode: resolvedChainConfig.defaultMode
|
|
1748
|
-
};
|
|
1749
|
-
}
|
|
1750
|
-
function resolvePimlicoConfig(options) {
|
|
1751
|
-
const {
|
|
1752
|
-
calls,
|
|
1753
|
-
localPrivateKey,
|
|
1754
|
-
accountAbstractionConfig = DEFAULT_AA_CONFIG,
|
|
1755
|
-
chainsById,
|
|
1756
|
-
rpcUrl,
|
|
1757
|
-
modeOverride,
|
|
1758
|
-
publicOnly = false,
|
|
1759
|
-
throwOnMissingConfig = false,
|
|
1760
|
-
apiKey: preResolvedApiKey
|
|
1761
|
-
} = options;
|
|
1762
|
-
if (!calls || localPrivateKey) {
|
|
1763
|
-
return null;
|
|
1764
|
-
}
|
|
1765
|
-
const config = __spreadProps(__spreadValues({}, accountAbstractionConfig), {
|
|
1766
|
-
provider: "pimlico"
|
|
1767
1753
|
});
|
|
1768
|
-
const chainConfig = getAAChainConfig(config, calls, chainsById);
|
|
1769
|
-
if (!chainConfig) {
|
|
1770
|
-
if (throwOnMissingConfig) {
|
|
1771
|
-
const chainIds = Array.from(new Set(calls.map((c) => c.chainId)));
|
|
1772
|
-
throw new Error(
|
|
1773
|
-
`AA is not configured for chain ${chainIds[0]}, or batching is disabled for that chain.`
|
|
1774
|
-
);
|
|
1775
|
-
}
|
|
1776
|
-
return null;
|
|
1777
|
-
}
|
|
1778
|
-
const apiKey = preResolvedApiKey != null ? preResolvedApiKey : readEnv(PIMLICO_API_KEY_ENVS, { publicOnly });
|
|
1779
|
-
if (!apiKey) {
|
|
1780
|
-
if (throwOnMissingConfig) {
|
|
1781
|
-
throw new Error("Pimlico AA requires PIMLICO_API_KEY.");
|
|
1782
|
-
}
|
|
1783
|
-
return null;
|
|
1784
|
-
}
|
|
1785
|
-
const chain = chainsById[chainConfig.chainId];
|
|
1786
|
-
if (!chain) {
|
|
1787
|
-
return null;
|
|
1788
|
-
}
|
|
1789
|
-
if (modeOverride && !chainConfig.supportedModes.includes(modeOverride)) {
|
|
1790
|
-
if (throwOnMissingConfig) {
|
|
1791
|
-
throw new Error(
|
|
1792
|
-
`AA mode "${modeOverride}" is not supported on chain ${chainConfig.chainId}.`
|
|
1793
|
-
);
|
|
1794
|
-
}
|
|
1795
|
-
return null;
|
|
1796
|
-
}
|
|
1797
|
-
const resolvedChainConfig = modeOverride ? __spreadProps(__spreadValues({}, chainConfig), { defaultMode: modeOverride }) : chainConfig;
|
|
1798
|
-
const plan = buildAAExecutionPlan(config, resolvedChainConfig);
|
|
1799
|
-
return {
|
|
1800
|
-
chainConfig: resolvedChainConfig,
|
|
1801
|
-
plan,
|
|
1802
|
-
apiKey,
|
|
1803
|
-
chain,
|
|
1804
|
-
rpcUrl,
|
|
1805
|
-
mode: resolvedChainConfig.defaultMode
|
|
1806
|
-
};
|
|
1807
1754
|
}
|
|
1808
1755
|
|
|
1809
|
-
// src/aa/alchemy.ts
|
|
1756
|
+
// src/aa/alchemy/provider.ts
|
|
1810
1757
|
function createAlchemyAAProvider({
|
|
1811
1758
|
accountAbstractionConfig = DEFAULT_AA_CONFIG,
|
|
1812
1759
|
useAlchemyAA,
|
|
@@ -1815,7 +1762,7 @@ function createAlchemyAAProvider({
|
|
|
1815
1762
|
getPreferredRpcUrl
|
|
1816
1763
|
}) {
|
|
1817
1764
|
return function useAlchemyAAProvider(calls, localPrivateKey) {
|
|
1818
|
-
var _a
|
|
1765
|
+
var _a;
|
|
1819
1766
|
const resolved = resolveAlchemyConfig({
|
|
1820
1767
|
calls,
|
|
1821
1768
|
localPrivateKey,
|
|
@@ -1835,49 +1782,16 @@ function createAlchemyAAProvider({
|
|
|
1835
1782
|
} : void 0;
|
|
1836
1783
|
const query = useAlchemyAA(params);
|
|
1837
1784
|
return {
|
|
1838
|
-
|
|
1839
|
-
query,
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
error: (_b = query.error) != null ? _b : null
|
|
1785
|
+
resolved: resolved != null ? resolved : null,
|
|
1786
|
+
account: query.account,
|
|
1787
|
+
pending: Boolean(resolved && query.pending),
|
|
1788
|
+
error: (_a = query.error) != null ? _a : null
|
|
1843
1789
|
};
|
|
1844
1790
|
};
|
|
1845
1791
|
}
|
|
1846
1792
|
|
|
1847
|
-
// src/aa/
|
|
1848
|
-
|
|
1849
|
-
accountAbstractionConfig = DEFAULT_AA_CONFIG,
|
|
1850
|
-
usePimlicoAA,
|
|
1851
|
-
chainsById,
|
|
1852
|
-
rpcUrl
|
|
1853
|
-
}) {
|
|
1854
|
-
return function usePimlicoAAProvider(calls, localPrivateKey) {
|
|
1855
|
-
var _a, _b;
|
|
1856
|
-
const resolved = resolvePimlicoConfig({
|
|
1857
|
-
calls,
|
|
1858
|
-
localPrivateKey,
|
|
1859
|
-
accountAbstractionConfig,
|
|
1860
|
-
chainsById,
|
|
1861
|
-
rpcUrl,
|
|
1862
|
-
publicOnly: true
|
|
1863
|
-
});
|
|
1864
|
-
const params = resolved ? {
|
|
1865
|
-
enabled: true,
|
|
1866
|
-
apiKey: resolved.apiKey,
|
|
1867
|
-
chain: resolved.chain,
|
|
1868
|
-
mode: resolved.mode,
|
|
1869
|
-
rpcUrl: resolved.rpcUrl
|
|
1870
|
-
} : void 0;
|
|
1871
|
-
const query = usePimlicoAA(params);
|
|
1872
|
-
return {
|
|
1873
|
-
plan: (_a = resolved == null ? void 0 : resolved.plan) != null ? _a : null,
|
|
1874
|
-
query,
|
|
1875
|
-
AA: query.AA,
|
|
1876
|
-
isPending: Boolean(resolved && query.isPending),
|
|
1877
|
-
error: (_b = query.error) != null ? _b : null
|
|
1878
|
-
};
|
|
1879
|
-
};
|
|
1880
|
-
}
|
|
1793
|
+
// src/aa/alchemy/create.ts
|
|
1794
|
+
var import_accounts2 = require("viem/accounts");
|
|
1881
1795
|
|
|
1882
1796
|
// src/aa/adapt.ts
|
|
1883
1797
|
function adaptSmartAccount(account) {
|
|
@@ -1903,32 +1817,8 @@ function isAlchemySponsorshipLimitError(error) {
|
|
|
1903
1817
|
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");
|
|
1904
1818
|
}
|
|
1905
1819
|
|
|
1906
|
-
// src/aa/
|
|
1907
|
-
var import_aa_alchemy = require("@getpara/aa-alchemy");
|
|
1908
|
-
var import_aa_pimlico = require("@getpara/aa-pimlico");
|
|
1820
|
+
// src/aa/owner.ts
|
|
1909
1821
|
var import_accounts = require("viem/accounts");
|
|
1910
|
-
async function createAAProviderState(options) {
|
|
1911
|
-
if (options.provider === "alchemy") {
|
|
1912
|
-
return createAlchemyAAState({
|
|
1913
|
-
chain: options.chain,
|
|
1914
|
-
owner: options.owner,
|
|
1915
|
-
rpcUrl: options.rpcUrl,
|
|
1916
|
-
callList: options.callList,
|
|
1917
|
-
mode: options.mode,
|
|
1918
|
-
apiKey: options.apiKey,
|
|
1919
|
-
gasPolicyId: options.gasPolicyId,
|
|
1920
|
-
sponsored: options.sponsored
|
|
1921
|
-
});
|
|
1922
|
-
}
|
|
1923
|
-
return createPimlicoAAState({
|
|
1924
|
-
chain: options.chain,
|
|
1925
|
-
owner: options.owner,
|
|
1926
|
-
rpcUrl: options.rpcUrl,
|
|
1927
|
-
callList: options.callList,
|
|
1928
|
-
mode: options.mode,
|
|
1929
|
-
apiKey: options.apiKey
|
|
1930
|
-
});
|
|
1931
|
-
}
|
|
1932
1822
|
function getDirectOwnerParams(owner) {
|
|
1933
1823
|
return {
|
|
1934
1824
|
kind: "ready",
|
|
@@ -1974,24 +1864,27 @@ function getOwnerParams(owner) {
|
|
|
1974
1864
|
return getSessionOwnerParams(owner);
|
|
1975
1865
|
}
|
|
1976
1866
|
}
|
|
1977
|
-
function getMissingOwnerState(
|
|
1867
|
+
function getMissingOwnerState(resolved, provider) {
|
|
1978
1868
|
return {
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1869
|
+
resolved,
|
|
1870
|
+
account: null,
|
|
1871
|
+
pending: false,
|
|
1982
1872
|
error: new Error(
|
|
1983
1873
|
`${provider} AA account creation requires a direct owner or a supported session owner.`
|
|
1984
1874
|
)
|
|
1985
1875
|
};
|
|
1986
1876
|
}
|
|
1987
|
-
function getUnsupportedAdapterState(
|
|
1877
|
+
function getUnsupportedAdapterState(resolved, adapter) {
|
|
1988
1878
|
return {
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1879
|
+
resolved,
|
|
1880
|
+
account: null,
|
|
1881
|
+
pending: false,
|
|
1992
1882
|
error: new Error(`Session adapter "${adapter}" is not implemented.`)
|
|
1993
1883
|
};
|
|
1994
1884
|
}
|
|
1885
|
+
|
|
1886
|
+
// src/aa/alchemy/create.ts
|
|
1887
|
+
var ALCHEMY_7702_DELEGATION_ADDRESS = "0x69007702764179f14F51cdce752f4f775d74E139";
|
|
1995
1888
|
async function createAlchemyAAState(options) {
|
|
1996
1889
|
var _a, _b;
|
|
1997
1890
|
const {
|
|
@@ -2016,70 +1909,71 @@ async function createAlchemyAAState(options) {
|
|
|
2016
1909
|
}
|
|
2017
1910
|
const apiKey = (_a = options.apiKey) != null ? _a : resolved.apiKey;
|
|
2018
1911
|
const gasPolicyId = sponsored ? (_b = options.gasPolicyId) != null ? _b : readEnv(ALCHEMY_GAS_POLICY_ENVS) : void 0;
|
|
2019
|
-
const
|
|
2020
|
-
sponsorship: gasPolicyId ? resolved.
|
|
1912
|
+
const execution = __spreadProps(__spreadValues({}, resolved), {
|
|
1913
|
+
sponsorship: gasPolicyId ? resolved.sponsorship : "disabled",
|
|
2021
1914
|
fallbackToEoa: false
|
|
2022
1915
|
});
|
|
2023
1916
|
const ownerParams = getOwnerParams(owner);
|
|
2024
1917
|
if (ownerParams.kind === "missing") {
|
|
2025
|
-
return getMissingOwnerState(
|
|
1918
|
+
return getMissingOwnerState(execution, "alchemy");
|
|
2026
1919
|
}
|
|
2027
1920
|
if (ownerParams.kind === "unsupported_adapter") {
|
|
2028
|
-
return getUnsupportedAdapterState(
|
|
1921
|
+
return getUnsupportedAdapterState(execution, ownerParams.adapter);
|
|
2029
1922
|
}
|
|
2030
1923
|
if (owner.kind === "direct") {
|
|
2031
1924
|
try {
|
|
2032
1925
|
return await createAlchemyWalletApisState({
|
|
2033
|
-
|
|
1926
|
+
resolved: execution,
|
|
2034
1927
|
chain,
|
|
2035
1928
|
privateKey: owner.privateKey,
|
|
2036
1929
|
apiKey,
|
|
2037
1930
|
gasPolicyId,
|
|
2038
|
-
mode:
|
|
1931
|
+
mode: execution.mode
|
|
2039
1932
|
});
|
|
2040
1933
|
} catch (error) {
|
|
2041
1934
|
return {
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
1935
|
+
resolved: execution,
|
|
1936
|
+
account: null,
|
|
1937
|
+
pending: false,
|
|
2045
1938
|
error: error instanceof Error ? error : new Error(String(error))
|
|
2046
1939
|
};
|
|
2047
1940
|
}
|
|
2048
1941
|
}
|
|
2049
1942
|
try {
|
|
2050
|
-
const
|
|
1943
|
+
const { createAlchemySmartAccount } = await import("@getpara/aa-alchemy");
|
|
1944
|
+
const smartAccount = await createAlchemySmartAccount(__spreadProps(__spreadValues({}, ownerParams.ownerParams), {
|
|
2051
1945
|
apiKey,
|
|
2052
1946
|
gasPolicyId,
|
|
2053
1947
|
chain,
|
|
2054
1948
|
rpcUrl,
|
|
2055
|
-
mode:
|
|
1949
|
+
mode: execution.mode
|
|
2056
1950
|
}));
|
|
2057
1951
|
if (!smartAccount) {
|
|
2058
1952
|
return {
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
1953
|
+
resolved: execution,
|
|
1954
|
+
account: null,
|
|
1955
|
+
pending: false,
|
|
2062
1956
|
error: new Error("Alchemy AA account could not be initialized.")
|
|
2063
1957
|
};
|
|
2064
1958
|
}
|
|
2065
1959
|
return {
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
1960
|
+
resolved: execution,
|
|
1961
|
+
account: adaptSmartAccount(smartAccount),
|
|
1962
|
+
pending: false,
|
|
2069
1963
|
error: null
|
|
2070
1964
|
};
|
|
2071
1965
|
} catch (error) {
|
|
2072
1966
|
return {
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
1967
|
+
resolved: execution,
|
|
1968
|
+
account: null,
|
|
1969
|
+
pending: false,
|
|
2076
1970
|
error: error instanceof Error ? error : new Error(String(error))
|
|
2077
1971
|
};
|
|
2078
1972
|
}
|
|
2079
1973
|
}
|
|
2080
1974
|
async function createAlchemyWalletApisState(params) {
|
|
2081
1975
|
const { createSmartWalletClient, alchemyWalletTransport } = await import("@alchemy/wallet-apis");
|
|
2082
|
-
const signer = (0,
|
|
1976
|
+
const signer = (0, import_accounts2.privateKeyToAccount)(params.privateKey);
|
|
2083
1977
|
const walletClient = createSmartWalletClient(__spreadValues({
|
|
2084
1978
|
transport: alchemyWalletTransport({ apiKey: params.apiKey }),
|
|
2085
1979
|
chain: params.chain,
|
|
@@ -2087,8 +1981,8 @@ async function createAlchemyWalletApisState(params) {
|
|
|
2087
1981
|
}, params.gasPolicyId ? { paymaster: { policyId: params.gasPolicyId } } : {}));
|
|
2088
1982
|
let accountAddress = signer.address;
|
|
2089
1983
|
if (params.mode === "4337") {
|
|
2090
|
-
const
|
|
2091
|
-
accountAddress =
|
|
1984
|
+
const account2 = await walletClient.requestAccount();
|
|
1985
|
+
accountAddress = account2.address;
|
|
2092
1986
|
}
|
|
2093
1987
|
const sendCalls = async (calls) => {
|
|
2094
1988
|
var _a, _b;
|
|
@@ -2102,21 +1996,115 @@ async function createAlchemyWalletApisState(params) {
|
|
|
2102
1996
|
}
|
|
2103
1997
|
return { transactionHash };
|
|
2104
1998
|
};
|
|
2105
|
-
const
|
|
1999
|
+
const account = {
|
|
2106
2000
|
provider: "alchemy",
|
|
2107
2001
|
mode: params.mode,
|
|
2108
2002
|
AAAddress: accountAddress,
|
|
2109
|
-
delegationAddress: params.mode === "7702" ?
|
|
2003
|
+
delegationAddress: params.mode === "7702" ? ALCHEMY_7702_DELEGATION_ADDRESS : void 0,
|
|
2110
2004
|
sendTransaction: async (call) => sendCalls([call]),
|
|
2111
2005
|
sendBatchTransaction: async (calls) => sendCalls(calls)
|
|
2112
2006
|
};
|
|
2113
2007
|
return {
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2008
|
+
resolved: params.resolved,
|
|
2009
|
+
account,
|
|
2010
|
+
pending: false,
|
|
2117
2011
|
error: null
|
|
2118
2012
|
};
|
|
2119
2013
|
}
|
|
2014
|
+
|
|
2015
|
+
// src/aa/pimlico/resolve.ts
|
|
2016
|
+
function resolvePimlicoConfig(options) {
|
|
2017
|
+
const {
|
|
2018
|
+
calls,
|
|
2019
|
+
localPrivateKey,
|
|
2020
|
+
accountAbstractionConfig = DEFAULT_AA_CONFIG,
|
|
2021
|
+
chainsById,
|
|
2022
|
+
rpcUrl,
|
|
2023
|
+
modeOverride,
|
|
2024
|
+
publicOnly = false,
|
|
2025
|
+
throwOnMissingConfig = false,
|
|
2026
|
+
apiKey: preResolvedApiKey
|
|
2027
|
+
} = options;
|
|
2028
|
+
if (!calls || localPrivateKey) {
|
|
2029
|
+
return null;
|
|
2030
|
+
}
|
|
2031
|
+
const config = __spreadProps(__spreadValues({}, accountAbstractionConfig), {
|
|
2032
|
+
provider: "pimlico"
|
|
2033
|
+
});
|
|
2034
|
+
const chainConfig = getAAChainConfig(config, calls, chainsById);
|
|
2035
|
+
if (!chainConfig) {
|
|
2036
|
+
if (throwOnMissingConfig) {
|
|
2037
|
+
const chainIds = Array.from(new Set(calls.map((c) => c.chainId)));
|
|
2038
|
+
throw new Error(
|
|
2039
|
+
`AA is not configured for chain ${chainIds[0]}, or batching is disabled for that chain.`
|
|
2040
|
+
);
|
|
2041
|
+
}
|
|
2042
|
+
return null;
|
|
2043
|
+
}
|
|
2044
|
+
const apiKey = preResolvedApiKey != null ? preResolvedApiKey : readEnv(PIMLICO_API_KEY_ENVS, { publicOnly });
|
|
2045
|
+
if (!apiKey) {
|
|
2046
|
+
if (throwOnMissingConfig) {
|
|
2047
|
+
throw new Error("Pimlico AA requires PIMLICO_API_KEY.");
|
|
2048
|
+
}
|
|
2049
|
+
return null;
|
|
2050
|
+
}
|
|
2051
|
+
const chain = chainsById[chainConfig.chainId];
|
|
2052
|
+
if (!chain) {
|
|
2053
|
+
return null;
|
|
2054
|
+
}
|
|
2055
|
+
if (modeOverride && !chainConfig.supportedModes.includes(modeOverride)) {
|
|
2056
|
+
if (throwOnMissingConfig) {
|
|
2057
|
+
throw new Error(
|
|
2058
|
+
`AA mode "${modeOverride}" is not supported on chain ${chainConfig.chainId}.`
|
|
2059
|
+
);
|
|
2060
|
+
}
|
|
2061
|
+
return null;
|
|
2062
|
+
}
|
|
2063
|
+
const resolvedChainConfig = modeOverride ? __spreadProps(__spreadValues({}, chainConfig), { defaultMode: modeOverride }) : chainConfig;
|
|
2064
|
+
const resolved = buildAAExecutionPlan(config, resolvedChainConfig);
|
|
2065
|
+
return __spreadProps(__spreadValues({}, resolved), {
|
|
2066
|
+
apiKey,
|
|
2067
|
+
chain,
|
|
2068
|
+
rpcUrl,
|
|
2069
|
+
mode: resolvedChainConfig.defaultMode
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
// src/aa/pimlico/provider.ts
|
|
2074
|
+
function createPimlicoAAProvider({
|
|
2075
|
+
accountAbstractionConfig = DEFAULT_AA_CONFIG,
|
|
2076
|
+
usePimlicoAA,
|
|
2077
|
+
chainsById,
|
|
2078
|
+
rpcUrl
|
|
2079
|
+
}) {
|
|
2080
|
+
return function usePimlicoAAProvider(calls, localPrivateKey) {
|
|
2081
|
+
var _a;
|
|
2082
|
+
const resolved = resolvePimlicoConfig({
|
|
2083
|
+
calls,
|
|
2084
|
+
localPrivateKey,
|
|
2085
|
+
accountAbstractionConfig,
|
|
2086
|
+
chainsById,
|
|
2087
|
+
rpcUrl,
|
|
2088
|
+
publicOnly: true
|
|
2089
|
+
});
|
|
2090
|
+
const params = resolved ? {
|
|
2091
|
+
enabled: true,
|
|
2092
|
+
apiKey: resolved.apiKey,
|
|
2093
|
+
chain: resolved.chain,
|
|
2094
|
+
mode: resolved.mode,
|
|
2095
|
+
rpcUrl: resolved.rpcUrl
|
|
2096
|
+
} : void 0;
|
|
2097
|
+
const query = usePimlicoAA(params);
|
|
2098
|
+
return {
|
|
2099
|
+
resolved: resolved != null ? resolved : null,
|
|
2100
|
+
account: query.account,
|
|
2101
|
+
pending: Boolean(resolved && query.pending),
|
|
2102
|
+
error: (_a = query.error) != null ? _a : null
|
|
2103
|
+
};
|
|
2104
|
+
};
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
// src/aa/pimlico/create.ts
|
|
2120
2108
|
async function createPimlicoAAState(options) {
|
|
2121
2109
|
var _a;
|
|
2122
2110
|
const {
|
|
@@ -2138,46 +2126,71 @@ async function createPimlicoAAState(options) {
|
|
|
2138
2126
|
throw new Error("Pimlico AA config resolution failed.");
|
|
2139
2127
|
}
|
|
2140
2128
|
const apiKey = (_a = options.apiKey) != null ? _a : resolved.apiKey;
|
|
2141
|
-
const
|
|
2129
|
+
const execution = __spreadProps(__spreadValues({}, resolved), {
|
|
2142
2130
|
fallbackToEoa: false
|
|
2143
2131
|
});
|
|
2144
2132
|
const ownerParams = getOwnerParams(owner);
|
|
2145
2133
|
if (ownerParams.kind === "missing") {
|
|
2146
|
-
return getMissingOwnerState(
|
|
2134
|
+
return getMissingOwnerState(execution, "pimlico");
|
|
2147
2135
|
}
|
|
2148
2136
|
if (ownerParams.kind === "unsupported_adapter") {
|
|
2149
|
-
return getUnsupportedAdapterState(
|
|
2137
|
+
return getUnsupportedAdapterState(execution, ownerParams.adapter);
|
|
2150
2138
|
}
|
|
2151
2139
|
try {
|
|
2152
|
-
const
|
|
2140
|
+
const { createPimlicoSmartAccount } = await import("@getpara/aa-pimlico");
|
|
2141
|
+
const smartAccount = await createPimlicoSmartAccount(__spreadProps(__spreadValues({}, ownerParams.ownerParams), {
|
|
2153
2142
|
apiKey,
|
|
2154
2143
|
chain,
|
|
2155
2144
|
rpcUrl,
|
|
2156
|
-
mode:
|
|
2145
|
+
mode: execution.mode
|
|
2157
2146
|
}));
|
|
2158
2147
|
if (!smartAccount) {
|
|
2159
2148
|
return {
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2149
|
+
resolved: execution,
|
|
2150
|
+
account: null,
|
|
2151
|
+
pending: false,
|
|
2163
2152
|
error: new Error("Pimlico AA account could not be initialized.")
|
|
2164
2153
|
};
|
|
2165
2154
|
}
|
|
2166
2155
|
return {
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2156
|
+
resolved: execution,
|
|
2157
|
+
account: adaptSmartAccount(smartAccount),
|
|
2158
|
+
pending: false,
|
|
2170
2159
|
error: null
|
|
2171
2160
|
};
|
|
2172
2161
|
} catch (error) {
|
|
2173
2162
|
return {
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2163
|
+
resolved: execution,
|
|
2164
|
+
account: null,
|
|
2165
|
+
pending: false,
|
|
2177
2166
|
error: error instanceof Error ? error : new Error(String(error))
|
|
2178
2167
|
};
|
|
2179
2168
|
}
|
|
2180
2169
|
}
|
|
2170
|
+
|
|
2171
|
+
// src/aa/create.ts
|
|
2172
|
+
async function createAAProviderState(options) {
|
|
2173
|
+
if (options.provider === "alchemy") {
|
|
2174
|
+
return createAlchemyAAState({
|
|
2175
|
+
chain: options.chain,
|
|
2176
|
+
owner: options.owner,
|
|
2177
|
+
rpcUrl: options.rpcUrl,
|
|
2178
|
+
callList: options.callList,
|
|
2179
|
+
mode: options.mode,
|
|
2180
|
+
apiKey: options.apiKey,
|
|
2181
|
+
gasPolicyId: options.gasPolicyId,
|
|
2182
|
+
sponsored: options.sponsored
|
|
2183
|
+
});
|
|
2184
|
+
}
|
|
2185
|
+
return createPimlicoAAState({
|
|
2186
|
+
chain: options.chain,
|
|
2187
|
+
owner: options.owner,
|
|
2188
|
+
rpcUrl: options.rpcUrl,
|
|
2189
|
+
callList: options.callList,
|
|
2190
|
+
mode: options.mode,
|
|
2191
|
+
apiKey: options.apiKey
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2181
2194
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2182
2195
|
0 && (module.exports = {
|
|
2183
2196
|
AomiClient,
|