From d4ee4c3476926b229a60e5ae13e132ada2202ba1 Mon Sep 17 00:00:00 2001 From: Peter Olds Date: Tue, 30 Jul 2024 09:12:27 -0700 Subject: [PATCH] =?UTF-8?q?Add=20a=20default=20TypeAndVersion=20when=20one?= =?UTF-8?q?=20isn=E2=80=99t=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/services/ocr2/plugins/ccip/config/type_and_version.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/services/ocr2/plugins/ccip/config/type_and_version.go b/core/services/ocr2/plugins/ccip/config/type_and_version.go index 701d727b6a..48d56b486a 100644 --- a/core/services/ocr2/plugins/ccip/config/type_and_version.go +++ b/core/services/ocr2/plugins/ccip/config/type_and_version.go @@ -19,6 +19,7 @@ var ( EVM2EVMOffRamp ContractType = "EVM2EVMOffRamp" CommitStore ContractType = "CommitStore" PriceRegistry ContractType = "PriceRegistry" + Unknown ContractType = "Unknown" ContractTypes = mapset.NewSet[ContractType]( EVM2EVMOffRamp, EVM2EVMOnRamp, @@ -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 { @@ -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 {