Moved fetcher to generic directory (methods have to remain public since it is in seperate package now), added FetchHash method, created ERC20 and generic getters which call the fetcher with specific contract methods (GetTotalSupply, GetBalance, GetAllowance for ERC20 getter, and GetOwner, GetStoppedStatus, GetStringName, GetHashName, GetStringSymbol, GetHashSymbol, and GetDecimals for generic getter). Getter tests cover all but GetBalance and GetAllowance, and also cover all of the Fetcher methods- but with only nil methodArgs. GetAllowance and GetBalance tests are not working against infura and these are the only contract method calls with arguments passed in so I suspect this might be where the issue lies. Have tested GetBalance using previous version of FetchContractData without the variadic input to the Pack method and it fails with the same error so I don’t think it is due to those changes.

This commit is contained in:
Ian Norden
2018-11-03 13:49:23 -05:00
parent 99e549b3df
commit 9b41000b88
15 changed files with 837 additions and 243 deletions
@@ -0,0 +1,33 @@
// Copyright 2018 Vulcanize
//
// 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 every_block_test
import (
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"io/ioutil"
"log"
)
func TestEveryBlock(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Generic EveryBlock Suite")
}
var _ = BeforeSuite(func() {
log.SetOutput(ioutil.Discard)
})
+84
View File
@@ -0,0 +1,84 @@
// Copyright 2018 Vulcanize
//
// 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 every_block
import (
"github.com/ethereum/go-ethereum/common"
"github.com/vulcanize/vulcanizedb/examples/generic"
"github.com/vulcanize/vulcanizedb/pkg/core"
"math/big"
)
// Getter serves as a higher level data fetcher that invokes its underlying Fetcher methods for a given contract method
// Interface definition for a Getter
type GenericGetterInterface interface {
GetOwner(contractAbi, contractAddress string, blockNumber int64) (common.Address, error)
GetStoppedStatus(contractAbi, contractAddress string, blockNumber int64) (bool, error)
GetStringName(contractAbi, contractAddress string, blockNumber int64) (string, error)
GetHashName(contractAbi, contractAddress string, blockNumber int64) (common.Hash, error)
GetStringSymbol(contractAbi, contractAddress string, blockNumber int64) (string, error)
GetHashSymbol(contractAbi, contractAddress string, blockNumber int64) (common.Hash, error)
GetDecimals(contractAbi, contractAddress string, blockNumber int64) (big.Int, error)
GetBlockChain() core.BlockChain
}
// Getter struct
type Getter struct {
fetcher generic.Fetcher // Underlying Fetcher
}
// Initializes and returns a Getter with the given blockchain
func NewGetter(blockChain core.BlockChain) Getter {
return Getter{
fetcher: generic.Fetcher{
BlockChain: blockChain,
},
}
}
// Public getter methods for calling contract methods
func (g Getter) GetOwner(contractAbi, contractAddress string, blockNumber int64) (common.Address, error) {
return g.fetcher.FetchAddress("owner", contractAbi, contractAddress, blockNumber, nil)
}
func (g Getter) GetStoppedStatus(contractAbi, contractAddress string, blockNumber int64) (bool, error) {
return g.fetcher.FetchBool("stopped", contractAbi, contractAddress, blockNumber, nil)
}
func (g Getter) GetStringName(contractAbi, contractAddress string, blockNumber int64) (string, error) {
return g.fetcher.FetchString("name", contractAbi, contractAddress, blockNumber, nil)
}
func (g Getter) GetHashName(contractAbi, contractAddress string, blockNumber int64) (common.Hash, error) {
return g.fetcher.FetchHash("name", contractAbi, contractAddress, blockNumber, nil)
}
func (g Getter) GetStringSymbol(contractAbi, contractAddress string, blockNumber int64) (string, error) {
return g.fetcher.FetchString("symbol", contractAbi, contractAddress, blockNumber, nil)
}
func (g Getter) GetHashSymbol(contractAbi, contractAddress string, blockNumber int64) (common.Hash, error) {
return g.fetcher.FetchHash("symbol", contractAbi, contractAddress, blockNumber, nil)
}
func (g Getter) GetDecimals(contractAbi, contractAddress string, blockNumber int64) (big.Int, error) {
return g.fetcher.FetchBigInt("decimals", contractAbi, contractAddress, blockNumber, nil)
}
// Method to retrieve the Getter's blockchain
func (g Getter) GetBlockChain() core.BlockChain {
return g.fetcher.BlockChain
}
+364
View File
@@ -0,0 +1,364 @@
// Copyright 2018 Vulcanize
//
// 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 every_block_test
import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/ethereum/go-ethereum/common"
"github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/generic/every_block"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/geth"
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
"math/big"
)
var _ = Describe("every_block Getter", func() {
blockNumber := int64(5502914)
Describe("stopped", func() {
It("checks whether or not the contract has been stopped", func() {
fakeBlockChain := fakes.NewMockBlockChain()
testGetter := every_block.NewGetter(fakeBlockChain)
testAbi := "testAbi"
testContractAddress := "testContractAddress"
_, err := testGetter.GetStoppedStatus(testAbi, testContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
var expectedResult bool
expected := &expectedResult
fakeBlockChain.AssertFetchContractDataCalledWith(testAbi, testContractAddress, "stopped", nil, &expected, blockNumber)
})
It("gets dai token's stopped status at the given block height", func() {
infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
rawRpcClient, err := rpc.Dial(infuraIPC)
Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, node, transactionConverter)
realGetter := every_block.NewGetter(blockChain)
result, err := realGetter.GetStoppedStatus(constants.DaiAbiString, constants.DaiContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
Expect(result).To(Equal(false))
})
It("returns an error if the call to the blockchain fails", func() {
blockChain := fakes.NewMockBlockChain()
blockChain.SetFetchContractDataErr(fakes.FakeError)
errorGetter := every_block.NewGetter(blockChain)
result, err := errorGetter.GetStoppedStatus("", "", 0)
Expect(result).To(Equal(false))
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("stopped"))
Expect(err.Error()).To(ContainSubstring(fakes.FakeError.Error()))
})
})
Describe("owner", func() {
It("checks what the contract's owner address is", func() {
fakeBlockChain := fakes.NewMockBlockChain()
testGetter := every_block.NewGetter(fakeBlockChain)
testAbi := "testAbi"
testContractAddress := "testContractAddress"
_, err := testGetter.GetOwner(testAbi, testContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
var expectedResult common.Address
expected := &expectedResult
fakeBlockChain.AssertFetchContractDataCalledWith(testAbi, testContractAddress, "owner", nil, &expected, blockNumber)
})
It("gets dai token's owner address at the given block height", func() {
infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
rawRpcClient, err := rpc.Dial(infuraIPC)
Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, node, transactionConverter)
realGetter := every_block.NewGetter(blockChain)
result, err := realGetter.GetOwner(constants.DaiAbiString, constants.DaiContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
expectedResult := common.HexToAddress("0x0000000000000000000000000000000000000000")
Expect(result).To(Equal(expectedResult))
})
It("returns an error if the call to the blockchain fails", func() {
blockChain := fakes.NewMockBlockChain()
blockChain.SetFetchContractDataErr(fakes.FakeError)
errorGetter := every_block.NewGetter(blockChain)
result, err := errorGetter.GetOwner("", "", 0)
expectedResult := new(common.Address)
Expect(result).To(Equal(*expectedResult))
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("owner"))
Expect(err.Error()).To(ContainSubstring(fakes.FakeError.Error()))
})
})
Describe("hash name", func() {
It("checks the contract's name", func() {
fakeBlockChain := fakes.NewMockBlockChain()
testGetter := every_block.NewGetter(fakeBlockChain)
testAbi := "testAbi"
testContractAddress := "testContractAddress"
_, err := testGetter.GetHashName(testAbi, testContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
var expectedResult common.Hash
expected := &expectedResult
fakeBlockChain.AssertFetchContractDataCalledWith(testAbi, testContractAddress, "name", nil, &expected, blockNumber)
})
It("gets dai token's name at the given blockheight", func() {
infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
rawRpcClient, err := rpc.Dial(infuraIPC)
Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, node, transactionConverter)
realGetter := every_block.NewGetter(blockChain)
result, err := realGetter.GetHashName(constants.DaiAbiString, constants.DaiContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
expectedResult := common.HexToHash("0x44616920537461626c65636f696e2076312e3000000000000000000000000000")
Expect(result).To(Equal(expectedResult))
})
It("returns an error if the call to the blockchain fails", func() {
blockChain := fakes.NewMockBlockChain()
blockChain.SetFetchContractDataErr(fakes.FakeError)
errorGetter := every_block.NewGetter(blockChain)
result, err := errorGetter.GetHashName("", "", 0)
expectedResult := new(common.Hash)
Expect(result).To(Equal(*expectedResult))
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("name"))
Expect(err.Error()).To(ContainSubstring(fakes.FakeError.Error()))
})
})
Describe("hash symbol", func() {
It("checks the contract's symbol", func() {
fakeBlockChain := fakes.NewMockBlockChain()
testGetter := every_block.NewGetter(fakeBlockChain)
testAbi := "testAbi"
testContractAddress := "testContractAddress"
_, err := testGetter.GetHashSymbol(testAbi, testContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
var expectedResult common.Hash
expected := &expectedResult
fakeBlockChain.AssertFetchContractDataCalledWith(testAbi, testContractAddress, "symbol", nil, &expected, blockNumber)
})
It("gets dai token's symbol at the given blockheight", func() {
infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
rawRpcClient, err := rpc.Dial(infuraIPC)
Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, node, transactionConverter)
realGetter := every_block.NewGetter(blockChain)
result, err := realGetter.GetHashSymbol(constants.DaiAbiString, constants.DaiContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
expectedResult := common.HexToHash("0x4441490000000000000000000000000000000000000000000000000000000000")
Expect(result).To(Equal(expectedResult))
})
It("returns an error if the call to the blockchain fails", func() {
blockChain := fakes.NewMockBlockChain()
blockChain.SetFetchContractDataErr(fakes.FakeError)
errorGetter := every_block.NewGetter(blockChain)
result, err := errorGetter.GetHashSymbol("", "", 0)
expectedResult := new(common.Hash)
Expect(result).To(Equal(*expectedResult))
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("symbol"))
Expect(err.Error()).To(ContainSubstring(fakes.FakeError.Error()))
})
})
Describe("decimals", func() {
It("checks what the token's number of decimals", func() {
fakeBlockChain := fakes.NewMockBlockChain()
testGetter := every_block.NewGetter(fakeBlockChain)
testAbi := "testAbi"
testContractAddress := "testContractAddress"
_, err := testGetter.GetDecimals(testAbi, testContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
var expectedResult big.Int
expected := &expectedResult
fakeBlockChain.AssertFetchContractDataCalledWith(testAbi, testContractAddress, "decimals", nil, &expected, blockNumber)
})
It("gets dai token's number of decimals at the given block height", func() {
infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
rawRpcClient, err := rpc.Dial(infuraIPC)
Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, node, transactionConverter)
realGetter := every_block.NewGetter(blockChain)
result, err := realGetter.GetDecimals(constants.DaiAbiString, constants.DaiContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
expectedResult := big.Int{}
expectedResult.SetString("18", 10)
Expect(result).To(Equal(expectedResult))
})
It("returns an error if the call to the blockchain fails", func() {
blockChain := fakes.NewMockBlockChain()
blockChain.SetFetchContractDataErr(fakes.FakeError)
errorGetter := every_block.NewGetter(blockChain)
result, err := errorGetter.GetDecimals("", "", 0)
expectedResult := new(big.Int)
Expect(result).To(Equal(*expectedResult))
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("decimals"))
Expect(err.Error()).To(ContainSubstring(fakes.FakeError.Error()))
})
})
Describe("string name", func() {
It("checks the contract's name", func() {
fakeBlockChain := fakes.NewMockBlockChain()
testGetter := every_block.NewGetter(fakeBlockChain)
testAbi := "testAbi"
testContractAddress := "testContractAddress"
_, err := testGetter.GetStringName(testAbi, testContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
var expectedResult string
expected := &expectedResult
fakeBlockChain.AssertFetchContractDataCalledWith(testAbi, testContractAddress, "name", nil, &expected, blockNumber)
})
It("gets tusd token's name at the given blockheight", func() {
infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
rawRpcClient, err := rpc.Dial(infuraIPC)
Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, node, transactionConverter)
realGetter := every_block.NewGetter(blockChain)
result, err := realGetter.GetStringName(constants.TusdAbiString, constants.TusdContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
expectedResult := "TrueUSD"
Expect(result).To(Equal(expectedResult))
})
It("returns an error if the call to the blockchain fails", func() {
blockChain := fakes.NewMockBlockChain()
blockChain.SetFetchContractDataErr(fakes.FakeError)
errorGetter := every_block.NewGetter(blockChain)
result, err := errorGetter.GetStringName("", "", 0)
expectedResult := new(string)
Expect(result).To(Equal(*expectedResult))
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("name"))
Expect(err.Error()).To(ContainSubstring(fakes.FakeError.Error()))
})
})
Describe("string symbol", func() {
It("checks the contract's symbol", func() {
fakeBlockChain := fakes.NewMockBlockChain()
testGetter := every_block.NewGetter(fakeBlockChain)
testAbi := "testAbi"
testContractAddress := "testContractAddress"
_, err := testGetter.GetStringSymbol(testAbi, testContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
var expectedResult string
expected := &expectedResult
fakeBlockChain.AssertFetchContractDataCalledWith(testAbi, testContractAddress, "symbol", nil, &expected, blockNumber)
})
It("gets tusd token's symbol at the given blockheight", func() {
infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
rawRpcClient, err := rpc.Dial(infuraIPC)
Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, node, transactionConverter)
realGetter := every_block.NewGetter(blockChain)
result, err := realGetter.GetStringName(constants.TusdAbiString, constants.TusdContractAddress, blockNumber)
Expect(err).NotTo(HaveOccurred())
expectedResult := "TrueUSD"
Expect(result).To(Equal(expectedResult))
})
It("returns an error if the call to the blockchain fails", func() {
blockChain := fakes.NewMockBlockChain()
blockChain.SetFetchContractDataErr(fakes.FakeError)
errorGetter := every_block.NewGetter(blockChain)
result, err := errorGetter.GetStringSymbol("", "", 0)
expectedResult := new(string)
Expect(result).To(Equal(*expectedResult))
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("symbol"))
Expect(err.Error()).To(ContainSubstring(fakes.FakeError.Error()))
})
})
})
+121
View File
@@ -0,0 +1,121 @@
// Copyright 2018 Vulcanize
//
// 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 generic
import (
"fmt"
"log"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/vulcanize/vulcanizedb/pkg/core"
)
// Fetcher serves as the lower level data fetcher that calls the underlying
// blockchain's FetchConctractData method for a given return type
// Interface definition for a Fetcher
type FetcherInterface interface {
FetchBigInt(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (big.Int, error)
FetchBool(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (bool, error)
FetchAddress(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (common.Address, error)
FetchString(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (string, error)
FetchHash(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (common.Hash, error)
}
// Used to create a new Fetcher error for a given error and fetch method
func newFetcherError(err error, fetchMethod string) *fetcherError {
e := fetcherError{err.Error(), fetchMethod}
log.Println(e.Error())
return &e
}
// Fetcher struct
type Fetcher struct {
BlockChain core.BlockChain // Underyling Blockchain
}
// Fetcher error
type fetcherError struct {
err string
fetchMethod string
}
// Fetcher error method
func (fe *fetcherError) Error() string {
return fmt.Sprintf("Error fetching %s: %s", fe.fetchMethod, fe.err)
}
// Generic Fetcher methods used by Getters to call contract methods
// Method used to fetch big.Int value from contract
func (f Fetcher) FetchBigInt(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (big.Int, error) {
var result = new(big.Int)
err := f.BlockChain.FetchContractData(contractAbi, contractAddress, method, methodArgs, &result, blockNumber)
if err != nil {
return *result, newFetcherError(err, method)
}
return *result, nil
}
// Method used to fetch bool value from contract
func (f Fetcher) FetchBool(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (bool, error) {
var result = new(bool)
err := f.BlockChain.FetchContractData(contractAbi, contractAddress, method, methodArgs, &result, blockNumber)
if err != nil {
return *result, newFetcherError(err, method)
}
return *result, nil
}
// Method used to fetch address value from contract
func (f Fetcher) FetchAddress(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (common.Address, error) {
var result = new(common.Address)
err := f.BlockChain.FetchContractData(contractAbi, contractAddress, method, methodArgs, &result, blockNumber)
if err != nil {
return *result, newFetcherError(err, method)
}
return *result, nil
}
// Method used to fetch string value from contract
func (f Fetcher) FetchString(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (string, error) {
var result = new(string)
err := f.BlockChain.FetchContractData(contractAbi, contractAddress, method, methodArgs, &result, blockNumber)
if err != nil {
return *result, newFetcherError(err, method)
}
return *result, nil
}
// Method used to fetch hash value from contract
func (f Fetcher) FetchHash(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (common.Hash, error) {
var result = new(common.Hash)
err := f.BlockChain.FetchContractData(contractAbi, contractAddress, method, methodArgs, &result, blockNumber)
if err != nil {
return *result, newFetcherError(err, method)
}
return *result, nil
}