Skip to content

Commit

Permalink
Add a default TypeAndVersion when one isn’t set
Browse files Browse the repository at this point in the history
  • Loading branch information
polds committed Jul 30, 2024
1 parent c0f125c commit d4ee4c3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/services/ocr2/plugins/ccip/config/type_and_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
EVM2EVMOffRamp ContractType = "EVM2EVMOffRamp"
CommitStore ContractType = "CommitStore"
PriceRegistry ContractType = "PriceRegistry"
Unknown ContractType = "Unknown"
ContractTypes = mapset.NewSet[ContractType](
EVM2EVMOffRamp,
EVM2EVMOnRamp,
Expand All @@ -27,6 +28,9 @@ var (
)
)

// Version to use when TypeAndVersion is missing.
const defaultVersion = "1.0"

func VerifyTypeAndVersion(addr common.Address, client bind.ContractBackend, expectedType ContractType) (semver.Version, error) {
contractType, version, err := TypeAndVersion(addr, client)
if err != nil {
Expand Down Expand Up @@ -64,6 +68,9 @@ func TypeAndVersion(addr common.Address, client bind.ContractBackend) (ContractT
}

func ParseTypeAndVersion(tvStr string) (string, string, error) {
if tvStr == "" {
tvStr = string(Unknown) + " " + defaultVersion
}
typeAndVersionValues := strings.Split(tvStr, " ")

if len(typeAndVersionValues) < 2 {
Expand Down

0 comments on commit d4ee4c3

Please sign in to comment.