Skip to content

Commit

Permalink
Merge pull request #84 from kaleido-io/gas-estimate
Browse files Browse the repository at this point in the history
Add GasEstimate FFCAPI implementation
  • Loading branch information
peterbroadhurst authored May 25, 2023
2 parents 4d57847 + 8a07615 commit bfe784f
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cmd/config_docs_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

func TestGenerateConfigDocs(t *testing.T) {
// Initialize config of all plugins
initConfig()
InitConfig()
f, err := os.Create(filepath.Join("..", "config.md"))
assert.NoError(t, err)
generatedConfig, err := config.GenerateConfigMarkdown(context.Background(), "", config.GetKnownKeys())
Expand Down
8 changes: 7 additions & 1 deletion config.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
|clientAuth|Enables or disables client auth for TLS on this API|`string`|`<nil>`
|enabled|Enables or disables TLS on this API|`boolean`|`false`
|keyFile|The path to the private key file for TLS on this API|`string`|`<nil>`
|requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`<nil>`

## confirmations

Expand Down Expand Up @@ -108,6 +109,7 @@
|clientAuth|Enables or disables client auth for TLS on this API|`string`|`<nil>`
|enabled|Enables or disables TLS on this API|`boolean`|`false`
|keyFile|The path to the private key file for TLS on this API|`string`|`<nil>`
|requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`<nil>`

## cors

Expand Down Expand Up @@ -219,6 +221,7 @@
|clientAuth|Enables or disables client auth for TLS on this API|`string`|`<nil>`
|enabled|Enables or disables TLS on this API|`boolean`|`false`
|keyFile|The path to the private key file for TLS on this API|`string`|`<nil>`
|requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`<nil>`

## persistence

Expand Down Expand Up @@ -296,6 +299,7 @@
|clientAuth|Enables or disables client auth for TLS on this API|`string`|`<nil>`
|enabled|Enables or disables TLS on this API|`boolean`|`false`
|keyFile|The path to the private key file for TLS on this API|`string`|`<nil>`
|requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`<nil>`

## policyloop

Expand Down Expand Up @@ -384,6 +388,7 @@
|clientAuth|Enables or disables client auth for TLS on this API|`string`|`<nil>`
|enabled|Enables or disables TLS on this API|`boolean`|`false`
|keyFile|The path to the private key file for TLS on this API|`string`|`<nil>`
|requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`<nil>`

## transactions.handler.simple.retry

Expand Down Expand Up @@ -437,4 +442,5 @@
|certFile|The path to the certificate file for TLS on this API|`string`|`<nil>`
|clientAuth|Enables or disables client auth for TLS on this API|`string`|`<nil>`
|enabled|Enables or disables TLS on this API|`boolean`|`false`
|keyFile|The path to the private key file for TLS on this API|`string`|`<nil>`
|keyFile|The path to the private key file for TLS on this API|`string`|`<nil>`
|requiredDNAttributes|A set of required subject DN attributes. Each entry is a regular expression, and the subject certificate must have a matching attribute of the specified type (CN, C, O, OU, ST, L, STREET, POSTALCODE, SERIALNUMBER are valid attributes)|`map[string]string`|`<nil>`
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ go 1.19

require (
github.com/hashicorp/golang-lru v0.5.4
github.com/hyperledger/firefly-common v1.2.10
github.com/hyperledger/firefly-signer v1.1.7
github.com/hyperledger/firefly-transaction-manager v1.2.11
github.com/hyperledger/firefly-common v1.2.11
github.com/hyperledger/firefly-signer v1.1.8
github.com/hyperledger/firefly-transaction-manager v1.2.13
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.6.1
github.com/stretchr/testify v1.8.1
Expand All @@ -28,7 +28,7 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/getkin/kin-openapi v0.107.0 // indirect
github.com/getkin/kin-openapi v0.116.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
Expand Down Expand Up @@ -57,6 +57,7 @@ require (
github.com/oklog/ulid/v2 v2.1.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/perimeterx/marshmallow v1.1.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
Expand Down
24 changes: 16 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/getkin/kin-openapi v0.107.0 h1:bxhL6QArW7BXQj8NjXfIJQy680NsMKd25nwhvpCXchg=
github.com/getkin/kin-openapi v0.107.0/go.mod h1:9Dhr+FasATJZjS4iOLvB0hkaxgYdulrNYm2e9epLWOo=
github.com/getkin/kin-openapi v0.116.0 h1:o986hwgMzR972JzOG5j6+WTwWqllZLs1EJKMKCivs2E=
github.com/getkin/kin-openapi v0.116.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
Expand All @@ -115,6 +115,8 @@ github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -194,12 +196,12 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huandu/xstrings v1.3.1 h1:4jgBlKK6tLKFvO8u5pmYjG91cqytmDCDvGh7ECVFfFs=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/hyperledger/firefly-common v1.2.10 h1:im+GPaTnv764WmNvmtFFXz7+wx2IXg58Pf8AtDapM5o=
github.com/hyperledger/firefly-common v1.2.10/go.mod h1:kSAawo5is7RKWh3e9PMdWuR/OitfHAaAWVSK6V4lX80=
github.com/hyperledger/firefly-signer v1.1.7 h1:u0dITAM25V3406au5aShM2h829PeH86dQ0vnZ5HcnT8=
github.com/hyperledger/firefly-signer v1.1.7/go.mod h1:L05Rws/+A/IXDsNgubGFxstxmr40ZI82dzRKIFpj208=
github.com/hyperledger/firefly-transaction-manager v1.2.11 h1:48s28Q4zuYnFOkWJ080i0DLFnp41bd1YhJ35HT43YlY=
github.com/hyperledger/firefly-transaction-manager v1.2.11/go.mod h1:m9YeQPICf3688BCJoGVaYs31uSN7BjKISRUbLz3zjlU=
github.com/hyperledger/firefly-common v1.2.11 h1:ePDHJtorKE6ss8PtoPlyqLb+cB0TDB7ziM85Gtyerqs=
github.com/hyperledger/firefly-common v1.2.11/go.mod h1:17lOH4YufiPy82LpKm8fPa/YXJ0pUyq01zK1CmklJwM=
github.com/hyperledger/firefly-signer v1.1.8 h1:XyJjZXesih2dWYG31m5ZYt4irH7/PdkRutMPld7AqKE=
github.com/hyperledger/firefly-signer v1.1.8/go.mod h1:vNbbROziwqkOmO0b+9ky3devjcFg0JIkR2M1KG7seTQ=
github.com/hyperledger/firefly-transaction-manager v1.2.13 h1:qMBN3Eviaxn96b2zsSBpwZ/vEt3X+ojW8B+p3UzhOjg=
github.com/hyperledger/firefly-transaction-manager v1.2.13/go.mod h1:HjSAX2HoB/XccjXPD2h3z8owUMWrPYjspxLD55sRLnE=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
Expand Down Expand Up @@ -279,6 +281,8 @@ github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3v
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
github.com/perimeterx/marshmallow v1.1.4 h1:pZLDH9RjlLGGorbXhcaQLhfuV0pFMNfPO55FuFkxqLw=
github.com/perimeterx/marshmallow v1.1.4/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -356,6 +360,10 @@ github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs
github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
37 changes: 36 additions & 1 deletion internal/ethereum/estimate_gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ package ethereum
import (
"context"
"encoding/json"
"fmt"
"math/big"

"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly-common/pkg/i18n"
"github.com/hyperledger/firefly-common/pkg/log"
"github.com/hyperledger/firefly-evmconnect/internal/msgs"
Expand All @@ -30,7 +32,40 @@ import (
"github.com/hyperledger/firefly-transaction-manager/pkg/ffcapi"
)

func (c *ethConnector) estimateGas(ctx context.Context, tx *ethsigner.Transaction, method *abi.Entry, errors []*abi.Entry) (*ethtypes.HexInteger, ffcapi.ErrorReason, error) {
func (c *ethConnector) GasEstimate(ctx context.Context, transaction *ffcapi.TransactionInput) (*ffcapi.GasEstimateResponse, ffcapi.ErrorReason, error) {

tx := &ethsigner.Transaction{
Nonce: (*ethtypes.HexInteger)(transaction.Nonce),
GasLimit: (*ethtypes.HexInteger)(transaction.Gas),
Value: (*ethtypes.HexInteger)(transaction.Value),
}

// Parse the from address
from, err := ethtypes.NewAddress(transaction.From)
if err != nil {
return nil, "", i18n.NewError(ctx, msgs.MsgInvalidFromAddress, transaction.From, err)
}
tx.From = json.RawMessage(fmt.Sprintf(`"%s"`, from))

// Parse the to address - required for preparing an invoke, and must be valid if set
var to *ethtypes.Address0xHex
if transaction.To != "" {
to, err = ethtypes.NewAddress(transaction.To)
if err != nil {
return nil, "", i18n.NewError(ctx, msgs.MsgInvalidToAddress, transaction.To, err)
}
tx.To = to
}

// Do the gas estimation
gasEstimate, reason, err := c.gasEstimate(ctx, tx, nil, nil)
if err != nil {
return nil, reason, err
}
return &ffcapi.GasEstimateResponse{GasEstimate: (*fftypes.FFBigInt)(gasEstimate)}, "", nil
}

func (c *ethConnector) gasEstimate(ctx context.Context, tx *ethsigner.Transaction, method *abi.Entry, errors []*abi.Entry) (*ethtypes.HexInteger, ffcapi.ErrorReason, error) {

// Do the gas estimation
var gasEstimate ethtypes.HexInteger
Expand Down
92 changes: 92 additions & 0 deletions internal/ethereum/estimate_gas_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright © 2022 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ethereum

import (
"encoding/json"
"testing"

"github.com/hyperledger/firefly-signer/pkg/ethsigner"
"github.com/hyperledger/firefly-signer/pkg/ethtypes"
"github.com/hyperledger/firefly-signer/pkg/rpcbackend"
"github.com/hyperledger/firefly-transaction-manager/pkg/ffcapi"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

const sampleGasEstimate = `{
"ffcapi": {
"version": "v1.0.0",
"id": "904F177C-C790-4B01-BDF4-F2B4E52E607E",
"type": "get_address_balance"
},
"to": "0x4a8c8f1717570f9774652075e249ded38124d708",
"from": "0x73bd8f17787a0f9774652075e2ba5ed381246bef",
"value": "100000000",
"nonce": "0x01"
}`

func TestGasEstimateOK(t *testing.T) {

ctx, c, mRPC, done := newTestConnector(t)
defer done()

mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_estimateGas",
mock.MatchedBy(func(tx *ethsigner.Transaction) bool {
return true
})).
Return(nil).
Run(func(args mock.Arguments) {
args[1].(*ethtypes.HexInteger).BigInt().SetString("12345", 10)
})

var req ffcapi.TransactionInput
err := json.Unmarshal([]byte(sampleGasEstimate), &req)
assert.NoError(t, err)
res, reason, err := c.GasEstimate(ctx, &req)
assert.NoError(t, err)
assert.Empty(t, reason)

assert.Equal(t, int64(18517) /* 1.5 uplift */, res.GasEstimate.Int64())

}

func TestGasEstimateFail(t *testing.T) {

ctx, c, mRPC, done := newTestConnector(t)
defer done()

mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_estimateGas",
mock.MatchedBy(func(tx *ethsigner.Transaction) bool {
return true
})).
Return(&rpcbackend.RPCError{Message: "pop"})
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_call", mock.Anything, "latest").Run(
func(args mock.Arguments) {
*(args[1].(*ethtypes.HexBytes0xPrefix)) = ethtypes.MustNewHexBytes0xPrefix("0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000114d75707065747279206465746563746564000000000000000000000000000000")
},
).Return(nil)

var req ffcapi.TransactionInput
err := json.Unmarshal([]byte(sampleGasEstimate), &req)
assert.NoError(t, err)
res, reason, err := c.GasEstimate(ctx, &req)
assert.Regexp(t, "FF23021", err)
assert.Equal(t, ffcapi.ErrorReasonTransactionReverted, reason)
assert.Nil(t, res)

}
25 changes: 14 additions & 11 deletions internal/ethereum/exec_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,22 @@ func (c *ethConnector) callTransaction(ctx context.Context, tx *ethsigner.Transa
return nil, ffcapi.ErrorReasonTransactionReverted, i18n.NewError(ctx, msgs.MsgReverted, revertReason)
}

// Parse the data against the outputs
var jsonData []byte
outputValueTree, err := method.Outputs.DecodeABIDataCtx(ctx, outputData, 0)
if err == nil {
// Serialize down to JSON, and wrap in a JSONAny
jsonData, err = c.serializer.SerializeJSONCtx(ctx, outputValueTree)
}
if err != nil {
log.L(ctx).Warnf("Invalid return data: %s", outputData)
return nil, "", i18n.NewError(ctx, msgs.MsgReturnDataInvalid, err)
if method != nil {
// Parse the data against the outputs
var jsonData []byte
outputValueTree, err := method.Outputs.DecodeABIDataCtx(ctx, outputData, 0)
if err == nil {
// Serialize down to JSON, and wrap in a JSONAny
jsonData, err = c.serializer.SerializeJSONCtx(ctx, outputValueTree)
}
if err != nil {
log.L(ctx).Warnf("Invalid return data: %s", outputData)
return nil, "", i18n.NewError(ctx, msgs.MsgReturnDataInvalid, err)
}
return fftypes.JSONAnyPtrBytes(jsonData), "", nil
}
return fftypes.JSONAnyPtrBytes(jsonData), "", nil

return nil, mapError(callRPCMethods, rpcErr.Error()), rpcErr.Error()
}

// processRevertReason returns under 3 different circumstances:
Expand Down
2 changes: 1 addition & 1 deletion internal/ethereum/prepare_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func buildErrorsABI(ctx context.Context, errorSpecs []*fftypes.JSONAny) ([]*abi.
func (c *ethConnector) ensureGasEstimate(ctx context.Context, tx *ethsigner.Transaction, method *abi.Entry, errors []*abi.Entry, gasRequest *fftypes.FFBigInt) (*fftypes.FFBigInt, ffcapi.ErrorReason, error) {
if gasRequest == nil || gasRequest.Int().Sign() == 0 {
// If a value for gas has not been supplied, do a gas estimate
gas, reason, err := c.estimateGas(ctx, tx, method, errors)
gas, reason, err := c.gasEstimate(ctx, tx, method, errors)
if err != nil {
return nil, reason, err
}
Expand Down

0 comments on commit bfe784f

Please sign in to comment.