Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for EP7.0 and Etherspot's Modular accounts #126

Merged
Merged
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/sdk/base/BaseAccountAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ export abstract class BaseAccountAPI {
* Sign the filled userOp.
* @param userOp the UserOperation to sign (with signature field ignored)
*/
async signUserOp(userOp: any): Promise<any> {
async signUserOp(userOp: UserOperation): Promise<UserOperation> {
if (this.paymasterAPI != null) {
const paymasterAndData = await this.paymasterAPI.getPaymasterAndData(userOp);
userOp.paymasterAndData = paymasterAndData.result.paymasterAndData;
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/base/ERC4337EthersProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class ERC4337EthersProvider extends BaseProvider {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
wait: async (confirmations?: number): Promise<TransactionReceipt> => {
const transactionReceipt = await waitPromise;
if (userOp.factory != null) {
if (userOp.factory != null && userOp.factory.length > 0) {
// checking if the wallet has been deployed by the transaction; it must be if we are here
await this.smartAccountAPI.checkAccountPhantom();
}
Expand Down
10 changes: 2 additions & 8 deletions src/sdk/base/EtherspotWalletAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ export class EtherspotWalletAPI extends BaseAccountAPI {
throw new Error('the module is already installed')
}

const installModuleInterface = new ethers.utils.Interface(['function installModule(uint256 moduleTypeId,address module,bytes initData)']);
const installModuleData = installModuleInterface.encodeFunctionData('installModule', [moduleTypeId, module, initData]);

return installModuleData;
return accountContract.interface.encodeFunctionData('installModule', [moduleTypeId, module, initData]);
}

async uninstallModule(moduleTypeId: MODULE_TYPE, module: string, deinitData: string): Promise<string> {
Expand All @@ -69,10 +66,7 @@ export class EtherspotWalletAPI extends BaseAccountAPI {
throw new Error('the module is not installed in the wallet')
}

const uninstallModuleInterface = new ethers.utils.Interface(['function uninstallModule(uint256 moduleTypeId,address module,bytes deInitData)']);
const uninstallModuleData = uninstallModuleInterface.encodeFunctionData('uninstallModule', [moduleTypeId, module, deinitData]);

return uninstallModuleData;
return accountContract.interface.encodeFunctionData('uninstallModule', [moduleTypeId, module, deinitData]);
}

async checkAccountAddress(address: string): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/base/HttpRpcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class HttpRpcClient {
}
}

async getVerificationGasInfo(tx: any): Promise<any> {
async getVerificationGasInfo(tx: UserOperationStruct): Promise<any> {
const hexifiedUserOp = deepHexlify(await resolveProperties(tx));
try {
const response = await this.userOpJsonRpcProvider.send('eth_estimateUserOperationGas', [hexifiedUserOp, this.entryPointAddress]);
Expand Down
3 changes: 3 additions & 0 deletions src/sdk/base/VerifyingPaymasterAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export class VerifyingPaymasterAPI extends PaymasterAPI {
// A dummy value here is required in order to calculate a correct preVerificationGas value.
paymasterData: DUMMY_PAYMASTER_AND_DATA,
kaushalrajbacancy marked this conversation as resolved.
Show resolved Hide resolved
signature: userOp.signature ?? '0x',
paymaster: userOp?.paymaster,
paymasterVerificationGasLimit: userOp?.paymasterVerificationGasLimit,
paymasterPostOpGasLimit: userOp?.paymasterPostOpGasLimit,
};
const op = await ethers.utils.resolveProperties(pmOp);
op.preVerificationGas = calcPreVerificationGas(op);
Expand Down
1 change: 1 addition & 0 deletions src/sdk/common/ERC4337Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface UserOperation {
paymasterVerificationGasLimit?: BigNumberish
paymasterPostOpGasLimit?: BigNumberish
paymasterData?: BytesLike
paymasterAndData?: BytesLike
kaushalrajbacancy marked this conversation as resolved.
Show resolved Hide resolved
signature: BytesLike
}

Expand Down