@aa-sdk/core 4.0.0-alpha.4 → 4.0.0-alpha.6
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/smartContractAccount.d.ts +9 -3
- package/dist/cjs/account/smartContractAccount.js +11 -6
- package/dist/cjs/account/smartContractAccount.js.map +1 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/sendUserOperation.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/isSmartAccountClient.js.map +1 -1
- package/dist/cjs/client/types.d.ts +2 -7
- package/dist/cjs/client/types.js.map +1 -1
- package/dist/cjs/errors/account.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/errors/useroperation.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -5
- package/dist/cjs/index.js +6 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logger.js.map +1 -1
- package/dist/cjs/middleware/actions.js +2 -18
- package/dist/cjs/middleware/actions.js.map +1 -1
- package/dist/cjs/middleware/defaults/gasEstimator.js +3 -2
- package/dist/cjs/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/cjs/middleware/erc7677middleware.d.ts +40 -0
- package/dist/cjs/middleware/erc7677middleware.js +77 -0
- package/dist/cjs/middleware/erc7677middleware.js.map +1 -0
- package/dist/cjs/middleware/noopMiddleware.d.ts +2 -1
- package/dist/cjs/middleware/noopMiddleware.js.map +1 -1
- package/dist/cjs/middleware/types.d.ts +3 -2
- package/dist/cjs/middleware/types.js.map +1 -1
- package/dist/cjs/signer/local-account.d.ts +46 -46
- package/dist/cjs/signer/local-account.js.map +1 -1
- package/dist/cjs/signer/wallet-client.d.ts +46 -46
- package/dist/cjs/signer/wallet-client.js.map +1 -1
- package/dist/cjs/transport/split.js.map +1 -1
- package/dist/cjs/utils/bigint.js.map +1 -1
- package/dist/cjs/utils/bytes.js.map +1 -1
- package/dist/cjs/utils/defaults.d.ts +1 -3
- package/dist/cjs/utils/defaults.js +1 -41
- package/dist/cjs/utils/defaults.js.map +1 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/types.js.map +1 -1
- package/dist/cjs/utils/userop.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/smartContractAccount.d.ts +9 -3
- package/dist/esm/account/smartContractAccount.js +6 -1
- package/dist/esm/account/smartContractAccount.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendUserOperation.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/isSmartAccountClient.js.map +1 -1
- package/dist/esm/client/types.d.ts +2 -7
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/errors/account.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/errors/useroperation.js.map +1 -1
- package/dist/esm/index.d.ts +3 -5
- package/dist/esm/index.js +2 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/middleware/actions.js +3 -18
- package/dist/esm/middleware/actions.js.map +1 -1
- package/dist/esm/middleware/defaults/gasEstimator.js +3 -2
- package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/esm/middleware/erc7677middleware.d.ts +40 -0
- package/dist/esm/middleware/erc7677middleware.js +73 -0
- package/dist/esm/middleware/erc7677middleware.js.map +1 -0
- package/dist/esm/middleware/noopMiddleware.d.ts +2 -1
- package/dist/esm/middleware/noopMiddleware.js.map +1 -1
- package/dist/esm/middleware/types.d.ts +3 -2
- package/dist/esm/middleware/types.js.map +1 -1
- package/dist/esm/signer/local-account.d.ts +46 -46
- package/dist/esm/signer/local-account.js.map +1 -1
- package/dist/esm/signer/wallet-client.d.ts +46 -46
- package/dist/esm/signer/wallet-client.js.map +1 -1
- package/dist/esm/transport/split.js.map +1 -1
- package/dist/esm/utils/bigint.js.map +1 -1
- package/dist/esm/utils/bytes.js.map +1 -1
- package/dist/esm/utils/defaults.d.ts +1 -3
- package/dist/esm/utils/defaults.js +1 -40
- package/dist/esm/utils/defaults.js.map +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/types.js.map +1 -1
- package/dist/esm/utils/userop.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 +17 -11
- package/dist/types/account/smartContractAccount.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts +33 -33
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts +43 -59
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +18 -18
- package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts +3 -3
- package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts +3 -4
- package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts +0 -14
- package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts +0 -7
- package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts +17 -3
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
- package/dist/types/client/bundlerClient.d.ts +2 -2
- package/dist/types/client/decorators/bundlerClient.d.ts +8 -8
- package/dist/types/client/isSmartAccountClient.d.ts +4 -4
- package/dist/types/client/types.d.ts +2 -7
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/errors/account.d.ts +53 -4
- package/dist/types/errors/account.d.ts.map +1 -1
- package/dist/types/errors/client.d.ts +15 -0
- package/dist/types/errors/client.d.ts.map +1 -1
- package/dist/types/errors/entrypoint.d.ts +12 -0
- package/dist/types/errors/entrypoint.d.ts.map +1 -1
- package/dist/types/errors/signer.d.ts +5 -0
- package/dist/types/errors/signer.d.ts.map +1 -1
- package/dist/types/errors/transaction.d.ts +8 -1
- package/dist/types/errors/transaction.d.ts.map +1 -1
- package/dist/types/errors/useroperation.d.ts +5 -5
- package/dist/types/errors/useroperation.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logger.d.ts +88 -0
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/middleware/actions.d.ts +3 -3
- package/dist/types/middleware/actions.d.ts.map +1 -1
- package/dist/types/middleware/defaults/gasEstimator.d.ts +2 -2
- package/dist/types/middleware/defaults/gasEstimator.d.ts.map +1 -1
- package/dist/types/middleware/erc7677middleware.d.ts +62 -0
- package/dist/types/middleware/erc7677middleware.d.ts.map +1 -0
- package/dist/types/middleware/noopMiddleware.d.ts +4 -4
- package/dist/types/middleware/noopMiddleware.d.ts.map +1 -1
- package/dist/types/middleware/types.d.ts +3 -2
- package/dist/types/middleware/types.d.ts.map +1 -1
- package/dist/types/signer/local-account.d.ts +139 -47
- package/dist/types/signer/local-account.d.ts.map +1 -1
- package/dist/types/signer/wallet-client.d.ts +135 -46
- package/dist/types/signer/wallet-client.d.ts.map +1 -1
- package/dist/types/transport/split.d.ts +2 -2
- package/dist/types/utils/bigint.d.ts +14 -14
- package/dist/types/utils/bigint.d.ts.map +1 -1
- package/dist/types/utils/bytes.d.ts +5 -5
- package/dist/types/utils/defaults.d.ts +1 -11
- package/dist/types/utils/defaults.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +12 -12
- package/dist/types/utils/types.d.ts +2 -2
- package/dist/types/utils/userop.d.ts +33 -33
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -2
- package/src/account/smartContractAccount.ts +19 -12
- package/src/actions/smartAccount/buildUserOperationFromTx.ts +35 -35
- package/src/actions/smartAccount/buildUserOperationFromTxs.ts +44 -60
- package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +19 -19
- package/src/actions/smartAccount/estimateUserOperationGas.ts +3 -3
- package/src/actions/smartAccount/internal/initUserOperation.ts +3 -4
- package/src/actions/smartAccount/internal/runMiddlewareStack.ts +0 -22
- package/src/actions/smartAccount/internal/sendUserOperation.ts +0 -7
- package/src/actions/smartAccount/sendUserOperation.ts +17 -3
- package/src/client/bundlerClient.ts +2 -2
- package/src/client/decorators/bundlerClient.ts +8 -8
- package/src/client/isSmartAccountClient.ts +4 -4
- package/src/client/types.ts +2 -15
- package/src/errors/account.ts +64 -4
- package/src/errors/client.ts +18 -0
- package/src/errors/entrypoint.ts +12 -0
- package/src/errors/signer.ts +6 -0
- package/src/errors/transaction.ts +10 -1
- package/src/errors/useroperation.ts +5 -6
- package/src/index.ts +2 -8
- package/src/logger.ts +88 -0
- package/src/middleware/actions.ts +6 -27
- package/src/middleware/defaults/gasEstimator.ts +8 -5
- package/src/middleware/erc7677middleware.ts +201 -0
- package/src/middleware/noopMiddleware.ts +6 -4
- package/src/middleware/types.ts +16 -7
- package/src/signer/local-account.ts +94 -2
- package/src/signer/wallet-client.ts +89 -0
- package/src/transport/split.ts +2 -2
- package/src/utils/bigint.ts +15 -15
- package/src/utils/bytes.ts +5 -5
- package/src/utils/defaults.ts +2 -74
- package/src/utils/index.ts +12 -12
- package/src/utils/types.ts +2 -2
- package/src/utils/userop.ts +33 -33
- package/src/version.ts +1 -1
- package/dist/cjs/account/base.d.ts +0 -49
- package/dist/cjs/account/base.js +0 -257
- package/dist/cjs/account/base.js.map +0 -1
- package/dist/cjs/account/schema.d.ts +0 -100
- package/dist/cjs/account/schema.js +0 -43
- package/dist/cjs/account/schema.js.map +0 -1
- package/dist/cjs/account/simple.d.ts +0 -14
- package/dist/cjs/account/simple.js +0 -119
- package/dist/cjs/account/simple.js.map +0 -1
- package/dist/cjs/account/types.d.ts +0 -30
- package/dist/cjs/account/types.js +0 -3
- package/dist/cjs/account/types.js.map +0 -1
- package/dist/esm/account/base.d.ts +0 -49
- package/dist/esm/account/base.js +0 -253
- package/dist/esm/account/base.js.map +0 -1
- package/dist/esm/account/schema.d.ts +0 -100
- package/dist/esm/account/schema.js +0 -35
- package/dist/esm/account/schema.js.map +0 -1
- package/dist/esm/account/simple.d.ts +0 -14
- package/dist/esm/account/simple.js +0 -115
- package/dist/esm/account/simple.js.map +0 -1
- package/dist/esm/account/types.d.ts +0 -30
- package/dist/esm/account/types.js +0 -2
- package/dist/esm/account/types.js.map +0 -1
- package/dist/types/account/base.d.ts +0 -128
- package/dist/types/account/base.d.ts.map +0 -1
- package/dist/types/account/schema.d.ts +0 -101
- package/dist/types/account/schema.d.ts.map +0 -1
- package/dist/types/account/simple.d.ts +0 -15
- package/dist/types/account/simple.d.ts.map +0 -1
- package/dist/types/account/types.d.ts +0 -144
- package/dist/types/account/types.d.ts.map +0 -1
- package/src/account/base.ts +0 -415
- package/src/account/schema.ts +0 -51
- package/src/account/simple.ts +0 -221
- package/src/account/types.ts +0 -184
|
@@ -8,6 +8,11 @@ export type AccountOp = {
|
|
|
8
8
|
value?: bigint;
|
|
9
9
|
data: Hex | "0x";
|
|
10
10
|
};
|
|
11
|
+
export declare enum DeploymentState {
|
|
12
|
+
UNDEFINED = "0x0",
|
|
13
|
+
NOT_DEPLOYED = "0x1",
|
|
14
|
+
DEPLOYED = "0x2"
|
|
15
|
+
}
|
|
11
16
|
export type GetEntryPointFromAccount<TAccount extends SmartContractAccount | undefined, TAccountOverride extends SmartContractAccount = SmartContractAccount> = GetAccountParameter<TAccount, TAccountOverride> extends SmartContractAccount<string, infer TEntryPointVersion> ? TEntryPointVersion : EntryPointVersion;
|
|
12
17
|
export type GetAccountParameter<TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TAccountOverride extends SmartContractAccount = SmartContractAccount> = IsUndefined<TAccount> extends true ? {
|
|
13
18
|
account: TAccountOverride;
|
|
@@ -59,10 +64,11 @@ export type ToSmartContractAccountParams<Name extends string = string, TTranspor
|
|
|
59
64
|
encodeUpgradeToAndCall?: (params: UpgradeToAndCallParams) => Promise<Hex>;
|
|
60
65
|
} & Omit<CustomSource, "signTransaction" | "address">;
|
|
61
66
|
export declare const parseFactoryAddressFromAccountInitCode: (initCode: Hex) => [Address, Hex];
|
|
62
|
-
export
|
|
67
|
+
export type GetAccountAddressParams = {
|
|
63
68
|
client: PublicClient;
|
|
64
69
|
entryPoint: EntryPointDef;
|
|
65
|
-
accountAddress?:
|
|
70
|
+
accountAddress?: Address;
|
|
66
71
|
getAccountInitCode: () => Promise<Hex>;
|
|
67
|
-
}
|
|
72
|
+
};
|
|
73
|
+
export declare const getAccountAddress: ({ client, entryPoint, accountAddress, getAccountInitCode, }: GetAccountAddressParams) => Promise<`0x${string}`>;
|
|
68
74
|
export declare function toSmartContractAccount<Name extends string = string, TTransport extends Transport = Transport, TChain extends Chain = Chain, TEntryPointVersion extends EntryPointVersion = EntryPointVersion>({ transport, chain, entryPoint, source, accountAddress, getAccountInitCode, signMessage, signTypedData, encodeBatchExecute, encodeExecute, getDummySignature, signUserOperationHash, encodeUpgradeToAndCall, }: ToSmartContractAccountParams<Name, TTransport, TChain, TEntryPointVersion>): Promise<SmartContractAccount<Name, TEntryPointVersion>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toSmartContractAccount = exports.getAccountAddress = exports.parseFactoryAddressFromAccountInitCode = exports.isSmartAccountWithSigner = void 0;
|
|
3
|
+
exports.toSmartContractAccount = exports.getAccountAddress = exports.parseFactoryAddressFromAccountInitCode = exports.isSmartAccountWithSigner = exports.DeploymentState = void 0;
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
5
|
const accounts_1 = require("viem/accounts");
|
|
6
6
|
const bundlerClient_js_1 = require("../client/bundlerClient.js");
|
|
@@ -9,7 +9,12 @@ const client_js_1 = require("../errors/client.js");
|
|
|
9
9
|
const entrypoint_js_1 = require("../errors/entrypoint.js");
|
|
10
10
|
const logger_js_1 = require("../logger.js");
|
|
11
11
|
const utils_js_1 = require("../signer/utils.js");
|
|
12
|
-
|
|
12
|
+
var DeploymentState;
|
|
13
|
+
(function (DeploymentState) {
|
|
14
|
+
DeploymentState["UNDEFINED"] = "0x0";
|
|
15
|
+
DeploymentState["NOT_DEPLOYED"] = "0x1";
|
|
16
|
+
DeploymentState["DEPLOYED"] = "0x2";
|
|
17
|
+
})(DeploymentState || (exports.DeploymentState = DeploymentState = {}));
|
|
13
18
|
const isSmartAccountWithSigner = (account) => {
|
|
14
19
|
return "getSigner" in account;
|
|
15
20
|
};
|
|
@@ -63,20 +68,20 @@ async function toSmartContractAccount(params) {
|
|
|
63
68
|
accountAddress,
|
|
64
69
|
getAccountInitCode,
|
|
65
70
|
});
|
|
66
|
-
let deploymentState =
|
|
71
|
+
let deploymentState = DeploymentState.UNDEFINED;
|
|
67
72
|
const getInitCode = async () => {
|
|
68
|
-
if (deploymentState ===
|
|
73
|
+
if (deploymentState === DeploymentState.DEPLOYED) {
|
|
69
74
|
return "0x";
|
|
70
75
|
}
|
|
71
76
|
const contractCode = await client.getBytecode({
|
|
72
77
|
address: accountAddress_,
|
|
73
78
|
});
|
|
74
79
|
if ((contractCode?.length ?? 0) > 2) {
|
|
75
|
-
deploymentState =
|
|
80
|
+
deploymentState = DeploymentState.DEPLOYED;
|
|
76
81
|
return "0x";
|
|
77
82
|
}
|
|
78
83
|
else {
|
|
79
|
-
deploymentState =
|
|
84
|
+
deploymentState = DeploymentState.NOT_DEPLOYED;
|
|
80
85
|
}
|
|
81
86
|
return getAccountInitCode();
|
|
82
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartContractAccount.js","sourceRoot":"","sources":["../../../src/account/smartContractAccount.ts"],"names":[],"mappings":";;;AAAA,+BAcc;AACd,4CAA0C;AAC1C,iEAAiE;AAMjE,qDAM8B;AAC9B,mDAAyD;AACzD,2DAAiE;AACjE,4CAAsC;AAEtC,iDAA2D;AAG3D,uCAA4C;AAuDrC,MAAM,wBAAwB,GAAG,CACtC,OAA6B,EACc,EAAE;IAC7C,OAAO,WAAW,IAAI,OAAO,CAAC;AAChC,CAAC,CAAC;AAJW,QAAA,wBAAwB,4BAInC;AAyEK,MAAM,sCAAsC,GAAG,CACpD,QAAa,EACG,EAAE;IAClB,MAAM,cAAc,GAAY,KAAK,QAAQ,CAAC,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E,CAAC,CAAC;QAEH,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,wCAA2B,CACnC,oEAAoE,EACpE,8BAA8B,CAC/B,CAAC;QACJ,CAAC;QAED,OAAO,IAAA,WAAI,EAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QACrE,MAAM,IAAI,sCAAsB,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,GAAG,OAAO;QACV,MAAM;QAGN,qBAAqB,EAAE,sBAAsB;QAC7C,iBAAiB;QACjB,cAAc;QACd,kBAAkB,EAChB,kBAAkB;YAClB,CAAC,GAAG,EAAE;gBACJ,MAAM,IAAI,4CAA+B,CAAC,MAAM,CAAC,CAAC;YACpD,CAAC,CAAC;QACJ,aAAa;QACb,iBAAiB;QACjB,WAAW;QACX,sBAAsB,EAAE,uBAAuB;QAC/C,aAAa,EAAE,GAAG,EAAE,CAAC,UAAU;QAC/B,iBAAiB;QACjB,QAAQ;QACR,mBAAmB;QACnB,qBAAqB;QACrB,wBAAwB;KACzB,CAAC;AACJ,CAAC;AA3LD,wDA2LC","sourcesContent":["import {\n getContract,\n hexToBytes,\n trim,\n type Address,\n type Chain,\n type CustomSource,\n type Hex,\n type LocalAccount,\n type PublicClient,\n type SignableMessage,\n type Transport,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport { toAccount } from \"viem/accounts\";\nimport { createBundlerClient } from \"../client/bundlerClient.js\";\nimport type {\n EntryPointDef,\n EntryPointRegistryBase,\n EntryPointVersion,\n} from \"../entrypoint/types.js\";\nimport {\n BatchExecutionNotSupportedError,\n FailedToGetStorageSlotError,\n GetCounterFactualAddressError,\n SignTransactionNotSupportedError,\n UpgradesNotSupportedError,\n} from \"../errors/account.js\";\nimport { InvalidRpcUrlError } from \"../errors/client.js\";\nimport { InvalidEntryPointError } from \"../errors/entrypoint.js\";\nimport { Logger } from \"../logger.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport { wrapSignatureWith6492 } from \"../signer/utils.js\";\nimport type { NullAddress } from \"../types.js\";\nimport type { IsUndefined } from \"../utils/types.js\";\nimport { DeploymentState } from \"./base.js\";\n\nexport type AccountOp = {\n target: Address;\n value?: bigint;\n data: Hex | \"0x\";\n};\n\nexport type GetEntryPointFromAccount<\n TAccount extends SmartContractAccount | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount\n> = GetAccountParameter<\n TAccount,\n TAccountOverride\n> extends SmartContractAccount<string, infer TEntryPointVersion>\n ? TEntryPointVersion\n : EntryPointVersion;\n\nexport type GetAccountParameter<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount\n> = IsUndefined<TAccount> extends true\n ? { account: TAccountOverride }\n : { account?: TAccountOverride };\n\nexport type UpgradeToAndCallParams = {\n upgradeToAddress: Address;\n upgradeToInitData: Hex;\n};\n\nexport type SmartContractAccountWithSigner<\n Name extends string = string,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = SmartContractAccount<Name, TEntryPointVersion> & {\n getSigner: () => TSigner;\n};\n\n/**\n * Determines if the given SmartContractAccount has a signer associated with it.\n *\n * @example\n * ```ts\n * import { toSmartContractAccount } from \"@aa-sdk/core\";\n *\n * const account = await toSmartContractAccount(...);\n *\n * console.log(isSmartAccountWithSigner(account)); // false: the base account does not have a publicly accessible signer\n * ```\n *\n * @param {SmartContractAccount} account The account to check.\n * @returns {boolean} true if the account has a signer, otherwise false.\n */\nexport const isSmartAccountWithSigner = (\n account: SmartContractAccount\n): account is SmartContractAccountWithSigner => {\n return \"getSigner\" in account;\n};\n\n// [!region SmartContractAccount]\nexport type SmartContractAccount<\n Name extends string = string,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = LocalAccount<Name> & {\n source: Name;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute: (txs: AccountOp[]) => Promise<Hex>;\n signUserOperationHash: (uoHash: Hex) => Promise<Hex>;\n signMessageWith6492: (params: { message: SignableMessage }) => Promise<Hex>;\n signTypedDataWith6492: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>\n ) => Promise<Hex>;\n encodeUpgradeToAndCall: (params: UpgradeToAndCallParams) => Promise<Hex>;\n getNonce(nonceKey?: bigint): Promise<bigint>;\n getInitCode: () => Promise<Hex>;\n isAccountDeployed: () => Promise<boolean>;\n getFactoryAddress: () => Promise<Address>;\n getFactoryData: () => Promise<Hex>;\n getEntryPoint: () => EntryPointDef<TEntryPointVersion>;\n getImplementationAddress: () => Promise<NullAddress | Address>;\n};\n// [!endregion SmartContractAccount]\n\nexport interface AccountEntryPointRegistry<Name extends string = string>\n extends EntryPointRegistryBase<\n SmartContractAccount<Name, EntryPointVersion>\n > {\n \"0.6.0\": SmartContractAccount<Name, \"0.6.0\">;\n \"0.7.0\": SmartContractAccount<Name, \"0.7.0\">;\n}\n\n// [!region ToSmartContractAccountParams]\nexport type ToSmartContractAccountParams<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = {\n source: Name;\n transport: TTransport;\n chain: TChain;\n entryPoint: EntryPointDef<TEntryPointVersion, TChain>;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute?: (txs: AccountOp[]) => Promise<Hex>;\n // if not provided, will default to just using signMessage over the Hex\n signUserOperationHash?: (uoHash: Hex) => Promise<Hex>;\n encodeUpgradeToAndCall?: (params: UpgradeToAndCallParams) => Promise<Hex>;\n} & Omit<CustomSource, \"signTransaction\" | \"address\">;\n// [!endregion ToSmartContractAccountParams]\n\n/**\n * Parses the factory address and factory calldata from the provided account initialization code (initCode).\n *\n * @example\n * ```ts\n * import { parseFactoryAddressFromAccountInitCode } from \"@aa-sdk/core\";\n *\n * const [address, calldata] = parseFactoryAddressFromAccountInitCode(\"0xAddressCalldata\");\n * ```\n *\n * @param {Hex} initCode The initialization code from which to parse the factory address and calldata\n * @returns {[Address, Hex]} A tuple containing the parsed factory address and factory calldata\n */\nexport const parseFactoryAddressFromAccountInitCode = (\n initCode: Hex\n): [Address, Hex] => {\n const factoryAddress: Address = `0x${initCode.substring(2, 42)}`;\n const factoryCalldata: Hex = `0x${initCode.substring(42)}`;\n return [factoryAddress, factoryCalldata];\n};\n\n/**\n * Retrieves the account address. Uses a provided `accountAddress` if available; otherwise, it computes the address using the entry point contract and the initial code.\n *\n * @example\n * ```ts\n * import { getEntryPoint, getAccountAddress } from \"@aa-sdk/core\";\n *\n * const accountAddress = await getAccountAddress({\n * client,\n * entryPoint: getEntryPoint(chain),\n * getAccountInitCode: async () => \"0x{factoryAddress}{factoryCallData}\",\n * });\n * ```\n *\n * @param {object} config The configuration object\n * @param {PublicClient} config.client A public client instance to interact with the blockchain\n * @param {EntryPointDef} config.entryPoint The entry point definition which includes the address and ABI\n * @param {Address} config.accountAddress Optional existing account address\n * @param {function(): Promise<Hex>} config.getAccountInitCode A function that returns a Promise resolving to a Hex string representing the initial code of the account\n * @returns {Promise<Address>} A promise that resolves to the account address\n */\nexport const getAccountAddress = async ({\n client,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n}: {\n client: PublicClient;\n entryPoint: EntryPointDef;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n}) => {\n if (accountAddress) return accountAddress;\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const initCode = await getAccountInitCode();\n Logger.verbose(\"[BaseSmartContractAccount](getAddress) initCode: \", initCode);\n\n try {\n await entryPointContract.simulate.getSenderAddress([initCode]);\n } catch (err: any) {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) getSenderAddress err: \",\n err\n );\n if (err.cause?.data?.errorName === \"SenderAddressResult\") {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) entryPoint.getSenderAddress result:\",\n err.cause.data.args[0]\n );\n\n return err.cause.data.args[0] as Address;\n }\n\n if (err.details === \"Invalid URL\") {\n throw new InvalidRpcUrlError();\n }\n }\n\n throw new GetCounterFactualAddressError();\n};\n\n// [!region toSmartContractAccount]\nexport async function toSmartContractAccount<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>({\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n signMessage,\n signTypedData,\n encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n}: ToSmartContractAccountParams<\n Name,\n TTransport,\n TChain,\n TEntryPointVersion\n>): Promise<SmartContractAccount<Name, TEntryPointVersion>>;\n// [!endregion toSmartContractAccount]\n\n/**\n * 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.\n *\n * @example\n * ```ts\n * import { http, type SignableMessage } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const myAccount = await toSmartContractAccount({\n * /// REQUIRED PARAMS ///\n * source: \"MyAccount\",\n * transport: http(\"RPC_URL\"),\n * chain: sepolia,\n * // The EntryPointDef that your account is com\"patible with\n * entryPoint: getEntryPoint(sepolia, { version: \"0.6.0\" }),\n * // This should return a concatenation of your `factoryAddress` and the `callData` for your factory's create account method\n * getAccountInitCode: async () => \"0x{factoryAddress}{callData}\",\n * // an invalid signature that doesn't cause your account to revert during validation\n * getDummySignature: () => \"0x1234...\",\n * // given a UO in the form of {target, data, value} should output the calldata for calling your contract's execution method\n * encodeExecute: async (uo) => \"0xcalldata\",\n * signMessage: async ({ message }: { message: SignableMessage }) => \"0x...\",\n * signTypedData: async (typedData) => \"0x000\",\n *\n * /// OPTIONAL PARAMS ///\n * // if you already know your account's address, pass that in here to avoid generating a new counterfactual\n * accountAddress: \"0xaddressoverride\",\n * // if your account supports batching, this should take an array of UOs and return the calldata for calling your contract's batchExecute method\n * encodeBatchExecute: async (uos) => \"0x...\",\n * // if your contract expects a different signing scheme than the default signMessage scheme, you can override that here\n * signUserOperationHash: async (hash) => \"0x...\",\n * // allows you to define the calldata for upgrading your account\n * encodeUpgradeToAndCall: async (params) => \"0x...\",\n * });\n * ```\n *\n * @param {ToSmartContractAccountParams} params the parameters required for converting to a smart contract account\n * @param {Transport} params.transport the transport mechanism used for communication\n * @param {Chain} params.chain the blockchain chain used in the account\n * @param {EntryPoint} params.entryPoint the entry point of the smart contract\n * @param {string} params.source the source identifier for the account\n * @param {Address} [params.accountAddress] the address of the account\n * @param {() => Promise<Hex>} params.getAccountInitCode a function to get the initial state code of the account\n * @param {(message: { message: SignableMessage }) => Promise<Hex>} params.signMessage a function to sign a message\n * @param {(typedDataDefinition: TypedDataDefinition<typedData, primaryType>) => Promise<Hex>} params.signTypedData a function to sign typed data\n * @param {(transactions: Transaction[]) => Hex} [params.encodeBatchExecute] a function to encode batch transactions\n * @param {(tx: Transaction) => Hex} params.encodeExecute a function to encode a single transaction\n * @param {() => Promise<Hex>} params.getDummySignature a function to get a dummy signature\n * @param {(uoHash: Hex) => Promise<Hex>} [params.signUserOperationHash] a function to sign user operations\n * @param {(implementationAddress: Address, implementationCallData: Hex) => Hex} [params.encodeUpgradeToAndCall] a function to encode upgrade call\n * @returns {Promise<SmartContractAccount>} a promise that resolves to a SmartContractAccount object with methods and properties for interacting with the smart contract account\n */\nexport async function toSmartContractAccount(\n params: ToSmartContractAccountParams\n): Promise<SmartContractAccount> {\n const {\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n signMessage,\n signTypedData,\n encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n } = params;\n\n const client = createBundlerClient({\n // we set the retry count to 0 so that viem doesn't retry during\n // getting the address. That call always reverts and without this\n // viem will retry 3 times, making this call very slow\n transport: (opts) => transport({ ...opts, chain, retryCount: 0 }),\n chain,\n });\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const accountAddress_ = await getAccountAddress({\n client,\n entryPoint: entryPoint,\n accountAddress,\n getAccountInitCode,\n });\n\n let deploymentState = DeploymentState.UNDEFINED;\n\n const getInitCode = async () => {\n if (deploymentState === DeploymentState.DEPLOYED) {\n return \"0x\";\n }\n\n const contractCode = await client.getBytecode({\n address: accountAddress_,\n });\n\n if ((contractCode?.length ?? 0) > 2) {\n deploymentState = DeploymentState.DEPLOYED;\n return \"0x\";\n } else {\n deploymentState = DeploymentState.NOT_DEPLOYED;\n }\n\n return getAccountInitCode();\n };\n\n const signUserOperationHash_ =\n signUserOperationHash ??\n (async (uoHash: Hex) => {\n return signMessage({ message: { raw: hexToBytes(uoHash) } });\n });\n\n const getFactoryAddress = async (): Promise<Address> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[0];\n\n const getFactoryData = async (): Promise<Hex> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[1];\n\n const encodeUpgradeToAndCall_ =\n encodeUpgradeToAndCall ??\n (() => {\n throw new UpgradesNotSupportedError(source);\n });\n\n const isAccountDeployed = async () => {\n const initCode = await getInitCode();\n return initCode === \"0x\";\n };\n\n const getNonce = async (nonceKey = 0n): Promise<bigint> => {\n if (!(await isAccountDeployed())) {\n return 0n;\n }\n\n return entryPointContract.read.getNonce([\n accountAddress_,\n nonceKey,\n ]) as Promise<bigint>;\n };\n\n const account = toAccount({\n address: accountAddress_,\n signMessage,\n signTypedData,\n signTransaction: () => {\n throw new SignTransactionNotSupportedError();\n },\n });\n\n const create6492Signature = async (isDeployed: boolean, signature: Hex) => {\n if (isDeployed) {\n return signature;\n }\n\n const [factoryAddress, factoryCalldata] =\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode());\n\n return wrapSignatureWith6492({\n factoryAddress,\n factoryCalldata,\n signature,\n });\n };\n\n const signMessageWith6492 = async (message: { message: SignableMessage }) => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signMessage(message),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const signTypedDataWith6492 = async <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>\n ): Promise<Hex> => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signTypedData(typedDataDefinition),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const getImplementationAddress = async (): Promise<NullAddress | Address> => {\n const storage = await client.getStorageAt({\n address: account.address,\n // This is the default slot for the implementation address for Proxies\n slot: \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n });\n\n if (storage == null) {\n throw new FailedToGetStorageSlotError(\n \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n \"Proxy Implementation Address\"\n );\n }\n\n return trim(storage);\n };\n\n if (entryPoint.version !== \"0.6.0\" && entryPoint.version !== \"0.7.0\") {\n throw new InvalidEntryPointError(chain, entryPoint.version);\n }\n\n return {\n ...account,\n source,\n // TODO: I think this should probably be signUserOperation instead\n // and allow for generating the UO hash based on the EP version\n signUserOperationHash: signUserOperationHash_,\n getFactoryAddress,\n getFactoryData,\n encodeBatchExecute:\n encodeBatchExecute ??\n (() => {\n throw new BatchExecutionNotSupportedError(source);\n }),\n encodeExecute,\n getDummySignature,\n getInitCode,\n encodeUpgradeToAndCall: encodeUpgradeToAndCall_,\n getEntryPoint: () => entryPoint,\n isAccountDeployed,\n getNonce,\n signMessageWith6492,\n signTypedDataWith6492,\n getImplementationAddress,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"smartContractAccount.js","sourceRoot":"","sources":["../../../src/account/smartContractAccount.ts"],"names":[],"mappings":";;;AAAA,+BAcc;AACd,4CAA0C;AAC1C,iEAAiE;AAMjE,qDAM8B;AAC9B,mDAAyD;AACzD,2DAAiE;AACjE,4CAAsC;AAEtC,iDAA2D;AAU3D,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,uCAAoB,CAAA;IACpB,mCAAgB,CAAA;AAClB,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAiDM,MAAM,wBAAwB,GAAG,CACtC,OAA6B,EACc,EAAE;IAC7C,OAAO,WAAW,IAAI,OAAO,CAAC;AAChC,CAAC,CAAC;AAJW,QAAA,wBAAwB,4BAInC;AAyEK,MAAM,sCAAsC,GAAG,CACpD,QAAa,EACG,EAAE;IAClB,MAAM,cAAc,GAAY,KAAK,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;IACjE,MAAM,eAAe,GAAQ,KAAK,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;IAC3D,OAAO,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;AAC3C,CAAC,CAAC;AANW,QAAA,sCAAsC,0CAMjD;AA8BK,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,MAAM,EACN,UAAU,EACV,cAAc,EACd,kBAAkB,GACM,EAAE,EAAE;IAC5B,IAAI,cAAc;QAAE,OAAO,cAAc,CAAC;IAE1C,MAAM,kBAAkB,GAAG,IAAA,kBAAW,EAAC;QACrC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,k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C,MAAM,CAAC,CAAC;YACpD,CAAC,CAAC;QACJ,aAAa;QACb,iBAAiB;QACjB,WAAW;QACX,sBAAsB,EAAE,uBAAuB;QAC/C,aAAa,EAAE,GAAG,EAAE,CAAC,UAAU;QAC/B,iBAAiB;QACjB,QAAQ;QACR,mBAAmB;QACnB,qBAAqB;QACrB,wBAAwB;KACzB,CAAC;AACJ,CAAC;AA3LD,wDA2LC","sourcesContent":["import {\n getContract,\n hexToBytes,\n trim,\n type Address,\n type Chain,\n type CustomSource,\n type Hex,\n type LocalAccount,\n type PublicClient,\n type SignableMessage,\n type Transport,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport { toAccount } from \"viem/accounts\";\nimport { createBundlerClient } from \"../client/bundlerClient.js\";\nimport type {\n EntryPointDef,\n EntryPointRegistryBase,\n EntryPointVersion,\n} from \"../entrypoint/types.js\";\nimport {\n BatchExecutionNotSupportedError,\n FailedToGetStorageSlotError,\n GetCounterFactualAddressError,\n SignTransactionNotSupportedError,\n UpgradesNotSupportedError,\n} from \"../errors/account.js\";\nimport { InvalidRpcUrlError } from \"../errors/client.js\";\nimport { InvalidEntryPointError } from \"../errors/entrypoint.js\";\nimport { Logger } from \"../logger.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport { wrapSignatureWith6492 } from \"../signer/utils.js\";\nimport type { NullAddress } from \"../types.js\";\nimport type { IsUndefined } from \"../utils/types.js\";\n\nexport type AccountOp = {\n target: Address;\n value?: bigint;\n data: Hex | \"0x\";\n};\n\nexport enum DeploymentState {\n UNDEFINED = \"0x0\",\n NOT_DEPLOYED = \"0x1\",\n DEPLOYED = \"0x2\",\n}\n\nexport type GetEntryPointFromAccount<\n TAccount extends SmartContractAccount | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount\n> = GetAccountParameter<\n TAccount,\n TAccountOverride\n> extends SmartContractAccount<string, infer TEntryPointVersion>\n ? TEntryPointVersion\n : EntryPointVersion;\n\nexport type GetAccountParameter<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount\n> = IsUndefined<TAccount> extends true\n ? { account: TAccountOverride }\n : { account?: TAccountOverride };\n\nexport type UpgradeToAndCallParams = {\n upgradeToAddress: Address;\n upgradeToInitData: Hex;\n};\n\nexport type SmartContractAccountWithSigner<\n Name extends string = string,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = SmartContractAccount<Name, TEntryPointVersion> & {\n getSigner: () => TSigner;\n};\n\n/**\n * Determines if the given SmartContractAccount has a signer associated with it.\n *\n * @example\n * ```ts\n * import { toSmartContractAccount } from \"@aa-sdk/core\";\n *\n * const account = await toSmartContractAccount(...);\n *\n * console.log(isSmartAccountWithSigner(account)); // false: the base account does not have a publicly accessible signer\n * ```\n *\n * @param {SmartContractAccount} account The account to check.\n * @returns {boolean} true if the account has a signer, otherwise false.\n */\nexport const isSmartAccountWithSigner = (\n account: SmartContractAccount\n): account is SmartContractAccountWithSigner => {\n return \"getSigner\" in account;\n};\n\n// [!region SmartContractAccount]\nexport type SmartContractAccount<\n Name extends string = string,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = LocalAccount<Name> & {\n source: Name;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute: (txs: AccountOp[]) => Promise<Hex>;\n signUserOperationHash: (uoHash: Hex) => Promise<Hex>;\n signMessageWith6492: (params: { message: SignableMessage }) => Promise<Hex>;\n signTypedDataWith6492: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>\n ) => Promise<Hex>;\n encodeUpgradeToAndCall: (params: UpgradeToAndCallParams) => Promise<Hex>;\n getNonce(nonceKey?: bigint): Promise<bigint>;\n getInitCode: () => Promise<Hex>;\n isAccountDeployed: () => Promise<boolean>;\n getFactoryAddress: () => Promise<Address>;\n getFactoryData: () => Promise<Hex>;\n getEntryPoint: () => EntryPointDef<TEntryPointVersion>;\n getImplementationAddress: () => Promise<NullAddress | Address>;\n};\n// [!endregion SmartContractAccount]\n\nexport interface AccountEntryPointRegistry<Name extends string = string>\n extends EntryPointRegistryBase<\n SmartContractAccount<Name, EntryPointVersion>\n > {\n \"0.6.0\": SmartContractAccount<Name, \"0.6.0\">;\n \"0.7.0\": SmartContractAccount<Name, \"0.7.0\">;\n}\n\n// [!region ToSmartContractAccountParams]\nexport type ToSmartContractAccountParams<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = {\n source: Name;\n transport: TTransport;\n chain: TChain;\n entryPoint: EntryPointDef<TEntryPointVersion, TChain>;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute?: (txs: AccountOp[]) => Promise<Hex>;\n // if not provided, will default to just using signMessage over the Hex\n signUserOperationHash?: (uoHash: Hex) => Promise<Hex>;\n encodeUpgradeToAndCall?: (params: UpgradeToAndCallParams) => Promise<Hex>;\n} & Omit<CustomSource, \"signTransaction\" | \"address\">;\n// [!endregion ToSmartContractAccountParams]\n\n/**\n * Parses the factory address and factory calldata from the provided account initialization code (initCode).\n *\n * @example\n * ```ts\n * import { parseFactoryAddressFromAccountInitCode } from \"@aa-sdk/core\";\n *\n * const [address, calldata] = parseFactoryAddressFromAccountInitCode(\"0xAddressCalldata\");\n * ```\n *\n * @param {Hex} initCode The initialization code from which to parse the factory address and calldata\n * @returns {[Address, Hex]} A tuple containing the parsed factory address and factory calldata\n */\nexport const parseFactoryAddressFromAccountInitCode = (\n initCode: Hex\n): [Address, Hex] => {\n const factoryAddress: Address = `0x${initCode.substring(2, 42)}`;\n const factoryCalldata: Hex = `0x${initCode.substring(42)}`;\n return [factoryAddress, factoryCalldata];\n};\n\nexport type GetAccountAddressParams = {\n client: PublicClient;\n entryPoint: EntryPointDef;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n};\n\n/**\n * Retrieves the account address. Uses a provided `accountAddress` if available; otherwise, it computes the address using the entry point contract and the initial code.\n *\n * @example\n * ```ts\n * import { getEntryPoint, getAccountAddress } from \"@aa-sdk/core\";\n *\n * const accountAddress = await getAccountAddress({\n * client,\n * entryPoint: getEntryPoint(chain),\n * getAccountInitCode: async () => \"0x{factoryAddress}{factoryCallData}\",\n * });\n * ```\n *\n * @param {GetAccountAddressParams} params The configuration object\n * @param {PublicClient} params.client A public client instance to interact with the blockchain\n * @param {EntryPointDef} params.entryPoint The entry point definition which includes the address and ABI\n * @param {Address} params.accountAddress Optional existing account address\n * @param {() => Promise<Hex>} params.getAccountInitCode A function that returns a Promise resolving to a Hex string representing the initial code of the account\n * @returns {Promise<Address>} A promise that resolves to the account address\n */\nexport const getAccountAddress = async ({\n client,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n}: GetAccountAddressParams) => {\n if (accountAddress) return accountAddress;\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const initCode = await getAccountInitCode();\n Logger.verbose(\"[BaseSmartContractAccount](getAddress) initCode: \", initCode);\n\n try {\n await entryPointContract.simulate.getSenderAddress([initCode]);\n } catch (err: any) {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) getSenderAddress err: \",\n err\n );\n if (err.cause?.data?.errorName === \"SenderAddressResult\") {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) entryPoint.getSenderAddress result:\",\n err.cause.data.args[0]\n );\n\n return err.cause.data.args[0] as Address;\n }\n\n if (err.details === \"Invalid URL\") {\n throw new InvalidRpcUrlError();\n }\n }\n\n throw new GetCounterFactualAddressError();\n};\n\n// [!region toSmartContractAccount]\nexport async function toSmartContractAccount<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>({\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n signMessage,\n signTypedData,\n encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n}: ToSmartContractAccountParams<\n Name,\n TTransport,\n TChain,\n TEntryPointVersion\n>): Promise<SmartContractAccount<Name, TEntryPointVersion>>;\n// [!endregion toSmartContractAccount]\n\n/**\n * 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.\n *\n * @example\n * ```ts\n * import { http, type SignableMessage } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const myAccount = await toSmartContractAccount({\n * /// REQUIRED PARAMS ///\n * source: \"MyAccount\",\n * transport: http(\"RPC_URL\"),\n * chain: sepolia,\n * // The EntryPointDef that your account is com\"patible with\n * entryPoint: getEntryPoint(sepolia, { version: \"0.6.0\" }),\n * // This should return a concatenation of your `factoryAddress` and the `callData` for your factory's create account method\n * getAccountInitCode: async () => \"0x{factoryAddress}{callData}\",\n * // an invalid signature that doesn't cause your account to revert during validation\n * getDummySignature: () => \"0x1234...\",\n * // given a UO in the form of {target, data, value} should output the calldata for calling your contract's execution method\n * encodeExecute: async (uo) => \"0xcalldata\",\n * signMessage: async ({ message }: { message: SignableMessage }) => \"0x...\",\n * signTypedData: async (typedData) => \"0x000\",\n *\n * /// OPTIONAL PARAMS ///\n * // if you already know your account's address, pass that in here to avoid generating a new counterfactual\n * accountAddress: \"0xaddressoverride\",\n * // if your account supports batching, this should take an array of UOs and return the calldata for calling your contract's batchExecute method\n * encodeBatchExecute: async (uos) => \"0x...\",\n * // if your contract expects a different signing scheme than the default signMessage scheme, you can override that here\n * signUserOperationHash: async (hash) => \"0x...\",\n * // allows you to define the calldata for upgrading your account\n * encodeUpgradeToAndCall: async (params) => \"0x...\",\n * });\n * ```\n *\n * @param {ToSmartContractAccountParams} params the parameters required for converting to a smart contract account\n * @param {Transport} params.transport the transport mechanism used for communication\n * @param {Chain} params.chain the blockchain chain used in the account\n * @param {EntryPoint} params.entryPoint the entry point of the smart contract\n * @param {string} params.source the source identifier for the account\n * @param {Address} [params.accountAddress] the address of the account\n * @param {() => Promise<Hex>} params.getAccountInitCode a function to get the initial state code of the account\n * @param {(message: { message: SignableMessage }) => Promise<Hex>} params.signMessage a function to sign a message\n * @param {(typedDataDefinition: TypedDataDefinition<typedData, primaryType>) => Promise<Hex>} params.signTypedData a function to sign typed data\n * @param {(transactions: Transaction[]) => Hex} [params.encodeBatchExecute] a function to encode batch transactions\n * @param {(tx: Transaction) => Hex} params.encodeExecute a function to encode a single transaction\n * @param {() => Promise<Hex>} params.getDummySignature a function to get a dummy signature\n * @param {(uoHash: Hex) => Promise<Hex>} [params.signUserOperationHash] a function to sign user operations\n * @param {(implementationAddress: Address, implementationCallData: Hex) => Hex} [params.encodeUpgradeToAndCall] a function to encode upgrade call\n * @returns {Promise<SmartContractAccount>} a promise that resolves to a SmartContractAccount object with methods and properties for interacting with the smart contract account\n */\nexport async function toSmartContractAccount(\n params: ToSmartContractAccountParams\n): Promise<SmartContractAccount> {\n const {\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n signMessage,\n signTypedData,\n encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n } = params;\n\n const client = createBundlerClient({\n // we set the retry count to 0 so that viem doesn't retry during\n // getting the address. That call always reverts and without this\n // viem will retry 3 times, making this call very slow\n transport: (opts) => transport({ ...opts, chain, retryCount: 0 }),\n chain,\n });\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const accountAddress_ = await getAccountAddress({\n client,\n entryPoint: entryPoint,\n accountAddress,\n getAccountInitCode,\n });\n\n let deploymentState = DeploymentState.UNDEFINED;\n\n const getInitCode = async () => {\n if (deploymentState === DeploymentState.DEPLOYED) {\n return \"0x\";\n }\n\n const contractCode = await client.getBytecode({\n address: accountAddress_,\n });\n\n if ((contractCode?.length ?? 0) > 2) {\n deploymentState = DeploymentState.DEPLOYED;\n return \"0x\";\n } else {\n deploymentState = DeploymentState.NOT_DEPLOYED;\n }\n\n return getAccountInitCode();\n };\n\n const signUserOperationHash_ =\n signUserOperationHash ??\n (async (uoHash: Hex) => {\n return signMessage({ message: { raw: hexToBytes(uoHash) } });\n });\n\n const getFactoryAddress = async (): Promise<Address> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[0];\n\n const getFactoryData = async (): Promise<Hex> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[1];\n\n const encodeUpgradeToAndCall_ =\n encodeUpgradeToAndCall ??\n (() => {\n throw new UpgradesNotSupportedError(source);\n });\n\n const isAccountDeployed = async () => {\n const initCode = await getInitCode();\n return initCode === \"0x\";\n };\n\n const getNonce = async (nonceKey = 0n): Promise<bigint> => {\n if (!(await isAccountDeployed())) {\n return 0n;\n }\n\n return entryPointContract.read.getNonce([\n accountAddress_,\n nonceKey,\n ]) as Promise<bigint>;\n };\n\n const account = toAccount({\n address: accountAddress_,\n signMessage,\n signTypedData,\n signTransaction: () => {\n throw new SignTransactionNotSupportedError();\n },\n });\n\n const create6492Signature = async (isDeployed: boolean, signature: Hex) => {\n if (isDeployed) {\n return signature;\n }\n\n const [factoryAddress, factoryCalldata] =\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode());\n\n return wrapSignatureWith6492({\n factoryAddress,\n factoryCalldata,\n signature,\n });\n };\n\n const signMessageWith6492 = async (message: { message: SignableMessage }) => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signMessage(message),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const signTypedDataWith6492 = async <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>\n ): Promise<Hex> => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signTypedData(typedDataDefinition),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const getImplementationAddress = async (): Promise<NullAddress | Address> => {\n const storage = await client.getStorageAt({\n address: account.address,\n // This is the default slot for the implementation address for Proxies\n slot: \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n });\n\n if (storage == null) {\n throw new FailedToGetStorageSlotError(\n \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n \"Proxy Implementation Address\"\n );\n }\n\n return trim(storage);\n };\n\n if (entryPoint.version !== \"0.6.0\" && entryPoint.version !== \"0.7.0\") {\n throw new InvalidEntryPointError(chain, entryPoint.version);\n }\n\n return {\n ...account,\n source,\n // TODO: I think this should probably be signUserOperation instead\n // and allow for generating the UO hash based on the EP version\n signUserOperationHash: signUserOperationHash_,\n getFactoryAddress,\n getFactoryData,\n encodeBatchExecute:\n encodeBatchExecute ??\n (() => {\n throw new BatchExecutionNotSupportedError(source);\n }),\n encodeExecute,\n getDummySignature,\n getInitCode,\n encodeUpgradeToAndCall: encodeUpgradeToAndCall_,\n getEntryPoint: () => entryPoint,\n isAccountDeployed,\n getNonce,\n signMessageWith6492,\n signTypedDataWith6492,\n getImplementationAddress,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUserOperationFromTx.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTx.ts"],"names":[],"mappings":";;;AAUA,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AACjE,gEAA6E;AAK7E,mEAA6D;AA0CtD,KAAK,UAAU,wBAAwB,CAW5C,MAA2C,EAC3C,IAAiE,EACjE,SAAsD,EACtD,OAAkB;IAElB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;IACtD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,+CAA8B,EAAE,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG;QACjB,GAAG,SAAS;QACZ,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;QACrE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;YAChD,CAAC,CAAC,OAAO,CAAC,oBAAoB;YAC9B,CAAC,CAAC,SAAS;KACgC,CAAC;IAEhD,OAAO,IAAA,0CAAkB,EAAC,MAAM,EAAE;QAChC,EAAE,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,EAAE;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;SAC1C;QACD,OAAO,EAAE,OAA+B;QACxC,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC;AAnDD,4DAmDC","sourcesContent":["import {\n type Chain,\n type Client,\n type SendTransactionParameters,\n type Transport,\n} from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type {\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type { UserOperationContext } from \"./types.js\";\n\n/**\n * Performs
|
|
1
|
+
{"version":3,"file":"buildUserOperationFromTx.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTx.ts"],"names":[],"mappings":";;;AAUA,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AACjE,gEAA6E;AAK7E,mEAA6D;AA0CtD,KAAK,UAAU,wBAAwB,CAW5C,MAA2C,EAC3C,IAAiE,EACjE,SAAsD,EACtD,OAAkB;IAElB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;IACtD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,+CAA8B,EAAE,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG;QACjB,GAAG,SAAS;QACZ,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;QACrE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;YAChD,CAAC,CAAC,OAAO,CAAC,oBAAoB;YAC9B,CAAC,CAAC,SAAS;KACgC,CAAC;IAEhD,OAAO,IAAA,0CAAkB,EAAC,MAAM,EAAE;QAChC,EAAE,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,EAAE;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;SAC1C;QACD,OAAO,EAAE,OAA+B;QACxC,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC;AAnDD,4DAmDC","sourcesContent":["import {\n type Chain,\n type Client,\n type SendTransactionParameters,\n type Transport,\n} from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type {\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type { UserOperationContext } from \"./types.js\";\n\n/**\n * Performs `buildUserOperationFromTx` in batch and builds into a single, yet to be signed `UserOperation` (UO) struct. The output user operation struct will be filled with all gas fields (and paymaster data if a paymaster is used) based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`, `maxPriorityFeePerGas`) computed using the configured [`ClientMiddlewares`](/packages/aa-core/smart-account-client/middleware/index) on the `SmartAccountClient`\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * // buildUserOperationFromTx converts a traditional Ethereum transaction and returns\n * // the unsigned user operation struct after constructing the user operation struct\n * // through the middleware pipeline\n * const tx: RpcTransactionRequest = {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * };\n * const uoStruct = await smartAccountClient.buildUserOperationFromTx(tx);\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });\n * ```\n *\n * @param {Client<Transport, TChain, TAccount>} client the smart account client to use for RPC requests\n * @param {SendTransactionParameters} args the send tx parameters\n * @param {UserOperationOverrides} overrides optional overrides to use for any of the fields\n * @param {TContext} context if the smart account client requires additinoal context for building UOs\n * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTx<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<Transport, TChain, TAccount>,\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const { account = client.account, ...request } = args;\n if (!account || typeof account === \"string\") {\n throw new AccountNotFoundError();\n }\n\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTx\",\n client\n );\n }\n\n const _overrides = {\n ...overrides,\n maxFeePerGas: request.maxFeePerGas ? request.maxFeePerGas : undefined,\n maxPriorityFeePerGas: request.maxPriorityFeePerGas\n ? request.maxPriorityFeePerGas\n : undefined,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n return buildUserOperation(client, {\n uo: {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? request.value : 0n,\n },\n account: account as SmartContractAccount,\n context,\n overrides: _overrides,\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUserOperationFromTxs.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTxs.ts"],"names":[],"mappings":";;;AAAA,+BAAwE;AAKxE,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AACjE,gEAA6E;AAE7E,mDAAiD;AACjD,mEAA6D;
|
|
1
|
+
{"version":3,"file":"buildUserOperationFromTxs.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTxs.ts"],"names":[],"mappings":";;;AAAA,+BAAwE;AAKxE,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AACjE,gEAA6E;AAE7E,mDAAiD;AACjD,mEAA6D;AA6DtD,KAAK,UAAU,yBAAyB,CAW7C,MAA4C,EAC5C,IAAwE;IAExE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,2BAA2B,EAC3B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACrC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;YAChB,MAAM,IAAI,+CAA8B,EAAE,CAAC;QAC7C,CAAC;QAED,OAAO;YACL,MAAM,EAA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AS,CAAC;IAEhB,MAAM,UAAU,GAAG;QACjB,YAAY;QACZ,oBAAoB;KACyB,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,IAAA,0CAAkB,EAAC,MAAM,EAAE;QAChD,EAAE,EAAE,KAAK;QACT,OAAO;QACP,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ;QAER,KAAK;QACL,SAAS,EAAE,UAAU;KACtB,CAAC;AACJ,CAAC;AA/ED,8DA+EC","sourcesContent":["import { fromHex, type Chain, type Client, type Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type { UserOperationOverrides } from \"../../types\";\nimport { bigIntMax } from \"../../utils/index.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n BuildTransactionParameters,\n BuildUserOperationFromTransactionsResult,\n UserOperationContext,\n} from \"./types\";\n\n/**\n * Performs `buildUserOperationFromTx` in batch and builds into a single,\n * yet to be signed `UserOperation` (UO) struct. The output user operation struct\n * will be filled with all gas fields (and paymaster data if a paymaster is used)\n * based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`,\n * `maxPriorityFeePerGas`) computed using the configured ClientMiddlewares on the SmartAccountClient.\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n *\n * const requests: RpcTransactionRequest[] = [\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * ];\n * const uoStruct = await smartAccountClient.buildUserOperationFromTxs({\n * requests,\n * });\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({\n * request,\n * entryPoint: entryPointAddress,\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use to make RPC calls\n * @param {BuildTransactionParameters} args an object containing the requests to build as well as, the account if not hoisted, the context, the overrides, and optionally a flag to enable signing of the UO via the underlying middleware\n * @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTxs<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: BuildTransactionParameters<TAccount, TContext, TEntryPointVersion>\n): Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>> {\n const { account = client.account, requests, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTxs\",\n client\n );\n }\n\n const batch = requests.map((request) => {\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n return {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? fromHex(request.value, \"bigint\") : 0n,\n };\n });\n\n const mfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxFeePerGas != null)\n .map((x) => fromHex(x.maxFeePerGas!, \"bigint\"));\n const maxFeePerGas =\n overrides?.maxFeePerGas != null\n ? overrides?.maxFeePerGas\n : mfpgOverridesInTx().length > 0\n ? bigIntMax(...mfpgOverridesInTx())\n : undefined;\n\n const mpfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxPriorityFeePerGas != null)\n .map((x) => fromHex(x.maxPriorityFeePerGas!, \"bigint\"));\n const maxPriorityFeePerGas =\n overrides?.maxPriorityFeePerGas != null\n ? overrides?.maxPriorityFeePerGas\n : mpfpgOverridesInTx().length > 0\n ? bigIntMax(...mpfpgOverridesInTx())\n : undefined;\n\n const _overrides = {\n maxFeePerGas,\n maxPriorityFeePerGas,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n const uoStruct = await buildUserOperation(client, {\n uo: batch,\n account,\n context,\n overrides: _overrides,\n });\n\n return {\n uoStruct,\n // TODO: in v4 major version update, remove these as below parameters are not needed\n batch,\n overrides: _overrides,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkGasSponsorshipEligibility.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/checkGasSponsorshipEligibility.ts"],"names":[],"mappings":";;;AAEA,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AAEjE,mEAA6D;AAkC7D,SAAgB,8BAA8B,CAU5C,MAA4C,EAC5C,IAAqD;IAErD,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,0CAAkB,EAAC,MAAM,EAAE;QAChC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO;QACP,SAAS;QACT,OAAO;KACR,CAAC;SACC,IAAI,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAC5B,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;QACzC,CAAC,CAAE,mBAAoD;aAClD,gBAAgB,KAAK,IAAI;YAC3B,mBAAoD;iBAClD,gBAAgB,KAAK,IAAI;QAC9B,CAAC,CAAE,mBAAoD;aAClD,aAAa,KAAK,IAAI;YACxB,mBAAoD;iBAClD,aAAa,KAAK,IAAI,CAC9B;SACA,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AA7CD,wEA6CC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type { SmartContractAccount } from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\n\n/**\n * This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.\n * Internally, this method invokes
|
|
1
|
+
{"version":3,"file":"checkGasSponsorshipEligibility.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/checkGasSponsorshipEligibility.ts"],"names":[],"mappings":";;;AAEA,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AAEjE,mEAA6D;AAkC7D,SAAgB,8BAA8B,CAU5C,MAA4C,EAC5C,IAAqD;IAErD,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,0CAAkB,EAAC,MAAM,EAAE;QAChC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO;QACP,SAAS;QACT,OAAO;KACR,CAAC;SACC,IAAI,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAC5B,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;QACzC,CAAC,CAAE,mBAAoD;aAClD,gBAAgB,KAAK,IAAI;YAC3B,mBAAoD;iBAClD,gBAAgB,KAAK,IAAI;QAC9B,CAAC,CAAE,mBAAoD;aAClD,aAAa,KAAK,IAAI;YACxB,mBAAoD;iBAClD,aAAa,KAAK,IAAI,CAC9B;SACA,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AA7CD,wEA6CC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type { SmartContractAccount } from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\n\n/**\n * This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.\n * Internally, this method invokes `buildUserOperation`, which navigates through the middleware pipeline, including the `PaymasterMiddleware`. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty `paymasterAndData` field.\n * You can utilize this method before sending the user operation to confirm its eligibility for gas sponsorship. Depending on the outcome, it allows you to tailor the user experience accordingly, based on eligibility.\n *\n * @example\n * ```ts\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * const eligible = await smartAccountClient.checkGasSponsorshipEligibility({\n * uo: {\n * data: \"0xCalldata\",\n * target: \"0xTarget\",\n * value: 0n,\n * },\n * });\n *\n * console.log(\n * `User Operation is ${\n * eligible ? \"eligible\" : \"ineligible\"\n * } for gas sponsorship.`\n * );\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for making RPC calls\n * @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides\n * @returns {Promise<boolean>} a Promise containing a boolean indicating if the account is elgibile for sponsorship\n */\nexport function checkGasSponsorshipEligibility<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<boolean> {\n const { account = client.account, overrides, context } = args;\n\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"checkGasSponsorshipEligibility\",\n client\n );\n }\n\n return buildUserOperation(client, {\n uo: args.uo,\n account,\n overrides,\n context,\n })\n .then((userOperationStruct) =>\n account.getEntryPoint().version === \"0.6.0\"\n ? (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== null\n : (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== null\n )\n .catch(() => false);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/estimateUserOperationGas.ts"],"names":[],"mappings":";;;AAKA,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AAEjE,mDAAsE;AACtE,0EAAqE;AAmB9D,KAAK,UAAU,wBAAwB,CAW5C,MAA4C,EAC5C,IAAqD;IAErD,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACrD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,yCAAkB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5D,MAAM,OAAO,GAAG,IAAA,sBAAW,EAAC,MAAM,IAAA,4BAAiB,EAAC,MAAM,CAAC,CAAC,CAAC;QAC7D,OAAO,MAAM,CAAC,wBAAwB,CACpC,OAAO,EACP,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,EAC/B,SAAS,EAAE,aAAa,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAnCD,4DAmCC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport {\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationEstimateGasResponse } from \"../../types.js\";\nimport { deepHexlify, resolveProperties } from \"../../utils/index.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types.js\";\n\n/**\n * Description SmartAccountClientAction for estimating the gas cost of a user operation\n *\n * @async\n * @template {Transport} TTransport\n * @template {Chain | undefined} TChain\n * @template {SmartContractAccount | undefined} TAccount\n * @template {UserOperationContext | undefined} TContext\n * @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion\n * @param client smart account client\n * @param args send user operation parameters\n * @returns user operation gas estimate response\n */\nexport async function estimateUserOperationGas<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>> {\n const { account = client.account, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"estimateUserOperationGas\",\n client\n );\n }\n\n return _initUserOperation(client, args).then(async (struct) => {\n const request = deepHexlify(await resolveProperties(struct));\n return client.estimateUserOperationGas(\n request,\n account.getEntryPoint().address,\n overrides?.stateOverride\n );\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/estimateUserOperationGas.ts"],"names":[],"mappings":";;;AAKA,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AAEjE,mDAAsE;AACtE,0EAAqE;AAmB9D,KAAK,UAAU,wBAAwB,CAW5C,MAA4C,EAC5C,IAAqD;IAErD,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACrD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,yCAAkB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5D,MAAM,OAAO,GAAG,IAAA,sBAAW,EAAC,MAAM,IAAA,4BAAiB,EAAC,MAAM,CAAC,CAAC,CAAC;QAC7D,OAAO,MAAM,CAAC,wBAAwB,CACpC,OAAO,EACP,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,EAC/B,SAAS,EAAE,aAAa,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAnCD,4DAmCC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport {\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationEstimateGasResponse } from \"../../types.js\";\nimport { deepHexlify, resolveProperties } from \"../../utils/index.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types.js\";\n\n/**\n * Description SmartAccountClientAction for estimating the gas cost of a user operation\n *\n * @async\n * @template {Transport} TTransport\n * @template {Chain | undefined} TChain\n * @template {SmartContractAccount | undefined} TAccount\n * @template {UserOperationContext | undefined} TContext\n * @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion\n * @param {Client<TTransport, TChain, TAccount>} client smart account client\n * @param {SendUserOperationParameters<TAccount, TContext>} args send user operation parameters\n * @returns {Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>}user operation gas estimate response\n */\nexport async function estimateUserOperationGas<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>> {\n const { account = client.account, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"estimateUserOperationGas\",\n client\n );\n }\n\n return _initUserOperation(client, args).then(async (struct) => {\n const request = deepHexlify(await resolveProperties(struct));\n return client.estimateUserOperationGas(\n request,\n account.getEntryPoint().address,\n overrides?.stateOverride\n );\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initUserOperation.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/initUserOperation.ts"],"names":[],"mappings":";;;AAMA,2DAAkE;AAClE,yDAA+D;AAE/D,sDAA6E;
|
|
1
|
+
{"version":3,"file":"initUserOperation.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/initUserOperation.ts"],"names":[],"mappings":";;;AAMA,2DAAkE;AAClE,yDAA+D;AAE/D,sDAA6E;AAoBtE,KAAK,UAAU,kBAAkB,CAWtC,MAA4D,EAC5D,IAEwE;IAExE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACzD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,M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AAChB,CAAC;AA9DD,gDA8DC","sourcesContent":["import type { Chain, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../../account/smartContractAccount.js\";\nimport type { BaseSmartAccountClient } from \"../../../client/smartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../../errors/account.js\";\nimport { ChainNotFoundError } from \"../../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../../types.js\";\nimport { conditionalReturn, type Deferrable } from \"../../../utils/index.js\";\nimport type {\n BuildUserOperationParameters,\n SendUserOperationParameters,\n UserOperationContext,\n} from \"../types.js\";\n\n/**\n * Description internal action function of SmartAccountClient for initializing\n * a user operation for the sender account\n *\n * @template {Transport} TTransport\n * @template {Chain | undefined} TChain\n * @template {SmartContractAccount | undefined} TAccount\n * @template {UserOperationContext | undefined} TContext\n * @template {GetEntryPointFromAccount} TEntryPointVersion\n * @param {BaseSmartAccountClient<TTransport, TChain, TAccount>} client smart account client\n * @param {SendUserOperationParameters<TAccount, TContext, TEntryPointVersion> | BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args send user operation parameters\n * @returns {Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>} initialized user operation struct\n */\nexport async function _initUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: BaseSmartAccountClient<TTransport, TChain, TAccount>,\n args:\n | SendUserOperationParameters<TAccount, TContext, TEntryPointVersion>\n | BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>\n): Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>> {\n const { account = client.account, uo, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const entryPoint = account.getEntryPoint();\n\n const callData = Array.isArray(uo)\n ? account.encodeBatchExecute(uo)\n : typeof uo === \"string\"\n ? uo\n : account.encodeExecute(uo);\n\n const signature = account.getDummySignature();\n\n const nonce = account.getNonce(overrides?.nonceKey);\n\n const struct =\n entryPoint.version === \"0.6.0\"\n ? ({\n initCode: account.getInitCode(),\n sender: account.address,\n nonce,\n callData,\n signature,\n } as Deferrable<UserOperationStruct<TEntryPointVersion>>)\n : ({\n factory: conditionalReturn(\n account.isAccountDeployed().then((deployed) => !deployed),\n account.getFactoryAddress\n ),\n factoryData: conditionalReturn(\n account.isAccountDeployed().then((deployed) => !deployed),\n account.getFactoryData\n ),\n sender: account.address,\n nonce,\n callData,\n signature,\n } as Deferrable<UserOperationStruct<TEntryPointVersion>>);\n\n return struct;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runMiddlewareStack.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/runMiddlewareStack.ts"],"names":[],"mappings":";;;AAOA,2DAAkE;AAClE,6EAAuE;AAMvE,sDAIiC;
|
|
1
|
+
{"version":3,"file":"runMiddlewareStack.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/runMiddlewareStack.ts"],"names":[],"mappings":";;;AAOA,2DAAkE;AAClE,6EAAuE;AAMvE,sDAIiC;AAGjC,MAAM,SAAS,GACb,CAAU,GAAG,GAAyC,EAAE,EAAE,CAC1D,KAAK,EAAE,CAAI,EAAE,IAAU,EAAE,EAAE;IACzB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEG,KAAK,UAAU,mBAAmB,CAWvC,MAA4D,EAC5D,IAIqD;IAErD,MAAM,EAAE,EAAE,EAAE,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CAAC,CAAC;IAE9E,OAAO,IAAA,4BAAiB,EAEtB,MAAM,CAAC,CAAC;AACZ,CAAC;AAnED,kDAmEC","sourcesContent":["import type { Chain, Transport } from \"viem\";\nimport type {\n GetAccountParameter,\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../../account/smartContractAccount\";\nimport type { BaseSmartAccountClient } from \"../../../client/smartAccountClient\";\nimport { AccountNotFoundError } from \"../../../errors/account.js\";\nimport { noopMiddleware } from \"../../../middleware/noopMiddleware.js\";\nimport type { ClientMiddleware } from \"../../../middleware/types\";\nimport type {\n UserOperationOverridesParameter,\n UserOperationStruct,\n} from \"../../../types\";\nimport {\n bypassPaymasterAndData,\n resolveProperties,\n type Deferrable,\n} from \"../../../utils/index.js\";\nimport type { UserOperationContext } from \"../types\";\n\nconst asyncPipe =\n <S, Opts>(...fns: ((s: S, opts: Opts) => Promise<S>)[]) =>\n async (s: S, opts: Opts) => {\n let result = s;\n for (const fn of fns) {\n result = await fn(result, opts);\n }\n return result;\n };\n\nexport async function _runMiddlewareStack<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: BaseSmartAccountClient<TTransport, TChain, TAccount>,\n args: {\n uo: Deferrable<UserOperationStruct<TEntryPointVersion>>;\n context?: TContext;\n } & GetAccountParameter<TAccount> &\n UserOperationOverridesParameter<TEntryPointVersion>\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const { uo, overrides, account = client.account, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n const {\n dummyPaymasterAndData,\n paymasterAndData,\n }: Pick<\n ClientMiddleware<TContext>,\n \"dummyPaymasterAndData\" | \"paymasterAndData\"\n > = bypassPaymasterAndData(overrides)\n ? {\n dummyPaymasterAndData: async (uo, { overrides }) => {\n return {\n ...uo,\n ...(\"paymasterAndData\" in overrides!\n ? { paymasterAndData: overrides.paymasterAndData }\n : \"paymasterData\" in overrides! &&\n \"paymaster\" in overrides &&\n overrides.paymasterData !== \"0x\"\n ? {\n paymasterData: overrides.paymasterData,\n paymaster: overrides.paymaster,\n }\n : // At this point, nothing has run so no fields are set\n // for 0.7 when not using a paymaster, all fields should be undefined\n undefined),\n };\n },\n paymasterAndData: noopMiddleware,\n }\n : {\n dummyPaymasterAndData: client.middleware.dummyPaymasterAndData,\n paymasterAndData: client.middleware.paymasterAndData,\n };\n\n const result = await asyncPipe(\n dummyPaymasterAndData,\n client.middleware.feeEstimator,\n client.middleware.gasEstimator,\n client.middleware.customMiddleware,\n paymasterAndData,\n client.middleware.userOperationSimulator\n )(uo, { overrides, feeOptions: client.feeOptions, account, client, context });\n\n return resolveProperties<\n UserOperationStruct<GetEntryPointFromAccount<TAccount>>\n >(result);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/sendUserOperation.ts"],"names":[],"mappings":";;;AAQA,2DAAkE;AAClE,yDAA+D;AAK/D,kEAA4D;
|
|
1
|
+
{"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/sendUserOperation.ts"],"names":[],"mappings":";;;AAQA,2DAAkE;AAClE,yDAA+D;AAK/D,kEAA4D;AAGrD,KAAK,UAAU,kBAAkB,CAWtC,MAA4D,EAC5D,IAI+B;IAE/B,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,8BAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG,MAAM,IAAA,wCAAiB,EAAC,MAAM,EAAE;QAC9C,QAAQ;QACR,OAAO;QACP,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,MAAM,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;QACpE,OAAO;KACR,CAAC;AACJ,CAAC;AAvCD,gDAuCC","sourcesContent":["import type { Chain, Transport } from \"viem\";\nimport type {\n GetAccountParameter,\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../../account/smartContractAccount\";\nimport type { BaseSmartAccountClient } from \"../../../client/smartAccountClient\";\nimport type { SendUserOperationResult } from \"../../../client/types\";\nimport { AccountNotFoundError } from \"../../../errors/account.js\";\nimport { ChainNotFoundError } from \"../../../errors/client.js\";\nimport type {\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../../../types\";\nimport { signUserOperation } from \"../signUserOperation.js\";\nimport type { GetContextParameter, UserOperationContext } from \"../types\";\n\nexport async function _sendUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: BaseSmartAccountClient<TTransport, TChain, TAccount>,\n args: {\n uoStruct: UserOperationStruct<TEntryPointVersion>;\n overrides?: UserOperationOverrides<TEntryPointVersion>;\n } & GetAccountParameter<TAccount> &\n GetContextParameter<TContext>\n): Promise<SendUserOperationResult<TEntryPointVersion>> {\n const { account = client.account, uoStruct, context, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const entryPoint = account.getEntryPoint();\n const request = await signUserOperation(client, {\n uoStruct,\n account,\n context,\n overrides,\n });\n\n return {\n hash: await client.sendRawUserOperation(request, entryPoint.address),\n request,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendUserOperation.ts"],"names":[],"mappings":";;;AAKA,kFAAgF;AAEhF,wDAA+D;AAC/D,sDAAiE;AACjE,mEAA6D;AAC7D,0EAAqE;
|
|
1
|
+
{"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendUserOperation.ts"],"names":[],"mappings":";;;AAKA,kFAAgF;AAEhF,wDAA+D;AAC/D,sDAAiE;AACjE,mEAA6D;AAC7D,0EAAqE;AA2B9D,KAAK,UAAU,iBAAiB,CAWrC,MAA4C,EAC5C,IAAqD;IAErD,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,mBAAmB,EACnB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,IAAA,0CAAkB,EAAC,MAAM,EAAE;QAChD,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO;QACP,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO,IAAA,yCAAkB,EAAC,MAAM,EAAE;QAChC,OAAO;QACP,QAAQ;QACR,OAAO;QACP,SAAS;KACV,CAAC,CAAC;AACL,CAAC;AAzCD,8CAyCC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport type { SendUserOperationResult } from \"../../client/types.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types.js\";\n\n/**\n * Sends a user operation or batch of user operations using the connected account. Before executing, sendUserOperation will run the user operation through the middleware pipeline.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient, toSmartContractAccount } from \"@aa-sdk/core\";\n *\n * const account = await toSmartContractAccount(...);\n * const result = await createSmartAccountClient(...).sendUserOperation({\n * uo: {\n * target: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * }\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for RPC requests\n * @param {SendUserOperationParameters<TAccount, TContext>} args contains the UO or batch to send, context, overrides, and account if not hoisted on the client\n * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} a Promise containing the result of the user operation\n */\nexport async function sendUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<SendUserOperationResult<TEntryPointVersion>> {\n const { account = client.account, context, overrides } = args;\n\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"sendUserOperation\",\n client\n );\n }\n\n const uoStruct = await buildUserOperation(client, {\n uo: args.uo,\n account,\n context,\n overrides,\n });\n\n return _sendUserOperation(client, {\n account,\n uoStruct,\n context,\n overrides,\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundlerClient.js","sourceRoot":"","sources":["../../../src/client/bundlerClient.ts"],"names":[],"mappings":";;;AAAA,+BAac;AACd,mDAAyD;AACzD,8CAAwC;AACxC,oEAIuC;AA0BhC,MAAM,+BAA+B,GAIpB,CACtB,MAA8B,EACZ,EAAE;IACpB,OAAO,MAAM,CAAC,MAAM,CAAC,iCAAc,CAAC,CAAC;AACvC,CAAC,CAAC;AARW,QAAA,+BAA+B,mCAQ1C;AA8BF,SAAgB,mBAAmB,CACjC,IAA4C;IAE5C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,8BAAkB,EAAE,CAAC;IACjC,CAAC;IACD,MAAM,EACJ,GAAG,GAAG,gBAAgB,EACtB,IAAI,GAAG,uBAAuB,EAC9B,IAAI,GAAG,eAAe,GACvB,GAAG,IAAI,CAAC;IAET,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACpC,MAAM,iBAAiB,GAAG,SAAS,CAAC;QAClC,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,eAAe,EAAE,IAAI,CAAC,eAAe;KACtC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG;QACrB,GAAG,IAAI;QACP,GAAG;QACH,IAAI;QACJ,IAAI;KACL,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE;QACnB,IAAI,iBAAiB,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC7C,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,iBAAiB,CAAC,KAG9D,CAAC;YAEF,MAAM,YAAY,GAAG,aAAa,IAAI,EAAE,CAAC;YAEzC,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC9C,YAAY,CAAC,OAAO,GAAG;oBACrB,GAAG,YAAY,CAAC,OAAO;oBACvB,wBAAwB,EAAE,oBAAO;iBAClC,CAAC;YACJ,CAAC;YAED,OAAO,IAAA,mBAAY,EAAmB;gBACpC,GAAG,cAAc;gBACjB,SAAS,EAAE,IAAA,WAAI,EAAC,GAAG,EAAE;oBACnB,GAAG,iBAAiB,CAAC,MAAM;oBAC3B,YAAY;iBACb,CAAC;aACH,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAA,mBAAY,EAAmB,cAAc,CAAC,CAAC;IACxD,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,MAAM,CAAC,MAAM,CAAC,oBAAa,CAAC,CAAC,MAAM,CAAC,iCAAc,CAAC,CAAC;AAC7D,CAAC;AAtDD,kDAsDC","sourcesContent":["import {\n createClient,\n http,\n publicActions,\n type Chain,\n type Client,\n type FallbackTransport,\n type HttpTransportConfig,\n type PublicActions,\n type PublicClient,\n type PublicClientConfig,\n type PublicRpcSchema,\n type Transport,\n} from \"viem\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport { VERSION } from \"../version.js\";\nimport {\n bundlerActions,\n type BundlerActions,\n type BundlerRpcSchema,\n} from \"./decorators/bundlerClient.js\";\n\n// [!region BundlerClient]\nexport type BundlerClient<T extends Transport = Transport> = Client<\n T,\n Chain,\n undefined,\n [...PublicRpcSchema, ...BundlerRpcSchema],\n PublicActions<T, Chain> & BundlerActions\n>;\n\n/**\n * Creates a bundler client from an existing public client with the provided transport and chain.\n *\n * @example\n * ```ts\n * import { createPublicClient } from \"viem\";\n * import { createBundlerClientFromExisting } from \"@aa-sdk/core\";\n *\n * const publicClient = createPublicClient(...);\n * const bundlerClient = createBundlerClientFromExisting(publicClient);\n * ```\n *\n * @param {PublicClient<T, Chain>} client The existing public client to be extended with bundler actions\n * @returns {BundlerClient<T>} A bundler client that extends the functionality of the provided public client\n */\nexport const createBundlerClientFromExisting: <\n T extends Transport | FallbackTransport = Transport\n>(\n client: PublicClient<T, Chain>\n) => BundlerClient<T> = <T extends Transport | FallbackTransport = Transport>(\n client: PublicClient<T, Chain>\n): BundlerClient<T> => {\n return client.extend(bundlerActions);\n};\n// [!endregion BundlerClient]\n\n/**\n * Creates a PublicClient with methods for calling Bundler RPC methods\n *\n * @param args - configuration for the client\n * @returns a PublicClient with methods for calling Bundler RPC methods\n */\nexport function createBundlerClient<TTransport extends Transport>(\n args: PublicClientConfig<TTransport, Chain> & { type?: string }\n): BundlerClient<TTransport>;\n\n/**\n * Creates a Bundler Client using the provided configuration parameters, including chain and optional type.\n *\n * @example\n * ```ts\n * import { createBundlerClient } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n *\n * const client = createBundlerClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * });\n * ```\n *\n * @param {PublicClientConfig & { type?: string }} args Configuration for creating the Bundler Client, including parameters for the chain, transport, and optional type\n * @returns {BundlerClient} The created Bundler Client with extended public and bundler actions\n */\nexport function createBundlerClient(\n args: PublicClientConfig & { type?: string }\n): BundlerClient {\n if (!args.chain) {\n throw new ChainNotFoundError();\n }\n const {\n key = \"bundler-public\",\n name = \"Public Bundler Client\",\n type = \"bundlerClient\",\n } = args;\n\n const { transport, ...opts } = args;\n const resolvedTransport = transport({\n chain: args.chain,\n pollingInterval: opts.pollingInterval,\n });\n\n const baseParameters = {\n ...args,\n key,\n name,\n type,\n };\n\n const client = (() => {\n if (resolvedTransport.config.type === \"http\") {\n const { url, fetchOptions: fetchOptions_ } = resolvedTransport.value as {\n fetchOptions: HttpTransportConfig[\"fetchOptions\"];\n url: string;\n };\n\n const fetchOptions = fetchOptions_ ?? {};\n\n if (url.toLowerCase().indexOf(\"alchemy\") > -1) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n \"Alchemy-AA-Sdk-Version\": VERSION,\n };\n }\n\n return createClient<Transport, Chain>({\n ...baseParameters,\n transport: http(url, {\n ...resolvedTransport.config,\n fetchOptions,\n }),\n });\n }\n\n return createClient<Transport, Chain>(baseParameters);\n })();\n\n return client.extend(publicActions).extend(bundlerActions);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bundlerClient.js","sourceRoot":"","sources":["../../../src/client/bundlerClient.ts"],"names":[],"mappings":";;;AAAA,+BAac;AACd,mDAAyD;AACzD,8CAAwC;AACxC,oEAIuC;AA0BhC,MAAM,+BAA+B,GAIpB,CACtB,MAA8B,EACZ,EAAE;IACpB,OAAO,MAAM,CAAC,MAAM,CAAC,iCAAc,CAAC,CAAC;AACvC,CAAC,CAAC;AARW,QAAA,+BAA+B,mCAQ1C;AA8BF,SAAgB,mBAAmB,CACjC,IAA4C;IAE5C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,8BAAkB,EAAE,CAAC;IACjC,CAAC;IACD,MAAM,EACJ,GAAG,GAAG,gBAAgB,EACtB,IAAI,GAAG,uBAAuB,EAC9B,IAAI,GAAG,eAAe,GACvB,GAAG,IAAI,CAAC;IAET,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACpC,MAAM,iBAAiB,GAAG,SAAS,CAAC;QAClC,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,eAAe,EAAE,IAAI,CAAC,eAAe;KACtC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG;QACrB,GAAG,IAAI;QACP,GAAG;QACH,IAAI;QACJ,IAAI;KACL,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE;QACnB,IAAI,iBAAiB,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC7C,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,iBAAiB,CAAC,KAG9D,CAAC;YAEF,MAAM,YAAY,GAAG,aAAa,IAAI,EAAE,CAAC;YAEzC,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC9C,YAAY,CAAC,OAAO,GAAG;oBACrB,GAAG,YAAY,CAAC,OAAO;oBACvB,wBAAwB,EAAE,oBAAO;iBAClC,CAAC;YACJ,CAAC;YAED,OAAO,IAAA,mBAAY,EAAmB;gBACpC,GAAG,cAAc;gBACjB,SAAS,EAAE,IAAA,WAAI,EAAC,GAAG,EAAE;oBACnB,GAAG,iBAAiB,CAAC,MAAM;oBAC3B,YAAY;iBACb,CAAC;aACH,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAA,mBAAY,EAAmB,cAAc,CAAC,CAAC;IACxD,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,MAAM,CAAC,MAAM,CAAC,oBAAa,CAAC,CAAC,MAAM,CAAC,iCAAc,CAAC,CAAC;AAC7D,CAAC;AAtDD,kDAsDC","sourcesContent":["import {\n createClient,\n http,\n publicActions,\n type Chain,\n type Client,\n type FallbackTransport,\n type HttpTransportConfig,\n type PublicActions,\n type PublicClient,\n type PublicClientConfig,\n type PublicRpcSchema,\n type Transport,\n} from \"viem\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport { VERSION } from \"../version.js\";\nimport {\n bundlerActions,\n type BundlerActions,\n type BundlerRpcSchema,\n} from \"./decorators/bundlerClient.js\";\n\n// [!region BundlerClient]\nexport type BundlerClient<T extends Transport = Transport> = Client<\n T,\n Chain,\n undefined,\n [...PublicRpcSchema, ...BundlerRpcSchema],\n PublicActions<T, Chain> & BundlerActions\n>;\n\n/**\n * Creates a bundler client from an existing public client with the provided transport and chain.\n *\n * @example\n * ```ts\n * import { createPublicClient } from \"viem\";\n * import { createBundlerClientFromExisting } from \"@aa-sdk/core\";\n *\n * const publicClient = createPublicClient(...);\n * const bundlerClient = createBundlerClientFromExisting(publicClient);\n * ```\n *\n * @param {PublicClient<T, Chain>} client The existing public client to be extended with bundler actions\n * @returns {BundlerClient<T>} A bundler client that extends the functionality of the provided public client\n */\nexport const createBundlerClientFromExisting: <\n T extends Transport | FallbackTransport = Transport\n>(\n client: PublicClient<T, Chain>\n) => BundlerClient<T> = <T extends Transport | FallbackTransport = Transport>(\n client: PublicClient<T, Chain>\n): BundlerClient<T> => {\n return client.extend(bundlerActions);\n};\n// [!endregion BundlerClient]\n\n/**\n * Creates a PublicClient with methods for calling Bundler RPC methods\n *\n * @param {PublicClientConfig<TTransport, Chain> & { type?: string }} args - configuration for the client\n * @returns {BundlerClient<TTransport>} a PublicClient with methods for calling Bundler RPC methods\n */\nexport function createBundlerClient<TTransport extends Transport>(\n args: PublicClientConfig<TTransport, Chain> & { type?: string }\n): BundlerClient<TTransport>;\n\n/**\n * Creates a Bundler Client using the provided configuration parameters, including chain and optional type.\n *\n * @example\n * ```ts\n * import { createBundlerClient } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n *\n * const client = createBundlerClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * });\n * ```\n *\n * @param {PublicClientConfig & { type?: string }} args Configuration for creating the Bundler Client, including parameters for the chain, transport, and optional type\n * @returns {BundlerClient} The created Bundler Client with extended public and bundler actions\n */\nexport function createBundlerClient(\n args: PublicClientConfig & { type?: string }\n): BundlerClient {\n if (!args.chain) {\n throw new ChainNotFoundError();\n }\n const {\n key = \"bundler-public\",\n name = \"Public Bundler Client\",\n type = \"bundlerClient\",\n } = args;\n\n const { transport, ...opts } = args;\n const resolvedTransport = transport({\n chain: args.chain,\n pollingInterval: opts.pollingInterval,\n });\n\n const baseParameters = {\n ...args,\n key,\n name,\n type,\n };\n\n const client = (() => {\n if (resolvedTransport.config.type === \"http\") {\n const { url, fetchOptions: fetchOptions_ } = resolvedTransport.value as {\n fetchOptions: HttpTransportConfig[\"fetchOptions\"];\n url: string;\n };\n\n const fetchOptions = fetchOptions_ ?? {};\n\n if (url.toLowerCase().indexOf(\"alchemy\") > -1) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n \"Alchemy-AA-Sdk-Version\": VERSION,\n };\n }\n\n return createClient<Transport, Chain>({\n ...baseParameters,\n transport: http(url, {\n ...resolvedTransport.config,\n fetchOptions,\n }),\n });\n }\n\n return createClient<Transport, Chain>(baseParameters);\n })();\n\n return client.extend(publicActions).extend(bundlerActions);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundlerClient.js","sourceRoot":"","sources":["../../../../src/client/decorators/bundlerClient.ts"],"names":[],"mappings":";;;AAUA,mGAA6F;AAC7F,iGAA2F;AAC3F,+FAAyF;AACzF,iGAA2F;AAC3F,2FAAqF;AAwG9E,MAAM,cAAc,GASL,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACjC,wBAAwB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,CACrE,IAAA,sDAAwB,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;IAC1E,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,CAClD,IAAA,8CAAoB,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACvD,sBAAsB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACrC,IAAA,kDAAsB,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC;IAC1C,uBAAuB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,oDAAuB,EAAC,MAAM,CAAC;IACpE,uBAAuB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACtC,IAAA,oDAAuB,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC;CAC5C,CAAC,CAAC;AAnBU,QAAA,cAAc,kBAmBxB","sourcesContent":["import type {\n Address,\n Chain,\n Client,\n Hash,\n PublicRpcSchema,\n RpcStateOverride,\n StateOverride,\n Transport,\n} from \"viem\";\nimport { estimateUserOperationGas } from \"../../actions/bundler/estimateUserOperationGas.js\";\nimport { getSupportedEntryPoints } from \"../../actions/bundler/getSupportedEntryPoints.js\";\nimport { getUserOperationByHash } from \"../../actions/bundler/getUserOperationByHash.js\";\nimport { getUserOperationReceipt } from \"../../actions/bundler/getUserOperationReceipt.js\";\nimport { sendRawUserOperation } from \"../../actions/bundler/sendRawUserOperation.js\";\nimport type { EntryPointVersion } from \"../../entrypoint/types.js\";\nimport type {\n UserOperationEstimateGasResponse,\n UserOperationReceipt,\n UserOperationRequest,\n UserOperationResponse,\n} from \"../../types.js\";\n\n// Reference: https://eips.ethereum.org/EIPS/eip-4337#rpc-methods-eth-namespace\nexport type BundlerRpcSchema = [\n {\n Method: \"eth_sendUserOperation\";\n Parameters: [UserOperationRequest, Address];\n ReturnType: Hash;\n },\n {\n Method: \"eth_estimateUserOperationGas\";\n Parameters: [UserOperationRequest, Address, RpcStateOverride?];\n ReturnType: UserOperationEstimateGasResponse;\n },\n {\n Method: \"eth_getUserOperationReceipt\";\n Parameters: [Hash];\n ReturnType: UserOperationReceipt | null;\n },\n {\n Method: \"eth_getUserOperationByHash\";\n Parameters: [Hash];\n ReturnType: UserOperationResponse | null;\n },\n {\n Method: \"eth_supportedEntryPoints\";\n Parameters: [];\n ReturnType: Address[];\n }\n];\n\n// [!region BundlerActions]\nexport type BundlerActions = {\n /**\n * calls `eth_estimateUserOperationGas` and returns the result\n *\n * @param request - the
|
|
1
|
+
{"version":3,"file":"bundlerClient.js","sourceRoot":"","sources":["../../../../src/client/decorators/bundlerClient.ts"],"names":[],"mappings":";;;AAUA,mGAA6F;AAC7F,iGAA2F;AAC3F,+FAAyF;AACzF,iGAA2F;AAC3F,2FAAqF;AAwG9E,MAAM,cAAc,GASL,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACjC,wBAAwB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,CACrE,IAAA,sDAAwB,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;IAC1E,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,CAClD,IAAA,8CAAoB,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACvD,sBAAsB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACrC,IAAA,kDAAsB,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC;IAC1C,uBAAuB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,oDAAuB,EAAC,MAAM,CAAC;IACpE,uBAAuB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACtC,IAAA,oDAAuB,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC;CAC5C,CAAC,CAAC;AAnBU,QAAA,cAAc,kBAmBxB","sourcesContent":["import type {\n Address,\n Chain,\n Client,\n Hash,\n PublicRpcSchema,\n RpcStateOverride,\n StateOverride,\n Transport,\n} from \"viem\";\nimport { estimateUserOperationGas } from \"../../actions/bundler/estimateUserOperationGas.js\";\nimport { getSupportedEntryPoints } from \"../../actions/bundler/getSupportedEntryPoints.js\";\nimport { getUserOperationByHash } from \"../../actions/bundler/getUserOperationByHash.js\";\nimport { getUserOperationReceipt } from \"../../actions/bundler/getUserOperationReceipt.js\";\nimport { sendRawUserOperation } from \"../../actions/bundler/sendRawUserOperation.js\";\nimport type { EntryPointVersion } from \"../../entrypoint/types.js\";\nimport type {\n UserOperationEstimateGasResponse,\n UserOperationReceipt,\n UserOperationRequest,\n UserOperationResponse,\n} from \"../../types.js\";\n\n// Reference: https://eips.ethereum.org/EIPS/eip-4337#rpc-methods-eth-namespace\nexport type BundlerRpcSchema = [\n {\n Method: \"eth_sendUserOperation\";\n Parameters: [UserOperationRequest, Address];\n ReturnType: Hash;\n },\n {\n Method: \"eth_estimateUserOperationGas\";\n Parameters: [UserOperationRequest, Address, RpcStateOverride?];\n ReturnType: UserOperationEstimateGasResponse;\n },\n {\n Method: \"eth_getUserOperationReceipt\";\n Parameters: [Hash];\n ReturnType: UserOperationReceipt | null;\n },\n {\n Method: \"eth_getUserOperationByHash\";\n Parameters: [Hash];\n ReturnType: UserOperationResponse | null;\n },\n {\n Method: \"eth_supportedEntryPoints\";\n Parameters: [];\n ReturnType: Address[];\n }\n];\n\n// [!region BundlerActions]\nexport type BundlerActions = {\n /**\n * calls `eth_estimateUserOperationGas` and returns the result\n *\n * @param request - the UserOperationRequest to estimate gas for\n * @param entryPoint - the entry point address the op will be sent to\n * @param stateOverride - the state override to use for the estimation\n * @returns the gas estimates for the given response\n */\n estimateUserOperationGas<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n >(\n request: UserOperationRequest<TEntryPointVersion>,\n entryPoint: Address,\n stateOverride?: StateOverride\n ): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>;\n\n /**\n * calls `eth_sendUserOperation` and returns the hash of the sent UserOperation\n *\n * @param request - the UserOperationRequest to send\n * @param entryPoint - the entry point address the op will be sent to\n * @returns the hash of the sent UserOperation\n */\n sendRawUserOperation<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n >(\n request: UserOperationRequest<TEntryPointVersion>,\n entryPoint: Address\n ): Promise<Hash>;\n\n /**\n * calls `eth_getUserOperationByHash` and returns the UserOperationResponse\n *\n * @param hash - the hash of the UserOperation to fetch\n * @returns - the user operation if found or null\n */\n getUserOperationByHash(hash: Hash): Promise<UserOperationResponse | null>;\n\n /**\n * calls `eth_getUserOperationReceipt` and returns the UserOperationReceipt\n *\n * @param hash - the hash of the UserOperation to get the receipt for\n * @returns - a user operation receipt or null if not found\n */\n getUserOperationReceipt(hash: Hash): Promise<UserOperationReceipt | null>;\n\n /**\n * calls `eth_supportedEntryPoints` and returns the entry points the RPC supports\n *\n * @returns - an array of the entrypoint addresses supported\n */\n getSupportedEntryPoints(): Promise<Address[]>;\n};\n// [!endregion BundlerActions]\n\n/**\n * A viem client decorator that provides Bundler specific actions.\n * 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.\n *\n * NOTE: this is already added to the client returned from `createBundlerClient`\n *\n * @param {TClient} client The client instance that will be used to perform bundler actions\n * @returns {BundlerActions} An object containing various bundler-related actions that can be executed using the provided client\n */\nexport const bundlerActions: <\n TClient extends Client<\n Transport,\n Chain | undefined,\n any,\n [...PublicRpcSchema, ...BundlerRpcSchema]\n >\n>(\n client: TClient\n) => BundlerActions = (client) => ({\n estimateUserOperationGas: async (request, entryPoint, stateOverride) =>\n estimateUserOperationGas(client, { request, entryPoint, stateOverride }),\n sendRawUserOperation: async (request, entryPoint) =>\n sendRawUserOperation(client, { request, entryPoint }),\n getUserOperationByHash: async (hash) =>\n getUserOperationByHash(client, { hash }),\n getSupportedEntryPoints: async () => getSupportedEntryPoints(client),\n getUserOperationReceipt: async (hash) =>\n getUserOperationReceipt(client, { hash }),\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isSmartAccountClient.js","sourceRoot":"","sources":["../../../src/client/isSmartAccountClient.ts"],"names":[],"mappings":";;;AAEA,8EAAkF;AAclF,SAAgB,oBAAoB,CAOlC,MAA4C;IAE5C,KAAK,MAAM,GAAG,IAAI,oDAA4B,EAAE,CAAC;QAC/C,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,MAAM,IAAI,YAAY,IAAI,MAAM,CAAC;AAC1C,CAAC;AAhBD,oDAgBC;AAUD,SAAgB,wBAAwB,CAOtC,MAA4C;IAE5C,OAAO,MAAM,IAAI,YAAY,IAAI,MAAM,CAAC;AAC1C,CAAC;AAVD,4DAUC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type { SmartContractAccount } from \"../account/smartContractAccount\";\nimport { smartAccountClientMethodKeys } from \"./decorators/smartAccountClient.js\";\nimport type {\n BaseSmartAccountClient,\n SmartAccountClient,\n} from \"./smartAccountClient\";\n\n/**\n * Use this method to assert that a client is a BaseSmartAccountClient.\n * Useful for narrowing the type of the client down when used within the\n * smart account client decorators\n *\n * @param client a viem client\n * @returns true if the client is a SmartAccountClient\n */\nexport function isSmartAccountClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n): client is SmartAccountClient<TTransport, TChain, TAccount> {\n for (const key of smartAccountClientMethodKeys) {\n if (!(key in client)) {\n return false;\n }\n }\n\n return client && \"middleware\" in client;\n}\n\n/**\n * Use this method to assert that a client is a BaseSmartAccountClient.\n * Useful for narrowing the type of the client down when used within the\n * smart account action decorators\n *\n * @param client a viem client\n * @returns true if the account is a BaseSmartAccountClient\n */\nexport function isBaseSmartAccountClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n): client is BaseSmartAccountClient<TTransport, TChain, TAccount> {\n return client && \"middleware\" in client;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"isSmartAccountClient.js","sourceRoot":"","sources":["../../../src/client/isSmartAccountClient.ts"],"names":[],"mappings":";;;AAEA,8EAAkF;AAclF,SAAgB,oBAAoB,CAOlC,MAA4C;IAE5C,KAAK,MAAM,GAAG,IAAI,oDAA4B,EAAE,CAAC;QAC/C,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,MAAM,IAAI,YAAY,IAAI,MAAM,CAAC;AAC1C,CAAC;AAhBD,oDAgBC;AAUD,SAAgB,wBAAwB,CAOtC,MAA4C;IAE5C,OAAO,MAAM,IAAI,YAAY,IAAI,MAAM,CAAC;AAC1C,CAAC;AAVD,4DAUC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type { SmartContractAccount } from \"../account/smartContractAccount\";\nimport { smartAccountClientMethodKeys } from \"./decorators/smartAccountClient.js\";\nimport type {\n BaseSmartAccountClient,\n SmartAccountClient,\n} from \"./smartAccountClient\";\n\n/**\n * Use this method to assert that a client is a BaseSmartAccountClient.\n * Useful for narrowing the type of the client down when used within the\n * smart account client decorators\n *\n * @param {Client<TTransport, TChain, TAccount>} client a viem client\n * @returns {boolean} true if the client is a SmartAccountClient\n */\nexport function isSmartAccountClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n): client is SmartAccountClient<TTransport, TChain, TAccount> {\n for (const key of smartAccountClientMethodKeys) {\n if (!(key in client)) {\n return false;\n }\n }\n\n return client && \"middleware\" in client;\n}\n\n/**\n * Use this method to assert that a client is a BaseSmartAccountClient.\n * Useful for narrowing the type of the client down when used within the\n * smart account action decorators\n *\n * @param {Client<TTransport, TChain, TAccount>} client a viem client\n * @returns {boolean} true if the account is a BaseSmartAccountClient\n */\nexport function isBaseSmartAccountClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n): client is BaseSmartAccountClient<TTransport, TChain, TAccount> {\n return client && \"middleware\" in client;\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import type { Hash, Hex } from "viem";
|
|
|
3
3
|
import type { z } from "zod";
|
|
4
4
|
import type { UserOperationContext } from "../actions/smartAccount/types.js";
|
|
5
5
|
import type { EntryPointVersion } from "../entrypoint/types.js";
|
|
6
|
-
import type { ClientMiddleware
|
|
6
|
+
import type { ClientMiddleware } from "../middleware/types.js";
|
|
7
7
|
import type { UserOperationRequest } from "../types.js";
|
|
8
8
|
import type { ConnectionConfigSchema } from "./schema.js";
|
|
9
9
|
export type ConnectorData = {
|
|
@@ -18,9 +18,4 @@ export type UpgradeToData = {
|
|
|
18
18
|
implAddress: Address;
|
|
19
19
|
initializationData: Hex;
|
|
20
20
|
};
|
|
21
|
-
export type ClientMiddlewareConfig<TContext extends UserOperationContext | undefined = UserOperationContext | undefined> =
|
|
22
|
-
paymasterAndData?: {
|
|
23
|
-
dummyPaymasterAndData: () => UserOperationRequest<"0.6.0">["paymasterAndData"] | Pick<UserOperationRequest<"0.7.0">, "paymaster" | "paymasterData">;
|
|
24
|
-
paymasterAndData: ClientMiddlewareFn<TContext>;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
21
|
+
export type ClientMiddlewareConfig<TContext extends UserOperationContext | undefined = UserOperationContext | undefined> = Partial<ClientMiddleware<TContext>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address } from \"abitype\";\nimport type { Hash, Hex } from \"viem\";\nimport type { z } from \"zod\";\nimport type { UserOperationContext } from \"../actions/smartAccount/types.js\";\nimport type { EntryPointVersion } from \"../entrypoint/types.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address } from \"abitype\";\nimport type { Hash, Hex } from \"viem\";\nimport type { z } from \"zod\";\nimport type { UserOperationContext } from \"../actions/smartAccount/types.js\";\nimport type { EntryPointVersion } from \"../entrypoint/types.js\";\nimport type { ClientMiddleware } from \"../middleware/types.js\";\nimport type { UserOperationRequest } from \"../types.js\";\nimport type { ConnectionConfigSchema } from \"./schema.js\";\n\nexport type ConnectorData = {\n chainId?: Hex;\n};\n\nexport type ConnectionConfig = z.input<typeof ConnectionConfigSchema>;\n\n// [!region SendUserOperationResult]\nexport type SendUserOperationResult<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = {\n hash: Hash;\n request: UserOperationRequest<TEntryPointVersion>;\n};\n// [!endregion SendUserOperationResult]\n\n// [!region UpgradeToData]\nexport type UpgradeToData = {\n implAddress: Address;\n initializationData: Hex;\n};\n// [!endregion UpgradeToData]\n\n// [!region ClientMiddlewareConfig]\nexport type ClientMiddlewareConfig<\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Partial<ClientMiddleware<TContext>>;\n// [!endregion ClientMiddlewareConfig]\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/errors/account.ts"],"names":[],"mappings":";;;AAEA,uCAAsC;AAKtC,MAAa,oBAAqB,SAAQ,mBAAS;
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/errors/account.ts"],"names":[],"mappings":";;;AAEA,uCAAsC;AAKtC,MAAa,oBAAqB,SAAQ,mBAAS;IAO7C;QACF,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAPzD;;;;mBAAO,sBAAsB;WAAC;IAQvC,CAAC;CACF;AAVD,oDAUC;AAMD,MAAa,6BAA8B,SAAQ,mBAAS;IAU1D,YAAY,WAAmB,EAAE,KAAY,EAAE,OAA0B;QACvE,KAAK,CACH;YACE,0BAA0B,WAAW,mBAAmB,KAAK,CAAC,IAAI,2BAA2B,OAAO,EAAE;YACtG,gFAAgF;SACjF,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;QAfK;;;;mBAAO,+BAA+B;WAAC;IAgBhD,CAAC;CACF;AAlBD,sEAkBC;AAKD,MAAa,6BAA8B,SAAQ,mBAAS;IAKtD;QACF,KAAK,CAAC,iCAAiC,CAAC,CAAC;QALlC;;;;mBAAO,+BAA+B;WAAC;IAMhD,CAAC;CACF;AARD,sEAQC;AAKD,MAAa,yBAA0B,SAAQ,mBAAS;IAQtD,YAAY,WAAmB;QAC7B,KAAK,CAAC,iCAAiC,W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;WAAC;IAMtD,CAAC;CACF;AARD,kFAQC","sourcesContent":["import type { Chain } from \"viem\";\nimport type { EntryPointVersion } from \"../entrypoint/types.js\";\nimport { BaseError } from \"./base.js\";\n\n/**\n * This error is thrown when an account could not be found to execute a specific action. It extends the `BaseError` class.\n */\nexport class AccountNotFoundError extends BaseError {\n override name = \"AccountNotFoundError\";\n\n // TODO: extend this further using docs path as well\n\n /**\n * Constructor for initializing an error message indicating that an account could not be found to execute the specified action.\n */ constructor() {\n super(\"Could not find an Account to execute with this Action.\");\n }\n}\n\n/**\n * Represents an error that is thrown when no default factory is defined for a specific account type on a given chain and entry point version.\n * This error suggests providing an override via the `factoryAddress` parameter when creating an account.\n */\nexport class DefaultFactoryNotDefinedError extends BaseError {\n override name = \"DefaultFactoryNotDefinedError\";\n\n /**\n * Constructs an error message indicating that no default factory was found for the given account type, chain, and entry point version.\n *\n * @param {string} accountType the type of account\n * @param {Chain} chain the blockchain chain\n * @param {EntryPointVersion} version the entry point version\n */\n constructor(accountType: string, chain: Chain, version: EntryPointVersion) {\n super(\n [\n `No default factory for ${accountType} found on chain ${chain.name} for entrypoint version ${version}`,\n \"Supply an override via the `factoryAddress` parameter when creating an account\",\n ].join(\"\\n\")\n );\n }\n}\n\n/**\n * Custom error class for handling errors when getting a counterfactual address. This extends the `BaseError` class and provides a custom error message and name.\n */\nexport class GetCounterFactualAddressError extends BaseError {\n override name = \"GetCounterFactualAddressError\";\n\n /**\n * Constructor for initializing an error message indicating the failure of fetching the counter-factual address.\n */ constructor() {\n super(\"getCounterFactualAddress failed\");\n }\n}\n\n/**\n * An error class representing the condition where upgrades are not supported for a specific account type. This error extends the `BaseError` class and provides a custom error message based on the account type.\n */\nexport class UpgradesNotSupportedError extends BaseError {\n override name = \"UpgradesNotSupported\";\n\n /**\n * Error constructor for indicating that upgrades are not supported by the given account type.\n *\n * @param {string} accountType The type of account that does not support upgrades\n */\n constructor(accountType: string) {\n super(`Upgrades are not supported by ${accountType}`);\n }\n}\n\n/**\n * Error thrown when attempting to sign a transaction that is not supported by smart contracts.\n */\nexport class SignTransactionNotSupportedError extends BaseError {\n override name = \"SignTransactionNotSupported\";\n\n /**\n * Throws an error indicating that signing a transaction is not supported by smart contracts.\n *\n \n */ constructor() {\n super(`SignTransaction is not supported by smart contracts`);\n }\n}\n\n/**\n * Custom error class `FailedToGetStorageSlotError` which is used to signal a failure when attempting to retrieve a storage slot. This error includes the slot and slot descriptor in its message and inherits from `BaseError`.\n */\nexport class FailedToGetStorageSlotError extends BaseError {\n override name = \"FailedToGetStorageSlotError\";\n\n /**\n * Custom error message constructor for failing to get a specific storage slot.\n *\n * @param {string} slot The storage slot that failed to be accessed or retrieved\n * @param {string} slotDescriptor A description of the storage slot, for additional context in the error message\n */\n constructor(slot: string, slotDescriptor: string) {\n super(`Failed to get storage slot ${slot} (${slotDescriptor})`);\n }\n}\n\n/**\n * Represents an error indicating that batch execution is not supported for a specific account type.\n */\nexport class BatchExecutionNotSupportedError extends BaseError {\n override name = \"BatchExecutionNotSupportedError\";\n\n /**\n * Constructs an error message indicating that batch execution is not supported by the specified account type.\n *\n * @param {string} accountType the type of account that does not support batch execution\n */\n constructor(accountType: string) {\n super(`Batch execution is not supported by ${accountType}`);\n }\n}\n\n/**\n * Represents an error that occurs when an account requires an owner to execute but none is provided.\n */\nexport class AccountRequiresOwnerError extends BaseError {\n override name = \"AccountRequiresOwnerError\";\n\n /**\n * Constructs an error indicating that an account of the specified type requires an owner to execute.\n *\n * @param {string} accountType The type of account that requires an owner\n */\n constructor(accountType: string) {\n super(`Account of type ${accountType} requires an owner to execute`);\n }\n}\n\n/**\n * Represents an error that occurs when an attempt is made to call `UpgradeToAndCall` on an account type that does not support it. Includes the account type in the error message.\n */\nexport class UpgradeToAndCallNotSupportedError extends BaseError {\n override name = \"UpgradeToAndCallNotSupportedError\";\n\n /**\n * Constructs an error message indicating that `UpgradeToAndCall` is not supported by the specified account type.\n *\n * @param {string} accountType The type of account that does not support `UpgradeToAndCall`\n */\n constructor(accountType: string) {\n super(`UpgradeToAndCall is not supported by ${accountType}`);\n }\n}\n\n/**\n * Represents an error thrown when an account type does not match the expected type.\n */\nexport class IncorrectAccountType extends BaseError {\n override name = \"IncorrectAccountTypeError\";\n\n /**\n * Constructs an error object indicating that the expected account type does not match the actual account type.\n *\n * @param {string} expected the expected account type\n * @param {string} actual the actual account type that was received\n */\n constructor(expected: string, actual: string) {\n super(`Expected account type ${expected}, got ${actual}`);\n }\n}\n\n/**\n * Error class indicating that a smart account operation requires a signer.\n */\nexport class SmartAccountWithSignerRequiredError extends BaseError {\n override name = \"SmartAccountWithSignerRequiredError\";\n\n /**\n * Initializes a new instance of the error class with a predefined error message indicating that a smart account requires a signer.\n */ constructor() {\n super(\"Smart account requires a signer\");\n }\n}\n"]}
|