permissionless 0.0.11 → 0.0.13
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/CHANGELOG.md +16 -0
- package/_cjs/accounts/index.js +14 -0
- package/_cjs/accounts/index.js.map +1 -0
- package/_cjs/accounts/privateKeyToSafeSmartAccount.js +24 -0
- package/_cjs/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
- package/_cjs/accounts/privateKeyToSimpleSmartAccount.js +16 -0
- package/_cjs/accounts/privateKeyToSimpleSmartAccount.js.map +1 -0
- package/_cjs/accounts/signerToSafeSmartAccount.js +492 -0
- package/_cjs/accounts/signerToSafeSmartAccount.js.map +1 -0
- package/_cjs/accounts/signerToSimpleSmartAccount.js +190 -0
- package/_cjs/accounts/signerToSimpleSmartAccount.js.map +1 -0
- package/_cjs/accounts/types.js +23 -0
- package/_cjs/accounts/types.js.map +1 -0
- package/_cjs/actions/bundler/chainId.js.map +1 -1
- package/_cjs/actions/bundler/estimateUserOperationGas.js +4 -1
- package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_cjs/actions/bundler/getUserOperationByHash.js.map +1 -1
- package/_cjs/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/_cjs/actions/bundler/sendUserOperation.js +4 -1
- package/_cjs/actions/bundler/sendUserOperation.js.map +1 -1
- package/_cjs/actions/bundler/supportedEntryPoints.js.map +1 -1
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js +7 -2
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
- package/_cjs/actions/pimlico/getUserOperationStatus.js.map +1 -1
- package/_cjs/actions/pimlico/sponsorUserOperation.js +4 -1
- package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_cjs/actions/pimlico.js.map +1 -1
- package/_cjs/actions/public/getAccountNonce.js +4 -2
- package/_cjs/actions/public/getAccountNonce.js.map +1 -1
- package/_cjs/actions/public/getSenderAddress.js +7 -3
- package/_cjs/actions/public/getSenderAddress.js.map +1 -1
- package/_cjs/actions/smartAccount/deployContract.js +38 -0
- package/_cjs/actions/smartAccount/deployContract.js.map +1 -0
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +73 -0
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -0
- package/_cjs/actions/smartAccount/sendTransaction.js +44 -0
- package/_cjs/actions/smartAccount/sendTransaction.js.map +1 -0
- package/_cjs/actions/smartAccount/sendTransactions.js +46 -0
- package/_cjs/actions/smartAccount/sendTransactions.js.map +1 -0
- package/_cjs/actions/smartAccount/sendUserOperation.js +22 -0
- package/_cjs/actions/smartAccount/sendUserOperation.js.map +1 -0
- package/_cjs/actions/smartAccount/signMessage.js +16 -0
- package/_cjs/actions/smartAccount/signMessage.js.map +1 -0
- package/_cjs/actions/smartAccount/signTypedData.js +34 -0
- package/_cjs/actions/smartAccount/signTypedData.js.map +1 -0
- package/_cjs/actions/smartAccount/writeContract.js +21 -0
- package/_cjs/actions/smartAccount/writeContract.js.map +1 -0
- package/_cjs/actions/smartAccount.js +18 -0
- package/_cjs/actions/smartAccount.js.map +1 -0
- package/_cjs/actions/stackup/sponsorUserOperation.js +5 -1
- package/_cjs/actions/stackup/sponsorUserOperation.js.map +1 -1
- package/_cjs/clients/{bundler.js → createBundlerClient.js} +1 -1
- package/_cjs/clients/createBundlerClient.js.map +1 -0
- package/_cjs/clients/createSmartAccountClient.js +20 -0
- package/_cjs/clients/createSmartAccountClient.js.map +1 -0
- package/_cjs/clients/decorators/bundler.js.map +1 -1
- package/_cjs/clients/decorators/pimlico.js.map +1 -1
- package/_cjs/clients/decorators/smartAccount.js +33 -0
- package/_cjs/clients/decorators/smartAccount.js.map +1 -0
- package/_cjs/clients/decorators/stackup.js.map +1 -1
- package/_cjs/clients/pimlico.js.map +1 -1
- package/_cjs/clients/stackup.js.map +1 -1
- package/_cjs/index.js +9 -5
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/deepHexlify.js +4 -4
- package/_cjs/utils/deepHexlify.js.map +1 -1
- package/_cjs/utils/getAction.js +8 -0
- package/_cjs/utils/getAction.js.map +1 -0
- package/_cjs/utils/getUserOperationHash.js.map +1 -1
- package/_cjs/utils/index.js +7 -1
- package/_cjs/utils/index.js.map +1 -1
- package/_cjs/utils/observe.js +7 -2
- package/_cjs/utils/observe.js.map +1 -1
- package/_cjs/utils/signUserOperationHashWithECDSA.js +7 -7
- package/_cjs/utils/signUserOperationHashWithECDSA.js.map +1 -1
- package/_esm/accounts/index.js +7 -0
- package/_esm/accounts/index.js.map +1 -0
- package/_esm/accounts/privateKeyToSafeSmartAccount.js +26 -0
- package/_esm/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
- package/_esm/accounts/privateKeyToSimpleSmartAccount.js +18 -0
- package/_esm/accounts/privateKeyToSimpleSmartAccount.js.map +1 -0
- package/_esm/accounts/signerToSafeSmartAccount.js +499 -0
- package/_esm/accounts/signerToSafeSmartAccount.js.map +1 -0
- package/_esm/accounts/signerToSimpleSmartAccount.js +191 -0
- package/_esm/accounts/signerToSimpleSmartAccount.js.map +1 -0
- package/_esm/accounts/types.js +20 -0
- package/_esm/accounts/types.js.map +1 -0
- package/_esm/actions/bundler/chainId.js.map +1 -1
- package/_esm/actions/bundler/estimateUserOperationGas.js +4 -1
- package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_esm/actions/bundler/getUserOperationByHash.js.map +1 -1
- package/_esm/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/_esm/actions/bundler/sendUserOperation.js +4 -3
- package/_esm/actions/bundler/sendUserOperation.js.map +1 -1
- package/_esm/actions/bundler/supportedEntryPoints.js.map +1 -1
- package/_esm/actions/bundler/waitForUserOperationReceipt.js +7 -2
- package/_esm/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/pimlico/getUserOperationGasPrice.js +2 -2
- package/_esm/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
- package/_esm/actions/pimlico/getUserOperationStatus.js +1 -1
- package/_esm/actions/pimlico/getUserOperationStatus.js.map +1 -1
- package/_esm/actions/pimlico/sponsorUserOperation.js +4 -1
- package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_esm/actions/pimlico.js.map +1 -1
- package/_esm/actions/public/getAccountNonce.js +7 -5
- package/_esm/actions/public/getAccountNonce.js.map +1 -1
- package/_esm/actions/public/getSenderAddress.js +8 -5
- package/_esm/actions/public/getSenderAddress.js.map +1 -1
- package/_esm/actions/smartAccount/deployContract.js +64 -0
- package/_esm/actions/smartAccount/deployContract.js.map +1 -0
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js +69 -0
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -0
- package/_esm/actions/smartAccount/sendTransaction.js +88 -0
- package/_esm/actions/smartAccount/sendTransaction.js.map +1 -0
- package/_esm/actions/smartAccount/sendTransactions.js +90 -0
- package/_esm/actions/smartAccount/sendTransactions.js.map +1 -0
- package/_esm/actions/smartAccount/sendUserOperation.js +18 -0
- package/_esm/actions/smartAccount/sendUserOperation.js.map +1 -0
- package/_esm/actions/smartAccount/signMessage.js +59 -0
- package/_esm/actions/smartAccount/signMessage.js.map +1 -0
- package/_esm/actions/smartAccount/signTypedData.js +129 -0
- package/_esm/actions/smartAccount/signTypedData.js.map +1 -0
- package/_esm/actions/smartAccount/writeContract.js +19 -0
- package/_esm/actions/smartAccount/writeContract.js.map +1 -0
- package/_esm/actions/smartAccount.js +9 -0
- package/_esm/actions/smartAccount.js.map +1 -0
- package/_esm/actions/stackup/accounts.js +1 -1
- package/_esm/actions/stackup/sponsorUserOperation.js +6 -2
- package/_esm/actions/stackup/sponsorUserOperation.js.map +1 -1
- package/_esm/clients/{bundler.js → createBundlerClient.js} +1 -1
- package/_esm/clients/createBundlerClient.js.map +1 -0
- package/_esm/clients/createSmartAccountClient.js +38 -0
- package/_esm/clients/createSmartAccountClient.js.map +1 -0
- package/_esm/clients/decorators/bundler.js.map +1 -1
- package/_esm/clients/decorators/pimlico.js +1 -1
- package/_esm/clients/decorators/pimlico.js.map +1 -1
- package/_esm/clients/decorators/smartAccount.js +29 -0
- package/_esm/clients/decorators/smartAccount.js.map +1 -0
- package/_esm/clients/decorators/stackup.js.map +1 -1
- package/_esm/clients/pimlico.js +1 -1
- package/_esm/clients/pimlico.js.map +1 -1
- package/_esm/clients/stackup.js +1 -1
- package/_esm/clients/stackup.js.map +1 -1
- package/_esm/index.js +5 -2
- package/_esm/index.js.map +1 -1
- package/_esm/utils/deepHexlify.js +6 -4
- package/_esm/utils/deepHexlify.js.map +1 -1
- package/_esm/utils/getAction.js +6 -0
- package/_esm/utils/getAction.js.map +1 -0
- package/_esm/utils/getUserOperationHash.js.map +1 -1
- package/_esm/utils/index.js +5 -0
- package/_esm/utils/index.js.map +1 -1
- package/_esm/utils/observe.js +7 -2
- package/_esm/utils/observe.js.map +1 -1
- package/_esm/utils/signUserOperationHashWithECDSA.js +7 -6
- package/_esm/utils/signUserOperationHashWithECDSA.js.map +1 -1
- package/_types/accounts/index.d.ts +7 -0
- package/_types/accounts/index.d.ts.map +1 -0
- package/_types/accounts/privateKeyToSafeSmartAccount.d.ts +26 -0
- package/_types/accounts/privateKeyToSafeSmartAccount.d.ts.map +1 -0
- package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts +14 -0
- package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts.map +1 -0
- package/_types/accounts/signerToSafeSmartAccount.d.ts +28 -0
- package/_types/accounts/signerToSafeSmartAccount.d.ts.map +1 -0
- package/_types/accounts/signerToSimpleSmartAccount.d.ts +15 -0
- package/_types/accounts/signerToSimpleSmartAccount.d.ts.map +1 -0
- package/_types/accounts/types.d.ts +32 -0
- package/_types/accounts/types.d.ts.map +1 -0
- package/_types/actions/bundler/chainId.d.ts +3 -2
- package/_types/actions/bundler/chainId.d.ts.map +1 -1
- package/_types/actions/bundler/estimateUserOperationGas.d.ts +3 -3
- package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
- package/_types/actions/bundler/getUserOperationByHash.d.ts +3 -3
- package/_types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
- package/_types/actions/bundler/getUserOperationReceipt.d.ts +3 -3
- package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
- package/_types/actions/bundler/sendUserOperation.d.ts +3 -5
- package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/bundler/supportedEntryPoints.d.ts +3 -3
- package/_types/actions/bundler/supportedEntryPoints.d.ts.map +1 -1
- package/_types/actions/bundler/waitForUserOperationReceipt.d.ts +2 -3
- package/_types/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -1
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/pimlico/getUserOperationGasPrice.d.ts +5 -4
- package/_types/actions/pimlico/getUserOperationGasPrice.d.ts.map +1 -1
- package/_types/actions/pimlico/getUserOperationStatus.d.ts +4 -5
- package/_types/actions/pimlico/getUserOperationStatus.d.ts.map +1 -1
- package/_types/actions/pimlico/sponsorUserOperation.d.ts +3 -3
- package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
- package/_types/actions/pimlico.d.ts.map +1 -1
- package/_types/actions/public/getAccountNonce.d.ts +5 -5
- package/_types/actions/public/getAccountNonce.d.ts.map +1 -1
- package/_types/actions/public/getSenderAddress.d.ts +3 -4
- package/_types/actions/public/getSenderAddress.d.ts.map +1 -1
- package/_types/actions/smartAccount/deployContract.d.ts +34 -0
- package/_types/actions/smartAccount/deployContract.d.ts.map +1 -0
- package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts +20 -0
- package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -0
- package/_types/actions/smartAccount/sendTransaction.d.ts +52 -0
- package/_types/actions/smartAccount/sendTransaction.d.ts.map +1 -0
- package/_types/actions/smartAccount/sendTransactions.d.ts +63 -0
- package/_types/actions/smartAccount/sendTransactions.d.ts.map +1 -0
- package/_types/actions/smartAccount/sendUserOperation.d.ts +10 -0
- package/_types/actions/smartAccount/sendUserOperation.d.ts.map +1 -0
- package/_types/actions/smartAccount/signMessage.d.ts +50 -0
- package/_types/actions/smartAccount/signMessage.d.ts.map +1 -0
- package/_types/actions/smartAccount/signTypedData.d.ts +104 -0
- package/_types/actions/smartAccount/signTypedData.d.ts.map +1 -0
- package/_types/actions/smartAccount/writeContract.d.ts +57 -0
- package/_types/actions/smartAccount/writeContract.d.ts.map +1 -0
- package/_types/actions/smartAccount.d.ts +9 -0
- package/_types/actions/smartAccount.d.ts.map +1 -0
- package/_types/actions/stackup/accounts.d.ts +1 -1
- package/_types/actions/stackup/sponsorUserOperation.d.ts +1 -1
- package/_types/actions/stackup/sponsorUserOperation.d.ts.map +1 -1
- package/_types/clients/{bundler.d.ts → createBundlerClient.d.ts} +1 -1
- package/_types/clients/createBundlerClient.d.ts.map +1 -0
- package/_types/clients/createSmartAccountClient.d.ts +282 -0
- package/_types/clients/createSmartAccountClient.d.ts.map +1 -0
- package/_types/clients/decorators/bundler.d.ts +1 -1
- package/_types/clients/decorators/bundler.d.ts.map +1 -1
- package/_types/clients/decorators/pimlico.d.ts +3 -3
- package/_types/clients/decorators/pimlico.d.ts.map +1 -1
- package/_types/clients/decorators/smartAccount.d.ts +327 -0
- package/_types/clients/decorators/smartAccount.d.ts.map +1 -0
- package/_types/clients/decorators/stackup.d.ts.map +1 -1
- package/_types/clients/pimlico.d.ts +1 -1
- package/_types/clients/pimlico.d.ts.map +1 -1
- package/_types/clients/stackup.d.ts +1 -1
- package/_types/clients/stackup.d.ts.map +1 -1
- package/_types/index.d.ts +6 -3
- package/_types/index.d.ts.map +1 -1
- package/_types/types/bundler.d.ts +4 -1
- package/_types/types/bundler.d.ts.map +1 -1
- package/_types/types/index.d.ts +20 -0
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/pimlico.d.ts.map +1 -1
- package/_types/types/stackup.d.ts.map +1 -1
- package/_types/utils/deepHexlify.d.ts.map +1 -1
- package/_types/utils/getAction.d.ts +3 -0
- package/_types/utils/getAction.d.ts.map +1 -0
- package/_types/utils/getUserOperationHash.d.ts.map +1 -1
- package/_types/utils/index.d.ts +2 -0
- package/_types/utils/index.d.ts.map +1 -1
- package/_types/utils/observe.d.ts.map +1 -1
- package/_types/utils/signUserOperationHashWithECDSA.d.ts +3 -11
- package/_types/utils/signUserOperationHashWithECDSA.d.ts.map +1 -1
- package/accounts/index.ts +33 -0
- package/accounts/privateKeyToSafeSmartAccount.ts +73 -0
- package/accounts/privateKeyToSimpleSmartAccount.ts +44 -0
- package/accounts/signerToSafeSmartAccount.ts +775 -0
- package/accounts/signerToSimpleSmartAccount.ts +267 -0
- package/accounts/types.ts +64 -0
- package/actions/bundler/chainId.ts +10 -2
- package/actions/bundler/estimateUserOperationGas.ts +17 -6
- package/actions/bundler/getUserOperationByHash.ts +16 -5
- package/actions/bundler/getUserOperationReceipt.ts +17 -4
- package/actions/bundler/sendUserOperation.ts +19 -7
- package/actions/bundler/supportedEntryPoints.ts +10 -3
- package/actions/bundler/waitForUserOperationReceipt.ts +64 -26
- package/actions/index.ts +4 -1
- package/actions/pimlico/getUserOperationGasPrice.ts +13 -6
- package/actions/pimlico/getUserOperationStatus.ts +12 -5
- package/actions/pimlico/sponsorUserOperation.ts +20 -7
- package/actions/pimlico.ts +8 -2
- package/actions/public/getAccountNonce.ts +20 -8
- package/actions/public/getSenderAddress.ts +25 -8
- package/actions/smartAccount/deployContract.ts +110 -0
- package/actions/smartAccount/prepareUserOperationRequest.ts +140 -0
- package/actions/smartAccount/sendTransaction.ts +138 -0
- package/actions/smartAccount/sendTransactions.ts +141 -0
- package/actions/smartAccount/sendUserOperation.ts +70 -0
- package/actions/smartAccount/signMessage.ts +79 -0
- package/actions/smartAccount/signTypedData.ts +161 -0
- package/actions/smartAccount/writeContract.ts +126 -0
- package/actions/smartAccount.ts +49 -0
- package/actions/stackup/accounts.ts +1 -1
- package/actions/stackup/sponsorUserOperation.ts +14 -4
- package/clients/{bundler.ts → createBundlerClient.ts} +14 -3
- package/clients/createSmartAccountClient.ts +95 -0
- package/clients/decorators/bundler.ts +20 -10
- package/clients/decorators/pimlico.ts +21 -9
- package/clients/decorators/smartAccount.ts +451 -0
- package/clients/decorators/stackup.ts +12 -4
- package/clients/pimlico.ts +20 -5
- package/clients/stackup.ts +17 -4
- package/index.ts +20 -3
- package/package.json +12 -2
- package/types/bundler.ts +4 -1
- package/types/index.ts +29 -0
- package/types/pimlico.ts +12 -2
- package/types/stackup.ts +4 -1
- package/utils/deepHexlify.test.ts +13 -7
- package/utils/deepHexlify.ts +5 -4
- package/utils/getAction.ts +15 -0
- package/utils/getUserOperationHash.ts +10 -2
- package/utils/index.ts +15 -2
- package/utils/observe.ts +18 -5
- package/utils/signUserOperationHashWithECDSA.ts +17 -20
- package/_cjs/clients/bundler.js.map +0 -1
- package/_esm/clients/bundler.js.map +0 -1
- package/_types/clients/bundler.d.ts.map +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { estimateFeesPerGas } from "viem/actions";
|
|
2
|
+
import { getAction } from "../../utils/getAction.js";
|
|
3
|
+
import { AccountOrClientNotFoundError, parseAccount } from "../../utils/index.js";
|
|
4
|
+
import { estimateUserOperationGas } from "../bundler/estimateUserOperationGas.js";
|
|
5
|
+
export async function prepareUserOperationRequest(client, args) {
|
|
6
|
+
const { account: account_ = client.account, userOperation: partialUserOperation, sponsorUserOperation } = args;
|
|
7
|
+
if (!account_)
|
|
8
|
+
throw new AccountOrClientNotFoundError();
|
|
9
|
+
const account = parseAccount(account_);
|
|
10
|
+
const [sender, nonce, initCode, signature, callData, gasEstimation] = await Promise.all([
|
|
11
|
+
partialUserOperation.sender || account.address,
|
|
12
|
+
partialUserOperation.nonce || account.getNonce(),
|
|
13
|
+
partialUserOperation.initCode || account.getInitCode(),
|
|
14
|
+
partialUserOperation.signature || account.getDummySignature(),
|
|
15
|
+
partialUserOperation.callData,
|
|
16
|
+
!partialUserOperation.maxFeePerGas ||
|
|
17
|
+
!partialUserOperation.maxPriorityFeePerGas
|
|
18
|
+
? estimateFeesPerGas(account.client)
|
|
19
|
+
: undefined
|
|
20
|
+
]);
|
|
21
|
+
const userOperation = {
|
|
22
|
+
sender,
|
|
23
|
+
nonce,
|
|
24
|
+
initCode,
|
|
25
|
+
signature,
|
|
26
|
+
callData,
|
|
27
|
+
paymasterAndData: "0x",
|
|
28
|
+
maxFeePerGas: partialUserOperation.maxFeePerGas ||
|
|
29
|
+
gasEstimation?.maxFeePerGas ||
|
|
30
|
+
0n,
|
|
31
|
+
maxPriorityFeePerGas: partialUserOperation.maxPriorityFeePerGas ||
|
|
32
|
+
gasEstimation?.maxPriorityFeePerGas ||
|
|
33
|
+
0n,
|
|
34
|
+
callGasLimit: partialUserOperation.callGasLimit || 0n,
|
|
35
|
+
verificationGasLimit: partialUserOperation.verificationGasLimit || 0n,
|
|
36
|
+
preVerificationGas: partialUserOperation.preVerificationGas || 0n
|
|
37
|
+
};
|
|
38
|
+
if (sponsorUserOperation) {
|
|
39
|
+
const { callGasLimit, verificationGasLimit, preVerificationGas, paymasterAndData } = await sponsorUserOperation({
|
|
40
|
+
userOperation,
|
|
41
|
+
entryPoint: account.entryPoint
|
|
42
|
+
});
|
|
43
|
+
userOperation.paymasterAndData = paymasterAndData;
|
|
44
|
+
userOperation.callGasLimit = userOperation.callGasLimit || callGasLimit;
|
|
45
|
+
userOperation.verificationGasLimit =
|
|
46
|
+
userOperation.verificationGasLimit || verificationGasLimit;
|
|
47
|
+
userOperation.preVerificationGas =
|
|
48
|
+
userOperation.preVerificationGas || preVerificationGas;
|
|
49
|
+
}
|
|
50
|
+
else if (!userOperation.callGasLimit ||
|
|
51
|
+
!userOperation.verificationGasLimit ||
|
|
52
|
+
!userOperation.preVerificationGas) {
|
|
53
|
+
const gasParameters = await getAction(client, estimateUserOperationGas)({
|
|
54
|
+
userOperation: {
|
|
55
|
+
...userOperation
|
|
56
|
+
},
|
|
57
|
+
entryPoint: account.entryPoint
|
|
58
|
+
});
|
|
59
|
+
userOperation.callGasLimit =
|
|
60
|
+
userOperation.callGasLimit || gasParameters.callGasLimit;
|
|
61
|
+
userOperation.verificationGasLimit =
|
|
62
|
+
userOperation.verificationGasLimit ||
|
|
63
|
+
gasParameters.verificationGasLimit;
|
|
64
|
+
userOperation.preVerificationGas =
|
|
65
|
+
userOperation.preVerificationGas || gasParameters.preVerificationGas;
|
|
66
|
+
}
|
|
67
|
+
return userOperation;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=prepareUserOperationRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareUserOperationRequest.js","sourceRoot":"","sources":["../../../actions/smartAccount/prepareUserOperationRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAOjD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EACH,4BAA4B,EAC5B,YAAY,EACf,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAA;AAmCjF,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAK7C,MAA4C,EAC5C,IAAqD;IAErD,MAAM,EACF,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAClC,aAAa,EAAE,oBAAoB,EACnC,oBAAoB,EACvB,GAAG,IAAI,CAAA;IACR,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,4BAA4B,EAAE,CAAA;IAEvD,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAiB,CAAA;IAEtD,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,CAAC,GAC/D,MAAM,OAAO,CAAC,GAAG,CAAC;QACd,oBAAoB,CAAC,MAAM,IAAI,OAAO,CAAC,OAAO;QAC9C,oBAAoB,CAAC,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE;QAChD,oBAAoB,CAAC,QAAQ,IAAI,OAAO,CAAC,WAAW,EAAE;QACtD,oBAAoB,CAAC,SAAS,IAAI,OAAO,CAAC,iBAAiB,EAAE;QAC7D,oBAAoB,CAAC,QAAQ;QAC7B,CAAC,oBAAoB,CAAC,YAAY;YAClC,CAAC,oBAAoB,CAAC,oBAAoB;YACtC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC;YACpC,CAAC,CAAC,SAAS;KAClB,CAAC,CAAA;IAEN,MAAM,aAAa,GAAkB;QACjC,MAAM;QACN,KAAK;QACL,QAAQ;QACR,SAAS;QACT,QAAQ;QACR,gBAAgB,EAAE,IAAI;QACtB,YAAY,EACR,oBAAoB,CAAC,YAAY;YACjC,aAAa,EAAE,YAAY;YAC3B,EAAE;QACN,oBAAoB,EAChB,oBAAoB,CAAC,oBAAoB;YACzC,aAAa,EAAE,oBAAoB;YACnC,EAAE;QACN,YAAY,EAAE,oBAAoB,CAAC,YAAY,IAAI,EAAE;QACrD,oBAAoB,EAAE,oBAAoB,CAAC,oBAAoB,IAAI,EAAE;QACrE,kBAAkB,EAAE,oBAAoB,CAAC,kBAAkB,IAAI,EAAE;KACpE,CAAA;IAED,IAAI,oBAAoB,EAAE;QACtB,MAAM,EACF,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EACnB,GAAG,MAAM,oBAAoB,CAAC;YAC3B,aAAa;YACb,UAAU,EAAE,OAAO,CAAC,UAAU;SACjC,CAAC,CAAA;QACF,aAAa,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACjD,aAAa,CAAC,YAAY,GAAG,aAAa,CAAC,YAAY,IAAI,YAAY,CAAA;QACvE,aAAa,CAAC,oBAAoB;YAC9B,aAAa,CAAC,oBAAoB,IAAI,oBAAoB,CAAA;QAC9D,aAAa,CAAC,kBAAkB;YAC5B,aAAa,CAAC,kBAAkB,IAAI,kBAAkB,CAAA;KAC7D;SAAM,IACH,CAAC,aAAa,CAAC,YAAY;QAC3B,CAAC,aAAa,CAAC,oBAAoB;QACnC,CAAC,aAAa,CAAC,kBAAkB,EACnC;QACE,MAAM,aAAa,GAAG,MAAM,SAAS,CACjC,MAAM,EACN,wBAAwB,CAC3B,CAAC;YACE,aAAa,EAAE;gBACX,GAAG,aAAa;aACnB;YACD,UAAU,EAAE,OAAO,CAAC,UAAU;SACjC,CAAC,CAAA;QAEF,aAAa,CAAC,YAAY;YACtB,aAAa,CAAC,YAAY,IAAI,aAAa,CAAC,YAAY,CAAA;QAC5D,aAAa,CAAC,oBAAoB;YAC9B,aAAa,CAAC,oBAAoB;gBAClC,aAAa,CAAC,oBAAoB,CAAA;QACtC,aAAa,CAAC,kBAAkB;YAC5B,aAAa,CAAC,kBAAkB,IAAI,aAAa,CAAC,kBAAkB,CAAA;KAC3E;IAED,OAAO,aAAa,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {} from "../../accounts/types.js";
|
|
2
|
+
import { getAction } from "../../utils/getAction.js";
|
|
3
|
+
import { AccountOrClientNotFoundError, parseAccount } from "../../utils/index.js";
|
|
4
|
+
import { waitForUserOperationReceipt } from "../bundler/waitForUserOperationReceipt.js";
|
|
5
|
+
import {} from "./prepareUserOperationRequest.js";
|
|
6
|
+
import { sendUserOperation } from "./sendUserOperation.js";
|
|
7
|
+
/**
|
|
8
|
+
* Creates, signs, and sends a new transaction to the network.
|
|
9
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
10
|
+
*
|
|
11
|
+
* - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html
|
|
12
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions
|
|
13
|
+
* - JSON-RPC Methods:
|
|
14
|
+
* - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)
|
|
15
|
+
* - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)
|
|
16
|
+
*
|
|
17
|
+
* @param client - Client to use
|
|
18
|
+
* @param parameters - {@link SendTransactionParameters}
|
|
19
|
+
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { createWalletClient, custom } from 'viem'
|
|
23
|
+
* import { mainnet } from 'viem/chains'
|
|
24
|
+
* import { sendTransaction } from 'viem/wallet'
|
|
25
|
+
*
|
|
26
|
+
* const client = createWalletClient({
|
|
27
|
+
* chain: mainnet,
|
|
28
|
+
* transport: custom(window.ethereum),
|
|
29
|
+
* })
|
|
30
|
+
* const hash = await sendTransaction(client, {
|
|
31
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
32
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
33
|
+
* value: 1000000000000000000n,
|
|
34
|
+
* })
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Account Hoisting
|
|
38
|
+
* import { createWalletClient, http } from 'viem'
|
|
39
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
40
|
+
* import { mainnet } from 'viem/chains'
|
|
41
|
+
* import { sendTransaction } from 'viem/wallet'
|
|
42
|
+
*
|
|
43
|
+
* const client = createWalletClient({
|
|
44
|
+
* account: privateKeyToAccount('0x…'),
|
|
45
|
+
* chain: mainnet,
|
|
46
|
+
* transport: http(),
|
|
47
|
+
* })
|
|
48
|
+
* const hash = await sendTransaction(client, {
|
|
49
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
50
|
+
* value: 1000000000000000000n,
|
|
51
|
+
* })
|
|
52
|
+
*/
|
|
53
|
+
export async function sendTransaction(client, args) {
|
|
54
|
+
const { account: account_ = client.account, data, maxFeePerGas, maxPriorityFeePerGas, to, value, nonce, sponsorUserOperation } = args;
|
|
55
|
+
if (!account_) {
|
|
56
|
+
throw new AccountOrClientNotFoundError({
|
|
57
|
+
docsPath: "/docs/actions/wallet/sendTransaction"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const account = parseAccount(account_);
|
|
61
|
+
if (!to)
|
|
62
|
+
throw new Error("Missing to address");
|
|
63
|
+
if (account.type !== "local") {
|
|
64
|
+
throw new Error("RPC account type not supported");
|
|
65
|
+
}
|
|
66
|
+
const callData = await account.encodeCallData({
|
|
67
|
+
to,
|
|
68
|
+
value: value || 0n,
|
|
69
|
+
data: data || "0x"
|
|
70
|
+
});
|
|
71
|
+
const userOpHash = await getAction(client, sendUserOperation)({
|
|
72
|
+
userOperation: {
|
|
73
|
+
sender: account.address,
|
|
74
|
+
paymasterAndData: "0x",
|
|
75
|
+
maxFeePerGas: maxFeePerGas || 0n,
|
|
76
|
+
maxPriorityFeePerGas: maxPriorityFeePerGas || 0n,
|
|
77
|
+
callData: callData,
|
|
78
|
+
nonce: nonce ? BigInt(nonce) : undefined
|
|
79
|
+
},
|
|
80
|
+
account: account,
|
|
81
|
+
sponsorUserOperation
|
|
82
|
+
});
|
|
83
|
+
const userOperationReceipt = await getAction(client, waitForUserOperationReceipt)({
|
|
84
|
+
hash: userOpHash
|
|
85
|
+
});
|
|
86
|
+
return userOperationReceipt?.receipt.transactionHash;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=sendTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendTransaction.js","sourceRoot":"","sources":["../../../actions/smartAccount/sendTransaction.ts"],"names":[],"mappings":"AAOA,OAAO,EAAqB,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EACH,4BAA4B,EAC5B,YAAY,EACf,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAA;AACvF,OAAO,EAAuC,MAAM,kCAAkC,CAAA;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAS1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAKjC,MAA2C,EAC3C,IAIC;IAED,MAAM,EACF,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAClC,IAAI,EACJ,YAAY,EACZ,oBAAoB,EACpB,EAAE,EACF,KAAK,EACL,KAAK,EACL,oBAAoB,EACvB,GAAG,IAAI,CAAA;IAER,IAAI,CAAC,QAAQ,EAAE;QACX,MAAM,IAAI,4BAA4B,CAAC;YACnC,QAAQ,EAAE,sCAAsC;SACnD,CAAC,CAAA;KACL;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAiB,CAAA;IAEtD,IAAI,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;IAE9C,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;KACpD;IAED,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC;QAC1C,EAAE;QACF,KAAK,EAAE,KAAK,IAAI,EAAE;QAClB,IAAI,EAAE,IAAI,IAAI,IAAI;KACrB,CAAC,CAAA;IAEF,MAAM,UAAU,GAAG,MAAM,SAAS,CAC9B,MAAM,EACN,iBAAiB,CACpB,CAAC;QACE,aAAa,EAAE;YACX,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,gBAAgB,EAAE,IAAI;YACtB,YAAY,EAAE,YAAY,IAAI,EAAE;YAChC,oBAAoB,EAAE,oBAAoB,IAAI,EAAE;YAChD,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;SAC3C;QACD,OAAO,EAAE,OAAO;QAChB,oBAAoB;KACvB,CAAC,CAAA;IAEF,MAAM,oBAAoB,GAAG,MAAM,SAAS,CACxC,MAAM,EACN,2BAA2B,CAC9B,CAAC;QACE,IAAI,EAAE,UAAU;KACnB,CAAC,CAAA;IAEF,OAAO,oBAAoB,EAAE,OAAO,CAAC,eAAe,CAAA;AACxD,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {} from "../../accounts/types.js";
|
|
2
|
+
import { getAction } from "../../utils/getAction.js";
|
|
3
|
+
import { AccountOrClientNotFoundError, parseAccount } from "../../utils/index.js";
|
|
4
|
+
import { waitForUserOperationReceipt } from "../bundler/waitForUserOperationReceipt.js";
|
|
5
|
+
import {} from "./prepareUserOperationRequest.js";
|
|
6
|
+
import { sendUserOperation } from "./sendUserOperation.js";
|
|
7
|
+
/**
|
|
8
|
+
* Creates, signs, and sends a new transactions to the network.
|
|
9
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
10
|
+
*
|
|
11
|
+
* @param client - Client to use
|
|
12
|
+
* @param parameters - {@link SendTransactionParameters}
|
|
13
|
+
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* import { createWalletClient, custom } from 'viem'
|
|
17
|
+
* import { mainnet } from 'viem/chains'
|
|
18
|
+
* import { sendTransaction } from 'viem/wallet'
|
|
19
|
+
*
|
|
20
|
+
* const client = createWalletClient({
|
|
21
|
+
* chain: mainnet,
|
|
22
|
+
* transport: custom(window.ethereum),
|
|
23
|
+
* })
|
|
24
|
+
* const hash = await sendTransaction(client, [{
|
|
25
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
26
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
27
|
+
* value: 1000000000000000000n,
|
|
28
|
+
* }, {
|
|
29
|
+
* to: '0x61897970c51812dc3a010c7d01b50e0d17dc1234',
|
|
30
|
+
* value: 10000000000000000n,
|
|
31
|
+
* }])
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Account Hoisting
|
|
35
|
+
* import { createWalletClient, http } from 'viem'
|
|
36
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
37
|
+
* import { mainnet } from 'viem/chains'
|
|
38
|
+
* import { sendTransaction } from 'viem/wallet'
|
|
39
|
+
*
|
|
40
|
+
* const client = createWalletClient({
|
|
41
|
+
* account: privateKeyToAccount('0x…'),
|
|
42
|
+
* chain: mainnet,
|
|
43
|
+
* transport: http(),
|
|
44
|
+
* })
|
|
45
|
+
* const hash = await sendTransactions(client, [{
|
|
46
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
47
|
+
* value: 1000000000000000000n,
|
|
48
|
+
* }, {
|
|
49
|
+
* to: '0x61897970c51812dc3a010c7d01b50e0d17dc1234',
|
|
50
|
+
* value: 10000000000000000n,
|
|
51
|
+
* }])
|
|
52
|
+
*/
|
|
53
|
+
export async function sendTransactions(client, args) {
|
|
54
|
+
const { account: account_ = client.account, transactions, sponsorUserOperation, maxFeePerGas, maxPriorityFeePerGas, nonce } = args;
|
|
55
|
+
if (!account_) {
|
|
56
|
+
throw new AccountOrClientNotFoundError({
|
|
57
|
+
docsPath: "/docs/actions/wallet/sendTransaction"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const account = parseAccount(account_);
|
|
61
|
+
if (account.type !== "local") {
|
|
62
|
+
throw new Error("RPC account type not supported");
|
|
63
|
+
}
|
|
64
|
+
const callData = await account.encodeCallData(transactions.map(({ to, value, data }) => {
|
|
65
|
+
if (!to)
|
|
66
|
+
throw new Error("Missing to address");
|
|
67
|
+
return {
|
|
68
|
+
to,
|
|
69
|
+
value: value || 0n,
|
|
70
|
+
data: data || "0x"
|
|
71
|
+
};
|
|
72
|
+
}));
|
|
73
|
+
const userOpHash = await getAction(client, sendUserOperation)({
|
|
74
|
+
userOperation: {
|
|
75
|
+
sender: account.address,
|
|
76
|
+
paymasterAndData: "0x",
|
|
77
|
+
maxFeePerGas: maxFeePerGas || 0n,
|
|
78
|
+
maxPriorityFeePerGas: maxPriorityFeePerGas || 0n,
|
|
79
|
+
callData: callData,
|
|
80
|
+
nonce: nonce
|
|
81
|
+
},
|
|
82
|
+
account: account,
|
|
83
|
+
sponsorUserOperation
|
|
84
|
+
});
|
|
85
|
+
const userOperationReceipt = await getAction(client, waitForUserOperationReceipt)({
|
|
86
|
+
hash: userOpHash
|
|
87
|
+
});
|
|
88
|
+
return userOperationReceipt?.receipt.transactionHash;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=sendTransactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendTransactions.js","sourceRoot":"","sources":["../../../actions/smartAccount/sendTransactions.ts"],"names":[],"mappings":"AASA,OAAO,EAAqB,MAAM,yBAAyB,CAAA;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EACH,4BAA4B,EAC5B,YAAY,EACf,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAA;AACvF,OAAO,EAAuC,MAAM,kCAAkC,CAAA;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAa1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAIlC,MAA2C,EAC3C,IAAuD;IAEvD,MAAM,EACF,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAClC,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACR,GAAG,IAAI,CAAA;IAER,IAAI,CAAC,QAAQ,EAAE;QACX,MAAM,IAAI,4BAA4B,CAAC;YACnC,QAAQ,EAAE,sCAAsC;SACnD,CAAC,CAAA;KACL;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAiB,CAAA;IAEtD,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;KACpD;IAED,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,CACzC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;QACrC,IAAI,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;QAC9C,OAAO;YACH,EAAE;YACF,KAAK,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,EAAE,IAAI,IAAI,IAAI;SACrB,CAAA;IACL,CAAC,CAAC,CACL,CAAA;IAED,MAAM,UAAU,GAAG,MAAM,SAAS,CAC9B,MAAM,EACN,iBAAiB,CACpB,CAAC;QACE,aAAa,EAAE;YACX,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,gBAAgB,EAAE,IAAI;YACtB,YAAY,EAAE,YAAY,IAAI,EAAE;YAChC,oBAAoB,EAAE,oBAAoB,IAAI,EAAE;YAChD,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,KAAK;SACf;QACD,OAAO,EAAE,OAAO;QAChB,oBAAoB;KACvB,CAAC,CAAA;IAEF,MAAM,oBAAoB,GAAG,MAAM,SAAS,CACxC,MAAM,EACN,2BAA2B,CAC9B,CAAC;QACE,IAAI,EAAE,UAAU;KACnB,CAAC,CAAA;IAEF,OAAO,oBAAoB,EAAE,OAAO,CAAC,eAAe,CAAA;AACxD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getAction } from "../../utils/getAction.js";
|
|
2
|
+
import { AccountOrClientNotFoundError, parseAccount } from "../../utils/index.js";
|
|
3
|
+
import { sendUserOperation as sendUserOperationBundler } from "../bundler/sendUserOperation.js";
|
|
4
|
+
import { prepareUserOperationRequest } from "./prepareUserOperationRequest.js";
|
|
5
|
+
export async function sendUserOperation(client, args) {
|
|
6
|
+
const { account: account_ = client.account } = args;
|
|
7
|
+
if (!account_)
|
|
8
|
+
throw new AccountOrClientNotFoundError();
|
|
9
|
+
const account = parseAccount(account_);
|
|
10
|
+
const userOperation = await getAction(client, prepareUserOperationRequest)(args);
|
|
11
|
+
userOperation.signature = await account.signUserOperation(userOperation);
|
|
12
|
+
const userOpHash = await getAction(client, sendUserOperationBundler, "sendUserOperation")({
|
|
13
|
+
userOperation: userOperation,
|
|
14
|
+
entryPoint: account.entryPoint
|
|
15
|
+
});
|
|
16
|
+
return userOpHash;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=sendUserOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../actions/smartAccount/sendUserOperation.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EACH,4BAA4B,EAC5B,YAAY,EACf,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,iBAAiB,IAAI,wBAAwB,EAAE,MAAM,iCAAiC,CAAA;AAC/F,OAAO,EAEH,2BAA2B,EAC9B,MAAM,kCAAkC,CAAA;AAuBzC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAKnC,MAA4C,EAC5C,IAA2C;IAE3C,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAA;IACnD,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,4BAA4B,EAAE,CAAA;IAEvD,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAiB,CAAA;IAEtD,MAAM,aAAa,GAAG,MAAM,SAAS,CACjC,MAAM,EACN,2BAA2B,CAC9B,CAAC,IAAI,CAAC,CAAA;IAEP,aAAa,CAAC,SAAS,GAAG,MAAM,OAAO,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAA;IAExE,MAAM,UAAU,GAAG,MAAM,SAAS,CAC9B,MAAM,EACN,wBAAwB,EACxB,mBAAmB,CACtB,CAAC;QACE,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;KACjC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {} from "../../accounts/types.js";
|
|
2
|
+
import { AccountOrClientNotFoundError, parseAccount } from "../../utils/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
|
5
|
+
*
|
|
6
|
+
* - Docs: https://viem.sh/docs/actions/wallet/signMessage.html
|
|
7
|
+
* - JSON-RPC Methods:
|
|
8
|
+
* - JSON-RPC Accounts: [`personal_sign`](https://docs.metamask.io/guide/signing-data.html#personal-sign)
|
|
9
|
+
* - Local Accounts: Signs locally. No JSON-RPC request.
|
|
10
|
+
*
|
|
11
|
+
* With the calculated signature, you can:
|
|
12
|
+
* - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage.html) to verify the signature,
|
|
13
|
+
* - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress.html) to recover the signing address from a signature.
|
|
14
|
+
*
|
|
15
|
+
* @param client - Client to use
|
|
16
|
+
* @param parameters - {@link SignMessageParameters}
|
|
17
|
+
* @returns The signed message. {@link SignMessageReturnType}
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import { createWalletClient, custom } from 'viem'
|
|
21
|
+
* import { mainnet } from 'viem/chains'
|
|
22
|
+
* import { signMessage } from 'viem/wallet'
|
|
23
|
+
*
|
|
24
|
+
* const client = createWalletClient({
|
|
25
|
+
* chain: mainnet,
|
|
26
|
+
* transport: custom(window.ethereum),
|
|
27
|
+
* })
|
|
28
|
+
* const signature = await signMessage(client, {
|
|
29
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
30
|
+
* message: 'hello world',
|
|
31
|
+
* })
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Account Hoisting
|
|
35
|
+
* import { createWalletClient, custom } from 'viem'
|
|
36
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
37
|
+
* import { mainnet } from 'viem/chains'
|
|
38
|
+
* import { signMessage } from 'viem/wallet'
|
|
39
|
+
*
|
|
40
|
+
* const client = createWalletClient({
|
|
41
|
+
* account: privateKeyToAccount('0x…'),
|
|
42
|
+
* chain: mainnet,
|
|
43
|
+
* transport: custom(window.ethereum),
|
|
44
|
+
* })
|
|
45
|
+
* const signature = await signMessage(client, {
|
|
46
|
+
* message: 'hello world',
|
|
47
|
+
* })
|
|
48
|
+
*/
|
|
49
|
+
export async function signMessage(client, { account: account_ = client.account, message }) {
|
|
50
|
+
if (!account_)
|
|
51
|
+
throw new AccountOrClientNotFoundError({
|
|
52
|
+
docsPath: "/docs/actions/wallet/signMessage"
|
|
53
|
+
});
|
|
54
|
+
const account = parseAccount(account_);
|
|
55
|
+
if (account.type === "local")
|
|
56
|
+
return account.signMessage({ message });
|
|
57
|
+
throw new Error("Sign message is not supported by this account");
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=signMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../actions/smartAccount/signMessage.ts"],"names":[],"mappings":"AAOA,OAAO,EAAqB,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EACH,4BAA4B,EAC5B,YAAY,EACf,MAAM,sBAAsB,CAAA;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAI7B,MAA2C,EAC3C,EACI,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAClC,OAAO,EACuB;IAElC,IAAI,CAAC,QAAQ;QACT,MAAM,IAAI,4BAA4B,CAAC;YACnC,QAAQ,EAAE,kCAAkC;SAC/C,CAAC,CAAA;IAEN,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;IACtC,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;IAErE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { getTypesForEIP712Domain, validateTypedData } from "viem";
|
|
2
|
+
import {} from "../../accounts/types.js";
|
|
3
|
+
import { AccountOrClientNotFoundError, parseAccount } from "../../utils/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Signs typed data and calculates an Ethereum-specific signature in [https://eips.ethereum.org/EIPS/eip-712](https://eips.ethereum.org/EIPS/eip-712): `sign(keccak256("\x19\x01" ‖ domainSeparator ‖ hashStruct(message)))`
|
|
6
|
+
*
|
|
7
|
+
* - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html
|
|
8
|
+
* - JSON-RPC Methods:
|
|
9
|
+
* - JSON-RPC Accounts: [`eth_signTypedData_v4`](https://docs.metamask.io/guide/signing-data.html#signtypeddata-v4)
|
|
10
|
+
* - Local Accounts: Signs locally. No JSON-RPC request.
|
|
11
|
+
*
|
|
12
|
+
* @param client - Client to use
|
|
13
|
+
* @param parameters - {@link SignTypedDataParameters}
|
|
14
|
+
* @returns The signed data. {@link SignTypedDataReturnType}
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import { createWalletClient, custom } from 'viem'
|
|
18
|
+
* import { mainnet } from 'viem/chains'
|
|
19
|
+
* import { signTypedData } from 'viem/wallet'
|
|
20
|
+
*
|
|
21
|
+
* const client = createWalletClient({
|
|
22
|
+
* chain: mainnet,
|
|
23
|
+
* transport: custom(window.ethereum),
|
|
24
|
+
* })
|
|
25
|
+
* const signature = await signTypedData(client, {
|
|
26
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
27
|
+
* domain: {
|
|
28
|
+
* name: 'Ether Mail',
|
|
29
|
+
* version: '1',
|
|
30
|
+
* chainId: 1,
|
|
31
|
+
* verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
32
|
+
* },
|
|
33
|
+
* types: {
|
|
34
|
+
* Person: [
|
|
35
|
+
* { name: 'name', type: 'string' },
|
|
36
|
+
* { name: 'wallet', type: 'address' },
|
|
37
|
+
* ],
|
|
38
|
+
* Mail: [
|
|
39
|
+
* { name: 'from', type: 'Person' },
|
|
40
|
+
* { name: 'to', type: 'Person' },
|
|
41
|
+
* { name: 'contents', type: 'string' },
|
|
42
|
+
* ],
|
|
43
|
+
* },
|
|
44
|
+
* primaryType: 'Mail',
|
|
45
|
+
* message: {
|
|
46
|
+
* from: {
|
|
47
|
+
* name: 'Cow',
|
|
48
|
+
* wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
|
|
49
|
+
* },
|
|
50
|
+
* to: {
|
|
51
|
+
* name: 'Bob',
|
|
52
|
+
* wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
|
|
53
|
+
* },
|
|
54
|
+
* contents: 'Hello, Bob!',
|
|
55
|
+
* },
|
|
56
|
+
* })
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Account Hoisting
|
|
60
|
+
* import { createWalletClient, http } from 'viem'
|
|
61
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
62
|
+
* import { mainnet } from 'viem/chains'
|
|
63
|
+
* import { signTypedData } from 'viem/wallet'
|
|
64
|
+
*
|
|
65
|
+
* const client = createWalletClient({
|
|
66
|
+
* account: privateKeyToAccount('0x…'),
|
|
67
|
+
* chain: mainnet,
|
|
68
|
+
* transport: http(),
|
|
69
|
+
* })
|
|
70
|
+
* const signature = await signTypedData(client, {
|
|
71
|
+
* domain: {
|
|
72
|
+
* name: 'Ether Mail',
|
|
73
|
+
* version: '1',
|
|
74
|
+
* chainId: 1,
|
|
75
|
+
* verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
76
|
+
* },
|
|
77
|
+
* types: {
|
|
78
|
+
* Person: [
|
|
79
|
+
* { name: 'name', type: 'string' },
|
|
80
|
+
* { name: 'wallet', type: 'address' },
|
|
81
|
+
* ],
|
|
82
|
+
* Mail: [
|
|
83
|
+
* { name: 'from', type: 'Person' },
|
|
84
|
+
* { name: 'to', type: 'Person' },
|
|
85
|
+
* { name: 'contents', type: 'string' },
|
|
86
|
+
* ],
|
|
87
|
+
* },
|
|
88
|
+
* primaryType: 'Mail',
|
|
89
|
+
* message: {
|
|
90
|
+
* from: {
|
|
91
|
+
* name: 'Cow',
|
|
92
|
+
* wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
|
|
93
|
+
* },
|
|
94
|
+
* to: {
|
|
95
|
+
* name: 'Bob',
|
|
96
|
+
* wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
|
|
97
|
+
* },
|
|
98
|
+
* contents: 'Hello, Bob!',
|
|
99
|
+
* },
|
|
100
|
+
* })
|
|
101
|
+
*/
|
|
102
|
+
export async function signTypedData(client, { account: account_ = client.account, domain, message, primaryType, types: types_ }) {
|
|
103
|
+
if (!account_) {
|
|
104
|
+
throw new AccountOrClientNotFoundError({
|
|
105
|
+
docsPath: "/docs/actions/wallet/signMessage"
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const account = parseAccount(account_);
|
|
109
|
+
const types = {
|
|
110
|
+
EIP712Domain: getTypesForEIP712Domain({ domain }),
|
|
111
|
+
...types_
|
|
112
|
+
};
|
|
113
|
+
validateTypedData({
|
|
114
|
+
domain,
|
|
115
|
+
message,
|
|
116
|
+
primaryType,
|
|
117
|
+
types
|
|
118
|
+
});
|
|
119
|
+
if (account.type === "local") {
|
|
120
|
+
return account.signTypedData({
|
|
121
|
+
domain,
|
|
122
|
+
primaryType,
|
|
123
|
+
types,
|
|
124
|
+
message
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
throw new Error("Sign type message is not supported by this account");
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=signTypedData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../actions/smartAccount/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAQH,uBAAuB,EACvB,iBAAiB,EACpB,MAAM,MAAM,CAAA;AACb,OAAO,EAAqB,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EACH,4BAA4B,EAC5B,YAAY,EACf,MAAM,sBAAsB,CAAA;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAM/B,MAA2C,EAC3C,EACI,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAClC,MAAM,EACN,OAAO,EACP,WAAW,EACX,KAAK,EAAE,MAAM,EAC6C;IAE9D,IAAI,CAAC,QAAQ,EAAE;QACX,MAAM,IAAI,4BAA4B,CAAC;YACnC,QAAQ,EAAE,kCAAkC;SAC/C,CAAC,CAAA;KACL;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;IAEtC,MAAM,KAAK,GAAG;QACV,YAAY,EAAE,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;QACjD,GAAI,MAAqB;KAC5B,CAAA;IAED,iBAAiB,CAAC;QACd,MAAM;QACN,OAAO;QACP,WAAW;QACX,KAAK;KACe,CAAC,CAAA;IAEzB,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE;QAC1B,OAAO,OAAO,CAAC,aAAa,CAAC;YACzB,MAAM;YACN,WAAW;YACX,KAAK;YACL,OAAO;SACa,CAAC,CAAA;KAC5B;IAED,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;AACzE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { encodeFunctionData } from "viem";
|
|
2
|
+
import {} from "../../accounts/types.js";
|
|
3
|
+
import { getAction } from "../../utils/getAction.js";
|
|
4
|
+
import {} from "./prepareUserOperationRequest.js";
|
|
5
|
+
import { sendTransaction } from "./sendTransaction.js";
|
|
6
|
+
export async function writeContract(client, { abi, address, args, dataSuffix, functionName, ...request }) {
|
|
7
|
+
const data = encodeFunctionData({
|
|
8
|
+
abi,
|
|
9
|
+
args,
|
|
10
|
+
functionName
|
|
11
|
+
});
|
|
12
|
+
const hash = await getAction(client, (sendTransaction))({
|
|
13
|
+
data: `${data}${dataSuffix ? dataSuffix.replace("0x", "") : ""}`,
|
|
14
|
+
to: address,
|
|
15
|
+
...request
|
|
16
|
+
});
|
|
17
|
+
return hash;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=writeContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeContract.js","sourceRoot":"","sources":["../../../actions/smartAccount/writeContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAQH,kBAAkB,EACrB,MAAM,MAAM,CAAA;AACb,OAAO,EAAqB,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAuC,MAAM,kCAAkC,CAAA;AACtF,OAAO,EAEH,eAAe,EAClB,MAAM,sBAAsB,CAAA;AAoE7B,MAAM,CAAC,KAAK,UAAU,aAAa,CAO/B,MAA2C,EAC3C,EACI,GAAG,EACH,OAAO,EACP,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,GAAG,OAAO,EAOb;IAED,MAAM,IAAI,GAAG,kBAAkB,CAAC;QAC5B,GAAG;QACH,IAAI;QACJ,YAAY;KACiD,CAAC,CAAA;IAClE,MAAM,IAAI,GAAG,MAAM,SAAS,CACxB,MAAM,EACN,CAAA,eAAiD,CAAA,CACpD,CAAC;QACE,IAAI,EAAE,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;QAChE,EAAE,EAAE,OAAO;QACX,GAAG,OAAO;KAKb,CAAC,CAAA;IACF,OAAO,IAAI,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { deployContract } from "./smartAccount/deployContract.js";
|
|
2
|
+
import { prepareUserOperationRequest } from "./smartAccount/prepareUserOperationRequest.js";
|
|
3
|
+
import { sendTransaction } from "./smartAccount/sendTransaction.js";
|
|
4
|
+
import { sendUserOperation } from "./smartAccount/sendUserOperation.js";
|
|
5
|
+
import { signMessage } from "./smartAccount/signMessage.js";
|
|
6
|
+
import { signTypedData } from "./smartAccount/signTypedData.js";
|
|
7
|
+
import { sendTransactions } from "./smartAccount/sendTransactions.js";
|
|
8
|
+
export { deployContract, prepareUserOperationRequest, sendTransaction, sendUserOperation, signMessage, signTypedData, sendTransactions };
|
|
9
|
+
//# sourceMappingURL=smartAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smartAccount.js","sourceRoot":"","sources":["../../actions/smartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,cAAc,EACjB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EAIH,2BAA2B,EAC9B,MAAM,+CAA+C,CAAA;AAEtD,OAAO,EAEH,eAAe,EAClB,MAAM,mCAAmC,CAAA;AAE1C,OAAO,EAGH,iBAAiB,EACpB,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAE/D,OAAO,EAEH,gBAAgB,EACnB,MAAM,oCAAoC,CAAA;AAE3C,OAAO,EACH,cAAc,EAEd,2BAA2B,EAG3B,eAAe,EACf,iBAAiB,EAGjB,WAAW,EACX,aAAa,EAGb,gBAAgB,EAEnB,CAAA"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* const bundlerClient = createClient({
|
|
14
14
|
* chain: goerli,
|
|
15
|
-
* transport: http("https://api.stackup.sh/
|
|
15
|
+
* transport: http("https://api.stackup.sh/v2/paymaster/YOUR_API_KEY_HERE")
|
|
16
16
|
* })
|
|
17
17
|
*
|
|
18
18
|
* await accounts(bundlerClient, {
|
|
@@ -16,7 +16,7 @@ import { deepHexlify } from "../../utils/deepHexlify.js";
|
|
|
16
16
|
*
|
|
17
17
|
* const bundlerClient = createClient({
|
|
18
18
|
* chain: goerli,
|
|
19
|
-
* transport: http("https://api.stackup.sh/
|
|
19
|
+
* transport: http("https://api.stackup.sh/v2/paymaster/YOUR_API_KEY_HERE")
|
|
20
20
|
* })
|
|
21
21
|
*
|
|
22
22
|
* await sponsorUserOperation(bundlerClient, {
|
|
@@ -28,7 +28,11 @@ import { deepHexlify } from "../../utils/deepHexlify.js";
|
|
|
28
28
|
export const sponsorUserOperation = async (client, args) => {
|
|
29
29
|
const response = await client.request({
|
|
30
30
|
method: "pm_sponsorUserOperation",
|
|
31
|
-
params: [
|
|
31
|
+
params: [
|
|
32
|
+
deepHexlify(args.userOperation),
|
|
33
|
+
args.entryPoint,
|
|
34
|
+
args.context
|
|
35
|
+
]
|
|
32
36
|
});
|
|
33
37
|
return {
|
|
34
38
|
paymasterAndData: response.paymasterAndData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sponsorUserOperation.js","sourceRoot":"","sources":["../../../actions/stackup/sponsorUserOperation.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+B,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"sponsorUserOperation.js","sourceRoot":"","sources":["../../../actions/stackup/sponsorUserOperation.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+B,MAAM,0BAA0B,CAAA;AAMtE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAqBxD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACrC,MAA8B,EAC9B,IAAoC,EACG,EAAE;IACzC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,yBAAyB;QACjC,MAAM,EAAE;YACJ,WAAW,CAAC,IAAI,CAAC,aAAa,CAAiC;YAC/D,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,OAAO;SACf;KACJ,CAAC,CAAA;IAEF,OAAO;QACH,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;QAC3C,kBAAkB,EAAE,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QACvD,oBAAoB,EAAE,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC;QAC3D,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;KAC9C,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBundlerClient.js","sourceRoot":"","sources":["../../clients/createBundlerClient.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAuB,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAW7E;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAI/B,UAAgD,EACnC,EAAE;IACf,MAAM,EAAE,GAAG,GAAG,QAAQ,EAAE,IAAI,GAAG,gBAAgB,EAAE,GAAG,UAAU,CAAA;IAC9D,MAAM,MAAM,GAAG,YAAY,CAAC;QACxB,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,IAAI,EAAE,eAAe;KACxB,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;AACxC,CAAC,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createClient } from "viem";
|
|
2
|
+
import {} from "../accounts/types.js";
|
|
3
|
+
import {} from "../actions/smartAccount/prepareUserOperationRequest.js";
|
|
4
|
+
import {} from "../types/bundler.js";
|
|
5
|
+
import { smartAccountActions } from "./decorators/smartAccount.js";
|
|
6
|
+
/**
|
|
7
|
+
* Creates a EIP-4337 compliant Bundler Client with a given [Transport](https://viem.sh/docs/clients/intro.html) configured for a [Chain](https://viem.sh/docs/clients/chains.html).
|
|
8
|
+
*
|
|
9
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/clients/smartAccountClient
|
|
10
|
+
*
|
|
11
|
+
* A Bundler Client is an interface to "erc 4337" [JSON-RPC API](https://eips.ethereum.org/EIPS/eip-4337#rpc-methods-eth-namespace) methods such as sending user operation, estimating gas for a user operation, get user operation receipt, etc through Bundler Actions.
|
|
12
|
+
*
|
|
13
|
+
* @param config - {@link WalletClientConfig}
|
|
14
|
+
* @returns A Bundler Client. {@link SmartAccountClient}
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import { createPublicClient, http } from 'viem'
|
|
18
|
+
* import { mainnet } from 'viem/chains'
|
|
19
|
+
*
|
|
20
|
+
* const smartAccountClient = createSmartAccountClient({
|
|
21
|
+
* chain: mainnet,
|
|
22
|
+
* transport: http(BUNDLER_URL),
|
|
23
|
+
* })
|
|
24
|
+
*/
|
|
25
|
+
export const createSmartAccountClient = (parameters) => {
|
|
26
|
+
const { key = "Account", name = "Smart Account Client", transport } = parameters;
|
|
27
|
+
const client = createClient({
|
|
28
|
+
...parameters,
|
|
29
|
+
key,
|
|
30
|
+
name,
|
|
31
|
+
transport: (opts) => transport({ ...opts, retryCount: 0 }),
|
|
32
|
+
type: "smartAccountClient"
|
|
33
|
+
});
|
|
34
|
+
return client.extend(smartAccountActions({
|
|
35
|
+
sponsorUserOperation: parameters.sponsorUserOperation
|
|
36
|
+
}));
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=createSmartAccountClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSmartAccountClient.js","sourceRoot":"","sources":["../../clients/createSmartAccountClient.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EAAqB,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAuC,MAAM,wDAAwD,CAAA;AAC5G,OAAO,EAAyB,MAAM,qBAAqB,CAAA;AAE3D,OAAO,EAEH,mBAAmB,EACtB,MAAM,8BAA8B,CAAA;AAiCrC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAKpC,UACkC,EACiC,EAAE;IACrE,MAAM,EACF,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,sBAAsB,EAC7B,SAAS,EACZ,GAAG,UAAU,CAAA;IACd,MAAM,MAAM,GAAG,YAAY,CAAC;QACxB,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QAC1D,IAAI,EAAE,oBAAoB;KAC7B,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,MAAM,CAChB,mBAAmB,CAAC;QAChB,oBAAoB,EAAE,UAAU,CAAC,oBAAoB;KACxD,CAAC,CACL,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../../clients/decorators/bundler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAA;AAC1D,OAAO,EAGH,wBAAwB,EAC3B,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EAGH,sBAAsB,EACzB,MAAM,iDAAiD,CAAA;AACxD,OAAO,EAGH,uBAAuB,EAC1B,MAAM,kDAAkD,CAAA;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../../clients/decorators/bundler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAA;AAC1D,OAAO,EAGH,wBAAwB,EAC3B,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EAGH,sBAAsB,EACzB,MAAM,iDAAiD,CAAA;AACxD,OAAO,EAGH,uBAAuB,EAC1B,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAEH,iBAAiB,EACpB,MAAM,4CAA4C,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAA;AACpF,OAAO,EAEH,2BAA2B,EAC9B,MAAM,sDAAsD,CAAA;AAgL7D,MAAM,cAAc,GAAG,CAAC,MAAc,EAAkB,EAAE,CAAC,CAAC;IACxD,iBAAiB,EAAE,KAAK,EACpB,IAAiC,EACpB,EAAE,CAAC,iBAAiB,CAAC,MAAuB,EAAE,IAAI,CAAC;IACpE,wBAAwB,EAAE,CAAC,IAAwC,EAAE,EAAE,CACnE,wBAAwB,CAAC,MAAuB,EAAE,IAAI,CAAC;IAC3D,oBAAoB,EAAE,GAAuB,EAAE,CAC3C,oBAAoB,CAAC,MAAuB,CAAC;IACjD,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAuB,CAAC;IAC/C,sBAAsB,EAAE,CAAC,IAAsC,EAAE,EAAE,CAC/D,sBAAsB,CAAC,MAAuB,EAAE,IAAI,CAAC;IACzD,uBAAuB,EAAE,CAAC,IAAuC,EAAE,EAAE,CACjE,uBAAuB,CAAC,MAAuB,EAAE,IAAI,CAAC;IAC1D,2BAA2B,EAAE,CACzB,IAA2C,EAC7C,EAAE,CAAC,2BAA2B,CAAC,MAAuB,EAAE,IAAI,CAAC;CAClE,CAAC,CAAA;AAEF,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -9,7 +9,7 @@ export const pimlicoPaymasterActions = (client) => ({
|
|
|
9
9
|
sponsorUserOperation: async (args) => sponsorUserOperation(client, args)
|
|
10
10
|
});
|
|
11
11
|
/**
|
|
12
|
-
* TODO: Add support for pimlicoActions after we support all the actions of
|
|
12
|
+
* TODO: Add support for pimlicoActions after we support all the actions of v2 of the Pimlico API.
|
|
13
13
|
*/
|
|
14
14
|
// export const pimlicoActions = (client: Client) => {
|
|
15
15
|
// return {
|