-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11532 from smartcontractkit/rtinianov_multicontra…
…cttest Support contract mapping
- Loading branch information
Showing
14 changed files
with
245 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package evm | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
|
||
"github.com/smartcontractkit/chainlink-common/pkg/types" | ||
) | ||
|
||
type Bindings map[string]methodBindings | ||
|
||
func (b Bindings) addEvent(contractName, typeName string, evt common.Hash) error { | ||
ae, err := b.getBinding(contractName, typeName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
ae.evt = &evt | ||
return nil | ||
} | ||
|
||
func (b Bindings) getBinding(contractName, typeName string) (*addrEvtBinding, error) { | ||
typeNames, ok := b[contractName] | ||
if !ok { | ||
return nil, fmt.Errorf("%w: contract %s not found", types.ErrInvalidConfig, contractName) | ||
} | ||
|
||
ae, ok := typeNames[typeName] | ||
if !ok { | ||
return nil, fmt.Errorf("%w: method %s not found in contract %s", types.ErrInvalidConfig, typeName, contractName) | ||
} | ||
|
||
return ae, nil | ||
} | ||
|
||
type methodBindings map[string]*addrEvtBinding | ||
|
||
func NewAddrEvtFromAddress(address common.Address) *addrEvtBinding { | ||
return &addrEvtBinding{addr: address} | ||
} | ||
|
||
type addrEvtBinding struct { | ||
addr common.Address | ||
evt *common.Hash | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.