-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: allow signerless account registration #16
Conversation
WalkthroughThe changes introduce a new feature allowing accounts with a balance to be registered without requiring a signer. This includes the addition of a Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant Keeper
participant BankKeeper
User->>CLI: Register Account Signerlessly
CLI->>Keeper: Create MsgRegisterAccount
Keeper->>BankKeeper: Check Account Balance
BankKeeper-->>Keeper: Return Balance
Keeper-->>CLI: Account Registered Successfully
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@coderabbitai review |
Actions performedReview triggered.
|
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.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (4)
x/forwarding/ante.go (4)
130-139
: Add documentation for the function.The function is correctly implemented, but it lacks documentation. Consider adding a docstring to explain the purpose and behavior of the function.
+// SigVerificationGasConsumer handles signature verification for ForwardingPubKey and delegates to the default gas consumer for other types. func SigVerificationGasConsumer( meter storetypes.GasMeter, sig signing.SignatureV2, params authtypes.Params, ) error { switch sig.PubKey.(type) { case *types.ForwardingPubKey: return nil default: return ante.DefaultSigVerificationGasConsumer(meter, sig, params) } }
143-146
: Add documentation for the struct.The struct is correctly implemented, but it lacks documentation. Consider adding a docstring to explain the purpose and behavior of the struct.
+// SigVerificationDecorator wraps an existing signature verification decorator and incorporates a bank keeper. type SigVerificationDecorator struct { underlying ante.SigVerificationDecorator bank types.BankKeeper }
150-155
: Add documentation for the function.The function is correctly implemented, but it lacks documentation. Consider adding a docstring to explain the purpose and behavior of the function.
+// NewSigVerificationDecorator instantiates the SigVerificationDecorator. func NewSigVerificationDecorator(ak ante.AccountKeeper, bk types.BankKeeper, signModeHandler authsigning.SignModeHandler) SigVerificationDecorator { return SigVerificationDecorator{ underlying: ante.NewSigVerificationDecorator(ak, signModeHandler), bank: bk, } }
157-175
: Add documentation and improve error handling.The function is correctly implemented, but it lacks documentation. Additionally, the logic for handling
MsgRegisterAccount
could benefit from improved error handling. Consider adding a docstring to explain the purpose and behavior of the function and improving error handling forMsgRegisterAccount
.+// AnteHandle handles the transaction validation process for SigVerificationDecorator. func (d SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { if msgs := tx.GetMsgs(); len(msgs) == 1 { msg, ok := msgs[0].(*types.MsgRegisterAccount) if !ok { return d.underlying.AnteHandle(ctx, tx, simulate, next) } address := types.GenerateAddress(msg.Channel, msg.Recipient) balance := d.bank.GetAllBalances(ctx, address) if balance.IsZero() || msg.Signer != address.String() { - return d.underlying.AnteHandle(ctx, tx, simulate, next) + return ctx, fmt.Errorf("invalid MsgRegisterAccount message: insufficient balance or incorrect signer") } return next(ctx, tx, simulate) } return d.underlying.AnteHandle(ctx, tx, simulate, next) }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
x/forwarding/types/account.pb.go
is excluded by!**/*.pb.go
Files selected for processing (7)
- .changelog/unreleased/features/17-signerless-registration.md (1 hunks)
- proto/noble/forwarding/v1/account.proto (1 hunks)
- x/forwarding/ante.go (2 hunks)
- x/forwarding/client/cli/tx.go (3 hunks)
- x/forwarding/keeper/msg_server.go (1 hunks)
- x/forwarding/types/account.go (2 hunks)
- x/forwarding/types/codec.go (2 hunks)
Additional comments not posted (13)
.changelog/unreleased/features/17-signerless-registration.md (1)
1-1
: LGTM!The changelog entry is concise and correctly formatted.
proto/noble/forwarding/v1/account.proto (1)
17-22
: LGTM!The
ForwardingPubKey
message is well-defined and thegogoproto_stringer
option is correctly set tofalse
.x/forwarding/types/codec.go (1)
31-31
: LGTM!The
ForwardingPubKey
type is correctly registered as an implementation of thecryptotypes.PubKey
interface.x/forwarding/types/account.go (7)
38-38
: LGTM!The variable assertion correctly ensures that
ForwardingPubKey
satisfies thecryptotypes.PubKey
interface.
40-42
: LGTM!The
String
method is correctly implemented and follows best practices.
44-44
: LGTM!The
Address
method is correctly implemented and follows best practices.
46-46
: LGTM!The
Bytes
method is correctly implemented and follows best practices.
48-50
: LGTM!The
VerifySignature
method is correctly implemented to indicate that signature verification is not applicable for this type.
52-58
: LGTM!The
Equals
method is correctly implemented and follows best practices.
60-60
: LGTM!The
Type
method is correctly implemented and follows best practices.x/forwarding/keeper/msg_server.go (1)
32-34
: LGTM!The modified logic is correctly implemented and enhances the functionality of the account registration process.
x/forwarding/client/cli/tx.go (1)
53-116
: LGTM!The new command
TxRegisterAccountSignerlessly
is correctly implemented and follows best practices.x/forwarding/ante.go (1)
6-11
: LGTM!The import statements are necessary for the new functionality.
Summary by CodeRabbit
New Features
Enhancements
ForwardingPubKey
, has been introduced for better cryptographic operations and identity verification.Bug Fixes