-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: new userOp structure for EPv0.7 #677
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6fa4dac
feat: add new UserOp type
veljkovranic 704e67b
current state of work
veljkovranic 84214ea
huge update dealing with queue
veljkovranic 1a053b6
fix tests
veljkovranic c108ecc
oops
veljkovranic 78b7c52
initial fixes from PR
veljkovranic db56034
wip
veljkovranic f423c0f
refactor changes
veljkovranic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,70 @@ | ||
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; | ||
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; | ||
veljkovranic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check if we have Mongo indexes on these fields?
It's also a good opportunity to setup a connection to our MongoDB and browse the data if you didn't do it so far.
@TakGN can give you instructions how to connect to the prod database.