@aa-sdk/core 4.0.0-alpha.0 → 4.0.0-alpha.1
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/cjs/account/simple.js.map +1 -1
- package/dist/cjs/account/smartContractAccount.js +2 -1
- package/dist/cjs/account/smartContractAccount.js.map +1 -1
- package/dist/cjs/actions/smartAccount/buildUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/sendTransaction.js.map +1 -1
- package/dist/cjs/actions/smartAccount/sendTransactions.js.map +1 -1
- package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
- package/dist/cjs/client/bundlerClient.js.map +1 -1
- package/dist/cjs/client/decorators/bundlerClient.js.map +1 -1
- package/dist/cjs/client/decorators/smartAccountClient.js.map +1 -1
- package/dist/cjs/client/smartAccountClient.js.map +1 -1
- package/dist/cjs/ens/utils.js.map +1 -1
- package/dist/cjs/entrypoint/index.js.map +1 -1
- package/dist/cjs/errors/account.js.map +1 -1
- package/dist/cjs/errors/base.js.map +1 -1
- package/dist/cjs/errors/client.js.map +1 -1
- package/dist/cjs/errors/entrypoint.js.map +1 -1
- package/dist/cjs/errors/signer.js.map +1 -1
- package/dist/cjs/errors/transaction.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +2 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logger.js.map +1 -1
- package/dist/cjs/middleware/defaults/feeEstimator.d.ts +1 -1
- package/dist/cjs/middleware/defaults/feeEstimator.js +17 -15
- package/dist/cjs/middleware/defaults/feeEstimator.js.map +1 -1
- package/dist/cjs/middleware/defaults/paymasterAndData.js.map +1 -1
- package/dist/cjs/middleware/defaults/userOpSigner.js.map +1 -1
- package/dist/cjs/signer/local-account.js.map +1 -1
- package/dist/cjs/signer/schema.js.map +1 -1
- package/dist/cjs/signer/utils.d.ts +1 -9
- package/dist/cjs/signer/utils.js +1 -16
- package/dist/cjs/signer/utils.js.map +1 -1
- package/dist/cjs/signer/wallet-client.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +0 -1
- package/dist/cjs/utils/index.js +1 -9
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/account/simple.js.map +1 -1
- package/dist/esm/account/smartContractAccount.js +2 -1
- package/dist/esm/account/smartContractAccount.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
- package/dist/esm/client/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/ens/utils.js.map +1 -1
- package/dist/esm/entrypoint/index.js.map +1 -1
- package/dist/esm/errors/account.js.map +1 -1
- package/dist/esm/errors/base.js.map +1 -1
- package/dist/esm/errors/client.js.map +1 -1
- package/dist/esm/errors/entrypoint.js.map +1 -1
- package/dist/esm/errors/signer.js.map +1 -1
- package/dist/esm/errors/transaction.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/middleware/defaults/feeEstimator.d.ts +1 -1
- package/dist/esm/middleware/defaults/feeEstimator.js +17 -15
- package/dist/esm/middleware/defaults/feeEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/paymasterAndData.js.map +1 -1
- package/dist/esm/middleware/defaults/userOpSigner.js.map +1 -1
- package/dist/esm/signer/local-account.js.map +1 -1
- package/dist/esm/signer/schema.js.map +1 -1
- package/dist/esm/signer/utils.d.ts +1 -9
- package/dist/esm/signer/utils.js +0 -14
- package/dist/esm/signer/utils.js.map +1 -1
- package/dist/esm/signer/wallet-client.js.map +1 -1
- package/dist/esm/utils/index.d.ts +0 -1
- package/dist/esm/utils/index.js +0 -7
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/account/smartContractAccount.d.ts +49 -0
- package/dist/types/account/smartContractAccount.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperation.d.ts +23 -0
- package/dist/types/actions/smartAccount/buildUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts +22 -0
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendTransaction.d.ts +24 -0
- package/dist/types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendTransactions.d.ts +23 -0
- package/dist/types/actions/smartAccount/sendTransactions.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts +24 -0
- package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts.map +1 -1
- package/dist/types/client/bundlerClient.d.ts +15 -0
- package/dist/types/client/bundlerClient.d.ts.map +1 -1
- package/dist/types/client/decorators/bundlerClient.d.ts +9 -0
- package/dist/types/client/decorators/bundlerClient.d.ts.map +1 -1
- package/dist/types/client/decorators/smartAccountClient.d.ts +8 -0
- package/dist/types/client/decorators/smartAccountClient.d.ts.map +1 -1
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/ens/utils.d.ts +45 -0
- package/dist/types/ens/utils.d.ts.map +1 -1
- package/dist/types/entrypoint/index.d.ts +14 -0
- package/dist/types/entrypoint/index.d.ts.map +1 -1
- package/dist/types/errors/account.d.ts +34 -0
- package/dist/types/errors/account.d.ts.map +1 -1
- package/dist/types/errors/base.d.ts +5 -0
- package/dist/types/errors/base.d.ts.map +1 -1
- package/dist/types/errors/client.d.ts +9 -0
- package/dist/types/errors/client.d.ts.map +1 -1
- package/dist/types/errors/entrypoint.d.ts +6 -0
- package/dist/types/errors/entrypoint.d.ts.map +1 -1
- package/dist/types/errors/signer.d.ts +3 -0
- package/dist/types/errors/signer.d.ts.map +1 -1
- package/dist/types/errors/transaction.d.ts +6 -0
- package/dist/types/errors/transaction.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logger.d.ts +3 -0
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/middleware/defaults/feeEstimator.d.ts +21 -1
- package/dist/types/middleware/defaults/feeEstimator.d.ts.map +1 -1
- package/dist/types/middleware/defaults/paymasterAndData.d.ts +8 -0
- package/dist/types/middleware/defaults/paymasterAndData.d.ts.map +1 -1
- package/dist/types/middleware/defaults/userOpSigner.d.ts +10 -0
- package/dist/types/middleware/defaults/userOpSigner.d.ts.map +1 -1
- package/dist/types/signer/local-account.d.ts +3 -0
- package/dist/types/signer/local-account.d.ts.map +1 -1
- package/dist/types/signer/schema.d.ts +14 -0
- package/dist/types/signer/schema.d.ts.map +1 -1
- package/dist/types/signer/utils.d.ts +21 -9
- package/dist/types/signer/utils.d.ts.map +1 -1
- package/dist/types/signer/wallet-client.d.ts +3 -0
- package/dist/types/signer/wallet-client.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +54 -1
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/account/simple.ts +6 -0
- package/src/account/smartContractAccount.ts +120 -15
- package/src/actions/smartAccount/buildUserOperation.ts +23 -0
- package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +22 -0
- package/src/actions/smartAccount/sendTransaction.ts +24 -0
- package/src/actions/smartAccount/sendTransactions.ts +23 -0
- package/src/actions/smartAccount/waitForUserOperationTransacation.ts +24 -0
- package/src/client/bundlerClient.ts +32 -0
- package/src/client/decorators/bundlerClient.ts +9 -0
- package/src/client/decorators/smartAccountClient.ts +8 -0
- package/src/client/smartAccountClient.ts +41 -0
- package/src/ens/utils.ts +45 -0
- package/src/entrypoint/index.ts +30 -62
- package/src/errors/account.ts +34 -0
- package/src/errors/base.ts +5 -2
- package/src/errors/client.ts +9 -0
- package/src/errors/entrypoint.ts +6 -0
- package/src/errors/signer.ts +3 -0
- package/src/errors/transaction.ts +6 -0
- package/src/index.ts +1 -5
- package/src/logger.ts +3 -0
- package/src/middleware/defaults/feeEstimator.ts +24 -4
- package/src/middleware/defaults/paymasterAndData.ts +8 -0
- package/src/middleware/defaults/userOpSigner.ts +10 -0
- package/src/signer/local-account.ts +3 -0
- package/src/signer/schema.ts +14 -0
- package/src/signer/utils.ts +20 -32
- package/src/signer/wallet-client.ts +3 -0
- package/src/utils/index.ts +54 -13
- package/src/version.ts +1 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type HDAccount, type HDOptions, type Hex, type LocalAccount, type PrivateKeyAccount, type SignableMessage, type TypedDataDefinition } from "viem";
|
|
2
2
|
import type { SmartAccountSigner } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.
|
|
5
|
+
*/
|
|
3
6
|
export declare class LocalAccountSigner<T extends HDAccount | PrivateKeyAccount | LocalAccount> implements SmartAccountSigner<T> {
|
|
4
7
|
inner: T;
|
|
5
8
|
signerType: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-account.d.ts","sourceRoot":"","sources":["../../../src/signer/local-account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EAEpB,KAAK,mBAAmB,EACzB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,qBAAa,kBAAkB,CAC7B,CAAC,SAAS,SAAS,GAAG,iBAAiB,GAAG,YAAY,CACtD,YAAW,kBAAkB,CAAC,CAAC,CAAC;IAEhC,KAAK,EAAE,CAAC,CAAC;IACT,UAAU,EAAE,MAAM,CAAC;gBAEP,KAAK,EAAE,CAAC;IAKpB,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAIxE;IAEF,QAAQ,CAAC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uGAKnB,QAAQ,GAAG,CAAC,CAEb;IAEF,QAAQ,CAAC,UAAU,EAAE,MAAM,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAE/C;IAEF,MAAM,CAAC,uBAAuB,CAC5B,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,SAAS,GACf,kBAAkB,CAAC,SAAS,CAAC;IAKhC,MAAM,CAAC,yBAAyB,CAC9B,GAAG,EAAE,GAAG,GACP,kBAAkB,CAAC,iBAAiB,CAAC;CAIzC"}
|
|
1
|
+
{"version":3,"file":"local-account.d.ts","sourceRoot":"","sources":["../../../src/signer/local-account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EAEpB,KAAK,mBAAmB,EACzB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;GAEG;AACH,qBAAa,kBAAkB,CAC7B,CAAC,SAAS,SAAS,GAAG,iBAAiB,GAAG,YAAY,CACtD,YAAW,kBAAkB,CAAC,CAAC,CAAC;IAEhC,KAAK,EAAE,CAAC,CAAC;IACT,UAAU,EAAE,MAAM,CAAC;gBAEP,KAAK,EAAE,CAAC;IAKpB,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAIxE;IAEF,QAAQ,CAAC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uGAKnB,QAAQ,GAAG,CAAC,CAEb;IAEF,QAAQ,CAAC,UAAU,EAAE,MAAM,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAE/C;IAEF,MAAM,CAAC,uBAAuB,CAC5B,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,SAAS,GACf,kBAAkB,CAAC,SAAS,CAAC;IAKhC,MAAM,CAAC,yBAAyB,CAC9B,GAAG,EAAE,GAAG,GACP,kBAAkB,CAAC,iBAAiB,CAAC;CAIzC"}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { SmartAccountSigner } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the provided object is a `SmartAccountSigner`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { isSigner, LocalAccountSigner } from "@aa-sdk/core";
|
|
9
|
+
*
|
|
10
|
+
* const signer = new LocalAccountSigner(...);
|
|
11
|
+
* console.log(isSigner(signer)); // true
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param {any} signer the object to check
|
|
15
|
+
* @returns {boolean} A boolean indicating whether the object is a `SmartAccountSigner`
|
|
16
|
+
*/
|
|
3
17
|
export declare const isSigner: (signer: any) => signer is SmartAccountSigner<any>;
|
|
4
18
|
export declare const SignerSchema: z.ZodType<SmartAccountSigner<any>, z.ZodTypeDef, SmartAccountSigner<any>>;
|
|
5
19
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/signer/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,eAAO,MAAM,QAAQ,WAAY,GAAG,sCAUnC,CAAC;AAEF,eAAO,MAAM,YAAY,2EAAyC,CAAC"}
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/signer/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,WAAY,GAAG,sCAUnC,CAAC;AAEF,eAAO,MAAM,YAAY,2EAAyC,CAAC"}
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import { type Address, type Hash, type Hex
|
|
1
|
+
import { type Address, type Hash, type Hex } from "viem";
|
|
2
2
|
export type SignWith6492Params = {
|
|
3
3
|
factoryAddress: Address;
|
|
4
4
|
factoryCalldata: Hex;
|
|
5
5
|
signature: Hash;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a given signature with additional data following the EIP-6492 standard.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { wrapSignatureWith6492 } from "@aa-sdk/core";
|
|
13
|
+
*
|
|
14
|
+
* const signature = wrapSignatureWith6492({
|
|
15
|
+
* factoryAddress: "0x...",
|
|
16
|
+
* factoryCalldata: "0x...",
|
|
17
|
+
* signature: "0x...",
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param {SignWith6492Params} params The parameters to wrap the signature
|
|
22
|
+
* @param {Hex} params.factoryAddress The address of the factory
|
|
23
|
+
* @param {Hex} params.factoryCalldata The calldata for the factory
|
|
24
|
+
* @param {Hex} params.signature The original signature that needs to be wrapped
|
|
25
|
+
* @returns {Hash} The wrapped signature
|
|
26
|
+
*/
|
|
13
27
|
export declare const wrapSignatureWith6492: ({ factoryAddress, factoryCalldata, signature, }: SignWith6492Params) => Hash;
|
|
14
|
-
export declare const verifyEIP6492Signature: ({ signer, hash, signature, client, }: VerifyEIP6492SignatureParams) => Promise<boolean>;
|
|
15
|
-
export {};
|
|
16
28
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/signer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/signer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAEd,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,GAAG,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,qBAAqB,oDAI/B,kBAAkB,KAAG,IAgBvB,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type Hex, type SignableMessage, type TypedDataDefinition, type WalletClient } from "viem";
|
|
2
2
|
import type { SmartAccountSigner } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.
|
|
5
|
+
*/
|
|
3
6
|
export declare class WalletClientSigner implements SmartAccountSigner<WalletClient> {
|
|
4
7
|
signerType: string;
|
|
5
8
|
inner: WalletClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-client.d.ts","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,eAAe,EAEpB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,qBAAa,kBAAmB,YAAW,kBAAkB,CAAC,YAAY,CAAC;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;gBAER,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM;IAQpD,UAAU,EAAE,MAAM,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAGtC;IAEF,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAKtE;IAEJ,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0GAKV,QAAQ,GAAG,CAAC,CAOb;CACH"}
|
|
1
|
+
{"version":3,"file":"wallet-client.d.ts","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,eAAe,EAEpB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;GAEG;AACH,qBAAa,kBAAmB,YAAW,kBAAkB,CAAC,YAAY,CAAC;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;gBAER,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM;IAQpD,UAAU,EAAE,MAAM,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAGtC;IAEF,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAKtE;IAEJ,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0GAKV,QAAQ,GAAG,CAAC,CAOb;CACH"}
|
|
@@ -34,8 +34,41 @@ export declare function resolveProperties<T>(object: Deferrable<T>): Promise<T>;
|
|
|
34
34
|
* @returns object with all of its values hexlified
|
|
35
35
|
*/
|
|
36
36
|
export declare function deepHexlify(obj: any): any;
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Filters out properties with undefined or null values from the provided object.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { filterUndefined } from "@aa-sdk/core";
|
|
43
|
+
*
|
|
44
|
+
* const result = filterUndefined({
|
|
45
|
+
* foo: undefined,
|
|
46
|
+
* bar: null,
|
|
47
|
+
* baz: "baz",
|
|
48
|
+
* }); // { baz: "baz" }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param {T} obj the object from which to remove properties with undefined or null values
|
|
52
|
+
* @returns {T} the object with undefined or null properties removed
|
|
53
|
+
*/
|
|
38
54
|
export declare function filterUndefined<T>(obj: T): T;
|
|
55
|
+
/**
|
|
56
|
+
* Picks the specified keys from an object and returns a new object containing only those key-value pairs.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { pick } from "@aa-sdk/core";
|
|
61
|
+
*
|
|
62
|
+
* const picked = pick({
|
|
63
|
+
* foo: "foo",
|
|
64
|
+
* bar: "bar",
|
|
65
|
+
* }, ["foo"]); // { foo: "foo" }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @param {Record<string, unknown>} obj The object from which to pick keys
|
|
69
|
+
* @param {string|string[]} keys A single key or an array of keys to pick from the object
|
|
70
|
+
* @returns {Record<string, unknown>} A new object containing only the picked key-value pairs
|
|
71
|
+
*/
|
|
39
72
|
export declare function pick(obj: Record<string, unknown>, keys: string | string[]): {};
|
|
40
73
|
/**
|
|
41
74
|
* Utility method for checking if the passed in values are all equal (strictly)
|
|
@@ -53,6 +86,26 @@ export declare const allEqual: (...params: any[]) => boolean;
|
|
|
53
86
|
* @returns the value if condition holds true, undefined if not
|
|
54
87
|
*/
|
|
55
88
|
export declare const conditionalReturn: <T>(condition: Promise<boolean>, value: () => Promise<T>) => Promise<T | undefined>;
|
|
89
|
+
/**
|
|
90
|
+
* Converts an array of objects into a record (object) where each key is determined by the specified selector and the value is determined by the provided function.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* import { toRecord } from "@aa-sdk/core";
|
|
95
|
+
* import { sepolia, mainnet } from "viem/chains";
|
|
96
|
+
*
|
|
97
|
+
* const addressesByChain = toRecord(
|
|
98
|
+
* [sepolia, mainnet],
|
|
99
|
+
* "id",
|
|
100
|
+
* () => "0x..."
|
|
101
|
+
* ); // { [sepolia.id]: "0x...", [mainnet.id]: "0x..." }
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @param {T[]} array The array of objects to convert to a record
|
|
105
|
+
* @param {K} selector The key used to select the property that will become the record's key
|
|
106
|
+
* @param {(item: T) => V} fn The function that transforms each item in the array into the record's value
|
|
107
|
+
* @returns {Record<T[K], V>} The resulting record object
|
|
108
|
+
*/
|
|
56
109
|
export declare const toRecord: <T extends { [K in RecordableKeys<T>]: string | number | symbol; }, K_1 extends RecordableKeys<T>, V>(array: T[], selector: K_1, fn: (item: T) => V) => Record<T[K_1], V>;
|
|
57
110
|
export * from "./bigint.js";
|
|
58
111
|
export * from "./bytes.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAIlC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,eAAO,MAAM,eAAe,oBAE3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,YAAa,MAAM,KAAG,KAO1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,iJAQnB,CAAC;AAGJ,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAc5E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAqBzC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAIlC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,eAAO,MAAM,eAAe,oBAE3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,YAAa,MAAM,KAAG,KAO1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,iJAQnB,CAAC;AAGJ,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAc5E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAqBzC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAO5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,MAIzE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,cAAe,GAAG,EAAE,KAAG,OAK3C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,iBACjB,QAAQ,OAAO,CAAC,oDAEgD,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,2KAYM,CAAC;AAE5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,mBAAmB,YAAY,CAAC;AAChC,cAAc,aAAa,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.0.0-alpha.
|
|
1
|
+
export declare const VERSION = "4.0.0-alpha.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aa-sdk/core",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "4.0.0-alpha.
|
|
4
|
+
"version": "4.0.0-alpha.1",
|
|
5
5
|
"description": "viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts",
|
|
6
6
|
"author": "Alchemy",
|
|
7
7
|
"type": "module",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
67
67
|
},
|
|
68
68
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "cb4bf5f8a9aa8fdff1610130821b69ff806e79e6"
|
|
70
70
|
}
|
package/src/account/simple.ts
CHANGED
|
@@ -155,6 +155,12 @@ export async function createSimpleSmartAccount<
|
|
|
155
155
|
config: CreateSimpleAccountParams<TTransport, TSigner, TEntryPointVersion>
|
|
156
156
|
): Promise<SimpleSmartAccount<TSigner, TEntryPointVersion>>;
|
|
157
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Creates a simple smart account using the provided parameters, including chain, entry point, factory address, and additional parameters. This function also ensures that a signer is provided.
|
|
160
|
+
*
|
|
161
|
+
* @param {CreateSimpleAccountParams} config The parameters for creating a simple smart account
|
|
162
|
+
* @returns {Promise<SimpleSmartAccount>} A promise that resolves to a `SimpleSmartAccount` object containing the created account information and methods
|
|
163
|
+
*/
|
|
158
164
|
export async function createSimpleSmartAccount({
|
|
159
165
|
chain,
|
|
160
166
|
entryPoint = getEntryPoint(chain),
|
|
@@ -74,6 +74,21 @@ export type SmartContractAccountWithSigner<
|
|
|
74
74
|
getSigner: () => TSigner;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Determines if the given SmartContractAccount has a signer associated with it.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* import { toSmartContractAccount } from "@aa-sdk/core";
|
|
83
|
+
*
|
|
84
|
+
* const account = await toSmartContractAccount(...);
|
|
85
|
+
*
|
|
86
|
+
* console.log(isSmartAccountWithSigner(account)); // false: the base account does not have a publicly accessible signer
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @param {SmartContractAccount} account The account to check.
|
|
90
|
+
* @returns {boolean} true if the account has a signer, otherwise false.
|
|
91
|
+
*/
|
|
77
92
|
export const isSmartAccountWithSigner = (
|
|
78
93
|
account: SmartContractAccount
|
|
79
94
|
): account is SmartContractAccountWithSigner => {
|
|
@@ -138,6 +153,19 @@ export type ToSmartContractAccountParams<
|
|
|
138
153
|
} & Omit<CustomSource, "signTransaction" | "address">;
|
|
139
154
|
// [!endregion ToSmartContractAccountParams]
|
|
140
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Parses the factory address and factory calldata from the provided account initialization code (initCode).
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* import { parseFactoryAddressFromAccountInitCode } from "@aa-sdk/core";
|
|
162
|
+
*
|
|
163
|
+
* const [address, calldata] = parseFactoryAddressFromAccountInitCode("0xAddressCalldata");
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @param {Hex} initCode The initialization code from which to parse the factory address and calldata
|
|
167
|
+
* @returns {[Address, Hex]} A tuple containing the parsed factory address and factory calldata
|
|
168
|
+
*/
|
|
141
169
|
export const parseFactoryAddressFromAccountInitCode = (
|
|
142
170
|
initCode: Hex
|
|
143
171
|
): [Address, Hex] => {
|
|
@@ -146,6 +174,27 @@ export const parseFactoryAddressFromAccountInitCode = (
|
|
|
146
174
|
return [factoryAddress, factoryCalldata];
|
|
147
175
|
};
|
|
148
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Retrieves the account address. Uses a provided `accountAddress` if available; otherwise, it computes the address using the entry point contract and the initial code.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* import { getEntryPoint, getAccountAddress } from "@aa-sdk/core";
|
|
183
|
+
*
|
|
184
|
+
* const accountAddress = await getAccountAddress({
|
|
185
|
+
* client,
|
|
186
|
+
* entryPoint: getEntryPoint(chain),
|
|
187
|
+
* getAccountInitCode: async () => "0x{factoryAddress}{factoryCallData}",
|
|
188
|
+
* });
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* @param {object} config The configuration object
|
|
192
|
+
* @param {PublicClient} config.client A public client instance to interact with the blockchain
|
|
193
|
+
* @param {EntryPointDef} config.entryPoint The entry point definition which includes the address and ABI
|
|
194
|
+
* @param {Address} config.accountAddress Optional existing account address
|
|
195
|
+
* @param {function(): Promise<Hex>} config.getAccountInitCode A function that returns a Promise resolving to a Hex string representing the initial code of the account
|
|
196
|
+
* @returns {Promise<Address>} A promise that resolves to the account address
|
|
197
|
+
*/
|
|
149
198
|
export const getAccountAddress = async ({
|
|
150
199
|
client,
|
|
151
200
|
entryPoint,
|
|
@@ -220,21 +269,77 @@ export async function toSmartContractAccount<
|
|
|
220
269
|
>): Promise<SmartContractAccount<Name, TEntryPointVersion>>;
|
|
221
270
|
// [!endregion toSmartContractAccount]
|
|
222
271
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
272
|
+
/**
|
|
273
|
+
* Converts an account to a smart contract account and sets up various account-related methods using the provided parameters like transport, chain, entry point, and other utilities.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```ts
|
|
277
|
+
* import { http, type SignableMessage } from "viem";
|
|
278
|
+
* import { sepolia } from "viem/chains";
|
|
279
|
+
*
|
|
280
|
+
* const myAccount = await toSmartContractAccount({
|
|
281
|
+
* /// REQUIRED PARAMS ///
|
|
282
|
+
* source: "MyAccount",
|
|
283
|
+
* transport: http("RPC_URL"),
|
|
284
|
+
* chain: sepolia,
|
|
285
|
+
* // The EntryPointDef that your account is com"patible with
|
|
286
|
+
* entryPoint: getEntryPoint(sepolia, { version: "0.6.0" }),
|
|
287
|
+
* // This should return a concatenation of your `factoryAddress` and the `callData` for your factory's create account method
|
|
288
|
+
* getAccountInitCode: async () => "0x{factoryAddress}{callData}",
|
|
289
|
+
* // an invalid signature that doesn't cause your account to revert during validation
|
|
290
|
+
* getDummySignature: () => "0x1234...",
|
|
291
|
+
* // given a UO in the form of {target, data, value} should output the calldata for calling your contract's execution method
|
|
292
|
+
* encodeExecute: async (uo) => "0xcalldata",
|
|
293
|
+
* signMessage: async ({ message }: { message: SignableMessage }) => "0x...",
|
|
294
|
+
* signTypedData: async (typedData) => "0x000",
|
|
295
|
+
*
|
|
296
|
+
* /// OPTIONAL PARAMS ///
|
|
297
|
+
* // if you already know your account's address, pass that in here to avoid generating a new counterfactual
|
|
298
|
+
* accountAddress: "0xaddressoverride",
|
|
299
|
+
* // if your account supports batching, this should take an array of UOs and return the calldata for calling your contract's batchExecute method
|
|
300
|
+
* encodeBatchExecute: async (uos) => "0x...",
|
|
301
|
+
* // if your contract expects a different signing scheme than the default signMessage scheme, you can override that here
|
|
302
|
+
* signUserOperationHash: async (hash) => "0x...",
|
|
303
|
+
* // allows you to define the calldata for upgrading your account
|
|
304
|
+
* encodeUpgradeToAndCall: async (params) => "0x...",
|
|
305
|
+
* });
|
|
306
|
+
* ```
|
|
307
|
+
*
|
|
308
|
+
* @param {ToSmartContractAccountParams} params the parameters required for converting to a smart contract account
|
|
309
|
+
* @param {Transport} params.transport the transport mechanism used for communication
|
|
310
|
+
* @param {Chain} params.chain the blockchain chain used in the account
|
|
311
|
+
* @param {EntryPoint} params.entryPoint the entry point of the smart contract
|
|
312
|
+
* @param {string} params.source the source identifier for the account
|
|
313
|
+
* @param {Address} [params.accountAddress] the address of the account
|
|
314
|
+
* @param {() => Promise<Hex>} params.getAccountInitCode a function to get the initial state code of the account
|
|
315
|
+
* @param {(message: { message: SignableMessage }) => Promise<Hex>} params.signMessage a function to sign a message
|
|
316
|
+
* @param {(typedDataDefinition: TypedDataDefinition<typedData, primaryType>) => Promise<Hex>} params.signTypedData a function to sign typed data
|
|
317
|
+
* @param {(transactions: Transaction[]) => Hex} [params.encodeBatchExecute] a function to encode batch transactions
|
|
318
|
+
* @param {(tx: Transaction) => Hex} params.encodeExecute a function to encode a single transaction
|
|
319
|
+
* @param {() => Promise<Hex>} params.getDummySignature a function to get a dummy signature
|
|
320
|
+
* @param {(uoHash: Hex) => Promise<Hex>} [params.signUserOperationHash] a function to sign user operations
|
|
321
|
+
* @param {(implementationAddress: Address, implementationCallData: Hex) => Hex} [params.encodeUpgradeToAndCall] a function to encode upgrade call
|
|
322
|
+
* @returns {Promise<SmartContractAccount>} a promise that resolves to a SmartContractAccount object with methods and properties for interacting with the smart contract account
|
|
323
|
+
*/
|
|
324
|
+
export async function toSmartContractAccount(
|
|
325
|
+
params: ToSmartContractAccountParams
|
|
326
|
+
): Promise<SmartContractAccount> {
|
|
327
|
+
const {
|
|
328
|
+
transport,
|
|
329
|
+
chain,
|
|
330
|
+
entryPoint,
|
|
331
|
+
source,
|
|
332
|
+
accountAddress,
|
|
333
|
+
getAccountInitCode,
|
|
334
|
+
signMessage,
|
|
335
|
+
signTypedData,
|
|
336
|
+
encodeBatchExecute,
|
|
337
|
+
encodeExecute,
|
|
338
|
+
getDummySignature,
|
|
339
|
+
signUserOperationHash,
|
|
340
|
+
encodeUpgradeToAndCall,
|
|
341
|
+
} = params;
|
|
342
|
+
|
|
238
343
|
const client = createBundlerClient({
|
|
239
344
|
// we set the retry count to 0 so that viem doesn't retry during
|
|
240
345
|
// getting the address. That call always reverts and without this
|
|
@@ -14,6 +14,29 @@ import type {
|
|
|
14
14
|
UserOperationContext,
|
|
15
15
|
} from "./types";
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Builds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
23
|
+
*
|
|
24
|
+
* // smart account client is already extended with buildUserOperation
|
|
25
|
+
* const client = createSmartAccountClient(...);
|
|
26
|
+
* const result = await client.buildUserOperation({
|
|
27
|
+
* uo: {
|
|
28
|
+
* target: "0x...",
|
|
29
|
+
* data: "0x...", // or "0x",
|
|
30
|
+
* value: 0n, // optional
|
|
31
|
+
* },
|
|
32
|
+
* account, // only required if the client above is not connected to an account
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param {Client<TTransport, TChain, TAccount>} client the client instance used to build the user operation
|
|
37
|
+
* @param {BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args the parameters required to build the user operation, including account, overrides, and context
|
|
38
|
+
* @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a promise that resolves to a `UserOperationStruct` object containing the built user operation details
|
|
39
|
+
*/
|
|
17
40
|
export async function buildUserOperation<
|
|
18
41
|
TTransport extends Transport = Transport,
|
|
19
42
|
TChain extends Chain | undefined = Chain | undefined,
|
|
@@ -20,6 +20,28 @@ import type {
|
|
|
20
20
|
UserOperationContext,
|
|
21
21
|
} from "./types";
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Drops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import {
|
|
29
|
+
* createSmartAccountClient,
|
|
30
|
+
* } from "@aa-sdk/core";
|
|
31
|
+
*
|
|
32
|
+
* // smart account client is already extended with dropAndReplaceUserOperation
|
|
33
|
+
* const client = createSmartAccountClient(...);
|
|
34
|
+
* const { request } = await client.sendUserOperation(...);
|
|
35
|
+
* const result = await client.dropAndReplaceUserOperation({
|
|
36
|
+
* uoToDrop: request,
|
|
37
|
+
* account, // only required if the client above is not connected to an account
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param {Client<TTransport, TChain, TAccount>} client The client instance with the transport, chain, and account information
|
|
42
|
+
* @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context
|
|
43
|
+
* @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation
|
|
44
|
+
*/
|
|
23
45
|
export async function dropAndReplaceUserOperation<
|
|
24
46
|
TTransport extends Transport = Transport,
|
|
25
47
|
TChain extends Chain | undefined = Chain | undefined,
|
|
@@ -20,6 +20,30 @@ import { _sendUserOperation } from "./internal/sendUserOperation.js";
|
|
|
20
20
|
import type { UserOperationContext } from "./types.js";
|
|
21
21
|
import { waitForUserOperationTransaction } from "./waitForUserOperationTransacation.js";
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Sends a transaction using the provided client, arguments, optional overrides, and context.
|
|
25
|
+
* This sends a UO and then waits for it to be mined
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
30
|
+
*
|
|
31
|
+
* // smart account client is already extended with sendTransaction
|
|
32
|
+
* const client = createSmartAccountClient(...);
|
|
33
|
+
* const result = await client.sendTransaction({
|
|
34
|
+
* to: "0x...",
|
|
35
|
+
* data: "0x...", // or "0x",
|
|
36
|
+
* value: 0n, // optional
|
|
37
|
+
* account, // only required if the client above is not connected to an account
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param {Client<Transport, TChain, TAccount>} client The client to send the transaction through
|
|
42
|
+
* @param {SendTransactionParameters<TChain, TAccount, TChainOverride>} args The parameters required to send the transaction
|
|
43
|
+
* @param {UserOperationOverrides<TEntryPointVersion>} [overrides] Optional overrides for the user operation
|
|
44
|
+
* @param {UserOperationContext} [context] Optional context for the user operation
|
|
45
|
+
* @returns {Promise<Hex>} A promise that resolves to a hex string representing the transaction hash
|
|
46
|
+
*/
|
|
23
47
|
export async function sendTransaction<
|
|
24
48
|
TChain extends Chain | undefined = Chain | undefined,
|
|
25
49
|
TAccount extends SmartContractAccount | undefined =
|
|
@@ -9,6 +9,29 @@ import { _sendUserOperation } from "./internal/sendUserOperation.js";
|
|
|
9
9
|
import type { SendTransactionsParameters, UserOperationContext } from "./types";
|
|
10
10
|
import { waitForUserOperationTransaction } from "./waitForUserOperationTransacation.js";
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Sends transactions using the provided client and transaction parameters. This function builds user operations from the transactions, sends them, and waits for the transaction to be mined.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
18
|
+
*
|
|
19
|
+
* // smart account client is already extended with sendTransactions
|
|
20
|
+
* const client = createSmartAccountClient(...);
|
|
21
|
+
* const result = await client.sendTransactions({
|
|
22
|
+
* requests: [{
|
|
23
|
+
* to: "0x...",
|
|
24
|
+
* data: "0x...", // or "0x",
|
|
25
|
+
* value: 0n, // optional
|
|
26
|
+
* }],
|
|
27
|
+
* account, // only required if the client above is not connected to an account
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param {Client<TTransport, TChain, TAccount>} client The client used to send the transactions
|
|
32
|
+
* @param {SendTransactionsParameters<TAccount, TContext>} args The parameters for sending the transactions, including requests, overrides, account, and context
|
|
33
|
+
* @returns {Promise<Hex>} A promise that resolves to the transaction hash of the sent transactions
|
|
34
|
+
*/
|
|
12
35
|
export async function sendTransactions<
|
|
13
36
|
TTransport extends Transport = Transport,
|
|
14
37
|
TChain extends Chain | undefined = Chain | undefined,
|
|
@@ -6,6 +6,30 @@ import { FailedToFindTransactionError } from "../../errors/transaction.js";
|
|
|
6
6
|
import { Logger } from "../../logger.js";
|
|
7
7
|
import type { WaitForUserOperationTxParameters } from "./types.js";
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Waits for a user operation transaction to be confirmed by checking the receipt periodically until it is found or a maximum number of retries is reached.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
15
|
+
*
|
|
16
|
+
* // smart account client is already extended with waitForUserOperationTransaction
|
|
17
|
+
* const client = createSmartAccountClient(...);
|
|
18
|
+
* const result = await client.waitForUserOperationTransaction({
|
|
19
|
+
* hash: "0x...",
|
|
20
|
+
* retries: {...} // optional param to configure the retry amounts
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param {Client<TTransport, TChain, any>} client The client instance used to interact with the blockchain
|
|
25
|
+
* @param {WaitForUserOperationTxParameters} args The parameters for the transaction to wait for
|
|
26
|
+
* @param {Hex} args.hash The transaction hash to wait for
|
|
27
|
+
* @param {WaitForUserOperationTxParameters["retries"]} [args.retries] Optional retry parameters
|
|
28
|
+
* @param {number} [args.retries.maxRetries] The maximum number of retry attempts
|
|
29
|
+
* @param {number} [args.retries.intervalMs] The interval in milliseconds between retries
|
|
30
|
+
* @param {number} [args.retries.multiplier] The multiplier for the interval between retries
|
|
31
|
+
* @returns {Promise<Hex>} A promise that resolves to the transaction hash when the transaction is confirmed
|
|
32
|
+
*/
|
|
9
33
|
export const waitForUserOperationTransaction: <
|
|
10
34
|
TTransport extends Transport = Transport,
|
|
11
35
|
TChain extends Chain | undefined = Chain | undefined
|
|
@@ -29,6 +29,21 @@ export type BundlerClient<T extends Transport = Transport> = Client<
|
|
|
29
29
|
PublicActions<T, Chain> & BundlerActions
|
|
30
30
|
>;
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Creates a bundler client from an existing public client with the provided transport and chain.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { createPublicClient } from "viem";
|
|
38
|
+
* import { createBundlerClientFromExisting } from "@aa-sdk/core";
|
|
39
|
+
*
|
|
40
|
+
* const publicClient = createPublicClient(...);
|
|
41
|
+
* const bundlerClient = createBundlerClientFromExisting(publicClient);
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param {PublicClient<T, Chain>} client The existing public client to be extended with bundler actions
|
|
45
|
+
* @returns {BundlerClient<T>} A bundler client that extends the functionality of the provided public client
|
|
46
|
+
*/
|
|
32
47
|
export const createBundlerClientFromExisting: <
|
|
33
48
|
T extends Transport | FallbackTransport = Transport
|
|
34
49
|
>(
|
|
@@ -50,6 +65,23 @@ export function createBundlerClient<TTransport extends Transport>(
|
|
|
50
65
|
args: PublicClientConfig<TTransport, Chain> & { type?: string }
|
|
51
66
|
): BundlerClient<TTransport>;
|
|
52
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Creates a Bundler Client using the provided configuration parameters, including chain and optional type.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { createBundlerClient } from "@aa-sdk/core";
|
|
74
|
+
* import { sepolia } from "viem/chains";
|
|
75
|
+
*
|
|
76
|
+
* const client = createBundlerClient({
|
|
77
|
+
* chain: sepolia,
|
|
78
|
+
* transport: http("RPC_URL"),
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @param {PublicClientConfig & { type?: string }} args Configuration for creating the Bundler Client, including parameters for the chain, transport, and optional type
|
|
83
|
+
* @returns {BundlerClient} The created Bundler Client with extended public and bundler actions
|
|
84
|
+
*/
|
|
53
85
|
export function createBundlerClient(
|
|
54
86
|
args: PublicClientConfig & { type?: string }
|
|
55
87
|
): BundlerClient {
|
|
@@ -107,6 +107,15 @@ export type BundlerActions = {
|
|
|
107
107
|
};
|
|
108
108
|
// [!endregion BundlerActions]
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* A viem client decorator that provides Bundler specific actions.
|
|
112
|
+
* These actions include estimating gas for user operations, sending raw user operations, retrieving user operations by hash, getting supported entry points, and getting user operation receipts.
|
|
113
|
+
*
|
|
114
|
+
* NOTE: this is already added to the client returned from `createBundlerClient`
|
|
115
|
+
*
|
|
116
|
+
* @param {TClient} client The client instance that will be used to perform bundler actions
|
|
117
|
+
* @returns {BundlerActions} An object containing various bundler-related actions that can be executed using the provided client
|
|
118
|
+
*/
|
|
110
119
|
export const bundlerActions: <
|
|
111
120
|
TClient extends Client<
|
|
112
121
|
Transport,
|
|
@@ -133,6 +133,14 @@ export type BaseSmartAccountClientActions<
|
|
|
133
133
|
});
|
|
134
134
|
// #endregion SmartAccountClientActions
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Provides a set of smart account client actions to decorate the provided client. These actions include building and signing user operations, sending transactions, and more.
|
|
138
|
+
*
|
|
139
|
+
* NOTE: this is already added to clients returned from `createSmartAccountClient`
|
|
140
|
+
*
|
|
141
|
+
* @param {Client<TTransport, TChain, TAccount>} client The client to bind the smart account actions to
|
|
142
|
+
* @returns {BaseSmartAccountClientActions<TChain, TAccount, TContext>} An object containing various smart account client actions
|
|
143
|
+
*/
|
|
136
144
|
export const smartAccountClientActions: <
|
|
137
145
|
TTransport extends Transport = Transport,
|
|
138
146
|
TChain extends Chain | undefined = Chain | undefined,
|