2020-03-13 10:59:14 -07:00
|
|
|
package tx
|
2020-03-12 12:35:22 -07:00
|
|
|
|
|
|
|
import (
|
2020-03-24 13:36:12 -07:00
|
|
|
"bufio"
|
2021-03-25 03:52:54 -07:00
|
|
|
"context"
|
2020-03-24 13:36:12 -07:00
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2020-03-26 09:50:39 -07:00
|
|
|
|
2021-03-25 03:52:54 -07:00
|
|
|
gogogrpc "github.com/gogo/protobuf/grpc"
|
2020-06-30 13:59:21 -07:00
|
|
|
"github.com/spf13/pflag"
|
2020-03-24 13:36:12 -07:00
|
|
|
|
2020-06-01 05:46:03 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
2020-03-24 13:36:12 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/client/input"
|
2020-11-09 08:01:43 -08:00
|
|
|
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
2020-03-12 12:35:22 -07:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2020-04-15 14:55:02 -07:00
|
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
2020-09-10 11:26:47 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/types/tx"
|
2020-06-16 12:57:37 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
|
|
|
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
2020-03-12 12:35:22 -07:00
|
|
|
)
|
|
|
|
|
2020-06-30 13:59:21 -07:00
|
|
|
// GenerateOrBroadcastTxCLI will either generate and print and unsigned transaction
|
|
|
|
// or sign it and broadcast it returning an error upon failure.
|
|
|
|
func GenerateOrBroadcastTxCLI(clientCtx client.Context, flagSet *pflag.FlagSet, msgs ...sdk.Msg) error {
|
|
|
|
txf := NewFactoryCLI(clientCtx, flagSet)
|
|
|
|
return GenerateOrBroadcastTxWithFactory(clientCtx, txf, msgs...)
|
|
|
|
}
|
|
|
|
|
2020-05-21 14:29:34 -07:00
|
|
|
// GenerateOrBroadcastTxWithFactory will either generate and print and unsigned transaction
|
|
|
|
// or sign it and broadcast it returning an error upon failure.
|
2020-06-01 05:46:03 -07:00
|
|
|
func GenerateOrBroadcastTxWithFactory(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
|
2021-05-07 02:31:20 -07:00
|
|
|
// Validate all msgs before generating or broadcasting the tx.
|
|
|
|
// We were calling ValidateBasic separately in each CLI handler before.
|
|
|
|
// Right now, we're factorizing that call inside this function.
|
|
|
|
// ref: https://github.com/cosmos/cosmos-sdk/pull/9236#discussion_r623803504
|
|
|
|
for _, msg := range msgs {
|
2021-08-13 08:34:00 -07:00
|
|
|
if err := msg.ValidateBasic(); err != nil {
|
2021-05-07 02:31:20 -07:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-01 05:46:03 -07:00
|
|
|
if clientCtx.GenerateOnly {
|
2021-06-28 04:42:08 -07:00
|
|
|
return txf.PrintUnsignedTx(clientCtx, msgs...)
|
2020-03-24 13:36:12 -07:00
|
|
|
}
|
|
|
|
|
2020-06-01 05:46:03 -07:00
|
|
|
return BroadcastTx(clientCtx, txf, msgs...)
|
2020-03-24 13:36:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// BroadcastTx attempts to generate, sign and broadcast a transaction with the
|
|
|
|
// given set of messages. It will also simulate gas requirements if necessary.
|
|
|
|
// It will return an error upon failure.
|
2020-06-01 05:46:03 -07:00
|
|
|
func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
|
2021-06-28 04:42:08 -07:00
|
|
|
txf, err := txf.Prepare(clientCtx)
|
2020-03-24 13:36:12 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-06-01 05:46:03 -07:00
|
|
|
if txf.SimulateAndExecute() || clientCtx.Simulate {
|
2021-03-25 03:52:54 -07:00
|
|
|
_, adjusted, err := CalculateGas(clientCtx, txf, msgs...)
|
2020-03-24 13:36:12 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
txf = txf.WithGas(adjusted)
|
|
|
|
_, _ = fmt.Fprintf(os.Stderr, "%s\n", GasEstimateResponse{GasEstimate: txf.Gas()})
|
|
|
|
}
|
|
|
|
|
2020-06-01 05:46:03 -07:00
|
|
|
if clientCtx.Simulate {
|
2020-03-24 13:36:12 -07:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-06-28 04:42:08 -07:00
|
|
|
tx, err := txf.BuildUnsignedTx(msgs...)
|
2020-03-24 13:36:12 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-06-01 05:46:03 -07:00
|
|
|
if !clientCtx.SkipConfirm {
|
2020-08-21 08:43:12 -07:00
|
|
|
out, err := clientCtx.TxConfig.TxJSONEncoder()(tx.GetTx())
|
2020-03-24 13:36:12 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, _ = fmt.Fprintf(os.Stderr, "%s\n\n", out)
|
|
|
|
|
|
|
|
buf := bufio.NewReader(os.Stdin)
|
2020-04-08 02:38:28 -07:00
|
|
|
ok, err := input.GetConfirmation("confirm transaction before signing and broadcasting", buf, os.Stderr)
|
2020-04-29 19:36:34 -07:00
|
|
|
|
2020-03-24 13:36:12 -07:00
|
|
|
if err != nil || !ok {
|
|
|
|
_, _ = fmt.Fprintf(os.Stderr, "%s\n", "cancelled transaction")
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add fee grant module (#8061)
* Add docs
* Add BasicFeeAllowance implementation
* Add expiration structs and complete basic fee
* Add delegation messages, add validation logic
* Add keeper and helper structs
* Add alias and handler to top level
* Add delegation module
* Add basic querier
* Add types tests
* Add types tests
* More internal test coverage
* Solid internal test coverage
* Expose Querier to top level module
* Add FeeAccount to auth/types, like StdTx, SignDoc
* Fix all tests in x/auth
* All tests pass
* Appease the Golang Linter
* Add fee-account command line flag
* Start on DelegatedDeductFeeDecorator
* Cleanup the Decorator
* Wire up delegation module in simapp
* add basic test for decorator (no delegation)
* Table tests for deduct fees
* Table tests over all conditions of delegated fee decorator
* Build full ante handler stack and test it
* Start genesis
* Implement Genesis
* Rename package delegation to subkeys
* Clarify antes test cases, handle empty account w/o fees
* Allow paying delegated fees with no account
* Pull mempool into delegated ante, for control on StdFee
* Use custom DelegatedTx, DelegatedFee for subkeys
* Revert all changes to x/auth.StdTx
* Appease scopelint
* Register DelegatedTx with codec
* Address PR comments
* Remove unnecessary DelegatedMempoolFeeDecorator
* Cleaned up errors in querier
* Clean up message sign bytes
* Minor PR comments
* Replace GetAllFees... with Iterator variants
* PrepareForExport adjusts grant expiration height
* Panic on de/serialization error in keeper
* Move custom ante handler chain to tests, update docs
* More cleanup
* More doc cleanup
* Renamed subkeys module to fee_grant
* Rename subkeys/delegation to fee grant in all strings
* Modify Msg and Keeper methods to use Grant not Delegate
* Add PeriodicFeeAllowance
* Update aliases
* Cover all accept cases for PeriodicFeeAllowance
* Et tu scopelint?
* Update docs as requested
* Remove error return from GetFeeGrant
* Code cleanup as requested by PR
* Updated all errors to use new sdk/errors package
* Use test suite for keeper tests
* Clean up alias.go file
* Define expected interfaces in exported, rather than importing from account
* Remove dependency on auth/ante
* Improve godoc, Logger
* Cleaned up ExpiresAt
* Improve error reporting with UseGrantedFee
* Enforce period limit subset of basic limit
* Add events
* Rename fee_grant to feegrant
* Ensure KeeperTestSuite actually runs
* Move types/tx to types
* Update alias file, include ante
* I do need nolint in alias.go
* Properly emit events in the handler. Use cosmos-sdk in amino types
* Update godoc
* Linting...
* Update errors
* Update pkg doc and fix ante-handler order
* Merge PR #5782: Migrate x/feegrant to proto
* fix errors
* proto changes
* proto changes
* fix errors
* fix errors
* genesis state changed to proto
* fix keeper tests
* fix test
* fixed tests
* fix tests
* updated expected keepers
* updated ante tests
* lint
* deleted alias.go
* tx updated to proto tx
* remove explicit signmode
* tests
* Added `cli/query.go`
* Added tx.go in cli
* updated `module.go`
* resolve errors in tx.go
* Add fee payer gentx func
* updated tx
* fixed error
* WIP: cli tests
* fix query error
* fix tests
* Unused types and funcs
* fix tests
* rename helper func to create tx
* remove unused
* update tx cfg
* fix cli tests
* added simulations
* Add `decoder.go`
* fix build fail
* added init genesis code
* update tx.go
* fixed LGTM alert
* modified cli
* remove gogoproto extensions
* change acc address type to string
* lint
* fix simulations
* Add gen simulations
* remove legacy querier
* remove legacy code
* add grpc queries tests
* fix simulations
* update module.go
* lint
* register feegrant NewSimulationManager
* fix sims
* fix sims
* add genesis test
* add periodic grant
* updated cmd
* changed times
* updated flags
* removed days as period clock
* added condition for period and exp
* add periodic fee cli tests
* udpated tests
* fix lint
* fix tests
* fix sims
* renaming to `fee_grant`
* review changes
* fix test
* add condition for duplicate grants
* fix tests
* add `genTxWithFeeGranter` in tests
* fix simulation
* one of changes & test fixes
* fix test
* fix lint
* changed package name `feegrant` to `fee_grant`
* review comments
* review changes
* review change
* review changes
* added fee-account in flags
* address review changes
* read fee granter from cli
* updated create account with mnemonic
* Address review comments
* move `simapp/ante` file to `feegrant/ante`
* update keeper logic to create account
* update docs
* fix tests
* update `serviceMsgClientConn` from `msgservice`
* review changes
* add test case for using more fees than allowed
* eliminate panic checks from keeper
* fix lint
* change store keys string to bytes
* fix tests
* review changes
* review changes
* udpate docs
* make spend limit optional
* fix tests
* fix tests
* review changes
* add norace tag
* proto-docs
* add docs
Co-authored-by: Ethan Frey <ethanfrey@users.noreply.github.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
Co-authored-by: SaReN <sahithnarahari@gmail.com>
Co-authored-by: aleem1413 <aleem@vitwit.com>
Co-authored-by: MD Aleem <72057206+aleem1314@users.noreply.github.com>
Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-01-29 11:54:51 -08:00
|
|
|
tx.SetFeeGranter(clientCtx.GetFeeGranterAddress())
|
2020-12-14 13:44:15 -08:00
|
|
|
err = Sign(txf, clientCtx.GetFromName(), tx, true)
|
2020-06-16 12:57:37 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-07-20 05:30:12 -07:00
|
|
|
txBytes, err := clientCtx.TxConfig.TxEncoder()(tx.GetTx())
|
2020-03-24 13:36:12 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// broadcast to a Tendermint node
|
2020-06-01 05:46:03 -07:00
|
|
|
res, err := clientCtx.BroadcastTx(txBytes)
|
2020-03-24 13:36:12 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-12-08 12:17:40 -08:00
|
|
|
return clientCtx.PrintProto(res)
|
2020-03-24 13:36:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// CalculateGas simulates the execution of a transaction and returns the
|
|
|
|
// simulation response obtained by the query and the adjusted gas amount.
|
|
|
|
func CalculateGas(
|
2021-03-25 03:52:54 -07:00
|
|
|
clientCtx gogogrpc.ClientConn, txf Factory, msgs ...sdk.Msg,
|
|
|
|
) (*tx.SimulateResponse, uint64, error) {
|
2021-06-28 04:42:08 -07:00
|
|
|
txBytes, err := txf.BuildSimTx(msgs...)
|
2020-03-25 11:23:34 -07:00
|
|
|
if err != nil {
|
2021-03-25 03:52:54 -07:00
|
|
|
return nil, 0, err
|
2020-03-25 11:23:34 -07:00
|
|
|
}
|
|
|
|
|
2021-03-25 03:52:54 -07:00
|
|
|
txSvcClient := tx.NewServiceClient(clientCtx)
|
|
|
|
simRes, err := txSvcClient.Simulate(context.Background(), &tx.SimulateRequest{
|
|
|
|
TxBytes: txBytes,
|
|
|
|
})
|
2020-03-24 13:36:12 -07:00
|
|
|
if err != nil {
|
2021-03-25 03:52:54 -07:00
|
|
|
return nil, 0, err
|
2020-03-24 13:36:12 -07:00
|
|
|
}
|
|
|
|
|
2020-09-01 13:59:48 -07:00
|
|
|
return simRes, uint64(txf.GasAdjustment() * float64(simRes.GasInfo.GasUsed)), nil
|
2020-03-24 13:36:12 -07:00
|
|
|
}
|
|
|
|
|
2020-07-20 05:30:12 -07:00
|
|
|
// SignWithPrivKey signs a given tx with the given private key, and returns the
|
|
|
|
// corresponding SignatureV2 if the signing is successful.
|
|
|
|
func SignWithPrivKey(
|
2020-07-22 08:02:36 -07:00
|
|
|
signMode signing.SignMode, signerData authsigning.SignerData,
|
2020-11-09 08:01:43 -08:00
|
|
|
txBuilder client.TxBuilder, priv cryptotypes.PrivKey, txConfig client.TxConfig,
|
2020-08-21 07:20:47 -07:00
|
|
|
accSeq uint64,
|
2020-07-20 05:30:12 -07:00
|
|
|
) (signing.SignatureV2, error) {
|
|
|
|
var sigV2 signing.SignatureV2
|
|
|
|
|
2020-07-30 06:22:31 -07:00
|
|
|
// Generate the bytes to be signed.
|
|
|
|
signBytes, err := txConfig.SignModeHandler().GetSignBytes(signMode, signerData, txBuilder.GetTx())
|
2020-07-20 05:30:12 -07:00
|
|
|
if err != nil {
|
|
|
|
return sigV2, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sign those bytes
|
|
|
|
signature, err := priv.Sign(signBytes)
|
|
|
|
if err != nil {
|
|
|
|
return sigV2, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct the SignatureV2 struct
|
|
|
|
sigData := signing.SingleSignatureData{
|
|
|
|
SignMode: signMode,
|
|
|
|
Signature: signature,
|
|
|
|
}
|
2020-07-22 08:02:36 -07:00
|
|
|
|
2020-07-20 05:30:12 -07:00
|
|
|
sigV2 = signing.SignatureV2{
|
2020-08-21 07:20:47 -07:00
|
|
|
PubKey: priv.PubKey(),
|
|
|
|
Data: &sigData,
|
|
|
|
Sequence: accSeq,
|
2020-07-20 05:30:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return sigV2, nil
|
|
|
|
}
|
|
|
|
|
2020-12-14 13:44:15 -08:00
|
|
|
func checkMultipleSigners(mode signing.SignMode, tx authsigning.Tx) error {
|
|
|
|
if mode == signing.SignMode_SIGN_MODE_DIRECT &&
|
|
|
|
len(tx.GetSigners()) > 1 {
|
|
|
|
return sdkerrors.Wrap(sdkerrors.ErrNotSupported, "Signing in DIRECT mode is only supported for transactions with one signer only")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sign signs a given tx with a named key. The bytes signed over are canconical.
|
|
|
|
// The resulting signature will be added to the transaction builder overwriting the previous
|
|
|
|
// ones if overwrite=true (otherwise, the signature will be appended).
|
|
|
|
// Signing a transaction with mutltiple signers in the DIRECT mode is not supprted and will
|
|
|
|
// return an error.
|
2020-07-22 08:02:36 -07:00
|
|
|
// An error is returned upon failure.
|
2020-12-14 13:44:15 -08:00
|
|
|
func Sign(txf Factory, name string, txBuilder client.TxBuilder, overwriteSig bool) error {
|
2020-03-24 13:36:12 -07:00
|
|
|
if txf.keybase == nil {
|
2020-06-16 12:57:37 -07:00
|
|
|
return errors.New("keybase must be set prior to signing a transaction")
|
|
|
|
}
|
|
|
|
|
|
|
|
signMode := txf.signMode
|
|
|
|
if signMode == signing.SignMode_SIGN_MODE_UNSPECIFIED {
|
|
|
|
// use the SignModeHandler's default mode if unspecified
|
2020-07-20 05:30:12 -07:00
|
|
|
signMode = txf.txConfig.SignModeHandler().DefaultMode()
|
2020-03-24 13:36:12 -07:00
|
|
|
}
|
2020-12-14 13:44:15 -08:00
|
|
|
if err := checkMultipleSigners(signMode, txBuilder.GetTx()); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-03-24 13:36:12 -07:00
|
|
|
|
2021-09-20 05:02:15 -07:00
|
|
|
k, err := txf.keybase.Key(name)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
pubKey, err := k.GetPubKey()
|
2020-03-24 13:36:12 -07:00
|
|
|
if err != nil {
|
2020-06-16 12:57:37 -07:00
|
|
|
return err
|
2020-03-24 13:36:12 -07:00
|
|
|
}
|
2021-09-14 02:42:42 -07:00
|
|
|
|
|
|
|
pubkeys, err := txBuilder.GetTx().GetPubKeys()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
signerIndex := 0
|
|
|
|
for i, p := range pubkeys {
|
|
|
|
if p.Equals(pubKey) {
|
|
|
|
signerIndex = i
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-20 05:30:12 -07:00
|
|
|
signerData := authsigning.SignerData{
|
2020-08-21 07:20:47 -07:00
|
|
|
ChainID: txf.chainID,
|
|
|
|
AccountNumber: txf.accountNumber,
|
|
|
|
Sequence: txf.sequence,
|
2021-09-14 02:42:42 -07:00
|
|
|
SignerIndex: signerIndex,
|
2020-03-24 13:36:12 -07:00
|
|
|
}
|
|
|
|
|
2020-08-21 07:20:47 -07:00
|
|
|
// For SIGN_MODE_DIRECT, calling SetSignatures calls setSignerInfos on
|
2020-07-30 06:22:31 -07:00
|
|
|
// TxBuilder under the hood, and SignerInfos is needed to generated the
|
|
|
|
// sign bytes. This is the reason for setting SetSignatures here, with a
|
|
|
|
// nil signature.
|
|
|
|
//
|
|
|
|
// Note: this line is not needed for SIGN_MODE_LEGACY_AMINO, but putting it
|
|
|
|
// also doesn't affect its generated sign bytes, so for code's simplicity
|
|
|
|
// sake, we put it here.
|
|
|
|
sigData := signing.SingleSignatureData{
|
|
|
|
SignMode: signMode,
|
|
|
|
Signature: nil,
|
|
|
|
}
|
|
|
|
sig := signing.SignatureV2{
|
2020-08-21 07:20:47 -07:00
|
|
|
PubKey: pubKey,
|
|
|
|
Data: &sigData,
|
|
|
|
Sequence: txf.Sequence(),
|
2020-07-30 06:22:31 -07:00
|
|
|
}
|
2020-12-14 13:44:15 -08:00
|
|
|
var prevSignatures []signing.SignatureV2
|
|
|
|
if !overwriteSig {
|
|
|
|
prevSignatures, err = txBuilder.GetTx().GetSignaturesV2()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-07-30 06:22:31 -07:00
|
|
|
if err := txBuilder.SetSignatures(sig); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate the bytes to be signed.
|
2020-12-14 13:44:15 -08:00
|
|
|
bytesToSign, err := txf.txConfig.SignModeHandler().GetSignBytes(signMode, signerData, txBuilder.GetTx())
|
2020-06-16 12:57:37 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-04-15 14:55:02 -07:00
|
|
|
|
2020-07-20 05:30:12 -07:00
|
|
|
// Sign those bytes
|
2020-12-14 13:44:15 -08:00
|
|
|
sigBytes, _, err := txf.keybase.Sign(name, bytesToSign)
|
2020-06-16 12:57:37 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-04-15 14:55:02 -07:00
|
|
|
}
|
|
|
|
|
2020-07-20 05:30:12 -07:00
|
|
|
// Construct the SignatureV2 struct
|
2020-07-30 06:22:31 -07:00
|
|
|
sigData = signing.SingleSignatureData{
|
2020-07-20 05:30:12 -07:00
|
|
|
SignMode: signMode,
|
|
|
|
Signature: sigBytes,
|
|
|
|
}
|
2020-07-30 06:22:31 -07:00
|
|
|
sig = signing.SignatureV2{
|
2020-08-21 07:20:47 -07:00
|
|
|
PubKey: pubKey,
|
|
|
|
Data: &sigData,
|
|
|
|
Sequence: txf.Sequence(),
|
2020-04-15 14:55:02 -07:00
|
|
|
}
|
|
|
|
|
2020-12-14 13:44:15 -08:00
|
|
|
if overwriteSig {
|
|
|
|
return txBuilder.SetSignatures(sig)
|
|
|
|
}
|
|
|
|
prevSignatures = append(prevSignatures, sig)
|
|
|
|
return txBuilder.SetSignatures(prevSignatures...)
|
2020-03-24 13:36:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// GasEstimateResponse defines a response definition for tx gas estimation.
|
|
|
|
type GasEstimateResponse struct {
|
|
|
|
GasEstimate uint64 `json:"gas_estimate" yaml:"gas_estimate"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (gr GasEstimateResponse) String() string {
|
|
|
|
return fmt.Sprintf("gas estimate: %d", gr.GasEstimate)
|
|
|
|
}
|