@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/cli.js +79 -22
- package/dist/index.cjs +78 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +78 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2602,7 +2602,9 @@ function resolveAlchemyConfig(options) {
|
|
|
2602
2602
|
},
|
|
2603
2603
|
modeOverride,
|
|
2604
2604
|
publicOnly = false,
|
|
2605
|
-
throwOnMissingConfig = false
|
|
2605
|
+
throwOnMissingConfig = false,
|
|
2606
|
+
apiKey: preResolvedApiKey,
|
|
2607
|
+
gasPolicyId: preResolvedGasPolicyId
|
|
2606
2608
|
} = options;
|
|
2607
2609
|
if (!calls || localPrivateKey) {
|
|
2608
2610
|
return null;
|
|
@@ -2620,7 +2622,7 @@ function resolveAlchemyConfig(options) {
|
|
|
2620
2622
|
}
|
|
2621
2623
|
return null;
|
|
2622
2624
|
}
|
|
2623
|
-
const apiKey = readEnv(ALCHEMY_API_KEY_ENVS, { publicOnly });
|
|
2625
|
+
const apiKey = preResolvedApiKey != null ? preResolvedApiKey : readEnv(ALCHEMY_API_KEY_ENVS, { publicOnly });
|
|
2624
2626
|
if (!apiKey) {
|
|
2625
2627
|
if (throwOnMissingConfig) {
|
|
2626
2628
|
throw new Error("Alchemy AA requires ALCHEMY_API_KEY.");
|
|
@@ -2631,7 +2633,7 @@ function resolveAlchemyConfig(options) {
|
|
|
2631
2633
|
if (!chain) {
|
|
2632
2634
|
return null;
|
|
2633
2635
|
}
|
|
2634
|
-
const gasPolicyId = readGasPolicyEnv(
|
|
2636
|
+
const gasPolicyId = preResolvedGasPolicyId != null ? preResolvedGasPolicyId : readGasPolicyEnv(
|
|
2635
2637
|
chainConfig.chainId,
|
|
2636
2638
|
chainSlugById,
|
|
2637
2639
|
ALCHEMY_GAS_POLICY_ENVS,
|
|
@@ -2674,7 +2676,8 @@ function resolvePimlicoConfig(options) {
|
|
|
2674
2676
|
rpcUrl,
|
|
2675
2677
|
modeOverride,
|
|
2676
2678
|
publicOnly = false,
|
|
2677
|
-
throwOnMissingConfig = false
|
|
2679
|
+
throwOnMissingConfig = false,
|
|
2680
|
+
apiKey: preResolvedApiKey
|
|
2678
2681
|
} = options;
|
|
2679
2682
|
if (!calls || localPrivateKey) {
|
|
2680
2683
|
return null;
|
|
@@ -2692,7 +2695,7 @@ function resolvePimlicoConfig(options) {
|
|
|
2692
2695
|
}
|
|
2693
2696
|
return null;
|
|
2694
2697
|
}
|
|
2695
|
-
const apiKey = readEnv(PIMLICO_API_KEY_ENVS, { publicOnly });
|
|
2698
|
+
const apiKey = preResolvedApiKey != null ? preResolvedApiKey : readEnv(PIMLICO_API_KEY_ENVS, { publicOnly });
|
|
2696
2699
|
if (!apiKey) {
|
|
2697
2700
|
if (throwOnMissingConfig) {
|
|
2698
2701
|
throw new Error("Pimlico AA requires PIMLICO_API_KEY.");
|
|
@@ -2752,15 +2755,64 @@ import { createPimlicoSmartAccount } from "@getpara/aa-pimlico";
|
|
|
2752
2755
|
import { privateKeyToAccount } from "viem/accounts";
|
|
2753
2756
|
async function createAAProviderState(options) {
|
|
2754
2757
|
if (options.provider === "alchemy") {
|
|
2755
|
-
return createAlchemyAAState(
|
|
2758
|
+
return createAlchemyAAState({
|
|
2759
|
+
chain: options.chain,
|
|
2760
|
+
owner: options.owner,
|
|
2761
|
+
rpcUrl: options.rpcUrl,
|
|
2762
|
+
callList: options.callList,
|
|
2763
|
+
mode: options.mode,
|
|
2764
|
+
apiKey: options.apiKey,
|
|
2765
|
+
gasPolicyId: options.gasPolicyId,
|
|
2766
|
+
sponsored: options.sponsored
|
|
2767
|
+
});
|
|
2768
|
+
}
|
|
2769
|
+
return createPimlicoAAState({
|
|
2770
|
+
chain: options.chain,
|
|
2771
|
+
owner: options.owner,
|
|
2772
|
+
rpcUrl: options.rpcUrl,
|
|
2773
|
+
callList: options.callList,
|
|
2774
|
+
mode: options.mode,
|
|
2775
|
+
apiKey: options.apiKey
|
|
2776
|
+
});
|
|
2777
|
+
}
|
|
2778
|
+
function getOwnerParams(owner) {
|
|
2779
|
+
if (!owner) {
|
|
2780
|
+
return null;
|
|
2781
|
+
}
|
|
2782
|
+
if ("privateKey" in owner) {
|
|
2783
|
+
return {
|
|
2784
|
+
para: void 0,
|
|
2785
|
+
signer: privateKeyToAccount(owner.privateKey)
|
|
2786
|
+
};
|
|
2787
|
+
}
|
|
2788
|
+
if ("signer" in owner) {
|
|
2789
|
+
return __spreadValues({
|
|
2790
|
+
para: owner.para,
|
|
2791
|
+
signer: owner.signer
|
|
2792
|
+
}, owner.address ? { address: owner.address } : {});
|
|
2793
|
+
}
|
|
2794
|
+
if ("para" in owner) {
|
|
2795
|
+
return __spreadValues({
|
|
2796
|
+
para: owner.para
|
|
2797
|
+
}, owner.address ? { address: owner.address } : {});
|
|
2756
2798
|
}
|
|
2757
|
-
return
|
|
2799
|
+
return null;
|
|
2800
|
+
}
|
|
2801
|
+
function getMissingOwnerState(plan, provider) {
|
|
2802
|
+
return {
|
|
2803
|
+
plan,
|
|
2804
|
+
AA: null,
|
|
2805
|
+
isPending: false,
|
|
2806
|
+
error: new Error(
|
|
2807
|
+
`${provider} AA account creation requires a signer or Para session.`
|
|
2808
|
+
)
|
|
2809
|
+
};
|
|
2758
2810
|
}
|
|
2759
2811
|
async function createAlchemyAAState(options) {
|
|
2760
2812
|
var _a3, _b;
|
|
2761
2813
|
const {
|
|
2762
2814
|
chain,
|
|
2763
|
-
|
|
2815
|
+
owner,
|
|
2764
2816
|
rpcUrl,
|
|
2765
2817
|
callList,
|
|
2766
2818
|
mode,
|
|
@@ -2771,7 +2823,9 @@ async function createAlchemyAAState(options) {
|
|
|
2771
2823
|
chainsById: { [chain.id]: chain },
|
|
2772
2824
|
modeOverride: mode,
|
|
2773
2825
|
throwOnMissingConfig: true,
|
|
2774
|
-
getPreferredRpcUrl: () => rpcUrl
|
|
2826
|
+
getPreferredRpcUrl: () => rpcUrl,
|
|
2827
|
+
apiKey: options.apiKey,
|
|
2828
|
+
gasPolicyId: options.gasPolicyId
|
|
2775
2829
|
});
|
|
2776
2830
|
if (!resolved) {
|
|
2777
2831
|
throw new Error("Alchemy AA config resolution failed.");
|
|
@@ -2782,17 +2836,18 @@ async function createAlchemyAAState(options) {
|
|
|
2782
2836
|
sponsorship: gasPolicyId ? resolved.plan.sponsorship : "disabled",
|
|
2783
2837
|
fallbackToEoa: false
|
|
2784
2838
|
});
|
|
2785
|
-
const
|
|
2839
|
+
const ownerParams = getOwnerParams(owner);
|
|
2840
|
+
if (!ownerParams) {
|
|
2841
|
+
return getMissingOwnerState(plan, "alchemy");
|
|
2842
|
+
}
|
|
2786
2843
|
try {
|
|
2787
|
-
const smartAccount = await createAlchemySmartAccount({
|
|
2788
|
-
para: void 0,
|
|
2789
|
-
signer,
|
|
2844
|
+
const smartAccount = await createAlchemySmartAccount(__spreadProps(__spreadValues({}, ownerParams), {
|
|
2790
2845
|
apiKey,
|
|
2791
2846
|
gasPolicyId,
|
|
2792
2847
|
chain,
|
|
2793
2848
|
rpcUrl,
|
|
2794
2849
|
mode: plan.mode
|
|
2795
|
-
});
|
|
2850
|
+
}));
|
|
2796
2851
|
if (!smartAccount) {
|
|
2797
2852
|
return {
|
|
2798
2853
|
plan,
|
|
@@ -2820,7 +2875,7 @@ async function createPimlicoAAState(options) {
|
|
|
2820
2875
|
var _a3;
|
|
2821
2876
|
const {
|
|
2822
2877
|
chain,
|
|
2823
|
-
|
|
2878
|
+
owner,
|
|
2824
2879
|
rpcUrl,
|
|
2825
2880
|
callList,
|
|
2826
2881
|
mode
|
|
@@ -2830,7 +2885,8 @@ async function createPimlicoAAState(options) {
|
|
|
2830
2885
|
chainsById: { [chain.id]: chain },
|
|
2831
2886
|
rpcUrl,
|
|
2832
2887
|
modeOverride: mode,
|
|
2833
|
-
throwOnMissingConfig: true
|
|
2888
|
+
throwOnMissingConfig: true,
|
|
2889
|
+
apiKey: options.apiKey
|
|
2834
2890
|
});
|
|
2835
2891
|
if (!resolved) {
|
|
2836
2892
|
throw new Error("Pimlico AA config resolution failed.");
|
|
@@ -2839,16 +2895,17 @@ async function createPimlicoAAState(options) {
|
|
|
2839
2895
|
const plan = __spreadProps(__spreadValues({}, resolved.plan), {
|
|
2840
2896
|
fallbackToEoa: false
|
|
2841
2897
|
});
|
|
2842
|
-
const
|
|
2898
|
+
const ownerParams = getOwnerParams(owner);
|
|
2899
|
+
if (!ownerParams) {
|
|
2900
|
+
return getMissingOwnerState(plan, "pimlico");
|
|
2901
|
+
}
|
|
2843
2902
|
try {
|
|
2844
|
-
const smartAccount = await createPimlicoSmartAccount({
|
|
2845
|
-
para: void 0,
|
|
2846
|
-
signer,
|
|
2903
|
+
const smartAccount = await createPimlicoSmartAccount(__spreadProps(__spreadValues({}, ownerParams), {
|
|
2847
2904
|
apiKey,
|
|
2848
2905
|
chain,
|
|
2849
2906
|
rpcUrl,
|
|
2850
2907
|
mode: plan.mode
|
|
2851
|
-
});
|
|
2908
|
+
}));
|
|
2852
2909
|
if (!smartAccount) {
|
|
2853
2910
|
return {
|
|
2854
2911
|
plan,
|
|
@@ -2915,7 +2972,7 @@ async function createCliProviderState(params) {
|
|
|
2915
2972
|
return createAAProviderState({
|
|
2916
2973
|
provider: decision.provider,
|
|
2917
2974
|
chain,
|
|
2918
|
-
privateKey,
|
|
2975
|
+
owner: { privateKey },
|
|
2919
2976
|
rpcUrl,
|
|
2920
2977
|
callList,
|
|
2921
2978
|
mode: decision.aaMode,
|
package/dist/index.cjs
CHANGED
|
@@ -1462,7 +1462,9 @@ function resolveAlchemyConfig(options) {
|
|
|
1462
1462
|
},
|
|
1463
1463
|
modeOverride,
|
|
1464
1464
|
publicOnly = false,
|
|
1465
|
-
throwOnMissingConfig = false
|
|
1465
|
+
throwOnMissingConfig = false,
|
|
1466
|
+
apiKey: preResolvedApiKey,
|
|
1467
|
+
gasPolicyId: preResolvedGasPolicyId
|
|
1466
1468
|
} = options;
|
|
1467
1469
|
if (!calls || localPrivateKey) {
|
|
1468
1470
|
return null;
|
|
@@ -1480,7 +1482,7 @@ function resolveAlchemyConfig(options) {
|
|
|
1480
1482
|
}
|
|
1481
1483
|
return null;
|
|
1482
1484
|
}
|
|
1483
|
-
const apiKey = readEnv(ALCHEMY_API_KEY_ENVS, { publicOnly });
|
|
1485
|
+
const apiKey = preResolvedApiKey != null ? preResolvedApiKey : readEnv(ALCHEMY_API_KEY_ENVS, { publicOnly });
|
|
1484
1486
|
if (!apiKey) {
|
|
1485
1487
|
if (throwOnMissingConfig) {
|
|
1486
1488
|
throw new Error("Alchemy AA requires ALCHEMY_API_KEY.");
|
|
@@ -1491,7 +1493,7 @@ function resolveAlchemyConfig(options) {
|
|
|
1491
1493
|
if (!chain) {
|
|
1492
1494
|
return null;
|
|
1493
1495
|
}
|
|
1494
|
-
const gasPolicyId = readGasPolicyEnv(
|
|
1496
|
+
const gasPolicyId = preResolvedGasPolicyId != null ? preResolvedGasPolicyId : readGasPolicyEnv(
|
|
1495
1497
|
chainConfig.chainId,
|
|
1496
1498
|
chainSlugById,
|
|
1497
1499
|
ALCHEMY_GAS_POLICY_ENVS,
|
|
@@ -1534,7 +1536,8 @@ function resolvePimlicoConfig(options) {
|
|
|
1534
1536
|
rpcUrl,
|
|
1535
1537
|
modeOverride,
|
|
1536
1538
|
publicOnly = false,
|
|
1537
|
-
throwOnMissingConfig = false
|
|
1539
|
+
throwOnMissingConfig = false,
|
|
1540
|
+
apiKey: preResolvedApiKey
|
|
1538
1541
|
} = options;
|
|
1539
1542
|
if (!calls || localPrivateKey) {
|
|
1540
1543
|
return null;
|
|
@@ -1552,7 +1555,7 @@ function resolvePimlicoConfig(options) {
|
|
|
1552
1555
|
}
|
|
1553
1556
|
return null;
|
|
1554
1557
|
}
|
|
1555
|
-
const apiKey = readEnv(PIMLICO_API_KEY_ENVS, { publicOnly });
|
|
1558
|
+
const apiKey = preResolvedApiKey != null ? preResolvedApiKey : readEnv(PIMLICO_API_KEY_ENVS, { publicOnly });
|
|
1556
1559
|
if (!apiKey) {
|
|
1557
1560
|
if (throwOnMissingConfig) {
|
|
1558
1561
|
throw new Error("Pimlico AA requires PIMLICO_API_KEY.");
|
|
@@ -1685,15 +1688,64 @@ var import_aa_pimlico = require("@getpara/aa-pimlico");
|
|
|
1685
1688
|
var import_accounts = require("viem/accounts");
|
|
1686
1689
|
async function createAAProviderState(options) {
|
|
1687
1690
|
if (options.provider === "alchemy") {
|
|
1688
|
-
return createAlchemyAAState(
|
|
1691
|
+
return createAlchemyAAState({
|
|
1692
|
+
chain: options.chain,
|
|
1693
|
+
owner: options.owner,
|
|
1694
|
+
rpcUrl: options.rpcUrl,
|
|
1695
|
+
callList: options.callList,
|
|
1696
|
+
mode: options.mode,
|
|
1697
|
+
apiKey: options.apiKey,
|
|
1698
|
+
gasPolicyId: options.gasPolicyId,
|
|
1699
|
+
sponsored: options.sponsored
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
return createPimlicoAAState({
|
|
1703
|
+
chain: options.chain,
|
|
1704
|
+
owner: options.owner,
|
|
1705
|
+
rpcUrl: options.rpcUrl,
|
|
1706
|
+
callList: options.callList,
|
|
1707
|
+
mode: options.mode,
|
|
1708
|
+
apiKey: options.apiKey
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
function getOwnerParams(owner) {
|
|
1712
|
+
if (!owner) {
|
|
1713
|
+
return null;
|
|
1714
|
+
}
|
|
1715
|
+
if ("privateKey" in owner) {
|
|
1716
|
+
return {
|
|
1717
|
+
para: void 0,
|
|
1718
|
+
signer: (0, import_accounts.privateKeyToAccount)(owner.privateKey)
|
|
1719
|
+
};
|
|
1689
1720
|
}
|
|
1690
|
-
|
|
1721
|
+
if ("signer" in owner) {
|
|
1722
|
+
return __spreadValues({
|
|
1723
|
+
para: owner.para,
|
|
1724
|
+
signer: owner.signer
|
|
1725
|
+
}, owner.address ? { address: owner.address } : {});
|
|
1726
|
+
}
|
|
1727
|
+
if ("para" in owner) {
|
|
1728
|
+
return __spreadValues({
|
|
1729
|
+
para: owner.para
|
|
1730
|
+
}, owner.address ? { address: owner.address } : {});
|
|
1731
|
+
}
|
|
1732
|
+
return null;
|
|
1733
|
+
}
|
|
1734
|
+
function getMissingOwnerState(plan, provider) {
|
|
1735
|
+
return {
|
|
1736
|
+
plan,
|
|
1737
|
+
AA: null,
|
|
1738
|
+
isPending: false,
|
|
1739
|
+
error: new Error(
|
|
1740
|
+
`${provider} AA account creation requires a signer or Para session.`
|
|
1741
|
+
)
|
|
1742
|
+
};
|
|
1691
1743
|
}
|
|
1692
1744
|
async function createAlchemyAAState(options) {
|
|
1693
1745
|
var _a, _b;
|
|
1694
1746
|
const {
|
|
1695
1747
|
chain,
|
|
1696
|
-
|
|
1748
|
+
owner,
|
|
1697
1749
|
rpcUrl,
|
|
1698
1750
|
callList,
|
|
1699
1751
|
mode,
|
|
@@ -1704,7 +1756,9 @@ async function createAlchemyAAState(options) {
|
|
|
1704
1756
|
chainsById: { [chain.id]: chain },
|
|
1705
1757
|
modeOverride: mode,
|
|
1706
1758
|
throwOnMissingConfig: true,
|
|
1707
|
-
getPreferredRpcUrl: () => rpcUrl
|
|
1759
|
+
getPreferredRpcUrl: () => rpcUrl,
|
|
1760
|
+
apiKey: options.apiKey,
|
|
1761
|
+
gasPolicyId: options.gasPolicyId
|
|
1708
1762
|
});
|
|
1709
1763
|
if (!resolved) {
|
|
1710
1764
|
throw new Error("Alchemy AA config resolution failed.");
|
|
@@ -1715,17 +1769,18 @@ async function createAlchemyAAState(options) {
|
|
|
1715
1769
|
sponsorship: gasPolicyId ? resolved.plan.sponsorship : "disabled",
|
|
1716
1770
|
fallbackToEoa: false
|
|
1717
1771
|
});
|
|
1718
|
-
const
|
|
1772
|
+
const ownerParams = getOwnerParams(owner);
|
|
1773
|
+
if (!ownerParams) {
|
|
1774
|
+
return getMissingOwnerState(plan, "alchemy");
|
|
1775
|
+
}
|
|
1719
1776
|
try {
|
|
1720
|
-
const smartAccount = await (0, import_aa_alchemy.createAlchemySmartAccount)({
|
|
1721
|
-
para: void 0,
|
|
1722
|
-
signer,
|
|
1777
|
+
const smartAccount = await (0, import_aa_alchemy.createAlchemySmartAccount)(__spreadProps(__spreadValues({}, ownerParams), {
|
|
1723
1778
|
apiKey,
|
|
1724
1779
|
gasPolicyId,
|
|
1725
1780
|
chain,
|
|
1726
1781
|
rpcUrl,
|
|
1727
1782
|
mode: plan.mode
|
|
1728
|
-
});
|
|
1783
|
+
}));
|
|
1729
1784
|
if (!smartAccount) {
|
|
1730
1785
|
return {
|
|
1731
1786
|
plan,
|
|
@@ -1753,7 +1808,7 @@ async function createPimlicoAAState(options) {
|
|
|
1753
1808
|
var _a;
|
|
1754
1809
|
const {
|
|
1755
1810
|
chain,
|
|
1756
|
-
|
|
1811
|
+
owner,
|
|
1757
1812
|
rpcUrl,
|
|
1758
1813
|
callList,
|
|
1759
1814
|
mode
|
|
@@ -1763,7 +1818,8 @@ async function createPimlicoAAState(options) {
|
|
|
1763
1818
|
chainsById: { [chain.id]: chain },
|
|
1764
1819
|
rpcUrl,
|
|
1765
1820
|
modeOverride: mode,
|
|
1766
|
-
throwOnMissingConfig: true
|
|
1821
|
+
throwOnMissingConfig: true,
|
|
1822
|
+
apiKey: options.apiKey
|
|
1767
1823
|
});
|
|
1768
1824
|
if (!resolved) {
|
|
1769
1825
|
throw new Error("Pimlico AA config resolution failed.");
|
|
@@ -1772,16 +1828,17 @@ async function createPimlicoAAState(options) {
|
|
|
1772
1828
|
const plan = __spreadProps(__spreadValues({}, resolved.plan), {
|
|
1773
1829
|
fallbackToEoa: false
|
|
1774
1830
|
});
|
|
1775
|
-
const
|
|
1831
|
+
const ownerParams = getOwnerParams(owner);
|
|
1832
|
+
if (!ownerParams) {
|
|
1833
|
+
return getMissingOwnerState(plan, "pimlico");
|
|
1834
|
+
}
|
|
1776
1835
|
try {
|
|
1777
|
-
const smartAccount = await (0, import_aa_pimlico.createPimlicoSmartAccount)({
|
|
1778
|
-
para: void 0,
|
|
1779
|
-
signer,
|
|
1836
|
+
const smartAccount = await (0, import_aa_pimlico.createPimlicoSmartAccount)(__spreadProps(__spreadValues({}, ownerParams), {
|
|
1780
1837
|
apiKey,
|
|
1781
1838
|
chain,
|
|
1782
1839
|
rpcUrl,
|
|
1783
1840
|
mode: plan.mode
|
|
1784
|
-
});
|
|
1841
|
+
}));
|
|
1785
1842
|
if (!smartAccount) {
|
|
1786
1843
|
return {
|
|
1787
1844
|
plan,
|