-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #677 from bcnmy/feature/new-user-op
feat: new userOp structure for EPv0.7
- Loading branch information
Showing
51 changed files
with
1,307 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { | ||
FinalUserOperationDataType, | ||
IUserOperationV07DAO, | ||
InitialUserOperationV07DataType, | ||
} from "../interface"; | ||
import { IUserOperationV07, Mongo } from "../mongo"; | ||
|
||
export class UserOperationV07DAO implements IUserOperationV07DAO { | ||
private _db: Mongo; | ||
|
||
constructor() { | ||
this._db = Mongo.getInstance(); | ||
} | ||
|
||
async save( | ||
chainId: number, | ||
userOperationData: InitialUserOperationV07DataType, | ||
): Promise<void> { | ||
await this._db.getUserOperationV07(chainId).insertMany([userOperationData]); | ||
} | ||
|
||
async getUserOperationsDataByApiKey( | ||
chainId: number, | ||
bundlerApiKey: string, | ||
startTime: number, | ||
endTime: number, | ||
limit: number, | ||
offSet: number, | ||
): Promise<Array<IUserOperationV07>> { | ||
const data = await this._db | ||
.getUserOperationV07(chainId) | ||
.aggregate([ | ||
{ | ||
$match: { | ||
$and: [ | ||
{ "metaData.dappAPIKey": bundlerApiKey }, | ||
{ creationTime: { $gte: startTime } }, | ||
{ creationTime: { $lte: endTime } }, | ||
], | ||
}, | ||
}, | ||
]) | ||
.skip(offSet) | ||
.limit(limit); | ||
return data; | ||
} | ||
|
||
async getUserOperationDataByUserOpHash( | ||
chainId: number, | ||
userOpHash: string, | ||
): Promise<IUserOperationV07 | null> { | ||
const data = await this._db | ||
.getUserOperationV07(chainId) | ||
.findOne({ userOpHash }); | ||
return data; | ||
} | ||
|
||
async updateUserOpDataToDatabaseByTransactionIdAndUserOpHash( | ||
chainId: number, | ||
transactionId: string, | ||
userOpHash: string, | ||
userOperationData: FinalUserOperationDataType, | ||
): Promise<void> { | ||
await this._db.getUserOperationV07(chainId).updateOne( | ||
{ | ||
transactionId, | ||
userOpHash, | ||
}, | ||
userOperationData, | ||
); | ||
} | ||
|
||
async getUserOpsByTransactionId( | ||
chainId: number, | ||
transactionId: string, | ||
): Promise<IUserOperationV07[]> { | ||
const data = await this._db | ||
.getUserOperationV07(chainId) | ||
.find({ | ||
transactionId, | ||
}) | ||
.sort({ _id: -1 }) | ||
.lean(); | ||
return data; | ||
} | ||
|
||
async getUserOperationsCountByApiKey( | ||
chainId: number, | ||
bundlerApiKey: string, | ||
startTime: number, | ||
endTime: number, | ||
): Promise<number> { | ||
const data = await this._db.getUserOperationV07(chainId).count({ | ||
"metaData.dappAPIKey": bundlerApiKey, | ||
creationTime: { $gte: startTime, $lte: endTime }, | ||
}); | ||
return data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./TransactionDAO"; | ||
export * from "./UserOperationDAO"; | ||
export * from "./UserOperationStateDAO"; | ||
export * from "./UserOperationV07DAO"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { IUserOperationV07 } from "../mongo/interface"; | ||
|
||
export type InitialUserOperationV07DataType = { | ||
transactionId: string; | ||
dappAPIKey?: string; | ||
entryPoint: string; | ||
sender: string; | ||
nonce: number; | ||
callData: string; | ||
callGasLimit: number; | ||
verificationGasLimit: number; | ||
preVerificationGas: number; | ||
maxFeePerGas: number; | ||
maxPriorityFeePerGas: number; | ||
signature: string; | ||
userOpHash: string; | ||
chainId: number; | ||
status: string; | ||
paymaster: string; | ||
paymasterVerificationGasLimit: number; | ||
paymasterPostOpGasLimit: number; | ||
factory: string; | ||
factoryData: string; | ||
paymasterData: string; | ||
creationTime: number; | ||
metaData?: object; | ||
}; | ||
|
||
export type FinalUserOperationV07DataType = { | ||
transactionHash?: string; | ||
receipt: object; | ||
status: string; | ||
success: string; | ||
blockNumber: number; | ||
blockHash: string; | ||
actualGasCost: number; | ||
actualGasUsed: number; | ||
reason: string; | ||
logs: any; | ||
}; | ||
|
||
export interface IUserOperationV07DAO { | ||
save( | ||
chainId: number, | ||
initialUserOperationData: InitialUserOperationV07DataType, | ||
): Promise<void>; | ||
getUserOperationDataByUserOpHash( | ||
chainId: number, | ||
userOpHash: string, | ||
): Promise<IUserOperationV07 | null>; | ||
updateUserOpDataToDatabaseByTransactionIdAndUserOpHash( | ||
chainId: number, | ||
userOpHash: string, | ||
transactionId: string, | ||
initialUserOperationData: FinalUserOperationV07DataType, | ||
): Promise<void>; | ||
getUserOpsByTransactionId( | ||
chainId: number, | ||
transactionId: string, | ||
): Promise<IUserOperationV07[]>; | ||
getUserOperationsDataByApiKey( | ||
chainId: number, | ||
bundlerApiKey: string, | ||
startTime: number, | ||
endTime: number, | ||
limit: number, | ||
offSet: number, | ||
): Promise<Array<IUserOperationV07>>; | ||
getUserOperationsCountByApiKey( | ||
chainId: number, | ||
bundlerApiKey: string, | ||
startTime: number, | ||
endTime: number, | ||
): Promise<number>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from "./IDBService"; | ||
export * from "./ITransactionDAO"; | ||
export * from "./IUserOperationDAO"; | ||
export * from "./IUserOperationV07DAO"; | ||
export * from "./IUserOperationStateDAO"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,4 @@ export interface IUserOperation { | |
creationTime: number; | ||
metaData: object; | ||
dappAPIKey: string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export interface IUserOperationV07 { | ||
transactionId: string; | ||
transactionHash: string; | ||
entryPoint: string; | ||
sender: string; | ||
nonce: number; | ||
factory: string; | ||
factoryData: string, | ||
callData: string; | ||
callGasLimit: number; | ||
verificationGasLimit: number; | ||
preVerificationGas: number; | ||
maxFeePerGas: number; | ||
maxPriorityFeePerGas: number; | ||
signature: string; | ||
userOpHash: string; | ||
receipt: object; | ||
chainId: number; | ||
status: string; | ||
success: string; | ||
blockNumber: number; | ||
blockHash: string; | ||
paymaster: string; | ||
actualGasCost: number; | ||
actualGasUsed: number; | ||
reason: string; | ||
logs: object; | ||
creationTime: number; | ||
metaData: object; | ||
dappAPIKey: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./IBlockchainTransaction"; | ||
export * from "./IUserOperation"; | ||
export * from "./IUserOperationState"; | ||
export * from "./IUserOperationV07"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.