@aomi-labs/client 0.1.8 → 0.1.9
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 +58 -22
- package/dist/index.cjs +57 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +57 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2775,28 +2775,50 @@ async function createAAProviderState(options) {
|
|
|
2775
2775
|
apiKey: options.apiKey
|
|
2776
2776
|
});
|
|
2777
2777
|
}
|
|
2778
|
-
function
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
if ("privateKey" in owner) {
|
|
2783
|
-
return {
|
|
2778
|
+
function getDirectOwnerParams(owner) {
|
|
2779
|
+
return {
|
|
2780
|
+
kind: "ready",
|
|
2781
|
+
ownerParams: {
|
|
2784
2782
|
para: void 0,
|
|
2785
2783
|
signer: privateKeyToAccount(owner.privateKey)
|
|
2784
|
+
}
|
|
2785
|
+
};
|
|
2786
|
+
}
|
|
2787
|
+
function getParaSessionOwnerParams(owner) {
|
|
2788
|
+
if (owner.signer) {
|
|
2789
|
+
return {
|
|
2790
|
+
kind: "ready",
|
|
2791
|
+
ownerParams: __spreadValues({
|
|
2792
|
+
para: owner.session,
|
|
2793
|
+
signer: owner.signer
|
|
2794
|
+
}, owner.address ? { address: owner.address } : {})
|
|
2786
2795
|
};
|
|
2787
2796
|
}
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
}, owner.address ? { address: owner.address } : {})
|
|
2797
|
+
return {
|
|
2798
|
+
kind: "ready",
|
|
2799
|
+
ownerParams: __spreadValues({
|
|
2800
|
+
para: owner.session
|
|
2801
|
+
}, owner.address ? { address: owner.address } : {})
|
|
2802
|
+
};
|
|
2803
|
+
}
|
|
2804
|
+
function getSessionOwnerParams(owner) {
|
|
2805
|
+
switch (owner.adapter) {
|
|
2806
|
+
case "para":
|
|
2807
|
+
return getParaSessionOwnerParams(owner);
|
|
2808
|
+
default:
|
|
2809
|
+
return { kind: "unsupported_adapter", adapter: owner.adapter };
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
function getOwnerParams(owner) {
|
|
2813
|
+
if (!owner) {
|
|
2814
|
+
return { kind: "missing" };
|
|
2793
2815
|
}
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2816
|
+
switch (owner.kind) {
|
|
2817
|
+
case "direct":
|
|
2818
|
+
return getDirectOwnerParams(owner);
|
|
2819
|
+
case "session":
|
|
2820
|
+
return getSessionOwnerParams(owner);
|
|
2798
2821
|
}
|
|
2799
|
-
return null;
|
|
2800
2822
|
}
|
|
2801
2823
|
function getMissingOwnerState(plan, provider) {
|
|
2802
2824
|
return {
|
|
@@ -2804,10 +2826,18 @@ function getMissingOwnerState(plan, provider) {
|
|
|
2804
2826
|
AA: null,
|
|
2805
2827
|
isPending: false,
|
|
2806
2828
|
error: new Error(
|
|
2807
|
-
`${provider} AA account creation requires a
|
|
2829
|
+
`${provider} AA account creation requires a direct owner or a supported session owner.`
|
|
2808
2830
|
)
|
|
2809
2831
|
};
|
|
2810
2832
|
}
|
|
2833
|
+
function getUnsupportedAdapterState(plan, adapter) {
|
|
2834
|
+
return {
|
|
2835
|
+
plan,
|
|
2836
|
+
AA: null,
|
|
2837
|
+
isPending: false,
|
|
2838
|
+
error: new Error(`Session adapter "${adapter}" is not implemented.`)
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2811
2841
|
async function createAlchemyAAState(options) {
|
|
2812
2842
|
var _a3, _b;
|
|
2813
2843
|
const {
|
|
@@ -2837,11 +2867,14 @@ async function createAlchemyAAState(options) {
|
|
|
2837
2867
|
fallbackToEoa: false
|
|
2838
2868
|
});
|
|
2839
2869
|
const ownerParams = getOwnerParams(owner);
|
|
2840
|
-
if (
|
|
2870
|
+
if (ownerParams.kind === "missing") {
|
|
2841
2871
|
return getMissingOwnerState(plan, "alchemy");
|
|
2842
2872
|
}
|
|
2873
|
+
if (ownerParams.kind === "unsupported_adapter") {
|
|
2874
|
+
return getUnsupportedAdapterState(plan, ownerParams.adapter);
|
|
2875
|
+
}
|
|
2843
2876
|
try {
|
|
2844
|
-
const smartAccount = await createAlchemySmartAccount(__spreadProps(__spreadValues({}, ownerParams), {
|
|
2877
|
+
const smartAccount = await createAlchemySmartAccount(__spreadProps(__spreadValues({}, ownerParams.ownerParams), {
|
|
2845
2878
|
apiKey,
|
|
2846
2879
|
gasPolicyId,
|
|
2847
2880
|
chain,
|
|
@@ -2896,11 +2929,14 @@ async function createPimlicoAAState(options) {
|
|
|
2896
2929
|
fallbackToEoa: false
|
|
2897
2930
|
});
|
|
2898
2931
|
const ownerParams = getOwnerParams(owner);
|
|
2899
|
-
if (
|
|
2932
|
+
if (ownerParams.kind === "missing") {
|
|
2900
2933
|
return getMissingOwnerState(plan, "pimlico");
|
|
2901
2934
|
}
|
|
2935
|
+
if (ownerParams.kind === "unsupported_adapter") {
|
|
2936
|
+
return getUnsupportedAdapterState(plan, ownerParams.adapter);
|
|
2937
|
+
}
|
|
2902
2938
|
try {
|
|
2903
|
-
const smartAccount = await createPimlicoSmartAccount(__spreadProps(__spreadValues({}, ownerParams), {
|
|
2939
|
+
const smartAccount = await createPimlicoSmartAccount(__spreadProps(__spreadValues({}, ownerParams.ownerParams), {
|
|
2904
2940
|
apiKey,
|
|
2905
2941
|
chain,
|
|
2906
2942
|
rpcUrl,
|
|
@@ -2972,7 +3008,7 @@ async function createCliProviderState(params) {
|
|
|
2972
3008
|
return createAAProviderState({
|
|
2973
3009
|
provider: decision.provider,
|
|
2974
3010
|
chain,
|
|
2975
|
-
owner: { privateKey },
|
|
3011
|
+
owner: { kind: "direct", privateKey },
|
|
2976
3012
|
rpcUrl,
|
|
2977
3013
|
callList,
|
|
2978
3014
|
mode: decision.aaMode,
|
package/dist/index.cjs
CHANGED
|
@@ -1708,28 +1708,50 @@ async function createAAProviderState(options) {
|
|
|
1708
1708
|
apiKey: options.apiKey
|
|
1709
1709
|
});
|
|
1710
1710
|
}
|
|
1711
|
-
function
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
if ("privateKey" in owner) {
|
|
1716
|
-
return {
|
|
1711
|
+
function getDirectOwnerParams(owner) {
|
|
1712
|
+
return {
|
|
1713
|
+
kind: "ready",
|
|
1714
|
+
ownerParams: {
|
|
1717
1715
|
para: void 0,
|
|
1718
1716
|
signer: (0, import_accounts.privateKeyToAccount)(owner.privateKey)
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
}
|
|
1720
|
+
function getParaSessionOwnerParams(owner) {
|
|
1721
|
+
if (owner.signer) {
|
|
1722
|
+
return {
|
|
1723
|
+
kind: "ready",
|
|
1724
|
+
ownerParams: __spreadValues({
|
|
1725
|
+
para: owner.session,
|
|
1726
|
+
signer: owner.signer
|
|
1727
|
+
}, owner.address ? { address: owner.address } : {})
|
|
1719
1728
|
};
|
|
1720
1729
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
}, owner.address ? { address: owner.address } : {})
|
|
1730
|
+
return {
|
|
1731
|
+
kind: "ready",
|
|
1732
|
+
ownerParams: __spreadValues({
|
|
1733
|
+
para: owner.session
|
|
1734
|
+
}, owner.address ? { address: owner.address } : {})
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
function getSessionOwnerParams(owner) {
|
|
1738
|
+
switch (owner.adapter) {
|
|
1739
|
+
case "para":
|
|
1740
|
+
return getParaSessionOwnerParams(owner);
|
|
1741
|
+
default:
|
|
1742
|
+
return { kind: "unsupported_adapter", adapter: owner.adapter };
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
function getOwnerParams(owner) {
|
|
1746
|
+
if (!owner) {
|
|
1747
|
+
return { kind: "missing" };
|
|
1726
1748
|
}
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1749
|
+
switch (owner.kind) {
|
|
1750
|
+
case "direct":
|
|
1751
|
+
return getDirectOwnerParams(owner);
|
|
1752
|
+
case "session":
|
|
1753
|
+
return getSessionOwnerParams(owner);
|
|
1731
1754
|
}
|
|
1732
|
-
return null;
|
|
1733
1755
|
}
|
|
1734
1756
|
function getMissingOwnerState(plan, provider) {
|
|
1735
1757
|
return {
|
|
@@ -1737,10 +1759,18 @@ function getMissingOwnerState(plan, provider) {
|
|
|
1737
1759
|
AA: null,
|
|
1738
1760
|
isPending: false,
|
|
1739
1761
|
error: new Error(
|
|
1740
|
-
`${provider} AA account creation requires a
|
|
1762
|
+
`${provider} AA account creation requires a direct owner or a supported session owner.`
|
|
1741
1763
|
)
|
|
1742
1764
|
};
|
|
1743
1765
|
}
|
|
1766
|
+
function getUnsupportedAdapterState(plan, adapter) {
|
|
1767
|
+
return {
|
|
1768
|
+
plan,
|
|
1769
|
+
AA: null,
|
|
1770
|
+
isPending: false,
|
|
1771
|
+
error: new Error(`Session adapter "${adapter}" is not implemented.`)
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1744
1774
|
async function createAlchemyAAState(options) {
|
|
1745
1775
|
var _a, _b;
|
|
1746
1776
|
const {
|
|
@@ -1770,11 +1800,14 @@ async function createAlchemyAAState(options) {
|
|
|
1770
1800
|
fallbackToEoa: false
|
|
1771
1801
|
});
|
|
1772
1802
|
const ownerParams = getOwnerParams(owner);
|
|
1773
|
-
if (
|
|
1803
|
+
if (ownerParams.kind === "missing") {
|
|
1774
1804
|
return getMissingOwnerState(plan, "alchemy");
|
|
1775
1805
|
}
|
|
1806
|
+
if (ownerParams.kind === "unsupported_adapter") {
|
|
1807
|
+
return getUnsupportedAdapterState(plan, ownerParams.adapter);
|
|
1808
|
+
}
|
|
1776
1809
|
try {
|
|
1777
|
-
const smartAccount = await (0, import_aa_alchemy.createAlchemySmartAccount)(__spreadProps(__spreadValues({}, ownerParams), {
|
|
1810
|
+
const smartAccount = await (0, import_aa_alchemy.createAlchemySmartAccount)(__spreadProps(__spreadValues({}, ownerParams.ownerParams), {
|
|
1778
1811
|
apiKey,
|
|
1779
1812
|
gasPolicyId,
|
|
1780
1813
|
chain,
|
|
@@ -1829,11 +1862,14 @@ async function createPimlicoAAState(options) {
|
|
|
1829
1862
|
fallbackToEoa: false
|
|
1830
1863
|
});
|
|
1831
1864
|
const ownerParams = getOwnerParams(owner);
|
|
1832
|
-
if (
|
|
1865
|
+
if (ownerParams.kind === "missing") {
|
|
1833
1866
|
return getMissingOwnerState(plan, "pimlico");
|
|
1834
1867
|
}
|
|
1868
|
+
if (ownerParams.kind === "unsupported_adapter") {
|
|
1869
|
+
return getUnsupportedAdapterState(plan, ownerParams.adapter);
|
|
1870
|
+
}
|
|
1835
1871
|
try {
|
|
1836
|
-
const smartAccount = await (0, import_aa_pimlico.createPimlicoSmartAccount)(__spreadProps(__spreadValues({}, ownerParams), {
|
|
1872
|
+
const smartAccount = await (0, import_aa_pimlico.createPimlicoSmartAccount)(__spreadProps(__spreadValues({}, ownerParams.ownerParams), {
|
|
1837
1873
|
apiKey,
|
|
1838
1874
|
chain,
|
|
1839
1875
|
rpcUrl,
|