From 5c18639ef4b083f247e6c4a80e6cc8edc0039c26 Mon Sep 17 00:00:00 2001 From: Eric Meyer Date: Thu, 30 Nov 2017 16:15:32 -0600 Subject: [PATCH 1/2] Extract Attributes to contract struct --- pkg/core/blockchain.go | 6 +- pkg/fakes/blockchain.go | 25 +++-- pkg/geth/contract.go | 31 ++++-- pkg/geth/contract_test.go | 172 +++++++++++++++---------------- pkg/watched_contracts/summary.go | 4 +- 5 files changed, 128 insertions(+), 110 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 162a1f7a..c70be78c 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1,10 +1,14 @@ package core +type Contract struct { + Attributes ContractAttributes +} + type Blockchain interface { GetBlockByNumber(blockNumber int64) Block SubscribeToBlocks(blocks chan Block) StartListening() StopListening() - GetContractAttributes(contractHash string) (ContractAttributes, error) + GetContract(contractHash string) (Contract, error) GetContractStateAttribute(contractHash string, attributeName string) (interface{}, error) } diff --git a/pkg/fakes/blockchain.go b/pkg/fakes/blockchain.go index 6cea88f6..e1c933aa 100644 --- a/pkg/fakes/blockchain.go +++ b/pkg/fakes/blockchain.go @@ -13,16 +13,9 @@ type Blockchain struct { WasToldToStop bool } -func (blockchain *Blockchain) GetContractAttributes(contractHash string) (core.ContractAttributes, error) { - var contractAttributes core.ContractAttributes - attributes, ok := blockchain.contractAttributes[contractHash] - if ok { - for key, _ := range attributes { - contractAttributes = append(contractAttributes, core.ContractAttribute{Name: key, Type: "string"}) - } - } - sort.Sort(contractAttributes) - return contractAttributes, nil +func (blockchain *Blockchain) GetContract(contractHash string) (core.Contract, error) { + contractAttributes, err := blockchain.getContractAttributes(contractHash) + return core.Contract{Attributes: contractAttributes}, err } func (blockchain *Blockchain) GetContractStateAttribute(contractHash string, attributeName string) (interface{}, error) { @@ -73,3 +66,15 @@ func (blockchain *Blockchain) SetContractStateAttribute(contractHash string, att } blockchain.contractAttributes[contractHash][attributeName] = attributeValue } + +func (blockchain *Blockchain) getContractAttributes(contractHash string) (core.ContractAttributes, error) { + var contractAttributes core.ContractAttributes + attributes, ok := blockchain.contractAttributes[contractHash] + if ok { + for key, _ := range attributes { + contractAttributes = append(contractAttributes, core.ContractAttribute{Name: key, Type: "string"}) + } + } + sort.Sort(contractAttributes) + return contractAttributes, nil +} diff --git a/pkg/geth/contract.go b/pkg/geth/contract.go index 56eba35a..82a3fb7b 100644 --- a/pkg/geth/contract.go +++ b/pkg/geth/contract.go @@ -17,18 +17,13 @@ var ( ErrInvalidStateAttribute = errors.New("invalid state attribute") ) -func (blockchain *GethBlockchain) GetContractAttributes(contractHash string) (core.ContractAttributes, error) { - abiFilePath := filepath.Join(config.ProjectRoot(), "contracts", "public", fmt.Sprintf("%s.json", contractHash)) - parsed, _ := ParseAbiFile(abiFilePath) - var contractAttributes core.ContractAttributes - for _, abiElement := range parsed.Methods { - if (len(abiElement.Outputs) > 0) && (len(abiElement.Inputs) == 0) && abiElement.Const { - attributeType := abiElement.Outputs[0].Type.String() - contractAttributes = append(contractAttributes, core.ContractAttribute{abiElement.Name, attributeType}) - } +func (blockchain *GethBlockchain) GetContract(contractHash string) (core.Contract, error) { + attributes, err := blockchain.getContractAttributes(contractHash) + if err != nil { + return core.Contract{}, err + } else { + return core.Contract{Attributes: attributes}, nil } - sort.Sort(contractAttributes) - return contractAttributes, nil } func (blockchain *GethBlockchain) GetContractStateAttribute(contractHash string, attributeName string) (interface{}, error) { @@ -44,6 +39,20 @@ func (blockchain *GethBlockchain) GetContractStateAttribute(contractHash string, return result, nil } +func (blockchain *GethBlockchain) getContractAttributes(contractHash string) (core.ContractAttributes, error) { + abiFilePath := filepath.Join(config.ProjectRoot(), "contracts", "public", fmt.Sprintf("%s.json", contractHash)) + parsed, _ := ParseAbiFile(abiFilePath) + var contractAttributes core.ContractAttributes + for _, abiElement := range parsed.Methods { + if (len(abiElement.Outputs) > 0) && (len(abiElement.Inputs) == 0) && abiElement.Const { + attributeType := abiElement.Outputs[0].Type.String() + contractAttributes = append(contractAttributes, core.ContractAttribute{abiElement.Name, attributeType}) + } + } + sort.Sort(contractAttributes) + return contractAttributes, nil +} + func bindContract(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) { abiFilePath := filepath.Join(config.ProjectRoot(), "contracts", "public", fmt.Sprintf("%s.json", address.Hex())) parsed, err := ParseAbiFile(abiFilePath) diff --git a/pkg/geth/contract_test.go b/pkg/geth/contract_test.go index e55c8a1d..1212ebc2 100644 --- a/pkg/geth/contract_test.go +++ b/pkg/geth/contract_test.go @@ -1,88 +1,88 @@ package geth_test -//import ( -// cfg "github.com/8thlight/vulcanizedb/pkg/config" -// "github.com/8thlight/vulcanizedb/pkg/geth" -// "github.com/8thlight/vulcanizedb/pkg/geth/testing" -// . "github.com/onsi/ginkgo" -// . "github.com/onsi/gomega" -//) -// -//var _ = Describe("Reading contracts", func() { -// -// Describe("Reading the list of attributes", func() { -// It("returns a string attribute for a real contract", func() { -// config, _ := cfg.NewConfig("public") -// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) -// contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" -// -// attributes, err := blockchain.GetContractAttributes(contractHash) -// -// Expect(err).To(BeNil()) -// Expect(len(attributes)).NotTo(Equal(0)) -// symbolAttribute := *testing.FindAttribute(attributes, "symbol") -// Expect(symbolAttribute.Name).To(Equal("symbol")) -// Expect(symbolAttribute.Type).To(Equal("string")) -// }) -// -// It("does not return an attribute that takes an input", func() { -// config, _ := cfg.NewConfig("public") -// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) -// contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" -// -// attributes, err := blockchain.GetContractAttributes(contractHash) -// -// Expect(err).To(BeNil()) -// attribute := testing.FindAttribute(attributes, "balanceOf") -// Expect(attribute).To(BeNil()) -// }) -// -// It("does not return an attribute that is not constant", func() { -// config, _ := cfg.NewConfig("public") -// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) -// contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" -// -// attributes, err := blockchain.GetContractAttributes(contractHash) -// -// Expect(err).To(BeNil()) -// attribute := testing.FindAttribute(attributes, "unpause") -// Expect(attribute).To(BeNil()) -// }) -// }) -// -// Describe("Getting a contract attribute", func() { -// It("returns the correct attribute for a real contract", func() { -// config, _ := cfg.NewConfig("public") -// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) -// contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" -// -// name, err := blockchain.GetContractStateAttribute(contractHash, "name") -// -// Expect(name).To(Equal("OMGToken")) -// Expect(err).To(BeNil()) -// }) -// -// It("returns an error when there is no ABI for the given contract", func() { -// config, _ := cfg.NewConfig("public") -// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) -// contractHash := "MISSINGHASH" -// -// name, err := blockchain.GetContractStateAttribute(contractHash, "name") -// -// Expect(name).To(BeNil()) -// Expect(err).To(Equal(geth.ErrMissingAbiFile)) -// }) -// -// It("returns an error when asking for an attribute that does not exist", func() { -// config, _ := cfg.NewConfig("public") -// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) -// contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" -// -// name, err := blockchain.GetContractStateAttribute(contractHash, "missing_attribute") -// -// Expect(err).To(Equal(geth.ErrInvalidStateAttribute)) -// Expect(name).To(BeNil()) -// }) -// }) -// -//}) +import ( + cfg "github.com/8thlight/vulcanizedb/pkg/config" + "github.com/8thlight/vulcanizedb/pkg/geth" + "github.com/8thlight/vulcanizedb/pkg/geth/testing" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Reading contracts", func() { + + Describe("Reading the list of attributes", func() { + It("returns a string attribute for a real contract", func() { + config, _ := cfg.NewConfig("public") + blockchain := geth.NewGethBlockchain(config.Client.IPCPath) + contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" + + contract, err := blockchain.GetContract(contractHash) + + Expect(err).To(BeNil()) + Expect(len(contract.Attributes)).NotTo(Equal(0)) + symbolAttribute := *testing.FindAttribute(contract.Attributes, "symbol") + Expect(symbolAttribute.Name).To(Equal("symbol")) + Expect(symbolAttribute.Type).To(Equal("string")) + }) + + It("does not return an attribute that takes an input", func() { + config, _ := cfg.NewConfig("public") + blockchain := geth.NewGethBlockchain(config.Client.IPCPath) + contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" + + contract, err := blockchain.GetContract(contractHash) + + Expect(err).To(BeNil()) + attribute := testing.FindAttribute(contract.Attributes, "balanceOf") + Expect(attribute).To(BeNil()) + }) + + It("does not return an attribute that is not constant", func() { + config, _ := cfg.NewConfig("public") + blockchain := geth.NewGethBlockchain(config.Client.IPCPath) + contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" + + contract, err := blockchain.GetContract(contractHash) + + Expect(err).To(BeNil()) + attribute := testing.FindAttribute(contract.Attributes, "unpause") + Expect(attribute).To(BeNil()) + }) + }) + + Describe("Getting a contract attribute", func() { + It("returns the correct attribute for a real contract", func() { + config, _ := cfg.NewConfig("public") + blockchain := geth.NewGethBlockchain(config.Client.IPCPath) + contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" + + name, err := blockchain.GetContractStateAttribute(contractHash, "name") + + Expect(name).To(Equal("OMGToken")) + Expect(err).To(BeNil()) + }) + + It("returns an error when there is no ABI for the given contract", func() { + config, _ := cfg.NewConfig("public") + blockchain := geth.NewGethBlockchain(config.Client.IPCPath) + contractHash := "MISSINGHASH" + + name, err := blockchain.GetContractStateAttribute(contractHash, "name") + + Expect(name).To(BeNil()) + Expect(err).To(Equal(geth.ErrMissingAbiFile)) + }) + + It("returns an error when asking for an attribute that does not exist", func() { + config, _ := cfg.NewConfig("public") + blockchain := geth.NewGethBlockchain(config.Client.IPCPath) + contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" + + name, err := blockchain.GetContractStateAttribute(contractHash, "missing_attribute") + + Expect(err).To(Equal(geth.ErrInvalidStateAttribute)) + Expect(name).To(BeNil()) + }) + }) + +}) diff --git a/pkg/watched_contracts/summary.go b/pkg/watched_contracts/summary.go index 8007f514..6c4b3bf8 100644 --- a/pkg/watched_contracts/summary.go +++ b/pkg/watched_contracts/summary.go @@ -35,13 +35,13 @@ func (contractSummary ContractSummary) GetStateAttribute(attributeName string) i } func newContractSummary(blockchain core.Blockchain, watchedContract core.WatchedContract) *ContractSummary { - attributes, _ := blockchain.GetContractAttributes(watchedContract.Hash) + contract, _ := blockchain.GetContract(watchedContract.Hash) return &ContractSummary{ blockChain: blockchain, ContractHash: watchedContract.Hash, NumberOfTransactions: len(watchedContract.Transactions), LastTransaction: lastTransaction(watchedContract), - Attributes: attributes, + Attributes: contract.Attributes, } } From e9bfae941238966adedd87eb53d9d4a4d065be48 Mon Sep 17 00:00:00 2001 From: Eric Meyer Date: Thu, 30 Nov 2017 16:36:18 -0600 Subject: [PATCH 2/2] Update GetContractStateAttribute to take a Contract instead of contract hash --- pkg/core/blockchain.go | 6 +- pkg/core/watched_contract.go | 5 + pkg/fakes/blockchain.go | 10 +- pkg/geth/contract.go | 10 +- pkg/geth/contract_test.go | 175 ++++++++++++++++--------------- pkg/watched_contracts/summary.go | 4 +- 6 files changed, 112 insertions(+), 98 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index c70be78c..50c07f00 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1,14 +1,10 @@ package core -type Contract struct { - Attributes ContractAttributes -} - type Blockchain interface { GetBlockByNumber(blockNumber int64) Block SubscribeToBlocks(blocks chan Block) StartListening() StopListening() GetContract(contractHash string) (Contract, error) - GetContractStateAttribute(contractHash string, attributeName string) (interface{}, error) + GetAttribute(contract Contract, attributeName string) (interface{}, error) } diff --git a/pkg/core/watched_contract.go b/pkg/core/watched_contract.go index 85df30af..41bb9b1f 100644 --- a/pkg/core/watched_contract.go +++ b/pkg/core/watched_contract.go @@ -5,6 +5,11 @@ type WatchedContract struct { Transactions []Transaction } +type Contract struct { + Attributes ContractAttributes + Hash string +} + type ContractAttribute struct { Name string Type string diff --git a/pkg/fakes/blockchain.go b/pkg/fakes/blockchain.go index e1c933aa..edcca937 100644 --- a/pkg/fakes/blockchain.go +++ b/pkg/fakes/blockchain.go @@ -15,11 +15,15 @@ type Blockchain struct { func (blockchain *Blockchain) GetContract(contractHash string) (core.Contract, error) { contractAttributes, err := blockchain.getContractAttributes(contractHash) - return core.Contract{Attributes: contractAttributes}, err + contract := core.Contract{ + Attributes: contractAttributes, + Hash: contractHash, + } + return contract, err } -func (blockchain *Blockchain) GetContractStateAttribute(contractHash string, attributeName string) (interface{}, error) { - result := blockchain.contractAttributes[contractHash][attributeName] +func (blockchain *Blockchain) GetAttribute(contract core.Contract, attributeName string) (interface{}, error) { + result := blockchain.contractAttributes[contract.Hash][attributeName] return result, nil } diff --git a/pkg/geth/contract.go b/pkg/geth/contract.go index 82a3fb7b..f34e3f3c 100644 --- a/pkg/geth/contract.go +++ b/pkg/geth/contract.go @@ -22,12 +22,16 @@ func (blockchain *GethBlockchain) GetContract(contractHash string) (core.Contrac if err != nil { return core.Contract{}, err } else { - return core.Contract{Attributes: attributes}, nil + contract := core.Contract{ + Attributes: attributes, + Hash: contractHash, + } + return contract, nil } } -func (blockchain *GethBlockchain) GetContractStateAttribute(contractHash string, attributeName string) (interface{}, error) { - boundContract, err := bindContract(common.HexToAddress(contractHash), blockchain.client, blockchain.client) +func (blockchain *GethBlockchain) GetAttribute(contract core.Contract, attributeName string) (interface{}, error) { + boundContract, err := bindContract(common.HexToAddress(contract.Hash), blockchain.client, blockchain.client) if err != nil { return nil, err } diff --git a/pkg/geth/contract_test.go b/pkg/geth/contract_test.go index 1212ebc2..2bbb5db7 100644 --- a/pkg/geth/contract_test.go +++ b/pkg/geth/contract_test.go @@ -1,88 +1,91 @@ package geth_test -import ( - cfg "github.com/8thlight/vulcanizedb/pkg/config" - "github.com/8thlight/vulcanizedb/pkg/geth" - "github.com/8thlight/vulcanizedb/pkg/geth/testing" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Reading contracts", func() { - - Describe("Reading the list of attributes", func() { - It("returns a string attribute for a real contract", func() { - config, _ := cfg.NewConfig("public") - blockchain := geth.NewGethBlockchain(config.Client.IPCPath) - contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" - - contract, err := blockchain.GetContract(contractHash) - - Expect(err).To(BeNil()) - Expect(len(contract.Attributes)).NotTo(Equal(0)) - symbolAttribute := *testing.FindAttribute(contract.Attributes, "symbol") - Expect(symbolAttribute.Name).To(Equal("symbol")) - Expect(symbolAttribute.Type).To(Equal("string")) - }) - - It("does not return an attribute that takes an input", func() { - config, _ := cfg.NewConfig("public") - blockchain := geth.NewGethBlockchain(config.Client.IPCPath) - contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" - - contract, err := blockchain.GetContract(contractHash) - - Expect(err).To(BeNil()) - attribute := testing.FindAttribute(contract.Attributes, "balanceOf") - Expect(attribute).To(BeNil()) - }) - - It("does not return an attribute that is not constant", func() { - config, _ := cfg.NewConfig("public") - blockchain := geth.NewGethBlockchain(config.Client.IPCPath) - contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" - - contract, err := blockchain.GetContract(contractHash) - - Expect(err).To(BeNil()) - attribute := testing.FindAttribute(contract.Attributes, "unpause") - Expect(attribute).To(BeNil()) - }) - }) - - Describe("Getting a contract attribute", func() { - It("returns the correct attribute for a real contract", func() { - config, _ := cfg.NewConfig("public") - blockchain := geth.NewGethBlockchain(config.Client.IPCPath) - contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" - - name, err := blockchain.GetContractStateAttribute(contractHash, "name") - - Expect(name).To(Equal("OMGToken")) - Expect(err).To(BeNil()) - }) - - It("returns an error when there is no ABI for the given contract", func() { - config, _ := cfg.NewConfig("public") - blockchain := geth.NewGethBlockchain(config.Client.IPCPath) - contractHash := "MISSINGHASH" - - name, err := blockchain.GetContractStateAttribute(contractHash, "name") - - Expect(name).To(BeNil()) - Expect(err).To(Equal(geth.ErrMissingAbiFile)) - }) - - It("returns an error when asking for an attribute that does not exist", func() { - config, _ := cfg.NewConfig("public") - blockchain := geth.NewGethBlockchain(config.Client.IPCPath) - contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" - - name, err := blockchain.GetContractStateAttribute(contractHash, "missing_attribute") - - Expect(err).To(Equal(geth.ErrInvalidStateAttribute)) - Expect(name).To(BeNil()) - }) - }) - -}) +//import ( +// cfg "github.com/8thlight/vulcanizedb/pkg/config" +// "github.com/8thlight/vulcanizedb/pkg/geth" +// "github.com/8thlight/vulcanizedb/pkg/geth/testing" +// . "github.com/onsi/ginkgo" +// . "github.com/onsi/gomega" +//) +// +//var _ = Describe("Reading contracts", func() { +// +// Describe("Reading the list of attributes", func() { +// It("returns a string attribute for a real contract", func() { +// config, _ := cfg.NewConfig("public") +// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) +// contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" +// +// contract, err := blockchain.GetContract(contractHash) +// +// Expect(err).To(BeNil()) +// Expect(len(contract.Attributes)).NotTo(Equal(0)) +// symbolAttribute := *testing.FindAttribute(contract.Attributes, "symbol") +// Expect(symbolAttribute.Name).To(Equal("symbol")) +// Expect(symbolAttribute.Type).To(Equal("string")) +// }) +// +// It("does not return an attribute that takes an input", func() { +// config, _ := cfg.NewConfig("public") +// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) +// contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" +// +// contract, err := blockchain.GetContract(contractHash) +// +// Expect(err).To(BeNil()) +// attribute := testing.FindAttribute(contract.Attributes, "balanceOf") +// Expect(attribute).To(BeNil()) +// }) +// +// It("does not return an attribute that is not constant", func() { +// config, _ := cfg.NewConfig("public") +// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) +// contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" +// +// contract, err := blockchain.GetContract(contractHash) +// +// Expect(err).To(BeNil()) +// attribute := testing.FindAttribute(contract.Attributes, "unpause") +// Expect(attribute).To(BeNil()) +// }) +// }) +// +// Describe("Getting a contract attribute", func() { +// It("returns the correct attribute for a real contract", func() { +// config, _ := cfg.NewConfig("public") +// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) +// contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" +// +// contract, _ := blockchain.GetContract(contractHash) +// name, err := blockchain.GetAttribute(contract, "name") +// +// Expect(err).To(BeNil()) +// Expect(name).To(Equal("OMGToken")) +// }) +// +// It("returns an error when there is no ABI for the given contract", func() { +// config, _ := cfg.NewConfig("public") +// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) +// contractHash := "MISSINGHASH" +// +// contract, _ := blockchain.GetContract(contractHash) +// name, err := blockchain.GetAttribute(contract, "name") +// +// Expect(err).To(Equal(geth.ErrMissingAbiFile)) +// Expect(name).To(BeNil()) +// }) +// +// It("returns an error when asking for an attribute that does not exist", func() { +// config, _ := cfg.NewConfig("public") +// blockchain := geth.NewGethBlockchain(config.Client.IPCPath) +// contractHash := "0xd26114cd6EE289AccF82350c8d8487fedB8A0C07" +// +// contract, _ := blockchain.GetContract(contractHash) +// name, err := blockchain.GetAttribute(contract, "missing_attribute") +// +// Expect(err).To(Equal(geth.ErrInvalidStateAttribute)) +// Expect(name).To(BeNil()) +// }) +// }) +// +//}) diff --git a/pkg/watched_contracts/summary.go b/pkg/watched_contracts/summary.go index 6c4b3bf8..63d8d7d8 100644 --- a/pkg/watched_contracts/summary.go +++ b/pkg/watched_contracts/summary.go @@ -9,6 +9,7 @@ import ( ) type ContractSummary struct { + Contract core.Contract ContractHash string NumberOfTransactions int LastTransaction *core.Transaction @@ -30,7 +31,7 @@ func NewSummary(blockchain core.Blockchain, repository repositories.Repository, } func (contractSummary ContractSummary) GetStateAttribute(attributeName string) interface{} { - result, _ := contractSummary.blockChain.GetContractStateAttribute(contractSummary.ContractHash, attributeName) + result, _ := contractSummary.blockChain.GetAttribute(contractSummary.Contract, attributeName) return result } @@ -38,6 +39,7 @@ func newContractSummary(blockchain core.Blockchain, watchedContract core.Watched contract, _ := blockchain.GetContract(watchedContract.Hash) return &ContractSummary{ blockChain: blockchain, + Contract: contract, ContractHash: watchedContract.Hash, NumberOfTransactions: len(watchedContract.Transactions), LastTransaction: lastTransaction(watchedContract),