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,191 @@
|
|
|
1
|
+
import { concatHex, encodeFunctionData } from "viem";
|
|
2
|
+
import { toAccount } from "viem/accounts";
|
|
3
|
+
import { getBytecode, getChainId, signMessage, signTypedData } from "viem/actions";
|
|
4
|
+
import { getAccountNonce } from "../actions/public/getAccountNonce.js";
|
|
5
|
+
import { getSenderAddress } from "../actions/public/getSenderAddress.js";
|
|
6
|
+
import { getUserOperationHash } from "../utils/getUserOperationHash.js";
|
|
7
|
+
import { SignTransactionNotSupportedBySmartAccount } from "./types.js";
|
|
8
|
+
const getAccountInitCode = async (factoryAddress, owner, index = 0n) => {
|
|
9
|
+
if (!owner)
|
|
10
|
+
throw new Error("Owner account not found");
|
|
11
|
+
return concatHex([
|
|
12
|
+
factoryAddress,
|
|
13
|
+
encodeFunctionData({
|
|
14
|
+
abi: [
|
|
15
|
+
{
|
|
16
|
+
inputs: [
|
|
17
|
+
{
|
|
18
|
+
internalType: "address",
|
|
19
|
+
name: "owner",
|
|
20
|
+
type: "address"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
internalType: "uint256",
|
|
24
|
+
name: "salt",
|
|
25
|
+
type: "uint256"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
name: "createAccount",
|
|
29
|
+
outputs: [
|
|
30
|
+
{
|
|
31
|
+
internalType: "contract SimpleAccount",
|
|
32
|
+
name: "ret",
|
|
33
|
+
type: "address"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
stateMutability: "nonpayable",
|
|
37
|
+
type: "function"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
functionName: "createAccount",
|
|
41
|
+
args: [owner, index]
|
|
42
|
+
})
|
|
43
|
+
]);
|
|
44
|
+
};
|
|
45
|
+
const getAccountAddress = async ({ client, factoryAddress, entryPoint, owner, index = 0n }) => {
|
|
46
|
+
const initCode = await getAccountInitCode(factoryAddress, owner, index);
|
|
47
|
+
return getSenderAddress(client, {
|
|
48
|
+
initCode,
|
|
49
|
+
entryPoint
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* @description Creates an Simple Account from a private key.
|
|
54
|
+
*
|
|
55
|
+
* @returns A Private Key Simple Account.
|
|
56
|
+
*/
|
|
57
|
+
export async function signerToSimpleSmartAccount(client, { signer, factoryAddress, entryPoint, index = 0n }) {
|
|
58
|
+
const viemSigner = signer.type === "local"
|
|
59
|
+
? {
|
|
60
|
+
...signer,
|
|
61
|
+
signTransaction: (_, __) => {
|
|
62
|
+
throw new SignTransactionNotSupportedBySmartAccount();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
: signer;
|
|
66
|
+
const [accountAddress, chainId] = await Promise.all([
|
|
67
|
+
getAccountAddress({
|
|
68
|
+
client,
|
|
69
|
+
factoryAddress,
|
|
70
|
+
entryPoint,
|
|
71
|
+
owner: viemSigner.address,
|
|
72
|
+
index
|
|
73
|
+
}),
|
|
74
|
+
getChainId(client)
|
|
75
|
+
]);
|
|
76
|
+
if (!accountAddress)
|
|
77
|
+
throw new Error("Account address not found");
|
|
78
|
+
const account = toAccount({
|
|
79
|
+
address: accountAddress,
|
|
80
|
+
async signMessage({ message }) {
|
|
81
|
+
return signMessage(client, { account: viemSigner, message });
|
|
82
|
+
},
|
|
83
|
+
async signTransaction(_, __) {
|
|
84
|
+
throw new SignTransactionNotSupportedBySmartAccount();
|
|
85
|
+
},
|
|
86
|
+
async signTypedData(typedData) {
|
|
87
|
+
return signTypedData(client, { account: viemSigner, ...typedData });
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
...account,
|
|
92
|
+
client: client,
|
|
93
|
+
publicKey: accountAddress,
|
|
94
|
+
entryPoint: entryPoint,
|
|
95
|
+
source: "SimpleSmartAccount",
|
|
96
|
+
async getNonce() {
|
|
97
|
+
return getAccountNonce(client, {
|
|
98
|
+
sender: accountAddress,
|
|
99
|
+
entryPoint: entryPoint
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
async signUserOperation(userOperation) {
|
|
103
|
+
return account.signMessage({
|
|
104
|
+
message: {
|
|
105
|
+
raw: getUserOperationHash({
|
|
106
|
+
userOperation,
|
|
107
|
+
entryPoint: entryPoint,
|
|
108
|
+
chainId: chainId
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
async getInitCode() {
|
|
114
|
+
const contractCode = await getBytecode(client, {
|
|
115
|
+
address: accountAddress
|
|
116
|
+
});
|
|
117
|
+
if ((contractCode?.length ?? 0) > 2)
|
|
118
|
+
return "0x";
|
|
119
|
+
return getAccountInitCode(factoryAddress, viemSigner.address, index);
|
|
120
|
+
},
|
|
121
|
+
async encodeDeployCallData(_) {
|
|
122
|
+
throw new Error("Simple account doesn't support account deployment");
|
|
123
|
+
},
|
|
124
|
+
async encodeCallData(args) {
|
|
125
|
+
if (Array.isArray(args)) {
|
|
126
|
+
const argsArray = args;
|
|
127
|
+
return encodeFunctionData({
|
|
128
|
+
abi: [
|
|
129
|
+
{
|
|
130
|
+
inputs: [
|
|
131
|
+
{
|
|
132
|
+
internalType: "address[]",
|
|
133
|
+
name: "dest",
|
|
134
|
+
type: "address[]"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
internalType: "bytes[]",
|
|
138
|
+
name: "func",
|
|
139
|
+
type: "bytes[]"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
name: "executeBatch",
|
|
143
|
+
outputs: [],
|
|
144
|
+
stateMutability: "nonpayable",
|
|
145
|
+
type: "function"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
functionName: "executeBatch",
|
|
149
|
+
args: [
|
|
150
|
+
argsArray.map((a) => a.to),
|
|
151
|
+
argsArray.map((a) => a.data)
|
|
152
|
+
]
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
const { to, value, data } = args;
|
|
156
|
+
return encodeFunctionData({
|
|
157
|
+
abi: [
|
|
158
|
+
{
|
|
159
|
+
inputs: [
|
|
160
|
+
{
|
|
161
|
+
internalType: "address",
|
|
162
|
+
name: "dest",
|
|
163
|
+
type: "address"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
internalType: "uint256",
|
|
167
|
+
name: "value",
|
|
168
|
+
type: "uint256"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
internalType: "bytes",
|
|
172
|
+
name: "func",
|
|
173
|
+
type: "bytes"
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
name: "execute",
|
|
177
|
+
outputs: [],
|
|
178
|
+
stateMutability: "nonpayable",
|
|
179
|
+
type: "function"
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
functionName: "execute",
|
|
183
|
+
args: [to, value, data]
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
async getDummySignature() {
|
|
187
|
+
return "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=signerToSimpleSmartAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signerToSimpleSmartAccount.js","sourceRoot":"","sources":["../../accounts/signerToSimpleSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,SAAS,EACT,kBAAkB,EACrB,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EACH,WAAW,EACX,UAAU,EACV,WAAW,EACX,aAAa,EAChB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,EACH,yCAAyC,EAG5C,MAAM,YAAY,CAAA;AAOnB,MAAM,kBAAkB,GAAG,KAAK,EAC5B,cAAuB,EACvB,KAAc,EACd,KAAK,GAAG,EAAE,EACE,EAAE;IACd,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAEtD,OAAO,SAAS,CAAC;QACb,cAAc;QACd,kBAAkB,CAAC;YACf,GAAG,EAAE;gBACD;oBACI,MAAM,EAAE;wBACJ;4BACI,YAAY,EAAE,SAAS;4BACvB,IAAI,EAAE,OAAO;4BACb,IAAI,EAAE,SAAS;yBAClB;wBACD;4BACI,YAAY,EAAE,SAAS;4BACvB,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,SAAS;yBAClB;qBACJ;oBACD,IAAI,EAAE,eAAe;oBACrB,O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,EAAE,SAAS;6BAClB;4BACD;gCACI,YAAY,EAAE,OAAO;gCACrB,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,OAAO;6BAChB;yBACJ;wBACD,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,EAAE;wBACX,eAAe,EAAE,YAAY;wBAC7B,IAAI,EAAE,UAAU;qBACnB;iBACJ;gBACD,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC;aAC1B,CAAC,CAAA;QACN,CAAC;QACD,KAAK,CAAC,iBAAiB;YACnB,OAAO,sIAAsI,CAAA;QACjJ,CAAC;KACJ,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseError } from "viem";
|
|
2
|
+
import {} from "../types/index.js";
|
|
3
|
+
export class SignTransactionNotSupportedBySmartAccount extends BaseError {
|
|
4
|
+
constructor({ docsPath } = {}) {
|
|
5
|
+
super([
|
|
6
|
+
"A smart account cannot sign or send transaction, it can only sign message or userOperation.",
|
|
7
|
+
"Please send user operation instead."
|
|
8
|
+
].join("\n"), {
|
|
9
|
+
docsPath,
|
|
10
|
+
docsSlug: "account"
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "name", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: "SignTransactionNotSupportedBySmartAccount"
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../accounts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,SAAS,EAKZ,MAAM,MAAM,CAAA;AAEb,OAAO,EAAsB,MAAM,mBAAmB,CAAA;AAEtD,MAAM,OAAO,yCAA0C,SAAQ,SAAS;IAEpE,YAAY,EAAE,QAAQ,KAA4B,EAAE;QAChD,KAAK,CACD;YACI,6FAA6F;YAC7F,qCAAqC;SACxC,CAAC,IAAI,CAAC,IAAI,CAAC,EACZ;YACI,QAAQ;YACR,QAAQ,EAAE,SAAS;SACtB,CACJ,CAAA;QAXI;;;;mBAAO,2CAA2C;WAAA;IAY3D,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chainId.js","sourceRoot":"","sources":["../../../actions/bundler/chainId.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chainId.js","sourceRoot":"","sources":["../../../actions/bundler/chainId.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAKxB,MAA8D,EAChE,EAAE;IACA,OAAO,MAAM,CACT,MAAM,MAAM,CAAC,OAAO,CAAC;QACjB,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,EAAE;KACb,CAAC,CACL,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -30,7 +30,10 @@ export const estimateUserOperationGas = async (client, args) => {
|
|
|
30
30
|
const { userOperation, entryPoint } = args;
|
|
31
31
|
const response = await client.request({
|
|
32
32
|
method: "eth_estimateUserOperationGas",
|
|
33
|
-
params: [
|
|
33
|
+
params: [
|
|
34
|
+
deepHexlify(userOperation),
|
|
35
|
+
entryPoint
|
|
36
|
+
]
|
|
34
37
|
});
|
|
35
38
|
return {
|
|
36
39
|
preVerificationGas: BigInt(response.preVerificationGas || 0),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../actions/bundler/estimateUserOperationGas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../actions/bundler/estimateUserOperationGas.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAgBxD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAKzC,MAA8D,EAC9D,IAAwC,EACG,EAAE;IAC7C,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAE1C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,8BAA8B;QACtC,MAAM,EAAE;YACJ,WAAW,CAAC,aAAa,CAAiC;YAC1D,UAAqB;SACxB;KACJ,CAAC,CAAA;IAEF,OAAO;QACH,kBAAkB,EAAE,MAAM,CAAC,QAAQ,CAAC,kBAAkB,IAAI,CAAC,CAAC;QAC5D,oBAAoB,EAAE,MAAM,CAAC,QAAQ,CAAC,oBAAoB,IAAI,CAAC,CAAC;QAChE,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,IAAI,CAAC,CAAC;KACnD,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserOperationByHash.js","sourceRoot":"","sources":["../../../actions/bundler/getUserOperationByHash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getUserOperationByHash.js","sourceRoot":"","sources":["../../../actions/bundler/getUserOperationByHash.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAKvC,MAA8D,EAC9D,EAAE,IAAI,EAAoC,EACD,EAAE;IAC3C,MAAM,MAAM,GAAW,CAAC,IAAI,CAAC,CAAA;IAE7B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,4BAA4B;QACpC,MAAM;KACT,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,MAAM,EACF,aAAa,EACb,UAAU,EACV,eAAe,EACf,SAAS,EACT,WAAW,EACd,GAAG,QAAQ,CAAA;IAEZ,OAAO;QACH,aAAa,EAAE;YACX,GAAG,aAAa;YAChB,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;YAClC,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC;YAChD,oBAAoB,EAAE,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAC;YAChE,kBAAkB,EAAE,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC;YAC5D,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC;YAChD,oBAAoB,EAAE,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAC;SAClD;QAClB,UAAU,EAAE,UAAU;QACtB,eAAe,EAAE,eAAe;QAChC,SAAS,EAAE,SAAS;QACpB,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;KACnC,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserOperationReceipt.js","sourceRoot":"","sources":["../../../actions/bundler/getUserOperationReceipt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getUserOperationReceipt.js","sourceRoot":"","sources":["../../../actions/bundler/getUserOperationReceipt.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAuCrE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAKxC,MAA8D,EAC9D,EAAE,IAAI,EAAqC,EACM,EAAE;IACnD,MAAM,MAAM,GAAW,CAAC,IAAI,CAAC,CAAA;IAE7B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClC,MAAM,EAAE,6BAA6B;QACrC,MAAM;KACT,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,MAAM,oBAAoB,GAAsC;QAC5D,UAAU,EAAE,QAAQ,C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E,GAAG,CAAC,eAAe;YACpC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YAC9B,gBAAgB,EAAE,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC;YAC9C,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,MAAM,EAAE,GAAG,CAAC,MAAM;SACrB,CAAC,CAAC;KACN,CAAA;IAED,OAAO,oBAAoB,CAAA;AAC/B,CAAC,CAAA"}
|
|
@@ -8,7 +8,6 @@ import { deepHexlify } from "../../utils/deepHexlify.js";
|
|
|
8
8
|
* @param args {@link SendUserOperationParameters}.
|
|
9
9
|
* @returns UserOpHash that you can use to track user operation as {@link Hash}.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
11
|
* @example
|
|
13
12
|
* import { createClient } from "viem"
|
|
14
13
|
* import { sendUserOperation } from "permissionless/actions"
|
|
@@ -24,13 +23,15 @@ import { deepHexlify } from "../../utils/deepHexlify.js";
|
|
|
24
23
|
* })
|
|
25
24
|
*
|
|
26
25
|
* // Return '0xe9fad2cd67f9ca1d0b7a6513b2a42066784c8df938518da2b51bb8cc9a89ea34'
|
|
27
|
-
*
|
|
28
26
|
*/
|
|
29
27
|
export const sendUserOperation = async (client, args) => {
|
|
30
28
|
const { userOperation, entryPoint } = args;
|
|
31
29
|
return client.request({
|
|
32
30
|
method: "eth_sendUserOperation",
|
|
33
|
-
params: [
|
|
31
|
+
params: [
|
|
32
|
+
deepHexlify(userOperation),
|
|
33
|
+
entryPoint
|
|
34
|
+
]
|
|
34
35
|
});
|
|
35
36
|
};
|
|
36
37
|
//# sourceMappingURL=sendUserOperation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../actions/bundler/sendUserOperation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../actions/bundler/sendUserOperation.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAOxD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAKlC,MAA8D,EAC9D,IAAiC,EACpB,EAAE;IACf,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAE1C,OAAO,MAAM,CAAC,OAAO,CAAC;QAClB,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE;YACJ,WAAW,CAAC,aAAa,CAAiC;YAC1D,UAAqB;SACxB;KACJ,CAAC,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supportedEntryPoints.js","sourceRoot":"","sources":["../../../actions/bundler/supportedEntryPoints.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"supportedEntryPoints.js","sourceRoot":"","sources":["../../../actions/bundler/supportedEntryPoints.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAKrC,MAA8D,EAC5C,EAAE;IACpB,OAAO,MAAM,CAAC,OAAO,CAAC;QAClB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,EAAE;KACb,CAAC,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseError, stringify } from "viem";
|
|
2
|
+
import { getAction } from "../../utils/getAction.js";
|
|
2
3
|
import { observe } from "../../utils/observe.js";
|
|
3
4
|
import { getUserOperationReceipt } from "./getUserOperationReceipt.js";
|
|
4
5
|
export class WaitForUserOperationReceiptTimeoutError extends BaseError {
|
|
@@ -34,7 +35,11 @@ export class WaitForUserOperationReceiptTimeoutError extends BaseError {
|
|
|
34
35
|
* })
|
|
35
36
|
*/
|
|
36
37
|
export const waitForUserOperationReceipt = (bundlerClient, { hash, pollingInterval = bundlerClient.pollingInterval, timeout }) => {
|
|
37
|
-
const observerId = stringify([
|
|
38
|
+
const observerId = stringify([
|
|
39
|
+
"waitForUserOperationReceipt",
|
|
40
|
+
bundlerClient.uid,
|
|
41
|
+
hash
|
|
42
|
+
]);
|
|
38
43
|
let userOperationReceipt;
|
|
39
44
|
return new Promise((resolve, reject) => {
|
|
40
45
|
if (timeout) {
|
|
@@ -47,7 +52,7 @@ export const waitForUserOperationReceipt = (bundlerClient, { hash, pollingInterv
|
|
|
47
52
|
fn();
|
|
48
53
|
_unobserve();
|
|
49
54
|
};
|
|
50
|
-
const _userOperationReceipt = await
|
|
55
|
+
const _userOperationReceipt = await getAction(bundlerClient, getUserOperationReceipt)({ hash });
|
|
51
56
|
if (_userOperationReceipt !== null) {
|
|
52
57
|
userOperationReceipt = _userOperationReceipt;
|
|
53
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForUserOperationReceipt.js","sourceRoot":"","sources":["../../../actions/bundler/waitForUserOperationReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"waitForUserOperationReceipt.js","sourceRoot":"","sources":["../../../actions/bundler/waitForUserOperationReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,SAAS,EAKT,SAAS,EACZ,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAEH,uBAAuB,EAC1B,MAAM,8BAA8B,CAAA;AAErC,MAAM,OAAO,uCAAwC,SAAQ,SAAS;IAElE,YAAY,EAAE,IAAI,EAAkB;QAChC,KAAK,CACD,sDAAsD,IAAI,oBAAoB,CACjF,CAAA;QAJI;;;;mBAAO,yCAAyC;WAAA;IAKzD,CAAC;CACJ;AAcD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAKvC,aAAmD,EACnD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oot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAaA,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EACnB,MAAM,8BAA8B,CAAA;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAA;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAA;AACtF,OAAO,EAEH,uCAAuC,EAC1C,MAAM,0CAA0C,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAe7D,OAAO,EACH,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,OAAO,EACP,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,2BAA2B,EAC3B,uCAAuC,EAC1C,CAAA"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationGasPrice
|
|
5
5
|
*
|
|
6
|
-
* @param client
|
|
6
|
+
* @param client that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
|
|
7
7
|
* @returns slow, standard & fast values for maxFeePerGas & maxPriorityFeePerGas
|
|
8
8
|
*
|
|
9
9
|
*
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* const bundlerClient = createClient({
|
|
15
15
|
* chain: goerli,
|
|
16
|
-
* transport: http("https://api.pimlico.io/
|
|
16
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
17
17
|
* })
|
|
18
18
|
*
|
|
19
19
|
* await getUserOperationGasPrice(bundlerClient)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserOperationGasPrice.js","sourceRoot":"","sources":["../../../actions/pimlico/getUserOperationGasPrice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getUserOperationGasPrice.js","sourceRoot":"","sources":["../../../actions/pimlico/getUserOperationGasPrice.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAKzC,MAAqE,EAC1B,EAAE;IAC7C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,kCAAkC;QAC1C,MAAM,EAAE,EAAE;KACb,CAAC,CAAA;IAEF,OAAO;QACH,IAAI,EAAE;YACF,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC;YACjD,oBAAoB,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC;SACpE;QACD,QAAQ,EAAE;YACN,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC;YACrD,oBAAoB,EAAE,MAAM,CACxB,SAAS,CAAC,QAAQ,CAAC,oBAAoB,CAC1C;SACJ;QACD,IAAI,EAAE;YACF,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC;YACjD,oBAAoB,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC;SACpE;KACJ,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* const bundlerClient = createClient({
|
|
16
16
|
* chain: goerli,
|
|
17
|
-
* transport: http("https://api.pimlico.io/
|
|
17
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
18
18
|
* })
|
|
19
19
|
*
|
|
20
20
|
* await getUserOperationStatus(bundlerClient, { hash: userOpHash })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserOperationStatus.js","sourceRoot":"","sources":["../../../actions/pimlico/getUserOperationStatus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getUserOperationStatus.js","sourceRoot":"","sources":["../../../actions/pimlico/getUserOperationStatus.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAKvC,MAAqE,EACrE,EAAE,IAAI,EAAoC,EACD,EAAE;IAC3C,OAAO,MAAM,CAAC,OAAO,CAAC;QAClB,MAAM,EAAE,gCAAgC;QACxC,MAAM,EAAE,CAAC,IAAI,CAAC;KACjB,CAAC,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -27,7 +27,10 @@ import { deepHexlify } from "../../utils/deepHexlify.js";
|
|
|
27
27
|
export const sponsorUserOperation = async (client, args) => {
|
|
28
28
|
const response = await client.request({
|
|
29
29
|
method: "pm_sponsorUserOperation",
|
|
30
|
-
params: [
|
|
30
|
+
params: [
|
|
31
|
+
deepHexlify(args.userOperation),
|
|
32
|
+
args.entryPoint
|
|
33
|
+
]
|
|
31
34
|
});
|
|
32
35
|
return {
|
|
33
36
|
paymasterAndData: response.paymasterAndData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sponsorUserOperation.js","sourceRoot":"","sources":["../../../actions/pimlico/sponsorUserOperation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sponsorUserOperation.js","sourceRoot":"","sources":["../../../actions/pimlico/sponsorUserOperation.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAoBxD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAKrC,MAAuE,EACvE,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;SAClB;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../actions/pimlico.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,wBAAwB,EAC3B,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAGH,sBAAsB,EACzB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAGH,oBAAoB,EACvB,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../actions/pimlico.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,wBAAwB,EAC3B,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAGH,sBAAsB,EACzB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAGH,oBAAoB,EACvB,MAAM,mCAAmC,CAAA;AAM1C,OAAO,EACH,qBAAqB,EACrB,uBAAuB,EAC1B,MAAM,kCAAkC,CAAA;AAYzC,OAAO,EACH,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EAC1B,CAAA"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { readContract } from "viem/actions";
|
|
2
|
+
import { getAction } from "../../utils/getAction.js";
|
|
1
3
|
/**
|
|
2
4
|
* Returns the nonce of the account with the entry point.
|
|
3
5
|
*
|
|
4
6
|
* - Docs: https://docs.pimlico.io/permissionless/reference/public-actions/getAccountNonce
|
|
5
7
|
*
|
|
6
|
-
* @param
|
|
8
|
+
* @param client {@link client} that you created using viem's createPublicClient.
|
|
7
9
|
* @param args {@link GetAccountNonceParams} address, entryPoint & key
|
|
8
10
|
* @returns bigint nonce
|
|
9
11
|
*
|
|
@@ -11,12 +13,12 @@
|
|
|
11
13
|
* import { createPublicClient } from "viem"
|
|
12
14
|
* import { getAccountNonce } from "permissionless/actions"
|
|
13
15
|
*
|
|
14
|
-
* const
|
|
16
|
+
* const client = createPublicClient({
|
|
15
17
|
* chain: goerli,
|
|
16
18
|
* transport: http("https://goerli.infura.io/v3/your-infura-key")
|
|
17
19
|
* })
|
|
18
20
|
*
|
|
19
|
-
* const nonce = await getAccountNonce(
|
|
21
|
+
* const nonce = await getAccountNonce(client, {
|
|
20
22
|
* address,
|
|
21
23
|
* entryPoint,
|
|
22
24
|
* key
|
|
@@ -24,8 +26,8 @@
|
|
|
24
26
|
*
|
|
25
27
|
* // Return 0n
|
|
26
28
|
*/
|
|
27
|
-
export const getAccountNonce = async (
|
|
28
|
-
return await
|
|
29
|
+
export const getAccountNonce = async (client, { sender, entryPoint, key = BigInt(0) }) => {
|
|
30
|
+
return await getAction(client, readContract)({
|
|
29
31
|
address: entryPoint,
|
|
30
32
|
abi: [
|
|
31
33
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAccountNonce.js","sourceRoot":"","sources":["../../../actions/public/getAccountNonce.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getAccountNonce.js","sourceRoot":"","sources":["../../../actions/public/getAccountNonce.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAQpD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAIhC,MAAkC,EAClC,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,EAAyB,EAC/C,EAAE;IACjB,OAAO,MAAM,SAAS,CAClB,MAAM,EACN,YAAY,CACf,CAAC;QACE,OAAO,EAAE,UAAU;QACnB,GAAG,EAAE;YACD;gBACI,MAAM,EAAE;oBACJ;wBACI,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,SAAS;qBAClB;oBACD;wBACI,IAAI,EAAE,KAAK;wBACX,IAAI,EAAE,SAAS;qBAClB;iBACJ;gBACD,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE;oBACL;wBACI,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE,SAAS;qBAClB;iBACJ;gBACD,eAAe,EAAE,MAAM;gBACvB,IAAI,EAAE,UAAU;aACnB;SACJ;QACD,YAAY,EAAE,UAAU;QACxB,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC;KACtB,CAAC,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BaseError } from "viem";
|
|
2
|
+
import { simulateContract } from "viem/actions";
|
|
3
|
+
import { getAction } from "../../utils/getAction.js";
|
|
2
4
|
export class InvalidEntryPointError extends BaseError {
|
|
3
5
|
constructor({ cause, entryPoint } = {}) {
|
|
4
6
|
super(`The entry point address (\`entryPoint\`${entryPoint ? ` = ${entryPoint}` : ""}) is not a valid entry point. getSenderAddress did not revert with a SenderAddressResult error.`, {
|
|
@@ -17,8 +19,7 @@ export class InvalidEntryPointError extends BaseError {
|
|
|
17
19
|
*
|
|
18
20
|
* - Docs: https://docs.pimlico.io/permissionless/reference/public-actions/getSenderAddress
|
|
19
21
|
*
|
|
20
|
-
*
|
|
21
|
-
* @param publicClient {@link PublicClient} that you created using viem's createPublicClient.
|
|
22
|
+
* @param client {@link Client} that you created using viem's createPublicClient.
|
|
22
23
|
* @param args {@link GetSenderAddressParams} initCode & entryPoint
|
|
23
24
|
* @returns Sender's Address
|
|
24
25
|
*
|
|
@@ -38,9 +39,9 @@ export class InvalidEntryPointError extends BaseError {
|
|
|
38
39
|
*
|
|
39
40
|
* // Return '0x7a88a206ba40b37a8c07a2b5688cf8b287318b63'
|
|
40
41
|
*/
|
|
41
|
-
export const getSenderAddress = async (
|
|
42
|
+
export const getSenderAddress = async (client, { initCode, entryPoint }) => {
|
|
42
43
|
try {
|
|
43
|
-
await
|
|
44
|
+
await getAction(client, simulateContract)({
|
|
44
45
|
address: entryPoint,
|
|
45
46
|
abi: [
|
|
46
47
|
{
|
|
@@ -77,7 +78,9 @@ export const getSenderAddress = async (publicClient, { initCode, entryPoint }) =
|
|
|
77
78
|
if (err.cause.name === "ContractFunctionRevertedError") {
|
|
78
79
|
const revertError = err.cause;
|
|
79
80
|
const errorName = revertError.data?.errorName ?? "";
|
|
80
|
-
if (errorName === "SenderAddressResult" &&
|
|
81
|
+
if (errorName === "SenderAddressResult" &&
|
|
82
|
+
revertError.data?.args &&
|
|
83
|
+
revertError.data?.args[0]) {
|
|
81
84
|
return revertError.data?.args[0];
|
|
82
85
|
}
|
|
83
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSenderAddress.js","sourceRoot":"","sources":["../../../actions/public/getSenderAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,SAAS,
|
|
1
|
+
{"version":3,"file":"getSenderAddress.js","sourceRoot":"","sources":["../../../actions/public/getSenderAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,SAAS,EAOZ,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,gBAAgB,EAAE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,WAAW,GAAG,GAAG,CAAC,KAA0C,CAAA;YAClE,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,EAAE,SAAS,IAAI,EAAE,CAAA;YACnD,IACI,SAAS,KAAK,qBAAqB;gBACnC,WAAW,CAAC,IAAI,EAAE,IAAI;gBACtB,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAC3B;gBACE,OAAO,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAY,CAAA;aAC9C;SACJ;QAED,MAAM,CAAC,CAAA;KACV;IAED,MAAM,IAAI,sBAAsB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAA;AACpD,CAAC,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {} from "viem";
|
|
2
|
+
import { getAction } from "../../utils/getAction.js";
|
|
3
|
+
import { parseAccount } from "../../utils/index.js";
|
|
4
|
+
import { AccountOrClientNotFoundError } from "../../utils/signUserOperationHashWithECDSA.js";
|
|
5
|
+
import { waitForUserOperationReceipt } from "../bundler/waitForUserOperationReceipt.js";
|
|
6
|
+
import {} from "./prepareUserOperationRequest.js";
|
|
7
|
+
import { sendUserOperation } from "./sendUserOperation.js";
|
|
8
|
+
/**
|
|
9
|
+
* Deploys a contract to the network, given bytecode and constructor arguments.
|
|
10
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
11
|
+
*
|
|
12
|
+
* - Docs: https://viem.sh/docs/contract/deployContract.html
|
|
13
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts
|
|
14
|
+
*
|
|
15
|
+
* @param client - Client to use
|
|
16
|
+
* @param parameters - {@link DeployContractParameters}
|
|
17
|
+
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link DeployContractReturnType}
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import { createWalletClient, http } from 'viem'
|
|
21
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
22
|
+
* import { mainnet } from 'viem/chains'
|
|
23
|
+
* import { deployContract } from 'viem/contract'
|
|
24
|
+
*
|
|
25
|
+
* const client = createWalletClient({
|
|
26
|
+
* account: privateKeyToAccount('0x…'),
|
|
27
|
+
* chain: mainnet,
|
|
28
|
+
* transport: http(),
|
|
29
|
+
* })
|
|
30
|
+
* const hash = await deployContract(client, {
|
|
31
|
+
* abi: [],
|
|
32
|
+
* account: '0x…,
|
|
33
|
+
* bytecode: '0x608060405260405161083e38038061083e833981016040819052610...',
|
|
34
|
+
* })
|
|
35
|
+
*/
|
|
36
|
+
export async function deployContract(client, { abi, args, bytecode, sponsorUserOperation, ...request }) {
|
|
37
|
+
const { account: account_ = client.account } = request;
|
|
38
|
+
if (!account_) {
|
|
39
|
+
throw new AccountOrClientNotFoundError({
|
|
40
|
+
docsPath: "/docs/actions/wallet/sendTransaction"
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const account = parseAccount(account_);
|
|
44
|
+
const userOpHash = await getAction(client, sendUserOperation)({
|
|
45
|
+
userOperation: {
|
|
46
|
+
sender: account.address,
|
|
47
|
+
paymasterAndData: "0x",
|
|
48
|
+
maxFeePerGas: request.maxFeePerGas || 0n,
|
|
49
|
+
maxPriorityFeePerGas: request.maxPriorityFeePerGas || 0n,
|
|
50
|
+
callData: await account.encodeDeployCallData({
|
|
51
|
+
abi,
|
|
52
|
+
args,
|
|
53
|
+
bytecode
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
account: account,
|
|
57
|
+
sponsorUserOperation
|
|
58
|
+
});
|
|
59
|
+
const userOperationReceipt = await getAction(client, waitForUserOperationReceipt)({
|
|
60
|
+
hash: userOpHash
|
|
61
|
+
});
|
|
62
|
+
return userOperationReceipt?.receipt.transactionHash;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=deployContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployContract.js","sourceRoot":"","sources":["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