forked from cerc-io/ipld-eth-server
Handle events
- Adds interfaces for developers to build handlers that update data in response to log events - Resolves #29
This commit is contained in:
@@ -30,11 +30,10 @@ func template() string {
|
||||
func transactionToString(transaction *core.Transaction) string {
|
||||
if transaction == nil {
|
||||
return "NONE"
|
||||
} else {
|
||||
return fmt.Sprintf(`Hash: %s
|
||||
}
|
||||
return fmt.Sprintf(`Hash: %s
|
||||
To: %s
|
||||
From: %s`, transaction.Hash, transaction.To, transaction.From)
|
||||
}
|
||||
}
|
||||
|
||||
func attributesString(summary ContractSummary) string {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"math/big"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/repositories"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
)
|
||||
|
||||
type ContractSummary struct {
|
||||
@@ -17,13 +17,12 @@ type ContractSummary struct {
|
||||
blockChain core.Blockchain
|
||||
}
|
||||
|
||||
func NewSummary(blockchain core.Blockchain, contractRepository repositories.ContractRepository, contractHash string, blockNumber *big.Int) (ContractSummary, error) {
|
||||
func NewSummary(blockchain core.Blockchain, contractRepository datastore.ContractRepository, contractHash string, blockNumber *big.Int) (ContractSummary, error) {
|
||||
contract, err := contractRepository.GetContract(contractHash)
|
||||
if err != nil {
|
||||
return ContractSummary{}, err
|
||||
} else {
|
||||
return newContractSummary(blockchain, contract, blockNumber), nil
|
||||
}
|
||||
return newContractSummary(blockchain, contract, blockNumber), nil
|
||||
}
|
||||
|
||||
func (contractSummary ContractSummary) GetStateAttribute(attributeName string) interface{} {
|
||||
@@ -48,7 +47,6 @@ func newContractSummary(blockchain core.Blockchain, contract core.Contract, bloc
|
||||
func lastTransaction(contract core.Contract) *core.Transaction {
|
||||
if len(contract.Transactions) > 0 {
|
||||
return &contract.Transactions[0]
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/contract_summary"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/inmemory"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/repositories"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/repositories/inmemory"
|
||||
)
|
||||
|
||||
func NewCurrentContractSummary(blockchain core.Blockchain, contractRepository repositories.ContractRepository, contractHash string) (contract_summary.ContractSummary, error) {
|
||||
func NewCurrentContractSummary(blockchain core.Blockchain, contractRepository datastore.ContractRepository, contractHash string) (contract_summary.ContractSummary, error) {
|
||||
return contract_summary.NewSummary(blockchain, contractRepository, contractHash, nil)
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ var _ = Describe("The contract summary", func() {
|
||||
},
|
||||
))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user