@aomi-labs/client 0.1.18 → 0.1.19
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 +109 -15
- package/dist/index.cjs +71 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +71 -4
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.cts
CHANGED
|
@@ -287,10 +287,19 @@ declare class AomiClient {
|
|
|
287
287
|
created: boolean;
|
|
288
288
|
}>;
|
|
289
289
|
/**
|
|
290
|
-
* Simulate
|
|
290
|
+
* Simulate transactions as an atomic batch.
|
|
291
291
|
* Each tx sees state changes from previous txs (e.g., approve → swap).
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
* Sends full tx payloads — the backend does not look up by ID.
|
|
293
|
+
*/
|
|
294
|
+
simulateBatch(sessionId: string, transactions: Array<{
|
|
295
|
+
to: string;
|
|
296
|
+
value?: string;
|
|
297
|
+
data?: string;
|
|
298
|
+
label?: string;
|
|
299
|
+
}>, options?: {
|
|
300
|
+
from?: string;
|
|
301
|
+
chainId?: number;
|
|
302
|
+
}): Promise<AomiSimulateResponse>;
|
|
294
303
|
}
|
|
295
304
|
|
|
296
305
|
type Listener<T = unknown> = (payload: T) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -287,10 +287,19 @@ declare class AomiClient {
|
|
|
287
287
|
created: boolean;
|
|
288
288
|
}>;
|
|
289
289
|
/**
|
|
290
|
-
* Simulate
|
|
290
|
+
* Simulate transactions as an atomic batch.
|
|
291
291
|
* Each tx sees state changes from previous txs (e.g., approve → swap).
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
* Sends full tx payloads — the backend does not look up by ID.
|
|
293
|
+
*/
|
|
294
|
+
simulateBatch(sessionId: string, transactions: Array<{
|
|
295
|
+
to: string;
|
|
296
|
+
value?: string;
|
|
297
|
+
data?: string;
|
|
298
|
+
label?: string;
|
|
299
|
+
}>, options?: {
|
|
300
|
+
from?: string;
|
|
301
|
+
chainId?: number;
|
|
302
|
+
}): Promise<AomiSimulateResponse>;
|
|
294
303
|
}
|
|
295
304
|
|
|
296
305
|
type Listener<T = unknown> = (payload: T) => void;
|
package/dist/index.js
CHANGED
|
@@ -557,10 +557,11 @@ var AomiClient = class {
|
|
|
557
557
|
// Batch Simulation
|
|
558
558
|
// ===========================================================================
|
|
559
559
|
/**
|
|
560
|
-
* Simulate
|
|
560
|
+
* Simulate transactions as an atomic batch.
|
|
561
561
|
* Each tx sees state changes from previous txs (e.g., approve → swap).
|
|
562
|
+
* Sends full tx payloads — the backend does not look up by ID.
|
|
562
563
|
*/
|
|
563
|
-
async simulateBatch(sessionId,
|
|
564
|
+
async simulateBatch(sessionId, transactions, options) {
|
|
564
565
|
const url = joinApiPath(this.baseUrl, "/api/simulate");
|
|
565
566
|
const headers = new Headers(
|
|
566
567
|
withSessionHeader(sessionId, { "Content-Type": "application/json" })
|
|
@@ -568,13 +569,20 @@ var AomiClient = class {
|
|
|
568
569
|
if (this.apiKey) {
|
|
569
570
|
headers.set(API_KEY_HEADER, this.apiKey);
|
|
570
571
|
}
|
|
572
|
+
const payload = {
|
|
573
|
+
transactions,
|
|
574
|
+
from: options == null ? void 0 : options.from,
|
|
575
|
+
chain_id: options == null ? void 0 : options.chainId
|
|
576
|
+
};
|
|
571
577
|
const response = await fetch(url, {
|
|
572
578
|
method: "POST",
|
|
573
579
|
headers,
|
|
574
|
-
body: JSON.stringify(
|
|
580
|
+
body: JSON.stringify(payload)
|
|
575
581
|
});
|
|
576
582
|
if (!response.ok) {
|
|
577
|
-
|
|
583
|
+
const body = await response.text().catch(() => "");
|
|
584
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}${body ? `
|
|
585
|
+
${body}` : ""}`);
|
|
578
586
|
}
|
|
579
587
|
return await response.json();
|
|
580
588
|
}
|
|
@@ -1919,6 +1927,25 @@ async function createAlchemyAAState(options) {
|
|
|
1919
1927
|
if (ownerParams.kind === "unsupported_adapter") {
|
|
1920
1928
|
return getUnsupportedAdapterState(plan, ownerParams.adapter);
|
|
1921
1929
|
}
|
|
1930
|
+
if (owner.kind === "direct") {
|
|
1931
|
+
try {
|
|
1932
|
+
return await createAlchemyWalletApisState({
|
|
1933
|
+
plan,
|
|
1934
|
+
chain,
|
|
1935
|
+
privateKey: owner.privateKey,
|
|
1936
|
+
apiKey,
|
|
1937
|
+
gasPolicyId,
|
|
1938
|
+
mode: plan.mode
|
|
1939
|
+
});
|
|
1940
|
+
} catch (error) {
|
|
1941
|
+
return {
|
|
1942
|
+
plan,
|
|
1943
|
+
AA: null,
|
|
1944
|
+
isPending: false,
|
|
1945
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
1946
|
+
};
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1922
1949
|
try {
|
|
1923
1950
|
const smartAccount = await createAlchemySmartAccount(__spreadProps(__spreadValues({}, ownerParams.ownerParams), {
|
|
1924
1951
|
apiKey,
|
|
@@ -1950,6 +1977,46 @@ async function createAlchemyAAState(options) {
|
|
|
1950
1977
|
};
|
|
1951
1978
|
}
|
|
1952
1979
|
}
|
|
1980
|
+
async function createAlchemyWalletApisState(params) {
|
|
1981
|
+
const { createSmartWalletClient, alchemyWalletTransport } = await import("@alchemy/wallet-apis");
|
|
1982
|
+
const signer = privateKeyToAccount(params.privateKey);
|
|
1983
|
+
const walletClient = createSmartWalletClient(__spreadValues({
|
|
1984
|
+
transport: alchemyWalletTransport({ apiKey: params.apiKey }),
|
|
1985
|
+
chain: params.chain,
|
|
1986
|
+
signer
|
|
1987
|
+
}, params.gasPolicyId ? { paymaster: { policyId: params.gasPolicyId } } : {}));
|
|
1988
|
+
let accountAddress = signer.address;
|
|
1989
|
+
if (params.mode === "4337") {
|
|
1990
|
+
const account = await walletClient.requestAccount();
|
|
1991
|
+
accountAddress = account.address;
|
|
1992
|
+
}
|
|
1993
|
+
const sendCalls = async (calls) => {
|
|
1994
|
+
var _a, _b;
|
|
1995
|
+
const result = await walletClient.sendCalls(__spreadProps(__spreadValues({}, params.mode === "4337" ? { account: accountAddress } : {}), {
|
|
1996
|
+
calls
|
|
1997
|
+
}));
|
|
1998
|
+
const status = await walletClient.waitForCallsStatus({ id: result.id });
|
|
1999
|
+
const transactionHash = (_b = (_a = status.receipts) == null ? void 0 : _a[0]) == null ? void 0 : _b.transactionHash;
|
|
2000
|
+
if (!transactionHash) {
|
|
2001
|
+
throw new Error("Alchemy Wallets API did not return a transaction hash.");
|
|
2002
|
+
}
|
|
2003
|
+
return { transactionHash };
|
|
2004
|
+
};
|
|
2005
|
+
const AA = {
|
|
2006
|
+
provider: "alchemy",
|
|
2007
|
+
mode: params.mode,
|
|
2008
|
+
AAAddress: accountAddress,
|
|
2009
|
+
delegationAddress: params.mode === "7702" ? signer.address : void 0,
|
|
2010
|
+
sendTransaction: async (call) => sendCalls([call]),
|
|
2011
|
+
sendBatchTransaction: async (calls) => sendCalls(calls)
|
|
2012
|
+
};
|
|
2013
|
+
return {
|
|
2014
|
+
plan: params.plan,
|
|
2015
|
+
AA,
|
|
2016
|
+
isPending: false,
|
|
2017
|
+
error: null
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
1953
2020
|
async function createPimlicoAAState(options) {
|
|
1954
2021
|
var _a;
|
|
1955
2022
|
const {
|