FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

View File

@@ -0,0 +1,12 @@
// TODO(v3): Remove this in favor of `ox/WebAuthnP256` entirely.
import * as PublicKey from 'ox/PublicKey';
import * as WebAuthnP256 from 'ox/WebAuthnP256';
export async function createWebAuthnCredential(parameters) {
const credential = await WebAuthnP256.createCredential(parameters);
return {
id: credential.id,
publicKey: PublicKey.toHex(credential.publicKey, { includePrefix: false }),
raw: credential.raw,
};
}
//# sourceMappingURL=createWebAuthnCredential.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createWebAuthnCredential.js","sourceRoot":"","sources":["../../../account-abstraction/accounts/createWebAuthnCredential.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,KAAK,SAAS,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAA;AAe/C,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,UAA8C;IAE9C,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAA;IAClE,OAAO;QACL,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;QAC1E,GAAG,EAAE,UAAU,CAAC,GAAG;KACpB,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,752 @@
import * as Signature from 'ox/Signature';
import { readContract } from '../../../actions/public/readContract.js';
import { BaseError } from '../../../errors/base.js';
import { decodeFunctionData } from '../../../utils/abi/decodeFunctionData.js';
import { encodeAbiParameters } from '../../../utils/abi/encodeAbiParameters.js';
import { encodeFunctionData } from '../../../utils/abi/encodeFunctionData.js';
import { encodePacked } from '../../../utils/abi/encodePacked.js';
import { pad } from '../../../utils/data/pad.js';
import { size } from '../../../utils/data/size.js';
import { stringToHex } from '../../../utils/encoding/toHex.js';
import { hashMessage } from '../../../utils/signature/hashMessage.js';
import { hashTypedData } from '../../../utils/signature/hashTypedData.js';
import { parseSignature } from '../../../utils/signature/parseSignature.js';
import { entryPoint06Abi } from '../../constants/abis.js';
import { entryPoint06Address } from '../../constants/address.js';
import { getUserOperationHash } from '../../utils/userOperation/getUserOperationHash.js';
import { toSmartAccount } from '../toSmartAccount.js';
const factoryAddress = {
'1.1': '0xba5ed110efdba3d005bfc882d75358acbbb85842',
'1': '0x0ba5ed0c6aa8c49038f819e587e2633c4a9f428a',
};
/**
* @description Create a Coinbase Smart Account.
*
* @param parameters - {@link ToCoinbaseSmartAccountParameters}
* @returns Coinbase Smart Account. {@link ToCoinbaseSmartAccountReturnType}
*
* @example
* import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
* import { privateKeyToAccount } from 'viem/accounts'
* import { client } from './client.js'
*
* const account = toCoinbaseSmartAccount({
* client,
* owners: [privateKeyToAccount('0x...')],
* version: '1.1',
* })
*/
export async function toCoinbaseSmartAccount(parameters) {
const { client, ownerIndex = 0, owners, nonce = 0n, version = '1', } = parameters;
let address = parameters.address;
const entryPoint = {
abi: entryPoint06Abi,
address: entryPoint06Address,
version: '0.6',
};
const factory = {
abi: factoryAbi,
address: factoryAddress[version],
};
const owners_bytes = owners.map((owner) => {
if (typeof owner === 'string')
return pad(owner);
if (owner.type === 'webAuthn')
return owner.publicKey;
if (owner.type === 'local')
return pad(owner.address);
throw new BaseError('invalid owner type');
});
const owner = (() => {
const owner = owners[ownerIndex] ?? owners[0];
if (typeof owner === 'string')
return { address: owner, type: 'address' };
return owner;
})();
return toSmartAccount({
client,
entryPoint,
extend: { abi, factory },
async decodeCalls(data) {
const result = decodeFunctionData({
abi,
data,
});
if (result.functionName === 'execute')
return [
{ to: result.args[0], value: result.args[1], data: result.args[2] },
];
if (result.functionName === 'executeBatch')
return result.args[0].map((arg) => ({
to: arg.target,
value: arg.value,
data: arg.data,
}));
throw new BaseError(`unable to decode calls for "${result.functionName}"`);
},
async encodeCalls(calls) {
if (calls.length === 1)
return encodeFunctionData({
abi,
functionName: 'execute',
args: [calls[0].to, calls[0].value ?? 0n, calls[0].data ?? '0x'],
});
return encodeFunctionData({
abi,
functionName: 'executeBatch',
args: [
calls.map((call) => ({
data: call.data ?? '0x',
target: call.to,
value: call.value ?? 0n,
})),
],
});
},
async getAddress() {
address ??= await readContract(client, {
...factory,
functionName: 'getAddress',
args: [owners_bytes, nonce],
});
return address;
},
async getFactoryArgs() {
const factoryData = encodeFunctionData({
abi: factory.abi,
functionName: 'createAccount',
args: [owners_bytes, nonce],
});
return { factory: factory.address, factoryData };
},
async getStubSignature() {
if (owner.type === 'webAuthn')
return '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000';
return wrapSignature({
ownerIndex,
signature: '0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c',
});
},
async sign(parameters) {
const address = await this.getAddress();
const typedData = toReplaySafeTypedData({
address,
chainId: client.chain.id,
hash: parameters.hash,
});
if (owner.type === 'address')
throw new Error('owner cannot sign');
const signature = await signTypedData({ owner, typedData });
return wrapSignature({
ownerIndex,
signature,
});
},
async signMessage(parameters) {
const { message } = parameters;
const address = await this.getAddress();
const typedData = toReplaySafeTypedData({
address,
chainId: client.chain.id,
hash: hashMessage(message),
});
if (owner.type === 'address')
throw new Error('owner cannot sign');
const signature = await signTypedData({ owner, typedData });
return wrapSignature({
ownerIndex,
signature,
});
},
async signTypedData(parameters) {
const { domain, types, primaryType, message } = parameters;
const address = await this.getAddress();
const typedData = toReplaySafeTypedData({
address,
chainId: client.chain.id,
hash: hashTypedData({
domain,
message,
primaryType,
types,
}),
});
if (owner.type === 'address')
throw new Error('owner cannot sign');
const signature = await signTypedData({ owner, typedData });
return wrapSignature({
ownerIndex,
signature,
});
},
async signUserOperation(parameters) {
const { chainId = client.chain.id, ...userOperation } = parameters;
const address = await this.getAddress();
const hash = getUserOperationHash({
chainId,
entryPointAddress: entryPoint.address,
entryPointVersion: entryPoint.version,
userOperation: {
...userOperation,
sender: address,
},
});
if (owner.type === 'address')
throw new Error('owner cannot sign');
const signature = await sign({ hash, owner });
return wrapSignature({
ownerIndex,
signature,
});
},
userOperation: {
async estimateGas(userOperation) {
if (owner.type !== 'webAuthn')
return;
// Accounts with WebAuthn owner require a minimum verification gas limit of 800,000.
return {
verificationGasLimit: BigInt(Math.max(Number(userOperation.verificationGasLimit ?? 0n), 800_000)),
};
},
},
});
}
/////////////////////////////////////////////////////////////////////////////////////////////
// Utilities
/////////////////////////////////////////////////////////////////////////////////////////////
/** @internal */
export async function signTypedData({ typedData, owner, }) {
if (owner.type === 'local' && owner.signTypedData)
return owner.signTypedData(typedData);
const hash = hashTypedData(typedData);
return sign({ hash, owner });
}
/** @internal */
export async function sign({ hash, owner, }) {
// WebAuthn Account (Passkey)
if (owner.type === 'webAuthn') {
const { signature, webauthn } = await owner.sign({
hash,
});
return toWebAuthnSignature({ signature, webauthn });
}
if (owner.sign)
return owner.sign({ hash });
throw new BaseError('`owner` does not support raw sign.');
}
/** @internal */
export function toReplaySafeTypedData({ address, chainId, hash, }) {
return {
domain: {
chainId,
name: 'Coinbase Smart Wallet',
verifyingContract: address,
version: '1',
},
types: {
CoinbaseSmartWalletMessage: [
{
name: 'hash',
type: 'bytes32',
},
],
},
primaryType: 'CoinbaseSmartWalletMessage',
message: {
hash,
},
};
}
/** @internal */
export function toWebAuthnSignature({ webauthn, signature, }) {
const { r, s } = Signature.fromHex(signature);
return encodeAbiParameters([
{
components: [
{
name: 'authenticatorData',
type: 'bytes',
},
{ name: 'clientDataJSON', type: 'bytes' },
{ name: 'challengeIndex', type: 'uint256' },
{ name: 'typeIndex', type: 'uint256' },
{
name: 'r',
type: 'uint256',
},
{
name: 's',
type: 'uint256',
},
],
type: 'tuple',
},
], [
{
authenticatorData: webauthn.authenticatorData,
clientDataJSON: stringToHex(webauthn.clientDataJSON),
challengeIndex: BigInt(webauthn.challengeIndex ?? 0n),
typeIndex: BigInt(webauthn.typeIndex ?? 0n),
r,
s,
},
]);
}
/** @internal */
export function wrapSignature(parameters) {
const { ownerIndex = 0 } = parameters;
const signatureData = (() => {
if (size(parameters.signature) !== 65)
return parameters.signature;
const signature = parseSignature(parameters.signature);
return encodePacked(['bytes32', 'bytes32', 'uint8'], [signature.r, signature.s, signature.yParity === 0 ? 27 : 28]);
})();
return encodeAbiParameters([
{
components: [
{
name: 'ownerIndex',
type: 'uint8',
},
{
name: 'signatureData',
type: 'bytes',
},
],
type: 'tuple',
},
], [
{
ownerIndex,
signatureData,
},
]);
}
/////////////////////////////////////////////////////////////////////////////////////////////
// Constants
/////////////////////////////////////////////////////////////////////////////////////////////
const abi = [
{ inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
{
inputs: [{ name: 'owner', type: 'bytes' }],
name: 'AlreadyOwner',
type: 'error',
},
{ inputs: [], name: 'Initialized', type: 'error' },
{
inputs: [{ name: 'owner', type: 'bytes' }],
name: 'InvalidEthereumAddressOwner',
type: 'error',
},
{
inputs: [{ name: 'key', type: 'uint256' }],
name: 'InvalidNonceKey',
type: 'error',
},
{
inputs: [{ name: 'owner', type: 'bytes' }],
name: 'InvalidOwnerBytesLength',
type: 'error',
},
{ inputs: [], name: 'LastOwner', type: 'error' },
{
inputs: [{ name: 'index', type: 'uint256' }],
name: 'NoOwnerAtIndex',
type: 'error',
},
{
inputs: [{ name: 'ownersRemaining', type: 'uint256' }],
name: 'NotLastOwner',
type: 'error',
},
{
inputs: [{ name: 'selector', type: 'bytes4' }],
name: 'SelectorNotAllowed',
type: 'error',
},
{ inputs: [], name: 'Unauthorized', type: 'error' },
{ inputs: [], name: 'UnauthorizedCallContext', type: 'error' },
{ inputs: [], name: 'UpgradeFailed', type: 'error' },
{
inputs: [
{ name: 'index', type: 'uint256' },
{ name: 'expectedOwner', type: 'bytes' },
{ name: 'actualOwner', type: 'bytes' },
],
name: 'WrongOwnerAtIndex',
type: 'error',
},
{
anonymous: false,
inputs: [
{
indexed: true,
name: 'index',
type: 'uint256',
},
{ indexed: false, name: 'owner', type: 'bytes' },
],
name: 'AddOwner',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
name: 'index',
type: 'uint256',
},
{ indexed: false, name: 'owner', type: 'bytes' },
],
name: 'RemoveOwner',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
name: 'implementation',
type: 'address',
},
],
name: 'Upgraded',
type: 'event',
},
{ stateMutability: 'payable', type: 'fallback' },
{
inputs: [],
name: 'REPLAYABLE_NONCE_KEY',
outputs: [{ name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [{ name: 'owner', type: 'address' }],
name: 'addOwnerAddress',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ name: 'x', type: 'bytes32' },
{ name: 'y', type: 'bytes32' },
],
name: 'addOwnerPublicKey',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [{ name: 'functionSelector', type: 'bytes4' }],
name: 'canSkipChainIdValidation',
outputs: [{ name: '', type: 'bool' }],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [],
name: 'domainSeparator',
outputs: [{ name: '', type: 'bytes32' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'eip712Domain',
outputs: [
{ name: 'fields', type: 'bytes1' },
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
{ name: 'salt', type: 'bytes32' },
{ name: 'extensions', type: 'uint256[]' },
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'entryPoint',
outputs: [{ name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ name: 'target', type: 'address' },
{ name: 'value', type: 'uint256' },
{ name: 'data', type: 'bytes' },
],
name: 'execute',
outputs: [],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
components: [
{ name: 'target', type: 'address' },
{ name: 'value', type: 'uint256' },
{ name: 'data', type: 'bytes' },
],
name: 'calls',
type: 'tuple[]',
},
],
name: 'executeBatch',
outputs: [],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [{ name: 'calls', type: 'bytes[]' }],
name: 'executeWithoutChainIdValidation',
outputs: [],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
components: [
{ name: 'sender', type: 'address' },
{ name: 'nonce', type: 'uint256' },
{ name: 'initCode', type: 'bytes' },
{ name: 'callData', type: 'bytes' },
{ name: 'callGasLimit', type: 'uint256' },
{
name: 'verificationGasLimit',
type: 'uint256',
},
{
name: 'preVerificationGas',
type: 'uint256',
},
{ name: 'maxFeePerGas', type: 'uint256' },
{
name: 'maxPriorityFeePerGas',
type: 'uint256',
},
{ name: 'paymasterAndData', type: 'bytes' },
{ name: 'signature', type: 'bytes' },
],
name: 'userOp',
type: 'tuple',
},
],
name: 'getUserOpHashWithoutChainId',
outputs: [{ name: '', type: 'bytes32' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'implementation',
outputs: [{ name: '$', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [{ name: 'owners', type: 'bytes[]' }],
name: 'initialize',
outputs: [],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [{ name: 'account', type: 'address' }],
name: 'isOwnerAddress',
outputs: [{ name: '', type: 'bool' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [{ name: 'account', type: 'bytes' }],
name: 'isOwnerBytes',
outputs: [{ name: '', type: 'bool' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ name: 'x', type: 'bytes32' },
{ name: 'y', type: 'bytes32' },
],
name: 'isOwnerPublicKey',
outputs: [{ name: '', type: 'bool' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ name: 'hash', type: 'bytes32' },
{ name: 'signature', type: 'bytes' },
],
name: 'isValidSignature',
outputs: [{ name: 'result', type: 'bytes4' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'nextOwnerIndex',
outputs: [{ name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [{ name: 'index', type: 'uint256' }],
name: 'ownerAtIndex',
outputs: [{ name: '', type: 'bytes' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'ownerCount',
outputs: [{ name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'proxiableUUID',
outputs: [{ name: '', type: 'bytes32' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ name: 'index', type: 'uint256' },
{ name: 'owner', type: 'bytes' },
],
name: 'removeLastOwner',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ name: 'index', type: 'uint256' },
{ name: 'owner', type: 'bytes' },
],
name: 'removeOwnerAtIndex',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'removedOwnersCount',
outputs: [{ name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [{ name: 'hash', type: 'bytes32' }],
name: 'replaySafeHash',
outputs: [{ name: '', type: 'bytes32' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ name: 'newImplementation', type: 'address' },
{ name: 'data', type: 'bytes' },
],
name: 'upgradeToAndCall',
outputs: [],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{
components: [
{ name: 'sender', type: 'address' },
{ name: 'nonce', type: 'uint256' },
{ name: 'initCode', type: 'bytes' },
{ name: 'callData', type: 'bytes' },
{ name: 'callGasLimit', type: 'uint256' },
{
name: 'verificationGasLimit',
type: 'uint256',
},
{
name: 'preVerificationGas',
type: 'uint256',
},
{ name: 'maxFeePerGas', type: 'uint256' },
{
name: 'maxPriorityFeePerGas',
type: 'uint256',
},
{ name: 'paymasterAndData', type: 'bytes' },
{ name: 'signature', type: 'bytes' },
],
name: 'userOp',
type: 'tuple',
},
{ name: 'userOpHash', type: 'bytes32' },
{ name: 'missingAccountFunds', type: 'uint256' },
],
name: 'validateUserOp',
outputs: [{ name: 'validationData', type: 'uint256' }],
stateMutability: 'nonpayable',
type: 'function',
},
{ stateMutability: 'payable', type: 'receive' },
];
const factoryAbi = [
{
inputs: [{ name: 'implementation_', type: 'address' }],
stateMutability: 'payable',
type: 'constructor',
},
{ inputs: [], name: 'OwnerRequired', type: 'error' },
{
inputs: [
{ name: 'owners', type: 'bytes[]' },
{ name: 'nonce', type: 'uint256' },
],
name: 'createAccount',
outputs: [
{
name: 'account',
type: 'address',
},
],
stateMutability: 'payable',
type: 'function',
},
{
inputs: [
{ name: 'owners', type: 'bytes[]' },
{ name: 'nonce', type: 'uint256' },
],
name: 'getAddress',
outputs: [{ name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'implementation',
outputs: [{ name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'initCodeHash',
outputs: [{ name: '', type: 'bytes32' }],
stateMutability: 'view',
type: 'function',
},
];
//# sourceMappingURL=toCoinbaseSmartAccount.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,288 @@
import { BaseError } from '../../../errors/base.js';
import { decodeFunctionData } from '../../../utils/abi/decodeFunctionData.js';
import { encodeFunctionData } from '../../../utils/abi/encodeFunctionData.js';
import { entryPoint08Abi, entryPoint09Abi } from '../../constants/abis.js';
import { entryPoint08Address, entryPoint09Address, } from '../../constants/address.js';
import { getUserOperationTypedData } from '../../utils/userOperation/getUserOperationTypedData.js';
import { toSmartAccount } from '../toSmartAccount.js';
/**
* @description Create a Simple7702 Smart Account based off [eth-infinitism's `Simple7702Account.sol`](https://github.com/eth-infinitism/account-abstraction/blob/develop/contracts/accounts/Simple7702Account.sol).
*
* @param parameters - {@link ToSimple7702SmartAccountParameters}
* @returns Simple7702 Smart Account. {@link ToSimple7702SmartAccountReturnType}
*
* @example
* import { toSimple7702SmartAccount } from 'viem/account-abstraction'
* import { client } from './client.js'
*
* const implementation = toSimple7702SmartAccount({
* client,
* owner: '0x...',
* })
*/
export async function toSimple7702SmartAccount(parameters) {
const { client, getNonce, owner } = parameters;
const entryPoint = (() => {
if (parameters.entryPoint === '0.9')
return {
abi: entryPoint09Abi,
address: entryPoint09Address,
version: '0.9',
};
if (typeof parameters.entryPoint === 'object')
return parameters.entryPoint;
return {
abi: entryPoint08Abi,
address: entryPoint08Address,
version: '0.8',
};
})();
const implementation = (() => {
if (parameters.implementation)
return parameters.implementation;
if (parameters.entryPoint === '0.9')
return '0xa46cc63eBF4Bd77888AA327837d20b23A63a56B5';
return '0xe6Cae83BdE06E4c305530e199D7217f42808555B';
})();
return toSmartAccount({
authorization: { account: owner, address: implementation },
abi,
client,
extend: { abi, owner }, // not removing abi from here as this will be a breaking change
entryPoint,
getNonce,
async decodeCalls(data) {
const result = decodeFunctionData({
abi,
data,
});
if (result.functionName === 'execute')
return [
{ to: result.args[0], value: result.args[1], data: result.args[2] },
];
if (result.functionName === 'executeBatch')
return result.args[0].map((arg) => ({
to: arg.target,
value: arg.value,
data: arg.data,
}));
throw new BaseError(`unable to decode calls for "${result.functionName}"`);
},
async encodeCalls(calls) {
if (calls.length === 1)
return encodeFunctionData({
abi,
functionName: 'execute',
args: [calls[0].to, calls[0].value ?? 0n, calls[0].data ?? '0x'],
});
return encodeFunctionData({
abi,
functionName: 'executeBatch',
args: [
calls.map((call) => ({
data: call.data ?? '0x',
target: call.to,
value: call.value ?? 0n,
})),
],
});
},
async getAddress() {
return owner.address;
},
async getFactoryArgs() {
return { factory: '0x7702', factoryData: '0x' };
},
async getStubSignature() {
return '0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c';
},
async signMessage(parameters) {
const { message } = parameters;
return await owner.signMessage({ message });
},
async signTypedData(parameters) {
const { domain, types, primaryType, message } = parameters;
return await owner.signTypedData({
domain,
message,
primaryType,
types,
});
},
async signUserOperation(parameters) {
const { chainId = client.chain.id, ...userOperation } = parameters;
const address = await this.getAddress();
const typedData = getUserOperationTypedData({
chainId,
entryPointAddress: entryPoint.address,
userOperation: {
...userOperation,
sender: address,
},
});
return await owner.signTypedData(typedData);
},
});
}
/////////////////////////////////////////////////////////////////////////////////////////////
// Constants
const abi = [
{ inputs: [], name: 'ECDSAInvalidSignature', type: 'error' },
{
inputs: [{ internalType: 'uint256', name: 'length', type: 'uint256' }],
name: 'ECDSAInvalidSignatureLength',
type: 'error',
},
{
inputs: [{ internalType: 'bytes32', name: 's', type: 'bytes32' }],
name: 'ECDSAInvalidSignatureS',
type: 'error',
},
{
inputs: [
{ internalType: 'uint256', name: 'index', type: 'uint256' },
{ internalType: 'bytes', name: 'error', type: 'bytes' },
],
name: 'ExecuteError',
type: 'error',
},
{ stateMutability: 'payable', type: 'fallback' },
{
inputs: [],
name: 'entryPoint',
outputs: [
{ internalType: 'contract IEntryPoint', name: '', type: 'address' },
],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [
{ internalType: 'address', name: 'target', type: 'address' },
{ internalType: 'uint256', name: 'value', type: 'uint256' },
{ internalType: 'bytes', name: 'data', type: 'bytes' },
],
name: 'execute',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
components: [
{ internalType: 'address', name: 'target', type: 'address' },
{ internalType: 'uint256', name: 'value', type: 'uint256' },
{ internalType: 'bytes', name: 'data', type: 'bytes' },
],
internalType: 'struct BaseAccount.Call[]',
name: 'calls',
type: 'tuple[]',
},
],
name: 'executeBatch',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'getNonce',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ internalType: 'bytes32', name: 'hash', type: 'bytes32' },
{ internalType: 'bytes', name: 'signature', type: 'bytes' },
],
name: 'isValidSignature',
outputs: [{ internalType: 'bytes4', name: 'magicValue', type: 'bytes4' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ internalType: 'address', name: '', type: 'address' },
{ internalType: 'address', name: '', type: 'address' },
{ internalType: 'uint256[]', name: '', type: 'uint256[]' },
{ internalType: 'uint256[]', name: '', type: 'uint256[]' },
{ internalType: 'bytes', name: '', type: 'bytes' },
],
name: 'onERC1155BatchReceived',
outputs: [{ internalType: 'bytes4', name: '', type: 'bytes4' }],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'address', name: '', type: 'address' },
{ internalType: 'address', name: '', type: 'address' },
{ internalType: 'uint256', name: '', type: 'uint256' },
{ internalType: 'uint256', name: '', type: 'uint256' },
{ internalType: 'bytes', name: '', type: 'bytes' },
],
name: 'onERC1155Received',
outputs: [{ internalType: 'bytes4', name: '', type: 'bytes4' }],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{ internalType: 'address', name: '', type: 'address' },
{ internalType: 'address', name: '', type: 'address' },
{ internalType: 'uint256', name: '', type: 'uint256' },
{ internalType: 'bytes', name: '', type: 'bytes' },
],
name: 'onERC721Received',
outputs: [{ internalType: 'bytes4', name: '', type: 'bytes4' }],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [{ internalType: 'bytes4', name: 'id', type: 'bytes4' }],
name: 'supportsInterface',
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [
{
components: [
{ internalType: 'address', name: 'sender', type: 'address' },
{ internalType: 'uint256', name: 'nonce', type: 'uint256' },
{ internalType: 'bytes', name: 'initCode', type: 'bytes' },
{ internalType: 'bytes', name: 'callData', type: 'bytes' },
{
internalType: 'bytes32',
name: 'accountGasLimits',
type: 'bytes32',
},
{
internalType: 'uint256',
name: 'preVerificationGas',
type: 'uint256',
},
{ internalType: 'bytes32', name: 'gasFees', type: 'bytes32' },
{ internalType: 'bytes', name: 'paymasterAndData', type: 'bytes' },
{ internalType: 'bytes', name: 'signature', type: 'bytes' },
],
internalType: 'struct PackedUserOperation',
name: 'userOp',
type: 'tuple',
},
{ internalType: 'bytes32', name: 'userOpHash', type: 'bytes32' },
{ internalType: 'uint256', name: 'missingAccountFunds', type: 'uint256' },
],
name: 'validateUserOp',
outputs: [
{ internalType: 'uint256', name: 'validationData', type: 'uint256' },
],
stateMutability: 'nonpayable',
type: 'function',
},
{ stateMutability: 'payable', type: 'receive' },
];
//# sourceMappingURL=toSimple7702SmartAccount.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,717 @@
import { parseAccount } from '../../../accounts/utils/parseAccount.js';
import { readContract } from '../../../actions/public/readContract.js';
import { signMessage as signMessage_ } from '../../../actions/wallet/signMessage.js';
import { BaseError } from '../../../errors/base.js';
import { signMessage } from '../../../experimental/erc7739/actions/signMessage.js';
import { signTypedData } from '../../../experimental/erc7739/actions/signTypedData.js';
import { decodeFunctionData } from '../../../utils/abi/decodeFunctionData.js';
import { encodeFunctionData } from '../../../utils/abi/encodeFunctionData.js';
import { pad } from '../../../utils/data/pad.js';
import { getAction } from '../../../utils/getAction.js';
import { entryPoint07Abi } from '../../constants/abis.js';
import { entryPoint07Address } from '../../constants/address.js';
import { getUserOperationHash } from '../../utils/userOperation/getUserOperationHash.js';
import { toSmartAccount } from '../toSmartAccount.js';
/**
* @description Create a Solady Smart Account based off [Solady's `ERC4337.sol`](https://github.com/Vectorized/solady/blob/main/src/accounts/ERC4337.sol).
*
* @param parameters - {@link ToSoladySmartAccountParameters}
* @returns Solady Smart Account. {@link ToSoladySmartAccountReturnType}
*
* @example
* import { toSoladySmartAccount } from 'viem/account-abstraction'
* import { client } from './client.js'
*
* const implementation = toSoladySmartAccount({
* client,
* owner: '0x...',
* })
*/
export async function toSoladySmartAccount(parameters) {
const { address, client, entryPoint: entryPoint_ = {
abi: entryPoint07Abi,
address: entryPoint07Address,
version: '0.7',
}, factoryAddress = '0x5d82735936c6Cd5DE57cC3c1A799f6B2E6F933Df', getNonce, salt = '0x0', } = parameters;
const entryPoint = {
abi: entryPoint_.abi,
address: entryPoint_.address,
version: entryPoint_.version,
};
const factory = {
abi: factoryAbi,
address: factoryAddress,
};
const owner = parseAccount(parameters.owner);
return toSmartAccount({
client,
entryPoint,
getNonce,
extend: { abi, factory },
async decodeCalls(data) {
const result = decodeFunctionData({
abi,
data,
});
if (result.functionName === 'execute')
return [
{ to: result.args[0], value: result.args[1], data: result.args[2] },
];
if (result.functionName === 'executeBatch')
return result.args[0].map((arg) => ({
to: arg.target,
value: arg.value,
data: arg.data,
}));
throw new BaseError(`unable to decode calls for "${result.functionName}"`);
},
async encodeCalls(calls) {
if (calls.length === 1)
return encodeFunctionData({
abi,
functionName: 'execute',
args: [calls[0].to, calls[0].value ?? 0n, calls[0].data ?? '0x'],
});
return encodeFunctionData({
abi,
functionName: 'executeBatch',
args: [
calls.map((call) => ({
data: call.data ?? '0x',
target: call.to,
value: call.value ?? 0n,
})),
],
});
},
async getAddress() {
if (address)
return address;
return await readContract(client, {
...factory,
functionName: 'getAddress',
args: [pad(salt)],
});
},
async getFactoryArgs() {
const factoryData = encodeFunctionData({
abi: factory.abi,
functionName: 'createAccount',
args: [owner.address, pad(salt)],
});
return { factory: factory.address, factoryData };
},
async getStubSignature() {
return '0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c';
},
async signMessage(parameters) {
const { message } = parameters;
const [address, { factory, factoryData }] = await Promise.all([
this.getAddress(),
this.getFactoryArgs(),
]);
return await signMessage(client, {
account: owner,
factory,
factoryData,
message,
verifier: address,
});
},
async signTypedData(parameters) {
const { domain, types, primaryType, message } = parameters;
const [address, { factory, factoryData }] = await Promise.all([
this.getAddress(),
this.getFactoryArgs(),
]);
return await signTypedData(client, {
account: owner,
domain,
message,
factory,
factoryData,
primaryType,
types,
verifier: address,
});
},
async signUserOperation(parameters) {
const { chainId = client.chain.id, ...userOperation } = parameters;
const address = await this.getAddress();
const userOpHash = getUserOperationHash({
chainId,
entryPointAddress: entryPoint.address,
entryPointVersion: entryPoint.version,
userOperation: {
...userOperation,
sender: address,
},
});
const signature = await getAction(client, signMessage_, 'signMessage')({
account: owner,
message: {
raw: userOpHash,
},
});
return signature;
},
});
}
/////////////////////////////////////////////////////////////////////////////////////////////
// Constants
const abi = [
{
type: 'fallback',
stateMutability: 'payable',
},
{
type: 'receive',
stateMutability: 'payable',
},
{
type: 'function',
name: 'addDeposit',
inputs: [],
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'cancelOwnershipHandover',
inputs: [],
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'completeOwnershipHandover',
inputs: [
{
name: 'pendingOwner',
type: 'address',
},
],
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'delegateExecute',
inputs: [
{
name: 'delegate',
type: 'address',
},
{
name: 'data',
type: 'bytes',
},
],
outputs: [
{
name: 'result',
type: 'bytes',
},
],
stateMutability: 'payable',
},
{
type: 'function',
name: 'eip712Domain',
inputs: [],
outputs: [
{
name: 'name',
type: 'string',
},
{
name: 'version',
type: 'string',
},
{
name: 'chainId',
type: 'uint256',
},
{
name: 'verifyingContract',
type: 'address',
},
{
name: 'salt',
type: 'bytes32',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'entryPoint',
inputs: [],
outputs: [
{
name: '',
type: 'address',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'execute',
inputs: [
{
name: 'target',
type: 'address',
},
{
name: 'value',
type: 'uint256',
},
{
name: 'data',
type: 'bytes',
},
],
outputs: [
{
name: 'result',
type: 'bytes',
},
],
stateMutability: 'payable',
},
{
type: 'function',
name: 'executeBatch',
inputs: [
{
name: 'calls',
type: 'tuple[]',
components: [
{
name: 'target',
type: 'address',
},
{
name: 'value',
type: 'uint256',
},
{
name: 'data',
type: 'bytes',
},
],
},
],
outputs: [
{
name: 'results',
type: 'bytes[]',
},
],
stateMutability: 'payable',
},
{
type: 'function',
name: 'getDeposit',
inputs: [],
outputs: [
{
name: 'result',
type: 'uint256',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'initialize',
inputs: [
{
name: 'newOwner',
type: 'address',
},
],
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'isValidSignature',
inputs: [
{
name: 'hash',
type: 'bytes32',
},
{
name: 'signature',
type: 'bytes',
},
],
outputs: [
{
name: 'result',
type: 'bytes4',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'owner',
inputs: [],
outputs: [
{
name: 'result',
type: 'address',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'ownershipHandoverExpiresAt',
inputs: [
{
name: 'pendingOwner',
type: 'address',
},
],
outputs: [
{
name: 'result',
type: 'uint256',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'proxiableUUID',
inputs: [],
outputs: [
{
name: '',
type: 'bytes32',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'renounceOwnership',
inputs: [],
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'requestOwnershipHandover',
inputs: [],
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'storageLoad',
inputs: [
{
name: 'storageSlot',
type: 'bytes32',
},
],
outputs: [
{
name: 'result',
type: 'bytes32',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'storageStore',
inputs: [
{
name: 'storageSlot',
type: 'bytes32',
},
{
name: 'storageValue',
type: 'bytes32',
},
],
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'transferOwnership',
inputs: [
{
name: 'newOwner',
type: 'address',
},
],
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'upgradeToAndCall',
inputs: [
{
name: 'newImplementation',
type: 'address',
},
{
name: 'data',
type: 'bytes',
},
],
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'validateUserOp',
inputs: [
{
name: 'userOp',
type: 'tuple',
components: [
{
name: 'sender',
type: 'address',
},
{
name: 'nonce',
type: 'uint256',
},
{
name: 'initCode',
type: 'bytes',
},
{
name: 'callData',
type: 'bytes',
},
{
name: 'accountGasLimits',
type: 'bytes32',
},
{
name: 'preVerificationGas',
type: 'uint256',
},
{
name: 'gasFees',
type: 'bytes32',
},
{
name: 'paymasterAndData',
type: 'bytes',
},
{
name: 'signature',
type: 'bytes',
},
],
},
{
name: 'userOpHash',
type: 'bytes32',
},
{
name: 'missingAccountFunds',
type: 'uint256',
},
],
outputs: [
{
name: 'validationData',
type: 'uint256',
},
],
stateMutability: 'payable',
},
{
type: 'function',
name: 'withdrawDepositTo',
inputs: [
{
name: 'to',
type: 'address',
},
{
name: 'amount',
type: 'uint256',
},
],
outputs: [],
stateMutability: 'payable',
},
{
type: 'event',
name: 'OwnershipHandoverCanceled',
inputs: [
{
name: 'pendingOwner',
type: 'address',
indexed: true,
},
],
anonymous: false,
},
{
type: 'event',
name: 'OwnershipHandoverRequested',
inputs: [
{
name: 'pendingOwner',
type: 'address',
indexed: true,
},
],
anonymous: false,
},
{
type: 'event',
name: 'OwnershipTransferred',
inputs: [
{
name: 'oldOwner',
type: 'address',
indexed: true,
},
{
name: 'newOwner',
type: 'address',
indexed: true,
},
],
anonymous: false,
},
{
type: 'event',
name: 'Upgraded',
inputs: [
{
name: 'implementation',
type: 'address',
indexed: true,
},
],
anonymous: false,
},
{
type: 'error',
name: 'AlreadyInitialized',
inputs: [],
},
{
type: 'error',
name: 'FnSelectorNotRecognized',
inputs: [],
},
{
type: 'error',
name: 'NewOwnerIsZeroAddress',
inputs: [],
},
{
type: 'error',
name: 'NoHandoverRequest',
inputs: [],
},
{
type: 'error',
name: 'Unauthorized',
inputs: [],
},
{
type: 'error',
name: 'UnauthorizedCallContext',
inputs: [],
},
{
type: 'error',
name: 'UpgradeFailed',
inputs: [],
},
];
const factoryAbi = [
{
type: 'constructor',
inputs: [
{
name: 'erc4337',
type: 'address',
},
],
stateMutability: 'nonpayable',
},
{
type: 'function',
name: 'createAccount',
inputs: [
{
name: 'owner',
type: 'address',
},
{
name: 'salt',
type: 'bytes32',
},
],
outputs: [
{
name: '',
type: 'address',
},
],
stateMutability: 'payable',
},
{
type: 'function',
name: 'getAddress',
inputs: [
{
name: 'salt',
type: 'bytes32',
},
],
outputs: [
{
name: '',
type: 'address',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'implementation',
inputs: [],
outputs: [
{
name: '',
type: 'address',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'initCodeHash',
inputs: [],
outputs: [
{
name: '',
type: 'bytes32',
},
],
stateMutability: 'view',
},
];
//# sourceMappingURL=toSoladySmartAccount.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,107 @@
import { parseAbi } from 'abitype';
import { getCode } from '../../actions/public/getCode.js';
import { readContract } from '../../actions/public/readContract.js';
import { getAction } from '../../utils/getAction.js';
import { createNonceManager } from '../../utils/nonceManager.js';
import { serializeErc6492Signature } from '../../utils/signature/serializeErc6492Signature.js';
/**
* @description Creates a Smart Account with a provided account implementation.
*
* @param parameters - {@link ToSmartAccountParameters}
* @returns A Smart Account. {@link ToSmartAccountReturnType}
*/
export async function toSmartAccount(implementation) {
const { extend, nonceKeyManager = createNonceManager({
source: {
get() {
return Date.now();
},
set() { },
},
}), ...rest } = implementation;
let deployed = false;
const address = await implementation.getAddress();
return {
...extend,
...rest,
address,
async getFactoryArgs() {
if ('isDeployed' in this && (await this.isDeployed()))
return { factory: undefined, factoryData: undefined };
return implementation.getFactoryArgs();
},
async getNonce(parameters) {
const key = parameters?.key ??
BigInt(await nonceKeyManager.consume({
address,
chainId: implementation.client.chain.id,
client: implementation.client,
}));
if (implementation.getNonce)
return await implementation.getNonce({ ...parameters, key });
const nonce = await readContract(implementation.client, {
abi: parseAbi([
'function getNonce(address, uint192) pure returns (uint256)',
]),
address: implementation.entryPoint.address,
functionName: 'getNonce',
args: [address, key],
});
return nonce;
},
async isDeployed() {
if (deployed)
return true;
const code = await getAction(implementation.client, getCode, 'getCode')({
address,
});
deployed = Boolean(code);
return deployed;
},
...(implementation.sign
? {
async sign(parameters) {
const [{ factory, factoryData }, signature] = await Promise.all([
this.getFactoryArgs(),
implementation.sign(parameters),
]);
if (factory && factoryData)
return serializeErc6492Signature({
address: factory,
data: factoryData,
signature,
});
return signature;
},
}
: {}),
async signMessage(parameters) {
const [{ factory, factoryData }, signature] = await Promise.all([
this.getFactoryArgs(),
implementation.signMessage(parameters),
]);
if (factory && factoryData && factory !== '0x7702')
return serializeErc6492Signature({
address: factory,
data: factoryData,
signature,
});
return signature;
},
async signTypedData(parameters) {
const [{ factory, factoryData }, signature] = await Promise.all([
this.getFactoryArgs(),
implementation.signTypedData(parameters),
]);
if (factory && factoryData && factory !== '0x7702')
return serializeErc6492Signature({
address: factory,
data: factoryData,
signature,
});
return signature;
},
type: 'smart',
};
}
//# sourceMappingURL=toSmartAccount.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"toSmartAccount.js","sourceRoot":"","sources":["../../../account-abstraction/accounts/toSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,MAAM,SAAS,CAAA;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oDAAoD,CAAA;AAe9F;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAGlC,cAA8B;IAE9B,MAAM,EACJ,MAAM,EACN,eAAe,GAAG,kBAAkB,CAAC;QACnC,MAAM,EAAE;YACN,GAAG;gBACD,OAAO,IAAI,CAAC,GAAG,EAAE,CAAA;YACnB,CAAC;YACD,GAAG,KAAI,CAAC;SACT;KACF,CAAC,EACF,GAAG,IAAI,EACR,GAAG,cAAc,CAAA;IAElB,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,UAAU,EAAE,CAAA;IAEjD,OAAO;QACL,GAAG,MAAM;QACT,GAAG,IAAI;QACP,OAAO;QACP,KAAK,CAAC,cAAc;YAClB,IAAI,YAAY,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;gBACnD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,CAAA;YACvD,OAAO,cAAc,CAAC,cAAc,EAAE,CAAA;QACxC,CAAC;QACD,KAAK,CAAC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,CAAA;oBACF,IAAI,OAAO,IAAI,WAAW;wBACxB,OAAO,yBAAyB,CAAC;4BAC/B,OAAO,EAAE,OAAO;4BAChB,IAAI,EAAE,WAAW;4BACjB,SAAS;yBACV,CAAC,CAAA;oBACJ,OAAO,SAAS,CAAA;gBAClB,CAAC;aACF;YACH,CAAC,CAAC,EAAE,CAAC;QACP,KAAK,CAAC,WAAW,CAAC,UAAU;YAC1B,MAAM,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,SAAS,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBAC9D,IAAI,CAAC,cAAc,EAAE;gBACrB,cAAc,CAAC,WAAW,CAAC,UAAU,CAAC;aACvC,CAAC,CAAA;YACF,IAAI,OAAO,IAAI,WAAW,IAAI,OAAO,KAAK,QAAQ;gBAChD,OAAO,yBAAyB,CAAC;oBAC/B,OAAO,EAAE,OAAO;oBAChB,IAAI,EAAE,WAAW;oBACjB,SAAS;iBACV,CAAC,CAAA;YACJ,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,UAAU;YAC5B,MAAM,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,SAAS,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBAC9D,IAAI,CAAC,cAAc,EAAE;gBACrB,cAAc,CAAC,aAAa,CAAC,UAAU,CAAC;aACzC,CAAC,CAAA;YACF,IAAI,OAAO,IAAI,WAAW,IAAI,OAAO,KAAK,QAAQ;gBAChD,OAAO,yBAAyB,CAAC;oBAC/B,OAAO,EAAE,OAAO;oBAChB,IAAI,EAAE,WAAW;oBACjB,SAAS;iBACV,CAAC,CAAA;YACJ,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,IAAI,EAAE,OAAO;KAC8B,CAAA;AAC/C,CAAC"}

View File

@@ -0,0 +1,38 @@
import * as Signature from 'ox/Signature';
import * as WebAuthnP256 from 'ox/WebAuthnP256';
import { hashMessage } from '../../utils/signature/hashMessage.js';
import { hashTypedData } from '../../utils/signature/hashTypedData.js';
/**
* @description Creates an Account from a WebAuthn Credential.
*
* @returns A WebAuthn Account.
*/
export function toWebAuthnAccount(parameters) {
const { getFn, rpId } = parameters;
const { id, publicKey } = parameters.credential;
return {
id,
publicKey,
async sign({ hash }) {
const { metadata, raw, signature } = await WebAuthnP256.sign({
credentialId: id,
getFn,
challenge: hash,
rpId,
});
return {
signature: Signature.toHex(signature),
raw,
webauthn: metadata,
};
},
async signMessage({ message }) {
return this.sign({ hash: hashMessage(message) });
},
async signTypedData(parameters) {
return this.sign({ hash: hashTypedData(parameters) });
},
type: 'webAuthn',
};
}
//# sourceMappingURL=toWebAuthnAccount.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"toWebAuthnAccount.js","sourceRoot":"","sources":["../../../account-abstraction/accounts/toWebAuthnAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAA;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AA6BtE;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAAuC;IAEvC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,UAAU,CAAA;IAClC,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,UAAU,CAAA;IAC/C,OAAO;QACL,EAAE;QACF,SAAS;QACT,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE;YACjB,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC;gBAC3D,YAAY,EAAE,EAAE;gBAChB,KAAK;gBACL,SAAS,EAAE,IAAI;gBACf,IAAI;aACL,CAAC,CAAA;YACF,OAAO;gBACL,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC;gBACrC,GAAG;gBACH,QAAQ,EAAE,QAAQ;aACnB,CAAA;QACH,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE;YAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAClD,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,UAAU;YAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;QACvD,CAAC;QACD,IAAI,EAAE,UAAU;KACjB,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../account-abstraction/accounts/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,73 @@
import { parseAccount, } from '../../../accounts/utils/parseAccount.js';
import { AccountNotFoundError } from '../../../errors/account.js';
import { getAction } from '../../../utils/getAction.js';
import { serializeStateOverride } from '../../../utils/stateOverride.js';
import { getUserOperationError } from '../../utils/errors/getUserOperationError.js';
import { formatUserOperationGas, } from '../../utils/formatters/userOperationGas.js';
import { formatUserOperationRequest, } from '../../utils/formatters/userOperationRequest.js';
import { prepareUserOperation, } from './prepareUserOperation.js';
/**
* Returns an estimate of gas values necessary to execute the User Operation.
*
* - Docs: https://viem.sh/actions/bundler/estimateUserOperationGas
*
* @param client - Client to use
* @param parameters - {@link EstimateUserOperationGasParameters}
* @returns The gas estimate (in wei). {@link EstimateUserOperationGasReturnType}
*
* @example
* import { createBundlerClient, http, parseEther } from 'viem'
* import { toSmartAccount } from 'viem/accounts'
* import { mainnet } from 'viem/chains'
* import { estimateUserOperationGas } from 'viem/actions'
*
* const account = await toSmartAccount({ ... })
*
* const bundlerClient = createBundlerClient({
* chain: mainnet,
* transport: http(),
* })
*
* const values = await estimateUserOperationGas(bundlerClient, {
* account,
* calls: [{ to: '0x...', value: parseEther('1') }],
* })
*/
export async function estimateUserOperationGas(client, parameters) {
const { account: account_ = client.account, entryPointAddress, stateOverride, } = parameters;
if (!account_ && !parameters.sender)
throw new AccountNotFoundError();
const account = account_ ? parseAccount(account_) : undefined;
const rpcStateOverride = serializeStateOverride(stateOverride);
const request = account
? await getAction(client, prepareUserOperation, 'prepareUserOperation')({
...parameters,
parameters: [
'authorization',
'factory',
'nonce',
'paymaster',
'signature',
],
})
: parameters;
try {
const params = [
formatUserOperationRequest(request),
(entryPointAddress ?? account?.entryPoint?.address),
];
const result = await client.request({
method: 'eth_estimateUserOperationGas',
params: rpcStateOverride ? [...params, rpcStateOverride] : [...params],
});
return formatUserOperationGas(result);
}
catch (error) {
const calls = parameters.calls;
throw getUserOperationError(error, {
...request,
...(calls ? { calls } : {}),
});
}
}
//# sourceMappingURL=estimateUserOperationGas.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../../account-abstraction/actions/bundler/estimateUserOperationGas.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,GACb,MAAM,yCAAyC,CAAA;AAGhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAcjE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AAgBxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AACnF,OAAO,EAEL,sBAAsB,GACvB,MAAM,4CAA4C,CAAA;AACnD,OAAO,EAEL,0BAA0B,GAC3B,MAAM,gDAAgD,CAAA;AACvD,OAAO,EAGL,oBAAoB,GACrB,MAAM,2BAA2B,CAAA;AAoElC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAK5C,MAAqD,E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CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5B,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}

View File

@@ -0,0 +1,25 @@
/**
* Returns the EntryPoints that the bundler supports.
*
* - Docs: https://viem.sh/actions/bundler/getSupportedEntryPoints
*
* @param client - Client to use
* @param parameters - {@link GetSupportedEntryPointsParameters}
* @returns Supported Entry Points. {@link GetSupportedEntryPointsReturnType}
*
* @example
* import { createBundlerClient, http, parseEther } from 'viem'
* import { mainnet } from 'viem/chains'
* import { getSupportedEntryPoints } from 'viem/actions'
*
* const bundlerClient = createBundlerClient({
* chain: mainnet,
* transport: http(),
* })
*
* const addresses = await getSupportedEntryPoints(bundlerClient)
*/
export function getSupportedEntryPoints(client) {
return client.request({ method: 'eth_supportedEntryPoints' });
}
//# sourceMappingURL=getSupportedEntryPoints.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getSupportedEntryPoints.js","sourceRoot":"","sources":["../../../../account-abstraction/actions/bundler/getSupportedEntryPoints.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAyB;IAC/D,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,0BAA0B,EAAE,CAAC,CAAA;AAC/D,CAAC"}

View File

@@ -0,0 +1,42 @@
import { UserOperationNotFoundError, } from '../../errors/userOperation.js';
import { formatUserOperation } from '../../utils/formatters/userOperation.js';
/**
* Retrieves information about a User Operation given a hash.
*
* - Docs: https://viem.sh/account-abstraction/actions/bundler/getUserOperation
*
* @param client - Client to use
* @param parameters - {@link GetUserOperationParameters}
* @returns The receipt. {@link GetUserOperationReturnType}
*
* @example
* import { createBundlerClient, http } from 'viem'
* import { mainnet } from 'viem/chains'
* import { getUserOperation } from 'viem/actions
*
* const client = createBundlerClient({
* chain: mainnet,
* transport: http(),
* })
*
* const receipt = await getUserOperation(client, {
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
* })
*/
export async function getUserOperation(client, { hash }) {
const result = await client.request({
method: 'eth_getUserOperationByHash',
params: [hash],
}, { dedupe: true });
if (!result)
throw new UserOperationNotFoundError({ hash });
const { blockHash, blockNumber, entryPoint, transactionHash, userOperation } = result;
return {
blockHash,
blockNumber: BigInt(blockNumber),
entryPoint,
transactionHash,
userOperation: formatUserOperation(userOperation),
};
}
//# sourceMappingURL=getUserOperation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getUserOperation.js","sourceRoot":"","sources":["../../../../account-abstraction/actions/bundler/getUserOperation.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,0BAA0B,GAE3B,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAyB7E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAyB,EACzB,EAAE,IAAI,EAA8B;IAEpC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CACjC;QACE,MAAM,EAAE,4BAA4B;QACpC,MAAM,EAAE,CAAC,IAAI,CAAC;KACf,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB,CAAA;IAED,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,0BAA0B,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IAE3D,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,GAC1E,MAAM,CAAA;IAER,OAAO;QACL,SAAS;QACT,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;QAChC,UAAU;QACV,eAAe;QACf,aAAa,EAAE,mBAAmB,CAAC,aAAa,CAAC;KAClD,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,35 @@
import { UserOperationReceiptNotFoundError, } from '../../errors/userOperation.js';
import { formatUserOperationReceipt } from '../../utils/formatters/userOperationReceipt.js';
/**
* Returns the User Operation Receipt given a User Operation hash.
*
* - Docs: https://viem.sh/docs/actions/bundler/getUserOperationReceipt
*
* @param client - Client to use
* @param parameters - {@link GetUserOperationReceiptParameters}
* @returns The receipt. {@link GetUserOperationReceiptReturnType}
*
* @example
* import { createBundlerClient, http } from 'viem'
* import { mainnet } from 'viem/chains'
* import { getUserOperationReceipt } from 'viem/actions
*
* const client = createBundlerClient({
* chain: mainnet,
* transport: http(),
* })
*
* const receipt = await getUserOperationReceipt(client, {
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
* })
*/
export async function getUserOperationReceipt(client, { hash }) {
const receipt = await client.request({
method: 'eth_getUserOperationReceipt',
params: [hash],
}, { dedupe: true });
if (!receipt)
throw new UserOperationReceiptNotFoundError({ hash });
return formatUserOperationReceipt(receipt);
}
//# sourceMappingURL=getUserOperationReceipt.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getUserOperationReceipt.js","sourceRoot":"","sources":["../../../../account-abstraction/actions/bundler/getUserOperationReceipt.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,iCAAiC,GAElC,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAA;AAc3F;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,MAAyB,EACzB,EAAE,IAAI,EAAqC;IAE3C,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAClC;QACE,MAAM,EAAE,6BAA6B;QACrC,MAAM,EAAE,CAAC,IAAI,CAAC;KACf,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB,CAAA;IAED,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,iCAAiC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IAEnE,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAA;AAC5C,CAAC"}

View File

@@ -0,0 +1,357 @@
import { parseAccount, } from '../../../accounts/utils/parseAccount.js';
import { prepareAuthorization } from '../../../actions/index.js';
import { estimateFeesPerGas, } from '../../../actions/public/estimateFeesPerGas.js';
import { getChainId as getChainId_ } from '../../../actions/public/getChainId.js';
import { AccountNotFoundError } from '../../../errors/account.js';
import { encodeFunctionData, } from '../../../utils/abi/encodeFunctionData.js';
import { concat } from '../../../utils/data/concat.js';
import { getAction } from '../../../utils/getAction.js';
import { getPaymasterData as getPaymasterData_, } from '../paymaster/getPaymasterData.js';
import { getPaymasterStubData as getPaymasterStubData_, } from '../paymaster/getPaymasterStubData.js';
import { estimateUserOperationGas, } from './estimateUserOperationGas.js';
const defaultParameters = [
'factory',
'fees',
'gas',
'paymaster',
'nonce',
'signature',
'authorization',
];
/**
* Prepares a User Operation and fills in missing properties.
*
* - Docs: https://viem.sh/actions/bundler/prepareUserOperation
*
* @param args - {@link PrepareUserOperationParameters}
* @returns The User Operation. {@link PrepareUserOperationReturnType}
*
* @example
* import { createBundlerClient, http } from 'viem'
* import { toSmartAccount } from 'viem/accounts'
* import { mainnet } from 'viem/chains'
* import { prepareUserOperation } from 'viem/actions'
*
* const account = await toSmartAccount({ ... })
*
* const client = createBundlerClient({
* chain: mainnet,
* transport: http(),
* })
*
* const request = await prepareUserOperation(client, {
* account,
* calls: [{ to: '0x...', value: parseEther('1') }],
* })
*/
export async function prepareUserOperation(client, parameters_) {
const parameters = parameters_;
const { account: account_ = client.account, dataSuffix = typeof client.dataSuffix === 'string'
? client.dataSuffix
: client.dataSuffix?.value, parameters: properties = defaultParameters, stateOverride, } = parameters;
////////////////////////////////////////////////////////////////////////////////
// Assert that an Account is defined.
////////////////////////////////////////////////////////////////////////////////
if (!account_)
throw new AccountNotFoundError();
const account = parseAccount(account_);
////////////////////////////////////////////////////////////////////////////////
// Declare typed Bundler Client.
////////////////////////////////////////////////////////////////////////////////
const bundlerClient = client;
////////////////////////////////////////////////////////////////////////////////
// Declare Paymaster properties.
////////////////////////////////////////////////////////////////////////////////
const paymaster = parameters.paymaster ?? bundlerClient?.paymaster;
const paymasterAddress = typeof paymaster === 'string' ? paymaster : undefined;
const { getPaymasterStubData, getPaymasterData } = (() => {
// If `paymaster: true`, we will assume the Bundler Client supports Paymaster Actions.
if (paymaster === true)
return {
getPaymasterStubData: (parameters) => getAction(bundlerClient, getPaymasterStubData_, 'getPaymasterStubData')(parameters),
getPaymasterData: (parameters) => getAction(bundlerClient, getPaymasterData_, 'getPaymasterData')(parameters),
};
// If Actions are passed to `paymaster` (via Paymaster Client or directly), we will use them.
if (typeof paymaster === 'object') {
const { getPaymasterStubData, getPaymasterData } = paymaster;
return {
getPaymasterStubData: (getPaymasterData && getPaymasterStubData
? getPaymasterStubData
: getPaymasterData),
getPaymasterData: getPaymasterData && getPaymasterStubData
? getPaymasterData
: undefined,
};
}
// No Paymaster functions.
return {
getPaymasterStubData: undefined,
getPaymasterData: undefined,
};
})();
const paymasterContext = parameters.paymasterContext
? parameters.paymasterContext
: bundlerClient?.paymasterContext;
////////////////////////////////////////////////////////////////////////////////
// Set up the User Operation request.
////////////////////////////////////////////////////////////////////////////////
let request = {
...parameters,
paymaster: paymasterAddress,
sender: account.address,
};
////////////////////////////////////////////////////////////////////////////////
// Concurrently prepare properties required to fill the User Operation.
////////////////////////////////////////////////////////////////////////////////
const [callData, factory, fees, nonce, authorization] = await Promise.all([
(async () => {
if (parameters.calls)
return account.encodeCalls(parameters.calls.map((call_) => {
const call = call_;
if (call.abi)
return {
data: encodeFunctionData(call),
to: call.to,
value: call.value,
};
return call;
}));
return parameters.callData;
})(),
(async () => {
if (!properties.includes('factory'))
return undefined;
if (parameters.initCode)
return { initCode: parameters.initCode };
if (parameters.factory && parameters.factoryData) {
return {
factory: parameters.factory,
factoryData: parameters.factoryData,
};
}
const { factory, factoryData } = await account.getFactoryArgs();
if (account.entryPoint.version === '0.6')
return {
initCode: factory && factoryData ? concat([factory, factoryData]) : undefined,
};
return {
factory,
factoryData,
};
})(),
(async () => {
if (!properties.includes('fees'))
return undefined;
// If we have sufficient properties for fees, return them.
if (typeof parameters.maxFeePerGas === 'bigint' &&
typeof parameters.maxPriorityFeePerGas === 'bigint')
return request;
// If the Bundler Client has a `estimateFeesPerGas` hook, run it.
if (bundlerClient?.userOperation?.estimateFeesPerGas) {
const fees = await bundlerClient.userOperation.estimateFeesPerGas({
account,
bundlerClient,
userOperation: request,
});
return {
...request,
...fees,
};
}
// Otherwise, we will need to estimate the fees to fill the fee properties.
try {
const client_ = bundlerClient.client ?? client;
const fees = await getAction(client_, estimateFeesPerGas, 'estimateFeesPerGas')({
chain: client_.chain,
type: 'eip1559',
});
return {
maxFeePerGas: typeof parameters.maxFeePerGas === 'bigint'
? parameters.maxFeePerGas
: BigInt(
// Bundlers unfortunately have strict rules on fee prechecks we will need to set a generous buffer.
2n * fees.maxFeePerGas),
maxPriorityFeePerGas: typeof parameters.maxPriorityFeePerGas === 'bigint'
? parameters.maxPriorityFeePerGas
: BigInt(
// Bundlers unfortunately have strict rules on fee prechecks we will need to set a generous buffer.
2n * fees.maxPriorityFeePerGas),
};
}
catch {
return undefined;
}
})(),
(async () => {
if (!properties.includes('nonce'))
return undefined;
if (typeof parameters.nonce === 'bigint')
return parameters.nonce;
return account.getNonce();
})(),
(async () => {
if (!properties.includes('authorization'))
return undefined;
if (typeof parameters.authorization === 'object')
return parameters.authorization;
if (account.authorization && !(await account.isDeployed())) {
const authorization = await prepareAuthorization(account.client, account.authorization);
return {
...authorization,
r: '0xfffffffffffffffffffffffffffffff000000000000000000000000000000000',
s: '0x7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
yParity: 1,
};
}
return undefined;
})(),
]);
////////////////////////////////////////////////////////////////////////////////
// Fill User Operation with the prepared properties from above.
////////////////////////////////////////////////////////////////////////////////
if (typeof callData !== 'undefined')
request.callData = dataSuffix ? concat([callData, dataSuffix]) : callData;
if (typeof factory !== 'undefined')
request = { ...request, ...factory };
if (typeof fees !== 'undefined')
request = { ...request, ...fees };
if (typeof nonce !== 'undefined')
request.nonce = nonce;
if (typeof authorization !== 'undefined')
request.authorization = authorization;
////////////////////////////////////////////////////////////////////////////////
// Fill User Operation with the `signature` property.
////////////////////////////////////////////////////////////////////////////////
if (properties.includes('signature')) {
if (typeof parameters.signature !== 'undefined')
request.signature = parameters.signature;
else
request.signature = await account.getStubSignature(request);
}
////////////////////////////////////////////////////////////////////////////////
// `initCode` is required to be filled with EntryPoint 0.6.
////////////////////////////////////////////////////////////////////////////////
// If no `initCode` is provided, we use an empty bytes string.
if (account.entryPoint.version === '0.6' && !request.initCode)
request.initCode = '0x';
////////////////////////////////////////////////////////////////////////////////
// Fill User Operation with paymaster-related properties for **gas estimation**.
////////////////////////////////////////////////////////////////////////////////
let chainId;
async function getChainId() {
if (chainId)
return chainId;
if (client.chain)
return client.chain.id;
const chainId_ = await getAction(client, getChainId_, 'getChainId')({});
chainId = chainId_;
return chainId;
}
// If the User Operation is intended to be sponsored, we will need to fill the paymaster-related
// User Operation properties required to estimate the User Operation gas.
let isPaymasterPopulated = false;
if (properties.includes('paymaster') &&
getPaymasterStubData &&
!paymasterAddress &&
!parameters.paymasterAndData) {
const { isFinal = false, sponsor: _, ...paymasterArgs } = await getPaymasterStubData({
chainId: await getChainId(),
entryPointAddress: account.entryPoint.address,
context: paymasterContext,
...request,
});
isPaymasterPopulated = isFinal;
request = {
...request,
...paymasterArgs,
};
}
////////////////////////////////////////////////////////////////////////////////
// `paymasterAndData` is required to be filled with EntryPoint 0.6.
////////////////////////////////////////////////////////////////////////////////
// If no `paymasterAndData` is provided, we use an empty bytes string.
if (account.entryPoint.version === '0.6' && !request.paymasterAndData)
request.paymasterAndData = '0x';
////////////////////////////////////////////////////////////////////////////////
// Fill User Operation with gas-related properties.
////////////////////////////////////////////////////////////////////////////////
if (properties.includes('gas')) {
// If the Account has opinionated gas estimation logic, run the `estimateGas` hook and
// fill the request with the prepared gas properties.
if (account.userOperation?.estimateGas) {
const gas = await account.userOperation.estimateGas(request);
request = {
...request,
...gas,
};
}
// If not all the gas properties are already populated, we will need to estimate the gas
// to fill the gas properties.
if (typeof request.callGasLimit === 'undefined' ||
typeof request.preVerificationGas === 'undefined' ||
typeof request.verificationGasLimit === 'undefined' ||
(request.paymaster &&
typeof request.paymasterPostOpGasLimit === 'undefined') ||
(request.paymaster &&
typeof request.paymasterVerificationGasLimit === 'undefined')) {
const gas = await getAction(bundlerClient, estimateUserOperationGas, 'estimateUserOperationGas')({
account,
// Some Bundlers fail if nullish gas values are provided for gas estimation :')
// so we will need to set a default zeroish value.
callGasLimit: 0n,
preVerificationGas: 0n,
verificationGasLimit: 0n,
stateOverride,
...(request.paymaster
? {
paymasterPostOpGasLimit: 0n,
paymasterVerificationGasLimit: 0n,
}
: {}),
...request,
});
request = {
...request,
callGasLimit: request.callGasLimit ?? gas.callGasLimit,
preVerificationGas: request.preVerificationGas ?? gas.preVerificationGas,
verificationGasLimit: request.verificationGasLimit ?? gas.verificationGasLimit,
paymasterPostOpGasLimit: request.paymasterPostOpGasLimit ?? gas.paymasterPostOpGasLimit,
paymasterVerificationGasLimit: request.paymasterVerificationGasLimit ??
gas.paymasterVerificationGasLimit,
};
}
}
////////////////////////////////////////////////////////////////////////////////
// Fill User Operation with paymaster-related properties for **sending** the User Operation.
////////////////////////////////////////////////////////////////////////////////
// If the User Operation is intended to be sponsored, we will need to fill the paymaster-related
// User Operation properties required to send the User Operation.
if (properties.includes('paymaster') &&
getPaymasterData &&
!paymasterAddress &&
!parameters.paymasterAndData &&
!isPaymasterPopulated) {
// Retrieve paymaster-related User Operation properties to be used for **sending** the User Operation.
const paymaster = await getPaymasterData({
chainId: await getChainId(),
entryPointAddress: account.entryPoint.address,
context: paymasterContext,
...request,
});
request = {
...request,
...paymaster,
};
}
////////////////////////////////////////////////////////////////////////////////
// Remove redundant properties that do not conform to the User Operation schema.
////////////////////////////////////////////////////////////////////////////////
delete request.calls;
delete request.parameters;
delete request.paymasterContext;
if (typeof request.paymaster !== 'string')
delete request.paymaster;
////////////////////////////////////////////////////////////////////////////////
return request;
}
//# sourceMappingURL=prepareUserOperation.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,66 @@
import { parseAccount } from '../../../accounts/utils/parseAccount.js';
import { AccountNotFoundError } from '../../../errors/account.js';
import { getAction } from '../../../utils/getAction.js';
import { getUserOperationError } from '../../utils/errors/getUserOperationError.js';
import { formatUserOperationRequest, } from '../../utils/formatters/userOperationRequest.js';
import { prepareUserOperation, } from './prepareUserOperation.js';
/**
* Broadcasts a User Operation to the Bundler.
*
* - Docs: https://viem.sh/actions/bundler/sendUserOperation
*
* @param client - Client to use
* @param parameters - {@link SendUserOperationParameters}
* @returns The User Operation hash. {@link SendUserOperationReturnType}
*
* @example
* import { createBundlerClient, http, parseEther } from 'viem'
* import { mainnet } from 'viem/chains'
* import { toSmartAccount } from 'viem/accounts'
* import { sendUserOperation } from 'viem/actions'
*
* const account = await toSmartAccount({ ... })
*
* const bundlerClient = createBundlerClient({
* chain: mainnet,
* transport: http(),
* })
*
* const values = await sendUserOperation(bundlerClient, {
* account,
* calls: [{ to: '0x...', value: parseEther('1') }],
* })
*/
export async function sendUserOperation(client, parameters) {
const { account: account_ = client.account, entryPointAddress } = parameters;
if (!account_ && !parameters.sender)
throw new AccountNotFoundError();
const account = account_ ? parseAccount(account_) : undefined;
const request = account
? await getAction(client, prepareUserOperation, 'prepareUserOperation')(parameters)
: parameters;
const signature = (parameters.signature ||
(await account?.signUserOperation?.(request)));
const rpcParameters = formatUserOperationRequest({
...request,
signature,
});
try {
return await client.request({
method: 'eth_sendUserOperation',
params: [
rpcParameters,
(entryPointAddress ?? account?.entryPoint?.address),
],
}, { retryCount: 0 });
}
catch (error) {
const calls = parameters.calls;
throw getUserOperationError(error, {
...request,
...(calls ? { calls } : {}),
signature,
});
}
}
//# sourceMappingURL=sendUserOperation.js.map

View File

@@ -0,0 +1 @@
{"version":3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O,CACzB;YACE,MAAM,EAAE,uBAAuB;YAC/B,MAAM,EAAE;gBACN,aAAa;gBACb,CAAC,iBAAiB,IAAI,OAAO,EAAE,UAAU,EAAE,OAAO,CAAE;aACrD;SACF,EACD,EAAE,UAAU,EAAE,CAAC,EAAE,CAClB,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,GAAI,UAAkB,CAAC,KAAK,CAAA;QACvC,MAAM,qBAAqB,CAAC,KAAkB,EAAE;YAC9C,GAAI,OAAyB;YAC7B,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3B,SAAS;SACV,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}

View File

@@ -0,0 +1,74 @@
import { getAction } from '../../../utils/getAction.js';
import { observe } from '../../../utils/observe.js';
import { poll } from '../../../utils/poll.js';
import { stringify } from '../../../utils/stringify.js';
import { WaitForUserOperationReceiptTimeoutError, } from '../../errors/userOperation.js';
import { getUserOperationReceipt, } from './getUserOperationReceipt.js';
/**
* Waits for the User Operation to be included on a [Block](https://viem.sh/docs/glossary/terms#block) (one confirmation), and then returns the User Operation receipt.
*
* - Docs: https://viem.sh/docs/actions/bundler/waitForUserOperationReceipt
*
* @param client - Client to use
* @param parameters - {@link WaitForUserOperationReceiptParameters}
* @returns The receipt. {@link WaitForUserOperationReceiptReturnType}
*
* @example
* import { createBundlerClient, http } from 'viem'
* import { mainnet } from 'viem/chains'
* import { waitForUserOperationReceipt } from 'viem/actions'
*
* const client = createBundlerClient({
* chain: mainnet,
* transport: http(),
* })
*
* const receipt = await waitForUserOperationReceipt(client, {
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
* })
*/
export function waitForUserOperationReceipt(client, parameters) {
const { hash, pollingInterval = client.pollingInterval, retryCount, timeout = 120_000, } = parameters;
let count = 0;
const observerId = stringify([
'waitForUserOperationReceipt',
client.uid,
hash,
]);
return new Promise((resolve, reject) => {
const unobserve = observe(observerId, { resolve, reject }, (emit) => {
const done = (fn) => {
unpoll();
fn();
unobserve();
};
const timeoutId = timeout
? setTimeout(() => done(() => emit.reject(new WaitForUserOperationReceiptTimeoutError({ hash }))), timeout)
: undefined;
const unpoll = poll(async () => {
if (retryCount && count >= retryCount) {
clearTimeout(timeoutId);
done(() => emit.reject(new WaitForUserOperationReceiptTimeoutError({ hash })));
}
try {
const receipt = await getAction(client, getUserOperationReceipt, 'getUserOperationReceipt')({ hash });
clearTimeout(timeoutId);
done(() => emit.resolve(receipt));
}
catch (err) {
const error = err;
if (error.name !== 'UserOperationReceiptNotFoundError') {
clearTimeout(timeoutId);
done(() => emit.reject(error));
}
}
count++;
}, {
emitOnBegin: true,
interval: pollingInterval,
});
return unpoll;
});
});
}
//# sourceMappingURL=waitForUserOperationReceipt.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"waitForUserOperationReceipt.js","sourceRoot":"","sources":["../../../../account-abstraction/actions/bundler/waitForUserOperationReceipt.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAyB,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAC1E,OAAO,EAAsB,IAAI,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EACL,uCAAuC,GAExC,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAEL,uBAAuB,GACxB,MAAM,8BAA8B,CAAA;AA4BrC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAAyB,EACzB,UAAiD;IAEjD,MAAM,EACJ,IAAI,EACJ,eAAe,GAAG,MAAM,CAAC,eAAe,EACxC,UAAU,EACV,OAAO,GAAG,OAAO,GAClB,GAAG,UAAU,CAAA;IAEd,IAAI,KAAK,GAAG,CAAC,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AC;oBACb,MAAM,KAAK,GAAG,GAAuC,CAAA;oBACrD,IAAI,KAAK,CAAC,IAAI,KAAK,mCAAmC,EAAE,CAAC;wBACvD,YAAY,CAAC,SAAS,CAAC,CAAA;wBACvB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;oBAChC,CAAC;gBACH,CAAC;gBAED,KAAK,EAAE,CAAA;YACT,CAAC,EACD;gBACE,WAAW,EAAE,IAAI;gBACjB,QAAQ,EAAE,eAAe;aAC1B,CACF,CAAA;YAED,OAAO,MAAM,CAAA;QACf,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}

View File

@@ -0,0 +1,56 @@
import { hexToBigInt } from '../../../utils/encoding/fromHex.js';
import { numberToHex } from '../../../utils/encoding/toHex.js';
import { formatUserOperationRequest, } from '../../utils/formatters/userOperationRequest.js';
/**
* Retrieves paymaster-related User Operation properties to be used for sending the User Operation.
*
* - Docs: https://viem.sh/account-abstraction/actions/paymaster/getPaymasterData
*
* @param client - Client to use
* @param parameters - {@link GetPaymasterDataParameters}
* @returns Paymaster-related User Operation properties. {@link GetPaymasterDataReturnType}
*
* @example
* import { http } from 'viem'
* import { createPaymasterClient, getPaymasterData } from 'viem/account-abstraction'
*
* const paymasterClient = createPaymasterClient({
* transport: http('https://...'),
* })
*
* const userOperation = { ... }
*
* const values = await getPaymasterData(paymasterClient, {
* chainId: 1,
* entryPointAddress: '0x...',
* ...userOperation,
* })
*/
export async function getPaymasterData(client, parameters) {
const { chainId, entryPointAddress, context, ...userOperation } = parameters;
const request = formatUserOperationRequest(userOperation);
const { paymasterPostOpGasLimit, paymasterVerificationGasLimit, ...rest } = await client.request({
method: 'pm_getPaymasterData',
params: [
{
...request,
callGasLimit: request.callGasLimit ?? '0x0',
verificationGasLimit: request.verificationGasLimit ?? '0x0',
preVerificationGas: request.preVerificationGas ?? '0x0',
},
entryPointAddress,
numberToHex(chainId),
context,
],
});
return {
...rest,
...(paymasterPostOpGasLimit && {
paymasterPostOpGasLimit: hexToBigInt(paymasterPostOpGasLimit),
}),
...(paymasterVerificationGasLimit && {
paymasterVerificationGasLimit: hexToBigInt(paymasterVerificationGasLimit),
}),
};
}
//# sourceMappingURL=getPaymasterData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getPaymasterData.js","sourceRoot":"","sources":["../../../../account-abstraction/actions/paymaster/getPaymasterData.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAE9D,OAAO,EAEL,0BAA0B,GAC3B,MAAM,gDAAgD,CAAA;AA6FvD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAyB,EACzB,UAAsC;IAEtC,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,GAAG,UAAU,CAAA;IAC5E,MAAM,OAAO,GAAG,0BAA0B,CAAC,aAAa,CAAC,CAAA;IACzD,MAAM,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,GAAG,IAAI,EAAE,GACvE,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN;gBACE,GAAG,OAAO;gBACV,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK;gBAC3C,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,IAAI,KAAK;gBAC3D,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,KAAK;aACxD;YACD,iBAAiB;YACjB,WAAW,CAAC,OAAO,CAAC;YACpB,OAAO;SACR;KACF,CAAC,CAAA;IACJ,OAAO;QACL,GAAG,IAAI;QACP,GAAG,CAAC,uBAAuB,IAAI;YAC7B,uBAAuB,EAAE,WAAW,CAAC,uBAAuB,CAAC;SAC9D,CAAC;QACF,GAAG,CAAC,6BAA6B,IAAI;YACnC,6BAA6B,EAAE,WAAW,CAAC,6BAA6B,CAAC;SAC1E,CAAC;KACsC,CAAA;AAC5C,CAAC"}

View File

@@ -0,0 +1,56 @@
import { hexToBigInt } from '../../../utils/encoding/fromHex.js';
import { numberToHex } from '../../../utils/encoding/toHex.js';
import { formatUserOperationRequest, } from '../../utils/formatters/userOperationRequest.js';
/**
* Retrieves paymaster-related User Operation properties to be used for gas estimation.
*
* - Docs: https://viem.sh/account-abstraction/actions/paymaster/getPaymasterStubData
*
* @param client - Client to use
* @param parameters - {@link GetPaymasterStubDataParameters}
* @returns Paymaster-related User Operation properties. {@link GetPaymasterStubDataReturnType}
*
* @example
* import { http } from 'viem'
* import { createPaymasterClient, getPaymasterStubData } from 'viem/account-abstraction'
*
* const paymasterClient = createPaymasterClient({
* transport: http('https://...'),
* })
*
* const userOperation = { ... }
*
* const values = await getPaymasterStubData(paymasterClient, {
* chainId: 1,
* entryPointAddress: '0x...',
* ...userOperation,
* })
*/
export async function getPaymasterStubData(client, parameters) {
const { chainId, entryPointAddress, context, ...userOperation } = parameters;
const request = formatUserOperationRequest(userOperation);
const { paymasterPostOpGasLimit, paymasterVerificationGasLimit, ...rest } = await client.request({
method: 'pm_getPaymasterStubData',
params: [
{
...request,
callGasLimit: request.callGasLimit ?? '0x0',
verificationGasLimit: request.verificationGasLimit ?? '0x0',
preVerificationGas: request.preVerificationGas ?? '0x0',
},
entryPointAddress,
numberToHex(chainId),
context,
],
});
return {
...rest,
...(paymasterPostOpGasLimit && {
paymasterPostOpGasLimit: hexToBigInt(paymasterPostOpGasLimit),
}),
...(paymasterVerificationGasLimit && {
paymasterVerificationGasLimit: hexToBigInt(paymasterVerificationGasLimit),
}),
};
}
//# sourceMappingURL=getPaymasterStubData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getPaymasterStubData.js","sourceRoot":"","sources":["../../../../account-abstraction/actions/paymaster/getPaymasterStubData.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAE9D,OAAO,EAEL,0BAA0B,GAC3B,MAAM,gDAAgD,CAAA;AAsEvD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAyB,EACzB,UAA0C;IAE1C,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,GAAG,UAAU,CAAA;IAC5E,MAAM,OAAO,GAAG,0BAA0B,CAAC,aAAa,CAAC,CAAA;IACzD,MAAM,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,GAAG,IAAI,EAAE,GACvE,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,MAAM,EAAE,yBAAyB;QACjC,MAAM,EAAE;YACN;gBACE,GAAG,OAAO;gBACV,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK;gBAC3C,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,IAAI,KAAK;gBAC3D,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,KAAK;aACxD;YACD,iBAAiB;YACjB,WAAW,CAAC,OAAO,CAAC;YACpB,OAAO;SACR;KACF,CAAC,CAAA;IACJ,OAAO;QACL,GAAG,IAAI;QACP,GAAG,CAAC,uBAAuB,IAAI;YAC7B,uBAAuB,EAAE,WAAW,CAAC,uBAAuB,CAAC;SAC9D,CAAC;QACF,GAAG,CAAC,6BAA6B,IAAI;YACnC,6BAA6B,EAAE,WAAW,CAAC,6BAA6B,CAAC;SAC1E,CAAC;KAC0C,CAAA;AAChD,CAAC"}

View File

@@ -0,0 +1,21 @@
import { createClient, } from '../../clients/createClient.js';
import { bundlerActions } from './decorators/bundler.js';
export function createBundlerClient(parameters) {
const { client: client_, dataSuffix, key = 'bundler', name = 'Bundler Client', paymaster, paymasterContext, transport, userOperation, } = parameters;
const client = Object.assign(createClient({
...parameters,
chain: parameters.chain ?? client_?.chain,
key,
name,
transport,
type: 'bundlerClient',
}), {
client: client_,
dataSuffix: dataSuffix ?? client_?.dataSuffix,
paymaster,
paymasterContext,
userOperation,
});
return client.extend(bundlerActions);
}
//# sourceMappingURL=createBundlerClient.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createBundlerClient.js","sourceRoot":"","sources":["../../../account-abstraction/clients/createBundlerClient.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,YAAY,GACb,MAAM,+BAA+B,CAAA;AAStC,OAAO,EAAuB,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAsH7E,MAAM,UAAU,mBAAmB,CACjC,UAA+B;IAE/B,MAAM,EACJ,MAAM,EAAE,OAAO,EACf,UAAU,EACV,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,gBAAgB,EACvB,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,aAAa,GACd,GAAG,UAAU,CAAA;IACd,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAC1B,YAAY,CAAC;QACX,GAAG,UAAU;QACb,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,OAAO,EAAE,KAAK;QACzC,GAAG;QACH,IAAI;QACJ,SAAS;QACT,IAAI,EAAE,eAAe;KACtB,CAAC,EACF;QACE,MAAM,EAAE,OAAO;QACf,UAAU,EAAE,UAAU,IAAI,OAAO,EAAE,UAAU;QAC7C,SAAS;QACT,gBAAgB;QAChB,aAAa;KACd,CACF,CAAA;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAQ,CAAA;AAC7C,CAAC"}

View File

@@ -0,0 +1,14 @@
import { createClient, } from '../../clients/createClient.js';
import { paymasterActions, } from './decorators/paymaster.js';
export function createPaymasterClient(parameters) {
const { key = 'bundler', name = 'Bundler Client', transport } = parameters;
const client = createClient({
...parameters,
key,
name,
transport,
type: 'PaymasterClient',
});
return client.extend(paymasterActions);
}
//# sourceMappingURL=createPaymasterClient.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createPaymasterClient.js","sourceRoot":"","sources":["../../../account-abstraction/clients/createPaymasterClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,GACb,MAAM,+BAA+B,CAAA;AAKtC,OAAO,EAEL,gBAAgB,GACjB,MAAM,2BAA2B,CAAA;AAoDlC,MAAM,UAAU,qBAAqB,CACnC,UAAiC;IAEjC,MAAM,EAAE,GAAG,GAAG,SAAS,EAAE,IAAI,GAAG,gBAAgB,EAAE,SAAS,EAAE,GAAG,UAAU,CAAA;IAC1E,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,SAAS;QACT,IAAI,EAAE,iBAAiB;KACxB,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;AACxC,CAAC"}

View File

@@ -0,0 +1,21 @@
import { getChainId, } from '../../../actions/public/getChainId.js';
import { estimateUserOperationGas, } from '../../actions/bundler/estimateUserOperationGas.js';
import { getSupportedEntryPoints, } from '../../actions/bundler/getSupportedEntryPoints.js';
import { getUserOperation, } from '../../actions/bundler/getUserOperation.js';
import { getUserOperationReceipt, } from '../../actions/bundler/getUserOperationReceipt.js';
import { prepareUserOperation, } from '../../actions/bundler/prepareUserOperation.js';
import { sendUserOperation, } from '../../actions/bundler/sendUserOperation.js';
import { waitForUserOperationReceipt, } from '../../actions/bundler/waitForUserOperationReceipt.js';
export function bundlerActions(client) {
return {
estimateUserOperationGas: (parameters) => estimateUserOperationGas(client, parameters),
getChainId: () => getChainId(client),
getSupportedEntryPoints: () => getSupportedEntryPoints(client),
getUserOperation: (parameters) => getUserOperation(client, parameters),
getUserOperationReceipt: (parameters) => getUserOperationReceipt(client, parameters),
prepareUserOperation: (parameters) => prepareUserOperation(client, parameters),
sendUserOperation: (parameters) => sendUserOperation(client, parameters),
waitForUserOperationReceipt: (parameters) => waitForUserOperationReceipt(client, parameters),
};
}
//# sourceMappingURL=bundler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../../../account-abstraction/clients/decorators/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,GACX,MAAM,uCAAuC,CAAA;AAK9C,OAAO,EAGL,wBAAwB,GACzB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EAEL,uBAAuB,GACxB,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAGL,gBAAgB,GACjB,MAAM,2CAA2C,CAAA;AAClD,OAAO,EAGL,uBAAuB,GACxB,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAIL,oBAAoB,GACrB,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAGL,iBAAiB,GAClB,MAAM,4CAA4C,CAAA;AACnD,OAAO,EAGL,2BAA2B,GAC5B,MAAM,sDAAsD,CAAA;AA0O7D,MAAM,UAAU,cAAc,CAI5B,MAAyC;IACzC,OAAO;QACL,wBAAwB,EAAE,CAAC,UAAU,EAAE,EAAE,CACvC,wBAAwB,CAAC,MAAM,EAAE,UAAU,CAAC;QAC9C,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QACpC,uBAAuB,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,MAAM,CAAC;QAC9D,gBAAgB,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC;QACtE,uBAAuB,EAAE,CAAC,UAAU,EAAE,EAAE,CACtC,uBAAuB,CAAC,MAAM,EAAE,UAAU,CAAC;QAC7C,oBAAoB,EAAE,CAAC,UAAU,EAAE,EAAE,CACnC,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC;QAC1C,iBAAiB,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC;QACxE,2BAA2B,EAAE,CAAC,UAAU,EAAE,EAAE,CAC1C,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC;KAClD,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,9 @@
import { getPaymasterData, } from '../../actions/paymaster/getPaymasterData.js';
import { getPaymasterStubData, } from '../../actions/paymaster/getPaymasterStubData.js';
export function paymasterActions(client) {
return {
getPaymasterData: (parameters) => getPaymasterData(client, parameters),
getPaymasterStubData: (parameters) => getPaymasterStubData(client, parameters),
};
}
//# sourceMappingURL=paymaster.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"paymaster.js","sourceRoot":"","sources":["../../../../account-abstraction/clients/decorators/paymaster.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,gBAAgB,GACjB,MAAM,6CAA6C,CAAA;AACpD,OAAO,EAGL,oBAAoB,GACrB,MAAM,iDAAiD,CAAA;AA6DxD,MAAM,UAAU,gBAAgB,CAC9B,MAAyB;IAEzB,OAAO;QACL,gBAAgB,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC;QACtE,oBAAoB,EAAE,CAAC,UAAU,EAAE,EAAE,CACnC,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC;KAC3C,CAAA;AACH,CAAC"}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
export const entryPoint06Address = '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789';
export const entryPoint07Address = '0x0000000071727De22E5E9d8BAf0edAc6f37da032';
export const entryPoint08Address = '0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108';
export const entryPoint09Address = '0x433709009B8330FDa32311DF1C2AFA402eD8D009';
//# sourceMappingURL=address.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../../account-abstraction/constants/address.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAC9B,4CAAqD,CAAA;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAC9B,4CAAqD,CAAA;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAC9B,4CAAqD,CAAA;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAC9B,4CAAqD,CAAA"}

View File

@@ -0,0 +1,601 @@
import { BaseError } from '../../errors/base.js';
export class AccountNotDeployedError extends BaseError {
constructor({ cause, }) {
super('Smart Account is not deployed.', {
cause,
metaMessages: [
'This could arise when:',
'- No `factory`/`factoryData` or `initCode` properties are provided for Smart Account deployment.',
'- An incorrect `sender` address is provided.',
],
name: 'AccountNotDeployedError',
});
}
}
Object.defineProperty(AccountNotDeployedError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa20/
});
export class ExecutionRevertedError extends BaseError {
constructor({ cause, data, message, } = {}) {
const reason = message
?.replace('execution reverted: ', '')
?.replace('execution reverted', '');
super(`Execution reverted ${reason ? `with reason: ${reason}` : 'for an unknown reason'}.`, {
cause,
name: 'ExecutionRevertedError',
});
Object.defineProperty(this, "data", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.data = data;
}
}
Object.defineProperty(ExecutionRevertedError, "code", {
enumerable: true,
configurable: true,
writable: true,
value: -32521
});
Object.defineProperty(ExecutionRevertedError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /execution reverted/
});
export class FailedToSendToBeneficiaryError extends BaseError {
constructor({ cause, }) {
super('Failed to send funds to beneficiary.', {
cause,
name: 'FailedToSendToBeneficiaryError',
});
}
}
Object.defineProperty(FailedToSendToBeneficiaryError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa91/
});
export class GasValuesOverflowError extends BaseError {
constructor({ cause, }) {
super('Gas value overflowed.', {
cause,
metaMessages: [
'This could arise when:',
'- one of the gas values exceeded 2**120 (uint120)',
].filter(Boolean),
name: 'GasValuesOverflowError',
});
}
}
Object.defineProperty(GasValuesOverflowError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa94/
});
export class HandleOpsOutOfGasError extends BaseError {
constructor({ cause, }) {
super('The `handleOps` function was called by the Bundler with a gas limit too low.', {
cause,
name: 'HandleOpsOutOfGasError',
});
}
}
Object.defineProperty(HandleOpsOutOfGasError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa95/
});
export class InitCodeFailedError extends BaseError {
constructor({ cause, factory, factoryData, initCode, }) {
super('Failed to simulate deployment for Smart Account.', {
cause,
metaMessages: [
'This could arise when:',
'- Invalid `factory`/`factoryData` or `initCode` properties are present',
'- Smart Account deployment execution ran out of gas (low `verificationGasLimit` value)',
'- Smart Account deployment execution reverted with an error\n',
factory && `factory: ${factory}`,
factoryData && `factoryData: ${factoryData}`,
initCode && `initCode: ${initCode}`,
].filter(Boolean),
name: 'InitCodeFailedError',
});
}
}
Object.defineProperty(InitCodeFailedError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa13/
});
export class InitCodeMustCreateSenderError extends BaseError {
constructor({ cause, factory, factoryData, initCode, }) {
super('Smart Account initialization implementation did not create an account.', {
cause,
metaMessages: [
'This could arise when:',
'- `factory`/`factoryData` or `initCode` properties are invalid',
'- Smart Account initialization implementation is incorrect\n',
factory && `factory: ${factory}`,
factoryData && `factoryData: ${factoryData}`,
initCode && `initCode: ${initCode}`,
].filter(Boolean),
name: 'InitCodeMustCreateSenderError',
});
}
}
Object.defineProperty(InitCodeMustCreateSenderError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa15/
});
export class InitCodeMustReturnSenderError extends BaseError {
constructor({ cause, factory, factoryData, initCode, sender, }) {
super('Smart Account initialization implementation does not return the expected sender.', {
cause,
metaMessages: [
'This could arise when:',
'Smart Account initialization implementation does not return a sender address\n',
factory && `factory: ${factory}`,
factoryData && `factoryData: ${factoryData}`,
initCode && `initCode: ${initCode}`,
sender && `sender: ${sender}`,
].filter(Boolean),
name: 'InitCodeMustReturnSenderError',
});
}
}
Object.defineProperty(InitCodeMustReturnSenderError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa14/
});
export class InsufficientPrefundError extends BaseError {
constructor({ cause, }) {
super('Smart Account does not have sufficient funds to execute the User Operation.', {
cause,
metaMessages: [
'This could arise when:',
'- the Smart Account does not have sufficient funds to cover the required prefund, or',
'- a Paymaster was not provided',
].filter(Boolean),
name: 'InsufficientPrefundError',
});
}
}
Object.defineProperty(InsufficientPrefundError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa21/
});
export class InternalCallOnlyError extends BaseError {
constructor({ cause, }) {
super('Bundler attempted to call an invalid function on the EntryPoint.', {
cause,
name: 'InternalCallOnlyError',
});
}
}
Object.defineProperty(InternalCallOnlyError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa92/
});
export class InvalidAggregatorError extends BaseError {
constructor({ cause, }) {
super('Bundler used an invalid aggregator for handling aggregated User Operations.', {
cause,
name: 'InvalidAggregatorError',
});
}
}
Object.defineProperty(InvalidAggregatorError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa96/
});
export class InvalidAccountNonceError extends BaseError {
constructor({ cause, nonce, }) {
super('Invalid Smart Account nonce used for User Operation.', {
cause,
metaMessages: [nonce && `nonce: ${nonce}`].filter(Boolean),
name: 'InvalidAccountNonceError',
});
}
}
Object.defineProperty(InvalidAccountNonceError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa25/
});
export class InvalidBeneficiaryError extends BaseError {
constructor({ cause, }) {
super('Bundler has not set a beneficiary address.', {
cause,
name: 'InvalidBeneficiaryError',
});
}
}
Object.defineProperty(InvalidBeneficiaryError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa90/
});
export class InvalidFieldsError extends BaseError {
constructor({ cause, }) {
super('Invalid fields set on User Operation.', {
cause,
name: 'InvalidFieldsError',
});
}
}
Object.defineProperty(InvalidFieldsError, "code", {
enumerable: true,
configurable: true,
writable: true,
value: -32602
});
export class InvalidPaymasterAndDataError extends BaseError {
constructor({ cause, paymasterAndData, }) {
super('Paymaster properties provided are invalid.', {
cause,
metaMessages: [
'This could arise when:',
'- the `paymasterAndData` property is of an incorrect length\n',
paymasterAndData && `paymasterAndData: ${paymasterAndData}`,
].filter(Boolean),
name: 'InvalidPaymasterAndDataError',
});
}
}
Object.defineProperty(InvalidPaymasterAndDataError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa93/
});
export class PaymasterDepositTooLowError extends BaseError {
constructor({ cause, }) {
super('Paymaster deposit for the User Operation is too low.', {
cause,
metaMessages: [
'This could arise when:',
'- the Paymaster has deposited less than the expected amount via the `deposit` function',
].filter(Boolean),
name: 'PaymasterDepositTooLowError',
});
}
}
Object.defineProperty(PaymasterDepositTooLowError, "code", {
enumerable: true,
configurable: true,
writable: true,
value: -32508
});
Object.defineProperty(PaymasterDepositTooLowError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa31/
});
export class PaymasterFunctionRevertedError extends BaseError {
constructor({ cause, }) {
super('The `validatePaymasterUserOp` function on the Paymaster reverted.', {
cause,
name: 'PaymasterFunctionRevertedError',
});
}
}
Object.defineProperty(PaymasterFunctionRevertedError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa33/
});
export class PaymasterNotDeployedError extends BaseError {
constructor({ cause, }) {
super('The Paymaster contract has not been deployed.', {
cause,
name: 'PaymasterNotDeployedError',
});
}
}
Object.defineProperty(PaymasterNotDeployedError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa30/
});
export class PaymasterRateLimitError extends BaseError {
constructor({ cause }) {
super('UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.', {
cause,
name: 'PaymasterRateLimitError',
});
}
}
Object.defineProperty(PaymasterRateLimitError, "code", {
enumerable: true,
configurable: true,
writable: true,
value: -32504
});
export class PaymasterStakeTooLowError extends BaseError {
constructor({ cause }) {
super('UserOperation rejected because paymaster (or signature aggregator) stake or unstake-delay is too low.', {
cause,
name: 'PaymasterStakeTooLowError',
});
}
}
Object.defineProperty(PaymasterStakeTooLowError, "code", {
enumerable: true,
configurable: true,
writable: true,
value: -32505
});
export class PaymasterPostOpFunctionRevertedError extends BaseError {
constructor({ cause, }) {
super('Paymaster `postOp` function reverted.', {
cause,
name: 'PaymasterPostOpFunctionRevertedError',
});
}
}
Object.defineProperty(PaymasterPostOpFunctionRevertedError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa50/
});
export class SenderAlreadyConstructedError extends BaseError {
constructor({ cause, factory, factoryData, initCode, }) {
super('Smart Account has already been deployed.', {
cause,
metaMessages: [
'Remove the following properties and try again:',
factory && '`factory`',
factoryData && '`factoryData`',
initCode && '`initCode`',
].filter(Boolean),
name: 'SenderAlreadyConstructedError',
});
}
}
Object.defineProperty(SenderAlreadyConstructedError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa10/
});
export class SignatureCheckFailedError extends BaseError {
constructor({ cause }) {
super('UserOperation rejected because account signature check failed (or paymaster signature, if the paymaster uses its data as signature).', {
cause,
name: 'SignatureCheckFailedError',
});
}
}
Object.defineProperty(SignatureCheckFailedError, "code", {
enumerable: true,
configurable: true,
writable: true,
value: -32507
});
export class SmartAccountFunctionRevertedError extends BaseError {
constructor({ cause, }) {
super('The `validateUserOp` function on the Smart Account reverted.', {
cause,
name: 'SmartAccountFunctionRevertedError',
});
}
}
Object.defineProperty(SmartAccountFunctionRevertedError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa23/
});
export class UnsupportedSignatureAggregatorError extends BaseError {
constructor({ cause }) {
super('UserOperation rejected because account specified unsupported signature aggregator.', {
cause,
name: 'UnsupportedSignatureAggregatorError',
});
}
}
Object.defineProperty(UnsupportedSignatureAggregatorError, "code", {
enumerable: true,
configurable: true,
writable: true,
value: -32506
});
export class UserOperationExpiredError extends BaseError {
constructor({ cause, }) {
super('User Operation expired.', {
cause,
metaMessages: [
'This could arise when:',
'- the `validAfter` or `validUntil` values returned from `validateUserOp` on the Smart Account are not satisfied',
].filter(Boolean),
name: 'UserOperationExpiredError',
});
}
}
Object.defineProperty(UserOperationExpiredError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa22/
});
export class UserOperationPaymasterExpiredError extends BaseError {
constructor({ cause, }) {
super('Paymaster for User Operation expired.', {
cause,
metaMessages: [
'This could arise when:',
'- the `validAfter` or `validUntil` values returned from `validatePaymasterUserOp` on the Paymaster are not satisfied',
].filter(Boolean),
name: 'UserOperationPaymasterExpiredError',
});
}
}
Object.defineProperty(UserOperationPaymasterExpiredError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa32/
});
export class UserOperationSignatureError extends BaseError {
constructor({ cause, }) {
super('Signature provided for the User Operation is invalid.', {
cause,
metaMessages: [
'This could arise when:',
'- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Smart Account',
].filter(Boolean),
name: 'UserOperationSignatureError',
});
}
}
Object.defineProperty(UserOperationSignatureError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa24/
});
export class UserOperationPaymasterSignatureError extends BaseError {
constructor({ cause, }) {
super('Signature provided for the User Operation is invalid.', {
cause,
metaMessages: [
'This could arise when:',
'- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Paymaster',
].filter(Boolean),
name: 'UserOperationPaymasterSignatureError',
});
}
}
Object.defineProperty(UserOperationPaymasterSignatureError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa34/
});
export class UserOperationRejectedByEntryPointError extends BaseError {
constructor({ cause }) {
super("User Operation rejected by EntryPoint's `simulateValidation` during account creation or validation.", {
cause,
name: 'UserOperationRejectedByEntryPointError',
});
}
}
Object.defineProperty(UserOperationRejectedByEntryPointError, "code", {
enumerable: true,
configurable: true,
writable: true,
value: -32500
});
export class UserOperationRejectedByPaymasterError extends BaseError {
constructor({ cause }) {
super("User Operation rejected by Paymaster's `validatePaymasterUserOp`.", {
cause,
name: 'UserOperationRejectedByPaymasterError',
});
}
}
Object.defineProperty(UserOperationRejectedByPaymasterError, "code", {
enumerable: true,
configurable: true,
writable: true,
value: -32501
});
export class UserOperationRejectedByOpCodeError extends BaseError {
constructor({ cause }) {
super('User Operation rejected with op code validation error.', {
cause,
name: 'UserOperationRejectedByOpCodeError',
});
}
}
Object.defineProperty(UserOperationRejectedByOpCodeError, "code", {
enumerable: true,
configurable: true,
writable: true,
value: -32502
});
export class UserOperationOutOfTimeRangeError extends BaseError {
constructor({ cause }) {
super('UserOperation out of time-range: either wallet or paymaster returned a time-range, and it is already expired (or will expire soon).', {
cause,
name: 'UserOperationOutOfTimeRangeError',
});
}
}
Object.defineProperty(UserOperationOutOfTimeRangeError, "code", {
enumerable: true,
configurable: true,
writable: true,
value: -32503
});
export class UnknownBundlerError extends BaseError {
constructor({ cause }) {
super(`An error occurred while executing user operation: ${cause?.shortMessage}`, {
cause,
name: 'UnknownBundlerError',
});
}
}
export class VerificationGasLimitExceededError extends BaseError {
constructor({ cause, }) {
super('User Operation verification gas limit exceeded.', {
cause,
metaMessages: [
'This could arise when:',
'- the gas used for verification exceeded the `verificationGasLimit`',
].filter(Boolean),
name: 'VerificationGasLimitExceededError',
});
}
}
Object.defineProperty(VerificationGasLimitExceededError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa40/
});
export class VerificationGasLimitTooLowError extends BaseError {
constructor({ cause, }) {
super('User Operation verification gas limit is too low.', {
cause,
metaMessages: [
'This could arise when:',
'- the `verificationGasLimit` is too low to verify the User Operation',
].filter(Boolean),
name: 'VerificationGasLimitTooLowError',
});
}
}
Object.defineProperty(VerificationGasLimitTooLowError, "message", {
enumerable: true,
configurable: true,
writable: true,
value: /aa41/
});
//# sourceMappingURL=bundler.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,63 @@
import { BaseError } from '../../errors/base.js';
import { prettyPrint } from '../../errors/transaction.js';
import { formatGwei } from '../../utils/index.js';
export class UserOperationExecutionError extends BaseError {
constructor(cause, { callData, callGasLimit, docsPath, factory, factoryData, initCode, maxFeePerGas, maxPriorityFeePerGas, nonce, paymaster, paymasterAndData, paymasterData, paymasterPostOpGasLimit, paymasterVerificationGasLimit, preVerificationGas, sender, signature, verificationGasLimit, }) {
const prettyArgs = prettyPrint({
callData,
callGasLimit,
factory,
factoryData,
initCode,
maxFeePerGas: typeof maxFeePerGas !== 'undefined' &&
`${formatGwei(maxFeePerGas)} gwei`,
maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== 'undefined' &&
`${formatGwei(maxPriorityFeePerGas)} gwei`,
nonce,
paymaster,
paymasterAndData,
paymasterData,
paymasterPostOpGasLimit,
paymasterVerificationGasLimit,
preVerificationGas,
sender,
signature,
verificationGasLimit,
});
super(cause.shortMessage, {
cause,
docsPath,
metaMessages: [
...(cause.metaMessages ? [...cause.metaMessages, ' '] : []),
'Request Arguments:',
prettyArgs,
].filter(Boolean),
name: 'UserOperationExecutionError',
});
Object.defineProperty(this, "cause", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.cause = cause;
}
}
export class UserOperationReceiptNotFoundError extends BaseError {
constructor({ hash }) {
super(`User Operation receipt with hash "${hash}" could not be found. The User Operation may not have been processed yet.`, { name: 'UserOperationReceiptNotFoundError' });
}
}
export class UserOperationNotFoundError extends BaseError {
constructor({ hash }) {
super(`User Operation with hash "${hash}" could not be found.`, {
name: 'UserOperationNotFoundError',
});
}
}
export class WaitForUserOperationReceiptTimeoutError extends BaseError {
constructor({ hash }) {
super(`Timed out while waiting for User Operation with hash "${hash}" to be confirmed.`, { name: 'WaitForUserOperationReceiptTimeoutError' });
}
}
//# sourceMappingURL=userOperation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"userOperation.js","sourceRoot":"","sources":["../../../account-abstraction/errors/userOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAMjD,MAAM,OAAO,2BAA4B,SAAQ,SAAS;IAGxD,YACE,KAAgB,EAChB,EACE,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,OAA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ACvD,YAAY,EAAE,IAAI,EAAkB;QAClC,KAAK,CAAC,6BAA6B,IAAI,uBAAuB,EAAE;YAC9D,IAAI,EAAE,4BAA4B;SACnC,CAAC,CAAA;IACJ,CAAC;CACF;AAMD,MAAM,OAAO,uCAAwC,SAAQ,SAAS;IACpE,YAAY,EAAE,IAAI,EAAkB;QAClC,KAAK,CACH,yDAAyD,IAAI,oBAAoB,EACjF,EAAE,IAAI,EAAE,yCAAyC,EAAE,CACpD,CAAA;IACH,CAAC;CACF"}

36
node_modules/viem/_esm/account-abstraction/index.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
// biome-ignore lint/performance/noBarrelFile: entrypoint
export { createWebAuthnCredential, } from './accounts/createWebAuthnCredential.js';
export { toCoinbaseSmartAccount, } from './accounts/implementations/toCoinbaseSmartAccount.js';
export { toSimple7702SmartAccount, } from './accounts/implementations/toSimple7702SmartAccount.js';
export { toSoladySmartAccount, } from './accounts/implementations/toSoladySmartAccount.js';
export { toSmartAccount, } from './accounts/toSmartAccount.js';
export { toWebAuthnAccount, } from './accounts/toWebAuthnAccount.js';
export { estimateUserOperationGas, } from './actions/bundler/estimateUserOperationGas.js';
export { getSupportedEntryPoints, } from './actions/bundler/getSupportedEntryPoints.js';
export { getUserOperation, } from './actions/bundler/getUserOperation.js';
export { getUserOperationReceipt, } from './actions/bundler/getUserOperationReceipt.js';
export { prepareUserOperation, } from './actions/bundler/prepareUserOperation.js';
export { sendUserOperation, } from './actions/bundler/sendUserOperation.js';
export { waitForUserOperationReceipt, } from './actions/bundler/waitForUserOperationReceipt.js';
export { getPaymasterData, } from './actions/paymaster/getPaymasterData.js';
export { getPaymasterStubData, } from './actions/paymaster/getPaymasterStubData.js';
export { createBundlerClient, } from './clients/createBundlerClient.js';
export { createPaymasterClient, } from './clients/createPaymasterClient.js';
export { bundlerActions, } from './clients/decorators/bundler.js';
export { paymasterActions, } from './clients/decorators/paymaster.js';
export { entryPoint06Abi, entryPoint07Abi, entryPoint08Abi, entryPoint09Abi, } from './constants/abis.js';
export { entryPoint06Address, entryPoint07Address, entryPoint08Address, entryPoint09Address, } from './constants/address.js';
export { AccountNotDeployedError, FailedToSendToBeneficiaryError, GasValuesOverflowError, HandleOpsOutOfGasError, InitCodeFailedError, InitCodeMustCreateSenderError, InitCodeMustReturnSenderError, InsufficientPrefundError, InternalCallOnlyError, InvalidAggregatorError, InvalidBeneficiaryError, InvalidPaymasterAndDataError, PaymasterDepositTooLowError, PaymasterFunctionRevertedError, PaymasterNotDeployedError, PaymasterPostOpFunctionRevertedError, SenderAlreadyConstructedError, SmartAccountFunctionRevertedError, UnknownBundlerError, UserOperationExpiredError, UserOperationPaymasterExpiredError, UserOperationPaymasterSignatureError, UserOperationSignatureError, VerificationGasLimitExceededError, VerificationGasLimitTooLowError, } from './errors/bundler.js';
export { UserOperationExecutionError, UserOperationNotFoundError, UserOperationReceiptNotFoundError, WaitForUserOperationReceiptTimeoutError, } from './errors/userOperation.js';
export { getBundlerError, } from './utils/errors/getBundlerError.js';
export { getUserOperationError, } from './utils/errors/getUserOperationError.js';
export { formatUserOperation, } from './utils/formatters/userOperation.js';
export { formatUserOperationGas, } from './utils/formatters/userOperationGas.js';
export { formatUserOperationReceipt, } from './utils/formatters/userOperationReceipt.js';
export { formatUserOperationRequest, } from './utils/formatters/userOperationRequest.js';
export { getInitCode, } from './utils/userOperation/getInitCode.js';
export { getUserOperationHash, } from './utils/userOperation/getUserOperationHash.js';
export { getUserOperationTypedData, } from './utils/userOperation/getUserOperationTypedData.js';
export { toPackedUserOperation, } from './utils/userOperation/toPackedUserOperation.js';
export { toUserOperation } from './utils/userOperation/toUserOperation.js';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../account-abstraction/index.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAGL,wBAAwB,GAEzB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAIL,sBAAsB,GACvB,MAAM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B,EAExB,qBAAqB,EAErB,sBAAsB,EAEtB,uBAAuB,EAEvB,4BAA4B,EAE5B,2BAA2B,EAE3B,8BAA8B,EAE9B,yBAAyB,EAEzB,oCAAoC,EAEpC,6BAA6B,EAE7B,iCAAiC,EAEjC,mBAAmB,EAEnB,yBAAyB,EAEzB,kCAAkC,EAElC,oCAAoC,EAEpC,2BAA2B,EAE3B,iCAAiC,EAEjC,+BAA+B,GAEhC,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,2BAA2B,EAE3B,0BAA0B,EAE1B,iCAAiC,EAEjC,uCAAuC,GAExC,MAAM,2BAA2B,CAAA;AAyBlC,OAAO,EAGL,eAAe,GAChB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAIL,qBAAqB,GACtB,MAAM,yCAAyC,CAAA;AAChD,OAAO,EAEL,mBAAmB,GACpB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAEL,sBAAsB,GACvB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAEL,0BAA0B,GAC3B,MAAM,4CAA4C,CAAA;AACnD,OAAO,EAEL,0BAA0B,GAC3B,MAAM,4CAA4C,CAAA;AACnD,OAAO,EAEL,WAAW,GACZ,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAGL,oBAAoB,GACrB,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAGL,yBAAyB,GAC1B,MAAM,oDAAoD,CAAA;AAC3D,OAAO,EAEL,qBAAqB,GACtB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAA"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=account.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../account-abstraction/types/account.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=entryPointVersion.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"entryPointVersion.js","sourceRoot":"","sources":["../../../account-abstraction/types/entryPointVersion.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=rpc.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../../account-abstraction/types/rpc.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=userOperation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"userOperation.js","sourceRoot":"","sources":["../../../account-abstraction/types/userOperation.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,184 @@
import { AccountNotDeployedError, ExecutionRevertedError, FailedToSendToBeneficiaryError, GasValuesOverflowError, HandleOpsOutOfGasError, InitCodeFailedError, InitCodeMustCreateSenderError, InitCodeMustReturnSenderError, InsufficientPrefundError, InternalCallOnlyError, InvalidAccountNonceError, InvalidAggregatorError, InvalidBeneficiaryError, InvalidFieldsError, InvalidPaymasterAndDataError, PaymasterDepositTooLowError, PaymasterFunctionRevertedError, PaymasterNotDeployedError, PaymasterPostOpFunctionRevertedError, PaymasterRateLimitError, PaymasterStakeTooLowError, SenderAlreadyConstructedError, SignatureCheckFailedError, SmartAccountFunctionRevertedError, UnknownBundlerError, UnsupportedSignatureAggregatorError, UserOperationExpiredError, UserOperationOutOfTimeRangeError, UserOperationPaymasterExpiredError, UserOperationPaymasterSignatureError, UserOperationRejectedByEntryPointError, UserOperationRejectedByOpCodeError, UserOperationRejectedByPaymasterError, UserOperationSignatureError, VerificationGasLimitExceededError, VerificationGasLimitTooLowError, } from '../../errors/bundler.js';
const bundlerErrors = [
ExecutionRevertedError,
InvalidFieldsError,
PaymasterDepositTooLowError,
PaymasterRateLimitError,
PaymasterStakeTooLowError,
SignatureCheckFailedError,
UnsupportedSignatureAggregatorError,
UserOperationOutOfTimeRangeError,
UserOperationRejectedByEntryPointError,
UserOperationRejectedByPaymasterError,
UserOperationRejectedByOpCodeError,
];
export function getBundlerError(err, args) {
const message = (err.details || '').toLowerCase();
if (AccountNotDeployedError.message.test(message))
return new AccountNotDeployedError({
cause: err,
});
if (FailedToSendToBeneficiaryError.message.test(message))
return new FailedToSendToBeneficiaryError({
cause: err,
});
if (GasValuesOverflowError.message.test(message))
return new GasValuesOverflowError({
cause: err,
});
if (HandleOpsOutOfGasError.message.test(message))
return new HandleOpsOutOfGasError({
cause: err,
});
if (InitCodeFailedError.message.test(message))
return new InitCodeFailedError({
cause: err,
factory: args.factory,
factoryData: args.factoryData,
initCode: args.initCode,
});
if (InitCodeMustCreateSenderError.message.test(message))
return new InitCodeMustCreateSenderError({
cause: err,
factory: args.factory,
factoryData: args.factoryData,
initCode: args.initCode,
});
if (InitCodeMustReturnSenderError.message.test(message))
return new InitCodeMustReturnSenderError({
cause: err,
factory: args.factory,
factoryData: args.factoryData,
initCode: args.initCode,
sender: args.sender,
});
if (InsufficientPrefundError.message.test(message))
return new InsufficientPrefundError({
cause: err,
});
if (InternalCallOnlyError.message.test(message))
return new InternalCallOnlyError({
cause: err,
});
if (InvalidAccountNonceError.message.test(message))
return new InvalidAccountNonceError({
cause: err,
nonce: args.nonce,
});
if (InvalidAggregatorError.message.test(message))
return new InvalidAggregatorError({
cause: err,
});
if (InvalidBeneficiaryError.message.test(message))
return new InvalidBeneficiaryError({
cause: err,
});
if (InvalidPaymasterAndDataError.message.test(message))
return new InvalidPaymasterAndDataError({
cause: err,
});
if (PaymasterDepositTooLowError.message.test(message))
return new PaymasterDepositTooLowError({
cause: err,
});
if (PaymasterFunctionRevertedError.message.test(message))
return new PaymasterFunctionRevertedError({
cause: err,
});
if (PaymasterNotDeployedError.message.test(message))
return new PaymasterNotDeployedError({
cause: err,
});
if (PaymasterPostOpFunctionRevertedError.message.test(message))
return new PaymasterPostOpFunctionRevertedError({
cause: err,
});
if (SmartAccountFunctionRevertedError.message.test(message))
return new SmartAccountFunctionRevertedError({
cause: err,
});
if (SenderAlreadyConstructedError.message.test(message))
return new SenderAlreadyConstructedError({
cause: err,
factory: args.factory,
factoryData: args.factoryData,
initCode: args.initCode,
});
if (UserOperationExpiredError.message.test(message))
return new UserOperationExpiredError({
cause: err,
});
if (UserOperationPaymasterExpiredError.message.test(message))
return new UserOperationPaymasterExpiredError({
cause: err,
});
if (UserOperationPaymasterSignatureError.message.test(message))
return new UserOperationPaymasterSignatureError({
cause: err,
});
if (UserOperationSignatureError.message.test(message))
return new UserOperationSignatureError({
cause: err,
});
if (VerificationGasLimitExceededError.message.test(message))
return new VerificationGasLimitExceededError({
cause: err,
});
if (VerificationGasLimitTooLowError.message.test(message))
return new VerificationGasLimitTooLowError({
cause: err,
});
const error = err.walk((e) => bundlerErrors.some((error) => error.code === e.code));
if (error) {
if (error.code === ExecutionRevertedError.code)
return new ExecutionRevertedError({
cause: err,
data: error.data,
message: error.details,
});
if (error.code === InvalidFieldsError.code)
return new InvalidFieldsError({
cause: err,
});
if (error.code === PaymasterDepositTooLowError.code)
return new PaymasterDepositTooLowError({
cause: err,
});
if (error.code === PaymasterRateLimitError.code)
return new PaymasterRateLimitError({
cause: err,
});
if (error.code === PaymasterStakeTooLowError.code)
return new PaymasterStakeTooLowError({
cause: err,
});
if (error.code === SignatureCheckFailedError.code)
return new SignatureCheckFailedError({
cause: err,
});
if (error.code === UnsupportedSignatureAggregatorError.code)
return new UnsupportedSignatureAggregatorError({
cause: err,
});
if (error.code === UserOperationOutOfTimeRangeError.code)
return new UserOperationOutOfTimeRangeError({
cause: err,
});
if (error.code === UserOperationRejectedByEntryPointError.code)
return new UserOperationRejectedByEntryPointError({
cause: err,
});
if (error.code === UserOperationRejectedByPaymasterError.code)
return new UserOperationRejectedByPaymasterError({
cause: err,
});
if (error.code === UserOperationRejectedByOpCodeError.code)
return new UserOperationRejectedByOpCodeError({
cause: err,
});
}
return new UnknownBundlerError({
cause: err,
});
}
//# sourceMappingURL=getBundlerError.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,85 @@
import { BaseError } from '../../../errors/base.js';
import { ContractFunctionExecutionError, ContractFunctionRevertedError, ContractFunctionZeroDataError, } from '../../../errors/contract.js';
import { decodeErrorResult } from '../../../utils/abi/decodeErrorResult.js';
import { ExecutionRevertedError } from '../../errors/bundler.js';
import { UserOperationExecutionError, } from '../../errors/userOperation.js';
import { getBundlerError, } from './getBundlerError.js';
export function getUserOperationError(err, { calls, docsPath, ...args }) {
const cause = (() => {
const cause = getBundlerError(err, args);
if (calls && cause instanceof ExecutionRevertedError) {
const revertData = getRevertData(cause);
const contractCalls = calls?.filter((call) => call.abi);
if (revertData && contractCalls.length > 0)
return getContractError({ calls: contractCalls, revertData });
}
return cause;
})();
return new UserOperationExecutionError(cause, {
docsPath,
...args,
});
}
/////////////////////////////////////////////////////////////////////////////////
function getRevertData(error) {
let revertData;
error.walk((e) => {
const error = e;
if (typeof error.data === 'string' ||
typeof error.data?.revertData === 'string' ||
(!(error instanceof BaseError) && typeof error.message === 'string')) {
const match = (error.data?.revertData ||
error.data ||
error.message).match?.(/(0x[A-Za-z0-9]*)/);
if (match) {
revertData = match[1];
return true;
}
}
return false;
});
return revertData;
}
function getContractError(parameters) {
const { calls, revertData } = parameters;
const { abi, functionName, args, to } = (() => {
const contractCalls = calls?.filter((call) => Boolean(call.abi));
if (contractCalls.length === 1)
return contractCalls[0];
const compatContractCalls = contractCalls.filter((call) => {
try {
return Boolean(decodeErrorResult({
abi: call.abi,
data: revertData,
}));
}
catch {
return false;
}
});
if (compatContractCalls.length === 1)
return compatContractCalls[0];
return {
abi: [],
functionName: contractCalls.reduce((acc, call) => `${acc ? `${acc} | ` : ''}${call.functionName}`, ''),
args: undefined,
to: undefined,
};
})();
const cause = (() => {
if (revertData === '0x')
return new ContractFunctionZeroDataError({ functionName });
return new ContractFunctionRevertedError({
abi,
data: revertData,
functionName,
});
})();
return new ContractFunctionExecutionError(cause, {
abi,
args,
contractAddress: to,
functionName,
});
}
//# sourceMappingURL=getUserOperationError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getUserOperationError.js","sourceRoot":"","sources":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jB,CAAC,CACH,CAAA;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC,CAAC,CAAA;QACF,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAA;QAEnE,OAAO;YACL,GAAG,EAAE,EAAE;YACP,YAAY,EAAE,aAAa,CAAC,MAAM,CAChC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,EAC9D,EAAE,CACH;YACD,IAAI,EAAE,SAAS;YACf,EAAE,EAAE,SAAS;SACd,CAAA;IACH,CAAC,CAAC,EAKD,CAAA;IAED,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE;QAClB,IAAI,UAAU,KAAK,IAAI;YACrB,OAAO,IAAI,6BAA6B,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;QAC5D,OAAO,IAAI,6BAA6B,CAAC;YACvC,GAAG;YACH,IAAI,EAAE,UAAU;YAChB,YAAY;SACb,CAAC,CAAA;IACJ,CAAC,CAAC,EAAE,CAAA;IACJ,OAAO,IAAI,8BAA8B,CAAC,KAAkB,EAAE;QAC5D,GAAG;QACH,IAAI;QACJ,eAAe,EAAE,EAAE;QACnB,YAAY;KACb,CAA+B,CAAA;AAClC,CAAC"}

View File

@@ -0,0 +1,21 @@
export function formatUserOperation(parameters) {
const userOperation = { ...parameters };
if (parameters.callGasLimit)
userOperation.callGasLimit = BigInt(parameters.callGasLimit);
if (parameters.maxFeePerGas)
userOperation.maxFeePerGas = BigInt(parameters.maxFeePerGas);
if (parameters.maxPriorityFeePerGas)
userOperation.maxPriorityFeePerGas = BigInt(parameters.maxPriorityFeePerGas);
if (parameters.nonce)
userOperation.nonce = BigInt(parameters.nonce);
if (parameters.paymasterPostOpGasLimit)
userOperation.paymasterPostOpGasLimit = BigInt(parameters.paymasterPostOpGasLimit);
if (parameters.paymasterVerificationGasLimit)
userOperation.paymasterVerificationGasLimit = BigInt(parameters.paymasterVerificationGasLimit);
if (parameters.preVerificationGas)
userOperation.preVerificationGas = BigInt(parameters.preVerificationGas);
if (parameters.verificationGasLimit)
userOperation.verificationGasLimit = BigInt(parameters.verificationGasLimit);
return userOperation;
}
//# sourceMappingURL=userOperation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"userOperation.js","sourceRoot":"","sources":["../../../../account-abstraction/utils/formatters/userOperation.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,mBAAmB,CAAC,UAA4B;IAC9D,MAAM,aAAa,GAAG,EAAE,GAAG,UAAU,EAA8B,CAAA;IAEnE,IAAI,UAAU,CAAC,YAAY;QACzB,aAAa,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;IAC9D,IAAI,UAAU,CAAC,YAAY;QACzB,aAAa,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;IAC9D,IAAI,UAAU,CAAC,oBAAoB;QACjC,aAAa,CAAC,oBAAoB,GAAG,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAA;IAC9E,IAAI,UAAU,CAAC,KAAK;QAAE,aAAa,CAAC,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACpE,IAAI,UAAU,CAAC,uBAAuB;QACpC,aAAa,CAAC,uBAAuB,GAAG,MAAM,CAC5C,UAAU,CAAC,uBAAuB,CACnC,CAAA;IACH,IAAI,UAAU,CAAC,6BAA6B;QAC1C,aAAa,CAAC,6BAA6B,GAAG,MAAM,CAClD,UAAU,CAAC,6BAA6B,CACzC,CAAA;IACH,IAAI,UAAU,CAAC,kBAAkB;QAC/B,aAAa,CAAC,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAA;IAC1E,IAAI,UAAU,CAAC,oBAAoB;QACjC,aAAa,CAAC,oBAAoB,GAAG,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAA;IAE9E,OAAO,aAAa,CAAA;AACtB,CAAC"}

View File

@@ -0,0 +1,15 @@
export function formatUserOperationGas(parameters) {
const gas = {};
if (parameters.callGasLimit)
gas.callGasLimit = BigInt(parameters.callGasLimit);
if (parameters.preVerificationGas)
gas.preVerificationGas = BigInt(parameters.preVerificationGas);
if (parameters.verificationGasLimit)
gas.verificationGasLimit = BigInt(parameters.verificationGasLimit);
if (parameters.paymasterPostOpGasLimit)
gas.paymasterPostOpGasLimit = BigInt(parameters.paymasterPostOpGasLimit);
if (parameters.paymasterVerificationGasLimit)
gas.paymasterVerificationGasLimit = BigInt(parameters.paymasterVerificationGasLimit);
return gas;
}
//# sourceMappingURL=userOperationGas.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"userOperationGas.js","sourceRoot":"","sources":["../../../../account-abstraction/utils/formatters/userOperationGas.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,sBAAsB,CACpC,UAAiD;IAEjD,MAAM,GAAG,GAAG,EAAwC,CAAA;IAEpD,IAAI,UAAU,CAAC,YAAY;QACzB,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;IACpD,IAAI,UAAU,CAAC,kBAAkB;QAC/B,GAAG,CAAC,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAA;IAChE,IAAI,UAAU,CAAC,oBAAoB;QACjC,GAAG,CAAC,oBAAoB,GAAG,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAA;IACpE,IAAI,UAAU,CAAC,uBAAuB;QACpC,GAAG,CAAC,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAA;IAC1E,IAAI,UAAU,CAAC,6BAA6B;QAC1C,GAAG,CAAC,6BAA6B,GAAG,MAAM,CACxC,UAAU,CAAC,6BAA6B,CACzC,CAAA;IAEH,OAAO,GAAG,CAAA;AACZ,CAAC"}

View File

@@ -0,0 +1,15 @@
import { formatLog } from '../../../utils/formatters/log.js';
import { formatTransactionReceipt } from '../../../utils/formatters/transactionReceipt.js';
export function formatUserOperationReceipt(parameters) {
const receipt = { ...parameters };
if (parameters.actualGasCost)
receipt.actualGasCost = BigInt(parameters.actualGasCost);
if (parameters.actualGasUsed)
receipt.actualGasUsed = BigInt(parameters.actualGasUsed);
if (parameters.logs)
receipt.logs = parameters.logs.map((log) => formatLog(log));
if (parameters.receipt)
receipt.receipt = formatTransactionReceipt(receipt.receipt);
return receipt;
}
//# sourceMappingURL=userOperationReceipt.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"userOperationReceipt.js","sourceRoot":"","sources":["../../../../account-abstraction/utils/formatters/userOperationReceipt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAM1F,MAAM,UAAU,0BAA0B,CACxC,UAAmC;IAEnC,MAAM,OAAO,GAAG,EAAE,GAAG,UAAU,EAAqC,CAAA;IAEpE,IAAI,UAAU,CAAC,aAAa;QAC1B,OAAO,CAAC,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAA;IAC1D,IAAI,UAAU,CAAC,aAAa;QAC1B,OAAO,CAAC,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAA;IAC1D,IAAI,UAAU,CAAC,IAAI;QACjB,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAQ,CAAA;IACpE,IAAI,UAAU,CAAC,OAAO;QACpB,OAAO,CAAC,OAAO,GAAG,wBAAwB,CAAC,OAAO,CAAC,OAAc,CAAC,CAAA;IAEpE,OAAO,OAAO,CAAA;AAChB,CAAC"}

View File

@@ -0,0 +1,61 @@
import { numberToHex } from '../../../utils/encoding/toHex.js';
import { pad } from '../../../utils/index.js';
export function formatUserOperationRequest(request) {
const rpcRequest = {};
if (typeof request.callData !== 'undefined')
rpcRequest.callData = request.callData;
if (typeof request.callGasLimit !== 'undefined')
rpcRequest.callGasLimit = numberToHex(request.callGasLimit);
if (typeof request.factory !== 'undefined')
rpcRequest.factory = request.factory;
if (typeof request.factoryData !== 'undefined')
rpcRequest.factoryData = request.factoryData;
if (typeof request.initCode !== 'undefined')
rpcRequest.initCode = request.initCode;
if (typeof request.maxFeePerGas !== 'undefined')
rpcRequest.maxFeePerGas = numberToHex(request.maxFeePerGas);
if (typeof request.maxPriorityFeePerGas !== 'undefined')
rpcRequest.maxPriorityFeePerGas = numberToHex(request.maxPriorityFeePerGas);
if (typeof request.nonce !== 'undefined')
rpcRequest.nonce = numberToHex(request.nonce);
if (typeof request.paymaster !== 'undefined')
rpcRequest.paymaster = request.paymaster;
if (typeof request.paymasterAndData !== 'undefined')
rpcRequest.paymasterAndData = request.paymasterAndData || '0x';
if (typeof request.paymasterData !== 'undefined')
rpcRequest.paymasterData = request.paymasterData;
if (typeof request.paymasterPostOpGasLimit !== 'undefined')
rpcRequest.paymasterPostOpGasLimit = numberToHex(request.paymasterPostOpGasLimit);
if (typeof request.paymasterSignature !== 'undefined')
rpcRequest.paymasterSignature = request.paymasterSignature;
if (typeof request.paymasterVerificationGasLimit !== 'undefined')
rpcRequest.paymasterVerificationGasLimit = numberToHex(request.paymasterVerificationGasLimit);
if (typeof request.preVerificationGas !== 'undefined')
rpcRequest.preVerificationGas = numberToHex(request.preVerificationGas);
if (typeof request.sender !== 'undefined')
rpcRequest.sender = request.sender;
if (typeof request.signature !== 'undefined')
rpcRequest.signature = request.signature;
if (typeof request.verificationGasLimit !== 'undefined')
rpcRequest.verificationGasLimit = numberToHex(request.verificationGasLimit);
if (typeof request.authorization !== 'undefined')
rpcRequest.eip7702Auth = formatAuthorization(request.authorization);
return rpcRequest;
}
function formatAuthorization(authorization) {
return {
address: authorization.address,
chainId: numberToHex(authorization.chainId),
nonce: numberToHex(authorization.nonce),
r: authorization.r
? numberToHex(BigInt(authorization.r), { size: 32 })
: pad('0x', { size: 32 }),
s: authorization.s
? numberToHex(BigInt(authorization.s), { size: 32 })
: pad('0x', { size: 32 }),
yParity: authorization.yParity
? numberToHex(authorization.yParity, { size: 1 })
: pad('0x', { size: 32 }),
};
}
//# sourceMappingURL=userOperationRequest.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"userOperationRequest.js","sourceRoot":"","sources":["../../../../account-abstraction/utils/formatters/userOperationRequest.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAM7C,MAAM,UAAU,0BAA0B,CACxC,OAAoC;IAEpC,MAAM,UAAU,GAAG,EAAsB,CAAA;IAEzC,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,WAAW;QACzC,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;IACxC,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,WAAW;QAC7C,UAAU,CAAC,YAAY,GAAG,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IAC7D,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,WAAW;QACxC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;IACtC,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,WAAW;QAC5C,UAAU,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;IAC9C,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,WAAW;QACzC,UAAU,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;IACxC,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,WAAW;QAC7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E,EAAE,EAAE,CAAC;KAC5B,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,16 @@
import { concat } from '../../../utils/data/concat.js';
export function getInitCode(userOperation, options = {}) {
const { forHash } = options;
const { authorization, factory, factoryData } = userOperation;
if (forHash &&
(factory === '0x7702' ||
factory === '0x7702000000000000000000000000000000000000')) {
if (!authorization)
return '0x7702000000000000000000000000000000000000';
return concat([authorization.address, factoryData ?? '0x']);
}
if (!factory)
return '0x';
return concat([factory, factoryData ?? '0x']);
}
//# sourceMappingURL=getInitCode.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getInitCode.js","sourceRoot":"","sources":["../../../../account-abstraction/utils/userOperation/getInitCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAQtD,MAAM,UAAU,WAAW,CACzB,aAGC,EACD,UAA8B,EAAE;IAEhC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAC3B,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,aAAa,CAAA;IAC7D,IACE,OAAO;QACP,CAAC,OAAO,KAAK,QAAQ;YACnB,OAAO,KAAK,4CAA4C,CAAC,EAC3D,CAAC;QACD,IAAI,CAAC,aAAa;YAAE,OAAO,4CAA4C,CAAA;QACvE,OAAO,MAAM,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,IAAI,IAAI,CAAC,CAAC,CAAA;IAC7D,CAAC;IACD,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IACzB,OAAO,MAAM,CAAC,CAAC,OAAO,EAAE,WAAW,IAAI,IAAI,CAAC,CAAC,CAAA;AAC/C,CAAC"}

View File

@@ -0,0 +1,78 @@
import { encodeAbiParameters } from '../../../utils/abi/encodeAbiParameters.js';
import { keccak256 } from '../../../utils/hash/keccak256.js';
import { hashTypedData } from '../../../utils/signature/hashTypedData.js';
import { getInitCode } from './getInitCode.js';
import { getUserOperationTypedData } from './getUserOperationTypedData.js';
import { toPackedUserOperation } from './toPackedUserOperation.js';
export function getUserOperationHash(parameters) {
const { chainId, entryPointAddress, entryPointVersion } = parameters;
const userOperation = parameters.userOperation;
const { authorization, callData = '0x', callGasLimit, maxFeePerGas, maxPriorityFeePerGas, nonce, paymasterAndData = '0x', preVerificationGas, sender, verificationGasLimit, } = userOperation;
if (entryPointVersion === '0.8' || entryPointVersion === '0.9')
return hashTypedData(getUserOperationTypedData({
chainId,
entryPointAddress,
userOperation,
}));
const packedUserOp = (() => {
if (entryPointVersion === '0.6') {
const factory = userOperation.initCode?.slice(0, 42);
const factoryData = userOperation.initCode?.slice(42);
const initCode = getInitCode({
authorization,
factory,
factoryData,
}, { forHash: true });
return encodeAbiParameters([
{ type: 'address' },
{ type: 'uint256' },
{ type: 'bytes32' },
{ type: 'bytes32' },
{ type: 'uint256' },
{ type: 'uint256' },
{ type: 'uint256' },
{ type: 'uint256' },
{ type: 'uint256' },
{ type: 'bytes32' },
], [
sender,
nonce,
keccak256(initCode),
keccak256(callData),
callGasLimit,
verificationGasLimit,
preVerificationGas,
maxFeePerGas,
maxPriorityFeePerGas,
keccak256(paymasterAndData),
]);
}
if (entryPointVersion === '0.7') {
const packedUserOp = toPackedUserOperation(userOperation, {
forHash: true,
});
return encodeAbiParameters([
{ type: 'address' },
{ type: 'uint256' },
{ type: 'bytes32' },
{ type: 'bytes32' },
{ type: 'bytes32' },
{ type: 'uint256' },
{ type: 'bytes32' },
{ type: 'bytes32' },
], [
packedUserOp.sender,
packedUserOp.nonce,
keccak256(packedUserOp.initCode),
keccak256(packedUserOp.callData),
packedUserOp.accountGasLimits,
packedUserOp.preVerificationGas,
packedUserOp.gasFees,
keccak256(packedUserOp.paymasterAndData),
]);
}
throw new Error(`entryPointVersion "${entryPointVersion}" not supported.`);
})();
return keccak256(encodeAbiParameters([{ type: 'bytes32' }, { type: 'address' }, { type: 'uint256' }], [keccak256(packedUserOp), entryPointAddress, BigInt(chainId)]));
}
//# sourceMappingURL=getUserOperationHash.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getUserOperationHash.js","sourceRoot":"","sources":["../../../../account-abstraction/utils/userOperation/getUserOperationHash.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAA;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAA;AAGzE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAalE,MAAM,UAAU,oBAAoB,CAGlC,UAA6D;IAE7D,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAA;IACpE,MAAM,aAAa,GAAG,UAAU,CAAC,aAA8B,CAAA;IAC/D,MAAM,EACJ,aAAa,EACb,QAAQ,GAAG,IAAI,EACf,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,gBAAgB,GAAG,IAAI,EACvB,kBAAkB,EAClB,MAAM,EACN,oBAAoB,GACrB,GAAG,aAAa,CAAA;IAEjB,IAAI,iBAAiB,KAAK,KAAK,IAAI,iBAAiB,KAAK,KAAK;QAC5D,OAAO,aAAa,CAClB,yBAAyB,CAAC;YACxB,OAAO;YACP,iBAAiB;YACjB,aAAa;SACd,CAAC,CACH,CAAA;IAEH,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE;QACzB,IAAI,iBAAiB,KAAK,KAAK,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAQ,CAAA;YAC3D,MAAM,WAAW,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAoB,CAA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BACE,YAAY,CAAC,MAAM;gBACnB,YAAY,CAAC,KAAK;gBAClB,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC;gBAChC,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC;gBAChC,YAAY,CAAC,gBAAgB;gBAC7B,YAAY,CAAC,kBAAkB;gBAC/B,YAAY,CAAC,OAAO;gBACpB,SAAS,CAAC,YAAY,CAAC,gBAAgB,CAAC;aACzC,CACF,CAAA;QACH,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,sBAAsB,iBAAiB,kBAAkB,CAAC,CAAA;IAC5E,CAAC,CAAC,EAAE,CAAA;IAEJ,OAAO,SAAS,CACd,mBAAmB,CACjB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAC/D,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAC9D,CACF,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,29 @@
import { toPackedUserOperation } from './toPackedUserOperation.js';
const types = {
PackedUserOperation: [
{ type: 'address', name: 'sender' },
{ type: 'uint256', name: 'nonce' },
{ type: 'bytes', name: 'initCode' },
{ type: 'bytes', name: 'callData' },
{ type: 'bytes32', name: 'accountGasLimits' },
{ type: 'uint256', name: 'preVerificationGas' },
{ type: 'bytes32', name: 'gasFees' },
{ type: 'bytes', name: 'paymasterAndData' },
],
};
export function getUserOperationTypedData(parameters) {
const { chainId, entryPointAddress, userOperation } = parameters;
const packedUserOp = toPackedUserOperation(userOperation, { forHash: true });
return {
types,
primaryType: 'PackedUserOperation',
domain: {
name: 'ERC4337',
version: '1',
chainId,
verifyingContract: entryPointAddress,
},
message: packedUserOp,
};
}
//# sourceMappingURL=getUserOperationTypedData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getUserOperationTypedData.js","sourceRoot":"","sources":["../../../../account-abstraction/utils/userOperation/getUserOperationTypedData.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAalE,MAAM,KAAK,GAAG;IACZ,mBAAmB,EAAE;QACnB,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;QACnC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE;QAClC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE;QACnC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE;QACnC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,EAAE;QAC7C,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,EAAE;QAC/C,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;QACpC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE;KAC5C;CACO,CAAA;AAEV,MAAM,UAAU,yBAAyB,CACvC,UAA+C;IAE/C,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,GAAG,UAAU,CAAA;IAEhE,MAAM,YAAY,GAAG,qBAAqB,CAAC,aAAa,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IAE5E,OAAO;QACL,KAAK;QACL,WAAW,EAAE,qBAAqB;QAClC,MAAM,EAAE;YACN,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,GAAG;YACZ,OAAO;YACP,iBAAiB,EAAE,iBAAiB;SACrC;QACD,OAAO,EAAE,YAAY;KACtB,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,58 @@
import { concat } from '../../../utils/data/concat.js';
import { pad } from '../../../utils/data/pad.js';
import { size } from '../../../utils/data/size.js';
import { numberToHex } from '../../../utils/index.js';
import { getInitCode } from './getInitCode.js';
/** Magic suffix for paymaster signature encoding (keccak256("PaymasterSignature")[:8]) */
const paymasterSignatureMagic = '0x22e325a297439656';
export function toPackedUserOperation(userOperation, options = {}) {
const { callGasLimit, callData, maxPriorityFeePerGas, maxFeePerGas, paymaster, paymasterData, paymasterPostOpGasLimit, paymasterSignature, paymasterVerificationGasLimit, sender, signature = '0x', verificationGasLimit, } = userOperation;
const accountGasLimits = concat([
pad(numberToHex(verificationGasLimit || 0n), { size: 16 }),
pad(numberToHex(callGasLimit || 0n), { size: 16 }),
]);
const initCode = getInitCode(userOperation, options);
const gasFees = concat([
pad(numberToHex(maxPriorityFeePerGas || 0n), { size: 16 }),
pad(numberToHex(maxFeePerGas || 0n), { size: 16 }),
]);
const nonce = userOperation.nonce ?? 0n;
// For v0.9, paymasterSignature can be provided separately and appended after paymasterData.
// The encoding uses a magic suffix and length prefix as per ERC-4337 spec:
// - forHash: just append the magic (signature is not part of hash)
// - !forHash: append signature + length (2 bytes) + magic
const paymasterAndData = paymaster
? concat([
paymaster,
pad(numberToHex(paymasterVerificationGasLimit || 0n), {
size: 16,
}),
pad(numberToHex(paymasterPostOpGasLimit || 0n), {
size: 16,
}),
paymasterData || '0x',
...(paymasterSignature
? options.forHash
? [paymasterSignatureMagic]
: [
paymasterSignature,
pad(numberToHex(size(paymasterSignature)), { size: 2 }),
paymasterSignatureMagic,
]
: []),
])
: '0x';
const preVerificationGas = userOperation.preVerificationGas ?? 0n;
return {
accountGasLimits,
callData,
initCode,
gasFees,
nonce,
paymasterAndData,
preVerificationGas,
sender,
signature,
};
}
//# sourceMappingURL=toPackedUserOperation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"toPackedUserOperation.js","sourceRoot":"","sources":["../../../../account-abstraction/utils/userOperation/toPackedUserOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,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AAW,CAAC,6BAA6B,IAAI,EAAE,CAAC,EAAE;gBACpD,IAAI,EAAE,EAAE;aACT,CAAC;YACF,GAAG,CAAC,WAAW,CAAC,uBAAuB,IAAI,EAAE,CAAC,EAAE;gBAC9C,IAAI,EAAE,EAAE;aACT,CAAC;YACF,aAAa,IAAI,IAAI;YACrB,GAAG,CAAC,kBAAkB;gBACpB,CAAC,CAAC,OAAO,CAAC,OAAO;oBACf,CAAC,CAAC,CAAC,uBAAuB,CAAC;oBAC3B,CAAC,CAAC;wBACE,kBAAmC;wBACnC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;wBACvD,uBAAuB;qBACxB;gBACL,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;QACJ,CAAC,CAAC,IAAI,CAAA;IACR,MAAM,kBAAkB,GAAG,aAAa,CAAC,kBAAkB,IAAI,EAAE,CAAA;IAEjE,OAAO;QACL,gBAAgB;QAChB,QAAQ;QACR,QAAQ;QACR,OAAO;QACP,KAAK;QACL,gBAAgB;QAChB,kBAAkB;QAClB,MAAM;QACN,SAAS;KACV,CAAA;AACH,CAAC"}

View File

@@ -0,0 +1,3 @@
import { UserOperation } from 'ox/erc4337';
export const toUserOperation = UserOperation.from;
//# sourceMappingURL=toUserOperation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"toUserOperation.js","sourceRoot":"","sources":["../../../../account-abstraction/utils/userOperation/toUserOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,CAAA"}

13
node_modules/viem/_esm/accounts/generateMnemonic.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { generateMnemonic as generateMnemonic_ } from '@scure/bip39';
/**
* @description Generates a random mnemonic phrase with a given wordlist.
*
* @param wordlist The wordlist to use for generating the mnemonic phrase.
* @param strength mnemonic strength 128-256 bits
*
* @returns A randomly generated mnemonic phrase.
*/
export function generateMnemonic(wordlist, strength) {
return generateMnemonic_(wordlist, strength);
}
//# sourceMappingURL=generateMnemonic.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"generateMnemonic.js","sourceRoot":"","sources":["../../accounts/generateMnemonic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,IAAI,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAKpE;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAkB,EAClB,QAA6B;IAE7B,OAAO,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AAC9C,CAAC"}

11
node_modules/viem/_esm/accounts/generatePrivateKey.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import { secp256k1 } from '@noble/curves/secp256k1';
import { toHex } from '../utils/encoding/toHex.js';
/**
* @description Generates a random private key.
*
* @returns A randomly generated private key.
*/
export function generatePrivateKey() {
return toHex(secp256k1.utils.randomPrivateKey());
}
//# sourceMappingURL=generatePrivateKey.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"generatePrivateKey.js","sourceRoot":"","sources":["../../accounts/generatePrivateKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAInD,OAAO,EAAuB,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAIvE;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAA;AAClD,CAAC"}

17
node_modules/viem/_esm/accounts/hdKeyToAccount.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import { toHex } from '../utils/encoding/toHex.js';
import { privateKeyToAccount, } from './privateKeyToAccount.js';
/**
* @description Creates an Account from a HD Key.
*
* @returns A HD Account.
*/
export function hdKeyToAccount(hdKey_, { accountIndex = 0, addressIndex = 0, changeIndex = 0, path, ...options } = {}) {
const hdKey = hdKey_.derive(path || `m/44'/60'/${accountIndex}'/${changeIndex}/${addressIndex}`);
const account = privateKeyToAccount(toHex(hdKey.privateKey), options);
return {
...account,
getHdKey: () => hdKey,
source: 'hd',
};
}
//# sourceMappingURL=hdKeyToAccount.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"hdKeyToAccount.js","sourceRoot":"","sources":["../../accounts/hdKeyToAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,EAGL,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AAUjC;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAa,EACb,EACE,YAAY,GAAG,CAAC,EAChB,YAAY,GAAG,CAAC,EAChB,WAAW,GAAG,CAAC,EACf,IAAI,EACJ,GAAG,OAAO,KACe,EAAE;IAE7B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,IAAI,IAAI,aAAa,YAAY,KAAK,WAAW,IAAI,YAAY,EAAE,CACpE,CAAA;IACD,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,UAAW,CAAC,EAAE,OAAO,CAAC,CAAA;IACtE,OAAO;QACL,GAAG,OAAO;QACV,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;QACrB,MAAM,EAAE,IAAI;KACb,CAAA;AACH,CAAC"}

22
node_modules/viem/_esm/accounts/index.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
// biome-ignore lint/performance/noBarrelFile: entrypoint module
export { HDKey } from '@scure/bip32';
export { createNonceManager, nonceManager, } from '../utils/nonceManager.js';
export {
/** @deprecated Use `serializeSignature` instead. */
serializeSignature as signatureToHex, serializeSignature, } from '../utils/signature/serializeSignature.js';
export { generateMnemonic, } from './generateMnemonic.js';
export { generatePrivateKey, } from './generatePrivateKey.js';
export { hdKeyToAccount, } from './hdKeyToAccount.js';
export { mnemonicToAccount, } from './mnemonicToAccount.js';
export { privateKeyToAccount, } from './privateKeyToAccount.js';
export { toAccount } from './toAccount.js';
export { parseAccount, } from './utils/parseAccount.js';
export { privateKeyToAddress, } from './utils/privateKeyToAddress.js';
export { publicKeyToAddress, } from './utils/publicKeyToAddress.js';
export { setSignEntropy, sign, } from './utils/sign.js';
export { signAuthorization, } from './utils/signAuthorization.js';
export { signMessage, } from './utils/signMessage.js';
export { signTransaction, } from './utils/signTransaction.js';
export { signTypedData, } from './utils/signTypedData.js';
export { czech, english, french, italian, japanese, korean, portuguese, simplifiedChinese, spanish, traditionalChinese, } from './wordlists.js';
//# sourceMappingURL=index.js.map

1
node_modules/viem/_esm/accounts/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEpC,OAAO,EAEL,kBAAkB,EAGlB,YAAY,GACb,MAAM,0BAA0B,CAAA;AACjC,OAAO;AAIL,oDAAoD;AACpD,kBAAkB,IAAI,cAAc,EACpC,kBAAkB,GACnB,MAAM,0CAA0C,CAAA;AACjD,OAAO,EAEL,gBAAgB,GACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAEL,kBAAkB,GACnB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAGL,cAAc,GACf,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAGL,iBAAiB,GAClB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAGL,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAA2B,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAWnE,OAAO,EAEL,YAAY,GACb,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAEL,mBAAmB,GACpB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAEL,kBAAkB,GACnB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAIL,cAAc,EACd,IAAI,GACL,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAIL,iBAAiB,GAClB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAIL,WAAW,GACZ,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAIL,eAAe,GAChB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAIL,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,OAAO,EACP,QAAQ,EACR,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,kBAAkB,GACnB,MAAM,gBAAgB,CAAA"}

13
node_modules/viem/_esm/accounts/mnemonicToAccount.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { HDKey } from '@scure/bip32';
import { mnemonicToSeedSync } from '@scure/bip39';
import { hdKeyToAccount, } from './hdKeyToAccount.js';
/**
* @description Creates an Account from a mnemonic phrase.
*
* @returns A HD Account.
*/
export function mnemonicToAccount(mnemonic, { passphrase, ...hdKeyOpts } = {}) {
const seed = mnemonicToSeedSync(mnemonic, passphrase);
return hdKeyToAccount(HDKey.fromMasterSeed(seed), hdKeyOpts);
}
//# sourceMappingURL=mnemonicToAccount.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"mnemonicToAccount.js","sourceRoot":"","sources":["../../accounts/mnemonicToAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAGjD,OAAO,EAGL,cAAc,GACf,MAAM,qBAAqB,CAAA;AAS5B;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,EAAE,UAAU,EAAE,GAAG,SAAS,KAA+B,EAAE;IAE3D,MAAM,IAAI,GAAG,kBAAkB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IACrD,OAAO,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAA;AAC9D,CAAC"}

44
node_modules/viem/_esm/accounts/privateKeyToAccount.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
import { secp256k1 } from '@noble/curves/secp256k1';
import { toHex } from '../utils/encoding/toHex.js';
import { toAccount } from './toAccount.js';
import { publicKeyToAddress, } from './utils/publicKeyToAddress.js';
import { sign } from './utils/sign.js';
import { signAuthorization } from './utils/signAuthorization.js';
import { signMessage } from './utils/signMessage.js';
import { signTransaction, } from './utils/signTransaction.js';
import { signTypedData, } from './utils/signTypedData.js';
/**
* @description Creates an Account from a private key.
*
* @returns A Private Key Account.
*/
export function privateKeyToAccount(privateKey, options = {}) {
const { nonceManager } = options;
const publicKey = toHex(secp256k1.getPublicKey(privateKey.slice(2), false));
const address = publicKeyToAddress(publicKey);
const account = toAccount({
address,
nonceManager,
async sign({ hash }) {
return sign({ hash, privateKey, to: 'hex' });
},
async signAuthorization(authorization) {
return signAuthorization({ ...authorization, privateKey });
},
async signMessage({ message }) {
return signMessage({ message, privateKey });
},
async signTransaction(transaction, { serializer } = {}) {
return signTransaction({ privateKey, transaction, serializer });
},
async signTypedData(typedData) {
return signTypedData({ ...typedData, privateKey });
},
});
return {
...account,
publicKey,
source: 'privateKey',
};
}
//# sourceMappingURL=privateKeyToAccount.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"privateKeyToAccount.js","sourceRoot":"","sources":["../../accounts/privateKeyToAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGnD,OAAO,EAAuB,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAEvE,OAAO,EAA2B,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAEnE,OAAO,EAEL,kBAAkB,GACnB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAsB,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,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;QAC3D,CAAC;KACF,CAAC,CAAA;IAEF,OAAO;QACL,GAAG,OAAO;QACV,SAAS;QACT,MAAM,EAAE,YAAY;KACA,CAAA;AACxB,CAAC"}

32
node_modules/viem/_esm/accounts/toAccount.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
// TODO(v3): Rename to `toLocalAccount` + add `source` property to define source (privateKey, mnemonic, hdKey, etc).
import { InvalidAddressError, } from '../errors/address.js';
import { isAddress, } from '../utils/address/isAddress.js';
/**
* @description Creates an Account from a custom signing implementation.
*
* @returns A Local Account.
*/
export function toAccount(source) {
if (typeof source === 'string') {
if (!isAddress(source, { strict: false }))
throw new InvalidAddressError({ address: source });
return {
address: source,
type: 'json-rpc',
};
}
if (!isAddress(source.address, { strict: false }))
throw new InvalidAddressError({ address: source.address });
return {
address: source.address,
nonceManager: source.nonceManager,
sign: source.sign,
signAuthorization: source.signAuthorization,
signMessage: source.signMessage,
signTransaction: source.signTransaction,
signTypedData: source.signTypedData,
source: 'custom',
type: 'local',
};
}
//# sourceMappingURL=toAccount.js.map

1
node_modules/viem/_esm/accounts/toAccount.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"toAccount.js","sourceRoot":"","sources":["../../accounts/toAccount.ts"],"names":[],"mappings":"AAAA,oHAAoH;AAIpH,OAAO,EACL,mBAAmB,GAEpB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAEL,SAAS,GACV,MAAM,+BAA+B,CAAA;AAiBtC;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,MAAqB;IAErB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;YACvC,MAAM,IAAI,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;QACpD,OAAO;YACL,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,UAAU;SACsB,CAAA;IAC1C,CAAC;IAED,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAC/C,MAAM,IAAI,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;IAC5D,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,OAAO;KACyB,CAAA;AAC1C,CAAC"}

2
node_modules/viem/_esm/accounts/types.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=types.js.map

1
node_modules/viem/_esm/accounts/types.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../accounts/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,6 @@
export function parseAccount(account) {
if (typeof account === 'string')
return { address: account, type: 'json-rpc' };
return account;
}
//# sourceMappingURL=parseAccount.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parseAccount.js","sourceRoot":"","sources":["../../../accounts/utils/parseAccount.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,YAAY,CAC1B,OAAyB;IAEzB,IAAI,OAAO,OAAO,KAAK,QAAQ;QAC7B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAS,CAAA;IACtD,OAAO,OAAc,CAAA;AACvB,CAAC"}

View File

@@ -0,0 +1,15 @@
import { secp256k1 } from '@noble/curves/secp256k1';
import { bytesToHex, } from '../../utils/encoding/toHex.js';
import { publicKeyToAddress, } from './publicKeyToAddress.js';
/**
* @description Converts an ECDSA private key to an address.
*
* @param privateKey The private key to convert.
*
* @returns The address.
*/
export function privateKeyToAddress(privateKey) {
const publicKey = bytesToHex(secp256k1.getPublicKey(privateKey.slice(2), false));
return publicKeyToAddress(publicKey);
}
//# sourceMappingURL=privateKeyToAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"privateKeyToAddress.js","sourceRoot":"","sources":["../../../accounts/utils/privateKeyToAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAKnD,OAAO,EAEL,UAAU,GACX,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAEL,kBAAkB,GACnB,MAAM,yBAAyB,CAAA;AAOhC;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAe;IACjD,MAAM,SAAS,GAAG,UAAU,CAC1B,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CACnD,CAAA;IACD,OAAO,kBAAkB,CAAC,SAAS,CAAC,CAAA;AACtC,CAAC"}

Some files were not shown because too many files have changed in this diff Show More