Skip to content

Commit

Permalink
more types
Browse files Browse the repository at this point in the history
  • Loading branch information
drortirosh committed Jun 26, 2023
1 parent 4aa1a44 commit 5b1336e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions gascalc/GasChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class GasChecker {
}

// generate the account "creation code"
async accountInitCode (factory: SimpleAccountFactory, salt: BigNumberish): string {
async accountInitCode (factory: SimpleAccountFactory, salt: BigNumberish): Promise<string> {
return concat([
await resolveAddress(factory.target),
factory.interface.encodeFunctionData('createAccount', [this.accountOwner.address, salt])
Expand Down Expand Up @@ -256,7 +256,7 @@ export class GasChecker {
).catch(e => {
const data = e.error?.data?.data ?? e.error?.data
if (data != null) {
const e1 = GasCheckCollector.inst.entryPoint.interface.parseError(data)
const e1 = GasCheckCollector.inst.entryPoint.interface.parseError(data)!
throw new Error(`${e1.name}(${e1.args?.toString()})`)
}
throw e
Expand Down
2 changes: 1 addition & 1 deletion src/AASigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export class AASigner extends AbstractSigner {

let initCode: BytesLike | undefined
if (this._isPhantom) {
initCode = getAccountInitCode(await this.signer.getAddress(), this.accountFactory)
initCode = await getAccountInitCode(await this.signer.getAddress(), this.accountFactory)
}
const execFromEntryPoint = await this._account!.execute.populateTransaction(tx.to!, tx.value ?? 0, tx.data!)

Expand Down
24 changes: 12 additions & 12 deletions test/entrypoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ describe('EntryPoint', function () {

it('should fail creation for wrong sender', async () => {
const op1 = await fillAndSign({
initCode: getAccountInitCode(accountOwner1.address, simpleAccountFactory),
initCode: await getAccountInitCode(accountOwner1.address, simpleAccountFactory),
sender: '0x'.padEnd(42, '1'),
verificationGasLimit: 3e6
}, accountOwner1, entryPoint)
Expand All @@ -328,7 +328,7 @@ describe('EntryPoint', function () {
})

it('should report failure on insufficient verificationGas (OOG) for creation', async () => {
const initCode = getAccountInitCode(accountOwner1.address, simpleAccountFactory).toString()
const initCode = await getAccountInitCode(accountOwner1.address, simpleAccountFactory)
const sender = await entryPoint.getSenderAddress.staticCall(initCode).catch(parseGetSenderAddressResult) as AddressLike
const op0 = await fillAndSign({
initCode,
Expand All @@ -354,7 +354,7 @@ describe('EntryPoint', function () {
const sender = await getAccountAddress(accountOwner1.address, simpleAccountFactory)
const op1 = await fillAndSign({
sender,
initCode: getAccountInitCode(accountOwner1.address, simpleAccountFactory)
initCode: await getAccountInitCode(accountOwner1.address, simpleAccountFactory)
}, accountOwner1, entryPoint)
await fund(op1.sender)

Expand All @@ -378,7 +378,7 @@ describe('EntryPoint', function () {

it('should not use banned ops during simulateValidation', async () => {
const op1 = await fillAndSign({
initCode: getAccountInitCode(accountOwner1.address, simpleAccountFactory),
initCode: await getAccountInitCode(accountOwner1.address, simpleAccountFactory),
sender: await getAccountAddress(accountOwner1.address, simpleAccountFactory)
}, accountOwner1, entryPoint)
await fund(op1.sender)
Expand Down Expand Up @@ -850,7 +850,7 @@ describe('EntryPoint', function () {

it('should reject create if sender address is wrong', async () => {
const op = await fillAndSign({
initCode: getAccountInitCode(accountOwner.address, simpleAccountFactory),
initCode: await getAccountInitCode(accountOwner.address, simpleAccountFactory),
verificationGasLimit: 2e6,
sender: '0x'.padEnd(42, '1')
}, accountOwner, entryPoint)
Expand All @@ -862,7 +862,7 @@ describe('EntryPoint', function () {

it('should reject create if account not funded', async () => {
const op = await fillAndSign({
initCode: getAccountInitCode(accountOwner.address, simpleAccountFactory, 100),
initCode: await getAccountInitCode(accountOwner.address, simpleAccountFactory, 100),
verificationGasLimit: 2e6
}, accountOwner, entryPoint)

Expand All @@ -882,7 +882,7 @@ describe('EntryPoint', function () {
const preAddr = await getAccountAddress(accountOwner.address, simpleAccountFactory, salt)
await fund(preAddr)
createOp = await fillAndSign({
initCode: getAccountInitCode(accountOwner.address, simpleAccountFactory, salt),
initCode: await getAccountInitCode(accountOwner.address, simpleAccountFactory, salt),
callGasLimit: 1e6,
verificationGasLimit: 2e6

Expand Down Expand Up @@ -942,7 +942,7 @@ describe('EntryPoint', function () {
await fund(account2.target)
// execute and increment counter
const op1 = await fillAndSign({
initCode: getAccountInitCode(accountOwner1.address, simpleAccountFactory),
initCode: await getAccountInitCode(accountOwner1.address, simpleAccountFactory),
callData: accountExecCounterFromEntryPoint.data,
callGasLimit: 2e6,
verificationGasLimit: 2e6
Expand Down Expand Up @@ -1177,7 +1177,7 @@ describe('EntryPoint', function () {
const op = await fillAndSign({
paymasterAndData: pm,
callData: accountExecFromEntryPoint.data,
initCode: getAccountInitCode(account2Owner.address, simpleAccountFactory),
initCode: await getAccountInitCode(account2Owner.address, simpleAccountFactory),
verificationGasLimit: 3e6,
callGasLimit: 1e6
}, account2Owner, entryPoint)
Expand All @@ -1188,7 +1188,7 @@ describe('EntryPoint', function () {
const op = await fillAndSign({
paymasterAndData: await resolveAddress(paymaster.target),
callData: accountExecFromEntryPoint.data,
initCode: getAccountInitCode(account2Owner.address, simpleAccountFactory),
initCode: await getAccountInitCode(account2Owner.address, simpleAccountFactory),

verificationGasLimit: 3e6,
callGasLimit: 1e6
Expand All @@ -1202,7 +1202,7 @@ describe('EntryPoint', function () {
const op = await fillAndSign({
paymasterAndData: await resolveAddress(paymaster.target),
callData: accountExecFromEntryPoint.data,
initCode: getAccountInitCode(account2Owner.address, simpleAccountFactory)
initCode: await getAccountInitCode(account2Owner.address, simpleAccountFactory)
}, account2Owner, entryPoint)
const beneficiaryAddress = createAddress()

Expand All @@ -1219,7 +1219,7 @@ describe('EntryPoint', function () {
const op = await fillAndSign({
paymasterAndData: await resolveAddress(paymaster.target),
callData: accountExecFromEntryPoint.data,
initCode: getAccountInitCode(anOwner.address, simpleAccountFactory)
initCode: await getAccountInitCode(anOwner.address, simpleAccountFactory)
}, anOwner, entryPoint)

const { paymasterInfo } = await entryPoint.simulateValidation.staticCall(op).catch(simulationResultCatch)
Expand Down
2 changes: 1 addition & 1 deletion test/testutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function calcGasUsage (rcpt: ContractTransactionReceipt, entryPoint
}

// helper function to create the initCode to deploy the account, using our account factory.
export function getAccountInitCode (owner: string, factory: SimpleAccountFactory, salt = 0): string {
export async function getAccountInitCode (owner: string, factory: SimpleAccountFactory, salt = 0): Promise<string> {
return concat([
await resolveAddress(factory.target),
factory.interface.encodeFunctionData('createAccount', [owner, salt])
Expand Down

0 comments on commit 5b1336e

Please sign in to comment.