-
Notifications
You must be signed in to change notification settings - Fork 0
Verifying paymaster #16
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f419474
Update contract ABI and re-generate go code
boqiu 1ed3615
rename gas tank paymaster file
boqiu 127b3f7
Extract blockchain util file
boqiu ba1167c
Add verifying paymaster service
boqiu 8b56a57
Add API for verifying paymaster
boqiu 89ae646
Add swagger docs for verifying paymaster APIs
boqiu 7194eed
Fix some bugs
boqiu 29a50aa
Add unit tests for verifying paymaster
boqiu 2ccaf4d
Fix copilot comment
boqiu 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 hidden or 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 hidden or 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,65 @@ | ||
| package api | ||
|
|
||
| import ( | ||
| "github.com/Conflux-Chain/fluent-backend/service" | ||
| "github.com/Conflux-Chain/go-conflux-util/api" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/ethereum/go-ethereum/common/hexutil" | ||
| "github.com/gin-gonic/gin" | ||
| ) | ||
|
|
||
| type VerifyingPaymasterController struct { | ||
| services service.Services | ||
| } | ||
|
|
||
| func NewVerifyingPaymasterController(services service.Services) *VerifyingPaymasterController { | ||
| return &VerifyingPaymasterController{services} | ||
| } | ||
|
|
||
| // Stub returns the stub paymasterData of verifying paymaster for gas estimation. | ||
| // | ||
| // @ID aaPaymasterStub | ||
| // @Summary Returns the stub paymasterData of verifying paymaster for gas estimation | ||
| // @Description Returns the stub paymasterData of verifying paymaster for gas estimation. | ||
| // @Tags Paymaster | ||
| // @Accept json | ||
| // @Produce json | ||
| // @Success 200 {object} api.BusinessError{data=string} "Paymaster and data (0x-prefixed hex)" | ||
| // @Failure 600 {object} api.BusinessError{data=string} "Internal server error" | ||
| // @Router /aa/paymaster/stub [get] | ||
| func (controller *VerifyingPaymasterController) Stub(c *gin.Context) (any, error) { | ||
| stub := controller.services.VerifyingPaymaster.Stub() | ||
|
|
||
| return hexutil.Encode(stub), nil | ||
| } | ||
|
|
||
| // Sign validates the given user operation, signs the paymasterData and returns the reassembled paymasterData. | ||
| // | ||
| // @ID aaPaymasterSign | ||
| // @Summary Sign paymasterData of given user operation and return reassembled paymasterData | ||
| // @Description Validates the given UserOperation, adds paymaster signature, and returns reassembled paymasterData. | ||
| // @Description Encoding format (129 bytes): paymaster(20) || paymasterVerificationGasLimit(16) || paymasterPostOpGasLimit(16) || validAfter(6) || validUntil(6) || signature(65). | ||
| // @Tags Paymaster | ||
| // @Accept json | ||
| // @Produce json | ||
| // @Param userOp body UserOperationWithAuth true "UserOperation for paymaster signing" | ||
| // @Success 200 {object} api.BusinessError{data=string} "Signed and reassembled paymasterData (0x-prefixed hex, 129 bytes)" | ||
| // @Failure 600 {object} api.BusinessError{data=string} "Internal server error" | ||
| // @Router /aa/paymaster/sign [post] | ||
| func (controller *VerifyingPaymasterController) Sign(c *gin.Context) (any, error) { | ||
| var input UserOperationWithAuth | ||
|
|
||
| if err := c.ShouldBind(&input); err != nil { | ||
| return nil, api.ErrValidation(err) | ||
| } | ||
|
|
||
| userOp := input.ToPackedUserOperation() | ||
| delegatedContract := common.HexToAddress(input.DelegatedContract) | ||
|
|
||
| paymasterData, err := controller.services.VerifyingPaymaster.Sign(userOp, delegatedContract) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return hexutil.Encode(paymasterData), nil | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.