Skip to content
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: add auto gas and fee estimations #3510

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/user/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func (s *Signer) CreateTx(msgs []sdktypes.Msg, opts ...TxOption) ([]byte, error)
}

func (s *Signer) SignTx(msgs []sdktypes.Msg, opts ...TxOption) (authsigning.Tx, string, uint64, error) {
txBuilder := s.txBuilder(opts...)
if err := txBuilder.SetMsgs(msgs...); err != nil {
txBuilder, err := s.txBuilder(msgs, opts...)
if err != nil {
return nil, "", 0, err
}

Expand Down Expand Up @@ -272,12 +272,16 @@ func (s *Signer) createSignature(builder client.TxBuilder, account *Account, seq
}

// txBuilder returns the default sdk Tx builder using the celestia-app encoding config
func (s *Signer) txBuilder(opts ...TxOption) client.TxBuilder {
func (s *Signer) txBuilder(msgs []sdktypes.Msg, opts ...TxOption) (client.TxBuilder, error) {
builder := s.enc.NewTxBuilder()
if err := builder.SetMsgs(msgs...); err != nil {
return nil, err
}

for _, opt := range opts {
builder = opt(builder)
}
return builder
return builder, nil
Comment on lines +275 to +284
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor txBuilder to simplify error handling and improve readability.

- if err := builder.SetMsgs(msgs...); err != nil {
-   return nil, err
- }
+ err := builder.SetMsgs(msgs...)
+ if err != nil {
+   return nil, err
+ }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func (s *Signer) txBuilder(msgs []sdktypes.Msg, opts ...TxOption) (client.TxBuilder, error) {
builder := s.enc.NewTxBuilder()
if err := builder.SetMsgs(msgs...); err != nil {
return nil, err
}
for _, opt := range opts {
builder = opt(builder)
}
return builder
return builder, nil
func (s *Signer) txBuilder(msgs []sdktypes.Msg, opts ...TxOption) (client.TxBuilder, error) {
builder := s.enc.NewTxBuilder()
err := builder.SetMsgs(msgs...)
if err != nil {
return nil, err
}
for _, opt := range opts {
builder = opt(builder)
}
return builder, nil

}

func (s *Signer) getSignatureV2(sequence uint64, pubKey cryptotypes.PubKey, signature []byte) signing.SignatureV2 {
Expand Down
Loading
Loading