From 10762214f9263f0cacfb898e40c32b2e297cfd03 Mon Sep 17 00:00:00 2001 From: Abdulbois Date: Wed, 20 Mar 2024 12:34:27 +0500 Subject: [PATCH] #502 Add schema version field to entities - Make 0 as default value for `schemaVersion` field - Remove `schemaVersion` from Product schema - Minor refactoring Signed-off-by: Abdulbois Signed-off-by: Abdulbois --- docs/transactions.md | 28 +++---- integration_tests/cli/compliance-demo.sh | 4 +- .../cli/compliance-provisioning.sh | 4 +- .../cli/compliance-revocation.sh | 4 +- integration_tests/cli/model-demo.sh | 4 +- integration_tests/cli/pki-demo.sh | 6 +- integration_tests/constants/constants.go | 3 +- proto/model/product.proto | 1 - .../module/types/model/product.ts | 20 +---- x/common/schema_version.go | 14 ---- x/compliance/client/cli/tx_certify_model.go | 2 +- x/compliance/client/cli/tx_provision_model.go | 2 +- x/compliance/client/cli/tx_revoke_model.go | 2 +- .../client/cli/tx_update_compliance_info.go | 2 +- .../keeper/msg_server_certify_model.go | 3 +- .../keeper/msg_server_provision_model.go | 3 +- .../keeper/msg_server_revoke_model.go | 3 +- .../msg_server_update_compliance_info.go | 3 +- x/model/client/cli/tx_model.go | 4 +- x/model/client/cli/tx_model_version.go | 4 +- x/model/keeper/msg_server_model.go | 19 ++--- x/model/keeper/msg_server_model_version.go | 5 +- x/model/types/product.pb.go | 73 +++++-------------- x/pki/client/cli/tx_add_noc_x_509_cert.go | 2 +- .../client/cli/tx_add_noc_x_509_root_cert.go | 2 +- ...x_add_pki_revocation_distribution_point.go | 2 +- x/pki/client/cli/tx_add_x_509_cert.go | 2 +- .../cli/tx_propose_add_x_509_root_cert.go | 2 +- ...pdate_pki_revocation_distribution_point.go | 2 +- x/pki/handler_test.go | 3 +- x/pki/handler_update_revocation_test.go | 11 ++- x/pki/keeper/msg_server_add_noc_x_509_cert.go | 3 +- .../msg_server_add_noc_x_509_root_cert.go | 3 +- ...r_add_pki_revocation_distribution_point.go | 3 +- x/pki/keeper/msg_server_add_x_509_cert.go | 3 +- .../msg_server_propose_add_x_509_root_cert.go | 3 +- ...pdate_pki_revocation_distribution_point.go | 3 +- x/vendorinfo/client/cli/tx_vendor_info.go | 4 +- x/vendorinfo/keeper/msg_server_vendor_info.go | 5 +- 39 files changed, 92 insertions(+), 174 deletions(-) delete mode 100644 x/common/schema_version.go diff --git a/docs/transactions.md b/docs/transactions.md index 8b5d6ceb2..189243758 100644 --- a/docs/transactions.md +++ b/docs/transactions.md @@ -128,7 +128,7 @@ Adds a record about a Vendor. - companyLegalName: `string` - Legal name of the vendor company - companyPreferredName: `optional(string)` - Preferred name of the vendor company - vendorLandingPageURL: `optional(string)` - URL of the vendor's landing page - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: `vendorinfo/VendorInfo/value/` - Who can send: - Account with a vendor role who has the matching Vendor ID @@ -148,7 +148,7 @@ Updates a record about a Vendor. - companyLegalName: `optional(string)` - Legal name of the vendor company - companyPreferredName: `optional(string)` - Preferred name of the vendor company - vendorLandingPageURL: `optional(string)` - URL of the vendor's landing page - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: `vendorinfo/VendorInfo/value/` - Who can send: - Account with a vendor role who has the matching Vendor ID @@ -211,7 +211,7 @@ Not all fields can be edited (see `EDIT_MODEL`). - supportURL: `optional(string)` - URL that contains product specific web page that contains support details for the device model. - productURL: `optional(string)` - URL that contains product specific web page that contains details for the device model. - lsfURL: `optional(string)` - URL to the Localized String File of this product. - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: - `model/Model/value//` - `model/VendorProducts/value/` @@ -257,7 +257,7 @@ All non-edited fields remain the same. - supportURL: `optional(string)` - URL that contains product specific web page that contains support details for the device model. - productURL: `optional(string)` - URL that contains product specific web page that contains details for the device model. - lsfURL: `optional(string)` - URL to the Localized String File of this product. - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - lsfRevision: `optional(uint32)` - LsfRevision is a monotonically increasing positive integer indicating the latest available version of Localized String File. - In State: `model/Model/value//` - Who can send: @@ -309,7 +309,7 @@ If one of `OTA_URl`, `OTA_checksum` or `OTA_checksum_type` fields is set, then t - otaChecksum `optional(string)` - Digest of the entire contents of the associated OTA Software Update Image under the OtaUrl attribute, encoded in base64 string representation. The digest SHALL have been computed using the algorithm specified in OtaChecksumType - otaChecksumType `optional(string)` - Numeric identifier as defined in IANA Named Information Hash Algorithm Registry for the type of otaChecksum. For example, a value of 1 would match the sha-256 identifier, which maps to the SHA-256 digest algorithm - releaseNotesURL `optional(string)` - URL that contains product specific web page that contains release notes for the device model. - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: - `model/ModelVersion/value///` - `model/ModelVersions/value//` @@ -356,7 +356,7 @@ All non-edited fields remain the same. - otaURL `optional(string)` - URL where to obtain the OTA image - otaFileSize `optional(string)` - OtaFileSize is the total size of the OTA software image in bytes - otaChecksum `optional(string)` - Digest of the entire contents of the associated OTA Software Update Image under the OtaUrl attribute, encoded in base64 string representation. The digest SHALL have been computed using the algorithm specified in OtaChecksumType - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: `model/ModelVersion/value///` - Who can send: @@ -494,7 +494,7 @@ from the revocation list. - transport `optional(string)` - optional field describing the transport - parentChild `optional(string)` - optional field describing the parent/child - Currently 'parent' and 'child' types are supported - certificationIDOfSoftwareComponent `optional(string)` - optional field describing the certification ID of software component - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: - `compliance/ComplianceInfo/value////` - `compliance/CertifiedModel/value////` @@ -532,7 +532,7 @@ Updates a compliance info by VID, PID, Software Version and Certification Type. - transport `optional(string)` - optional field describing the transport - parentChild `optional(string)` - optional field describing the parent/child - Currently 'parent' and 'child' types are supported - certificationIDOfSoftwareComponent `optional(string)` - optional field describing the certification ID of software component - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - Who can send: - CertificationCenter - CLI command: @@ -580,7 +580,7 @@ is written on the ledger (`CERTIFY_MODEL` was called), or - revocationDate: `string` - The date of model revocation (rfc3339 encoded), for example 2019-10-12T07:20:50.52Z - certificationType: `string` - Certification type - Currently 'zigbee' and 'matter', 'access control', 'product security' types are supported - reason `optional(string)` - optional comment describing the reason of revocation - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: - `compliance/ComplianceInfo/value////` - `compliance/RevokedModel/value////` @@ -620,7 +620,7 @@ Can not be set if there is already a certification record on the ledger (certifi - transport `optional(string)` - optional field describing the transport - parentChild `optional(string)` - optional field describing the parent/child - Currently 'parent' and 'child' types are supported - certificationIDOfSoftwareComponent `optional(string)` - optional field describing the certification ID of software component - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: - `compliance/ComplianceInfo/value////` - `compliance/ProvisionalModel/value////` @@ -841,7 +841,7 @@ The certificate is immutable. It can only be revoked by either the owner or a qu - cert: `string` - PEM encoded certificate. The corresponding CLI parameter can contain either a PEM string or a path to a file containing the data. - info: `optional(string)` - information/notes for the proposal - time: `optional(int64)` - proposal time (number of nanoseconds elapsed since January 1, 1970 UTC). CLI uses the current time for that field. - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: `pki/ProposedCertificate/value//` - Who can send: - Trustee @@ -924,7 +924,7 @@ The certificate is immutable. It can only be revoked by either the owner or a qu - `vid` field associated with the corresponding PAA on the ledger must be equal to the Vendor account's VID. - Parameters: - cert: `string` - PEM encoded certificate. The corresponding CLI parameter can contain either a PEM string or a path to a file containing the data. - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: - `pki/ApprovedCertificates/value//` - `pki/ChildCertificates/value//` @@ -1157,7 +1157,7 @@ This transaction adds a NOC root certificate owned by the Vendor. - the signature (self-signature) and expiration date must be valid. - Parameters: - cert: `string` - The NOC Root Certificate, encoded in X.509v3 PEM format. Can be a PEM string or a file path. - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: - `pki/ApprovedCertificates/value//` - `pki/ApprovedCertificatesBySubject/value/` @@ -1188,7 +1188,7 @@ already present on the ledger. - the signature (self-signature) and expiration date must be valid. - Parameters: - cert: `string` - The NOC non-root Certificate, encoded in X.509v3 PEM format. Can be a PEM string or a file path. - - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1) + - schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0) - In State: - `pki/ApprovedCertificates/value//` - `pki/ApprovedCertificatesBySubject/value/` diff --git a/integration_tests/cli/compliance-demo.sh b/integration_tests/cli/compliance-demo.sh index 88fe69df1..a232b8a0f 100755 --- a/integration_tests/cli/compliance-demo.sh +++ b/integration_tests/cli/compliance-demo.sh @@ -44,7 +44,7 @@ zigbee_certification_type="zigbee" matter_certification_type="matter" cd_certificate_id="123" cd_version_number=1 -schema_version_1=1 +schema_version_0=0 schema_version_2=2 echo "Certify unknown Model with VID: $vid PID: $pid SV: ${sv} with zigbee certification" result=$(echo "$passphrase" | dcld tx compliance certify-model --vid=$vid --pid=$pid --softwareVersion=$sv --softwareVersionString=$svs --certificationType="$zigbee_certification_type" --certificationDate="$certification_date" --cdCertificateId="$cd_certificate_id" --from $zb_account --yes) @@ -290,7 +290,7 @@ check_response "$result" "\"softwareVersionCertificationStatus\": 2" check_response "$result" "\"cDCertificateId\": \"$cd_certificate_id\"" check_response "$result" "\"date\": \"$certification_date\"" check_response "$result" "\"certificationType\": \"$matter_certification_type\"" -check_response "$result" "\"schemaVersion\": $schema_version_1" +check_response "$result" "\"schemaVersion\": $schema_version_0" echo "$result" test_divider diff --git a/integration_tests/cli/compliance-provisioning.sh b/integration_tests/cli/compliance-provisioning.sh index 6c7a52425..527bccf96 100755 --- a/integration_tests/cli/compliance-provisioning.sh +++ b/integration_tests/cli/compliance-provisioning.sh @@ -40,7 +40,7 @@ certification_type_matter="matter" provision_date="2020-02-02T02:20:20Z" provision_reason="some reason" cd_certificate_id="123" -schema_version_1=1 +schema_version_0=0 schema_version_2=2 test_divider @@ -165,7 +165,7 @@ check_response "$result" "\"date\": \"$provision_date\"" check_response "$result" "\"reason\": \"$provision_reason\"" check_response "$result" "\"certificationType\": \"$certification_type_matter\"" check_response "$result" "\"history\"" -check_response "$result" "\"schemaVersion\": $schema_version_1" +check_response "$result" "\"schemaVersion\": $schema_version_0" echo "$result" test_divider diff --git a/integration_tests/cli/compliance-revocation.sh b/integration_tests/cli/compliance-revocation.sh index d47e6293b..10b0f8aa1 100755 --- a/integration_tests/cli/compliance-revocation.sh +++ b/integration_tests/cli/compliance-revocation.sh @@ -48,7 +48,7 @@ test_divider echo "Revoke Certification for uncertificate Model with VID: $vid PID: $pid" revocation_date="2020-02-02T02:20:20Z" revocation_reason="some reason" -schema_version_1=1 +schema_version_0=0 schema_version_2=2 result=$(echo "$passphrase" | dcld tx compliance revoke-model --vid=$vid --pid=$pid --softwareVersion=$sv --softwareVersionString=$svs --certificationType="$certification_type" --revocationDate="$revocation_date" --reason "$revocation_reason" --cdVersionNumber=1 --schemaVersion=$schema_version_2 --from $zb_account --yes) check_response "$result" "\"code\": 0" @@ -145,7 +145,7 @@ check_response "$result" "\"softwareVersionCertificationStatus\": 3" check_response "$result" "\"date\": \"$revocation_date\"" check_response "$result" "\"reason\": \"$revocation_reason\"" check_response "$result" "\"certificationType\": \"$certification_type_matter\"" -check_response "$result" "\"schemaVersion\": $schema_version_1" +check_response "$result" "\"schemaVersion\": $schema_version_0" check_response "$result" "\"history\"" echo "$result" diff --git a/integration_tests/cli/model-demo.sh b/integration_tests/cli/model-demo.sh index 0538e5dfa..ec32d5597 100755 --- a/integration_tests/cli/model-demo.sh +++ b/integration_tests/cli/model-demo.sh @@ -58,7 +58,7 @@ echo "$result" test_divider productLabel="Device #1" -schema_version_1=1 +schema_version_0=0 schema_version_2=2 echo "Add Model with VID: $vid PID: $pid" result=$(echo "test1234" | dcld tx model add-model --vid=$vid --pid=$pid --deviceTypeID=1 --productName=TestProduct --productLabel="$productLabel" --partNumber=1 --commissioningCustomFlow=0 --schemaVersion=$schema_version_2 --from=$vendor_account --yes) @@ -88,7 +88,7 @@ result=$(dcld query model get-model --vid=$vid_with_pids --pid=$pid) check_response "$result" "\"vid\": $vid_with_pids" check_response "$result" "\"pid\": $pid" check_response "$result" "\"productLabel\": \"$productLabel\"" -check_response "$result" "\"schemaVersion\": $schema_version_1" +check_response "$result" "\"schemaVersion\": $schema_version_0" echo "$result" test_divider diff --git a/integration_tests/cli/pki-demo.sh b/integration_tests/cli/pki-demo.sh index 9c922c166..5f27f9d01 100755 --- a/integration_tests/cli/pki-demo.sh +++ b/integration_tests/cli/pki-demo.sh @@ -454,7 +454,7 @@ test_divider echo "$vendor_account add Leaf certificate" leaf_path="integration_tests/constants/leaf_cert" -schema_version_1=1 +schema_version_0=0 result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$leaf_path" --from $vendor_account --yes) check_response "$result" "\"code\": 0" @@ -467,7 +467,7 @@ check_response "$result" "\"subject\": \"$leaf_cert_subject\"" check_response "$result" "\"subjectKeyId\": \"$leaf_cert_subject_key_id\"" check_response "$result" "\"serialNumber\": \"$leaf_cert_serial_number\"" check_response "$result" "\"subjectAsText\": \"$leaf_cert_subject_as_text\"" -check_response "$result" "\"schemaVersion\": $schema_version_1" +check_response "$result" "\"schemaVersion\": $schema_version_0" check_response "$result" "\"approvals\": \\[\\]" echo "Request Leaf certificate by subjectKeyId - There is no approvals on leaf certificate" @@ -1183,7 +1183,7 @@ check_response "$result" "\"address\": \"$trustee_account_address\"" check_response "$result" "\"subjectKeyId\": \"$google_cert_subject_key_id\"" check_response "$result" "\"serialNumber\": \"$google_cert_serial_number\"" check_response "$result" "\"subjectAsText\": \"$google_cert_subject_as_text\"" -check_response "$result" "\"schemaVersion\": $schema_version_1" +check_response "$result" "\"schemaVersion\": $schema_version_0" check_response "$result" "\"vid\": $google_cert_vid" echo $result | jq diff --git a/integration_tests/constants/constants.go b/integration_tests/constants/constants.go index 2e2d521dc..0bdf0c221 100644 --- a/integration_tests/constants/constants.go +++ b/integration_tests/constants/constants.go @@ -175,7 +175,8 @@ var ( ValidHTTPURL = "http://valid.url.com" NotAValidURL = "not a valid url" - SchemaVersion uint32 = 1 + // SchemaVersion initial default value. + SchemaVersion uint32 ) /* diff --git a/proto/model/product.proto b/proto/model/product.proto index a14bf1524..35a67a652 100644 --- a/proto/model/product.proto +++ b/proto/model/product.proto @@ -8,5 +8,4 @@ message Product { int32 pid = 1; string name = 2; string partNumber = 3; - uint32 schemaVersion = 4; } diff --git a/vue/src/store/generated/zigbee-alliance/distributed-compliance-ledger/zigbeealliance.distributedcomplianceledger.model/module/types/model/product.ts b/vue/src/store/generated/zigbee-alliance/distributed-compliance-ledger/zigbeealliance.distributedcomplianceledger.model/module/types/model/product.ts index aee3de601..be21ed8f7 100644 --- a/vue/src/store/generated/zigbee-alliance/distributed-compliance-ledger/zigbeealliance.distributedcomplianceledger.model/module/types/model/product.ts +++ b/vue/src/store/generated/zigbee-alliance/distributed-compliance-ledger/zigbeealliance.distributedcomplianceledger.model/module/types/model/product.ts @@ -7,10 +7,9 @@ export interface Product { pid: number name: string partNumber: string - schemaVersion: number } -const baseProduct: object = { pid: 0, name: '', partNumber: '', schemaVersion: 0 } +const baseProduct: object = { pid: 0, name: '', partNumber: '' } export const Product = { encode(message: Product, writer: Writer = Writer.create()): Writer { @@ -23,9 +22,6 @@ export const Product = { if (message.partNumber !== '') { writer.uint32(26).string(message.partNumber) } - if (message.schemaVersion !== 0) { - writer.uint32(32).uint32(message.schemaVersion) - } return writer }, @@ -45,9 +41,6 @@ export const Product = { case 3: message.partNumber = reader.string() break - case 4: - message.schemaVersion = reader.uint32() - break default: reader.skipType(tag & 7) break @@ -73,11 +66,6 @@ export const Product = { } else { message.partNumber = '' } - if (object.schemaVersion !== undefined && object.schemaVersion !== null) { - message.schemaVersion = Number(object.schemaVersion) - } else { - message.schemaVersion = 0 - } return message }, @@ -86,7 +74,6 @@ export const Product = { message.pid !== undefined && (obj.pid = message.pid) message.name !== undefined && (obj.name = message.name) message.partNumber !== undefined && (obj.partNumber = message.partNumber) - message.schemaVersion !== undefined && (obj.schemaVersion = message.schemaVersion) return obj }, @@ -107,11 +94,6 @@ export const Product = { } else { message.partNumber = '' } - if (object.schemaVersion !== undefined && object.schemaVersion !== null) { - message.schemaVersion = object.schemaVersion - } else { - message.schemaVersion = 0 - } return message } } diff --git a/x/common/schema_version.go b/x/common/schema_version.go deleted file mode 100644 index b39dce824..000000000 --- a/x/common/schema_version.go +++ /dev/null @@ -1,14 +0,0 @@ -package common - -type SchemaVersion interface { - GetSchemaVersion() uint32 -} - -func GetSchemaVersionOrDefault(schemaVersion SchemaVersion) uint32 { - currentVersion := schemaVersion.GetSchemaVersion() - if currentVersion == 0 { - return 1 - } - - return currentVersion -} diff --git a/x/compliance/client/cli/tx_certify_model.go b/x/compliance/client/cli/tx_certify_model.go index efa49c1e3..1dccc6cb5 100644 --- a/x/compliance/client/cli/tx_certify_model.go +++ b/x/compliance/client/cli/tx_certify_model.go @@ -122,7 +122,7 @@ func CmdCertifyModel() *cobra.Command { "Parent or Child of the PFC certification route") cmd.Flags().StringVar(&certificationIDOfSoftwareComponent, FlagCertificationIDOfSoftwareComponent, "", "certification ID of software component") - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") _ = cmd.MarkFlagRequired(FlagVID) _ = cmd.MarkFlagRequired(FlagPID) diff --git a/x/compliance/client/cli/tx_provision_model.go b/x/compliance/client/cli/tx_provision_model.go index 000ac3100..d436f11f3 100644 --- a/x/compliance/client/cli/tx_provision_model.go +++ b/x/compliance/client/cli/tx_provision_model.go @@ -123,7 +123,7 @@ func CmdProvisionModel() *cobra.Command { "Parent or Child of the PFC certification route") cmd.Flags().StringVar(&certificationIDOfSoftwareComponent, FlagCertificationIDOfSoftwareComponent, "", "certification ID of software component") - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") _ = cmd.MarkFlagRequired(FlagVID) _ = cmd.MarkFlagRequired(FlagPID) diff --git a/x/compliance/client/cli/tx_revoke_model.go b/x/compliance/client/cli/tx_revoke_model.go index b3897018a..27be69a85 100644 --- a/x/compliance/client/cli/tx_revoke_model.go +++ b/x/compliance/client/cli/tx_revoke_model.go @@ -74,7 +74,7 @@ func CmdRevokeModel() *cobra.Command { "The date of model revocation (rfc3339 encoded), for example 2019-10-12T07:20:50.52Z") cmd.Flags().StringVar(&reason, FlagReason, "", "Optional comment describing the reason of revocation") - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") _ = cmd.MarkFlagRequired(FlagVID) _ = cmd.MarkFlagRequired(FlagPID) diff --git a/x/compliance/client/cli/tx_update_compliance_info.go b/x/compliance/client/cli/tx_update_compliance_info.go index 998341ce7..5271557bf 100644 --- a/x/compliance/client/cli/tx_update_compliance_info.go +++ b/x/compliance/client/cli/tx_update_compliance_info.go @@ -121,7 +121,7 @@ func CmdUpdateComplianceInfo() *cobra.Command { "Parent or Child of the PFC certification route") cmd.Flags().StringVar(&certificationIDOfSoftwareComponent, FlagCertificationIDOfSoftwareComponent, "", "certification ID of software component") - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") _ = cmd.MarkFlagRequired(FlagVID) _ = cmd.MarkFlagRequired(FlagPID) diff --git a/x/compliance/keeper/msg_server_certify_model.go b/x/compliance/keeper/msg_server_certify_model.go index 84e34340d..dc91b3d6f 100644 --- a/x/compliance/keeper/msg_server_certify_model.go +++ b/x/compliance/keeper/msg_server_certify_model.go @@ -8,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" dclcompltypes "github.com/zigbee-alliance/distributed-compliance-ledger/types/compliance" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" "github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance/types" dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types" modeltypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/model/types" @@ -95,7 +94,7 @@ func (k msgServer) CertifyModel(goCtx context.Context, msg *types.MsgCertifyMode History: []*dclcompltypes.ComplianceHistoryItem{}, CDVersionNumber: msg.CDVersionNumber, CDCertificateId: msg.CDCertificateId, - SchemaVersion: common.GetSchemaVersionOrDefault(msg), + SchemaVersion: msg.SchemaVersion, } } diff --git a/x/compliance/keeper/msg_server_provision_model.go b/x/compliance/keeper/msg_server_provision_model.go index 69f8ef7f0..1db37fb43 100644 --- a/x/compliance/keeper/msg_server_provision_model.go +++ b/x/compliance/keeper/msg_server_provision_model.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" dclcompltypes "github.com/zigbee-alliance/distributed-compliance-ledger/types/compliance" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" "github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance/types" dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types" modeltypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/model/types" @@ -82,7 +81,7 @@ func (k msgServer) ProvisionModel(goCtx context.Context, msg *types.MsgProvision Transport: msg.Transport, ParentChild: msg.ParentChild, CertificationIdOfSoftwareComponent: msg.CertificationIdOfSoftwareComponent, - SchemaVersion: common.GetSchemaVersionOrDefault(msg), + SchemaVersion: msg.SchemaVersion, } // store compliance info diff --git a/x/compliance/keeper/msg_server_revoke_model.go b/x/compliance/keeper/msg_server_revoke_model.go index e7ca0a4f9..202e6a4d6 100644 --- a/x/compliance/keeper/msg_server_revoke_model.go +++ b/x/compliance/keeper/msg_server_revoke_model.go @@ -8,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" dclcompltypes "github.com/zigbee-alliance/distributed-compliance-ledger/types/compliance" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" "github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance/types" dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types" modeltypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/model/types" @@ -123,7 +122,7 @@ func (k msgServer) RevokeModel(goCtx context.Context, msg *types.MsgRevokeModel) SoftwareVersionCertificationStatus: dclcompltypes.CodeRevoked, History: []*dclcompltypes.ComplianceHistoryItem{}, CDVersionNumber: msg.CDVersionNumber, - SchemaVersion: common.GetSchemaVersionOrDefault(msg), + SchemaVersion: msg.SchemaVersion, } } diff --git a/x/compliance/keeper/msg_server_update_compliance_info.go b/x/compliance/keeper/msg_server_update_compliance_info.go index d4dee734d..778a51c01 100644 --- a/x/compliance/keeper/msg_server_update_compliance_info.go +++ b/x/compliance/keeper/msg_server_update_compliance_info.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" "github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance/types" dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types" modeltypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/model/types" @@ -105,7 +104,7 @@ func (k msgServer) UpdateComplianceInfo(goCtx context.Context, msg *types.MsgUpd complianceInfo.Transport = msg.Transport } - complianceInfo.SchemaVersion = common.GetSchemaVersionOrDefault(msg) + complianceInfo.SchemaVersion = msg.SchemaVersion //nolint:nestif if msg.CDCertificateId != "" && msg.CDCertificateId != complianceInfo.CDCertificateId { diff --git a/x/model/client/cli/tx_model.go b/x/model/client/cli/tx_model.go index a5b2bed47..8b2a2f395 100644 --- a/x/model/client/cli/tx_model.go +++ b/x/model/client/cli/tx_model.go @@ -128,7 +128,7 @@ and for these values the commissioningModeSecondaryStepInstruction SHALL be set` "URL that contains product specific web page that contains details for the device model.") cmd.Flags().StringVar(&lsfURL, FlagLsfURL, "", "URL to the Localized String File of this product") cli.AddTxFlagsToCmd(cmd) - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") _ = cmd.MarkFlagRequired(FlagVid) _ = cmd.MarkFlagRequired(FlagPid) @@ -232,7 +232,7 @@ and for these values the commissioningModeSecondaryStepInstruction SHALL be set` cmd.Flags().StringVar(&lsfURL, FlagLsfURL, "", "URL to the Localized String File of this product") cmd.Flags().Int32Var(&lsfRevision, FlagLsfRevision, 0, "LsfRevision is a monotonically increasing positive integer indicating the latest available version of Localized String File") - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") cli.AddTxFlagsToCmd(cmd) diff --git a/x/model/client/cli/tx_model_version.go b/x/model/client/cli/tx_model_version.go index 1c45a8fc1..8942ca78e 100644 --- a/x/model/client/cli/tx_model_version.go +++ b/x/model/client/cli/tx_model_version.go @@ -105,7 +105,7 @@ SoftwareVersion for which this image can be applied`) cmd.Flags().StringVar(&releaseNotesURL, FlagReleaseNotesURL, "", `URL that contains product specific web page that contains release notes for the device model.`) - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") cli.AddTxFlagsToCmd(cmd) @@ -193,7 +193,7 @@ func CmdUpdateModelVersion() *cobra.Command { `MaxApplicableSoftwareVersion should specify the highest SoftwareVersion for which this image can be applied`) cmd.Flags().StringVar(&releaseNotesURL, FlagReleaseNotesURL, "", `URL that contains product specific web page that contains release notes for the device model.`) - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") cli.AddTxFlagsToCmd(cmd) diff --git a/x/model/keeper/msg_server_model.go b/x/model/keeper/msg_server_model.go index 9dbb0769d..f58c3fe87 100644 --- a/x/model/keeper/msg_server_model.go +++ b/x/model/keeper/msg_server_model.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" "github.com/zigbee-alliance/distributed-compliance-ledger/x/model/types" ) @@ -49,7 +48,7 @@ func (k msgServer) CreateModel(goCtx context.Context, msg *types.MsgCreateModel) SupportUrl: msg.SupportUrl, ProductUrl: msg.ProductUrl, LsfUrl: msg.LsfUrl, - SchemaVersion: common.GetSchemaVersionOrDefault(msg), + SchemaVersion: msg.SchemaVersion, } // if LsfUrl is not empty, we set lsfRevision to default value of 1 @@ -65,10 +64,9 @@ func (k msgServer) CreateModel(goCtx context.Context, msg *types.MsgCreateModel) // store new product in VendorProducts k.SetVendorProduct(ctx, model.Vid, types.Product{ - Pid: model.Pid, - Name: model.ProductName, - PartNumber: model.PartNumber, - SchemaVersion: common.GetSchemaVersionOrDefault(msg), + Pid: model.Pid, + Name: model.ProductName, + PartNumber: model.PartNumber, }) return &types.MsgCreateModelResponse{}, nil @@ -134,7 +132,7 @@ func (k msgServer) UpdateModel(goCtx context.Context, msg *types.MsgUpdateModel) model.ProductUrl = msg.ProductUrl } - model.SchemaVersion = common.GetSchemaVersionOrDefault(msg) + model.SchemaVersion = msg.SchemaVersion if msg.LsfRevision > 0 { // If lsfRevision is set but no lsfURL is provided or present in model @@ -160,10 +158,9 @@ func (k msgServer) UpdateModel(goCtx context.Context, msg *types.MsgUpdateModel) // store updated product in VendorProducts k.SetVendorProduct(ctx, model.Vid, types.Product{ - Pid: model.Pid, - Name: model.ProductName, - PartNumber: model.PartNumber, - SchemaVersion: common.GetSchemaVersionOrDefault(msg), + Pid: model.Pid, + Name: model.ProductName, + PartNumber: model.PartNumber, }) return &types.MsgUpdateModelResponse{}, nil diff --git a/x/model/keeper/msg_server_model_version.go b/x/model/keeper/msg_server_model_version.go index 245c1b1f5..dfc2f4c2a 100644 --- a/x/model/keeper/msg_server_model_version.go +++ b/x/model/keeper/msg_server_model_version.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" dclcompltypes "github.com/zigbee-alliance/distributed-compliance-ledger/types/compliance" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" "github.com/zigbee-alliance/distributed-compliance-ledger/x/model/types" ) @@ -59,7 +58,7 @@ func (k msgServer) CreateModelVersion(goCtx context.Context, msg *types.MsgCreat MinApplicableSoftwareVersion: msg.MinApplicableSoftwareVersion, MaxApplicableSoftwareVersion: msg.MaxApplicableSoftwareVersion, ReleaseNotesUrl: msg.ReleaseNotesUrl, - SchemaVersion: common.GetSchemaVersionOrDefault(msg), + SchemaVersion: msg.SchemaVersion, } // store new model version @@ -135,7 +134,7 @@ func (k msgServer) UpdateModelVersion(goCtx context.Context, msg *types.MsgUpdat modelVersion.ReleaseNotesUrl = msg.ReleaseNotesUrl } - modelVersion.SchemaVersion = common.GetSchemaVersionOrDefault(msg) + modelVersion.SchemaVersion = msg.SchemaVersion // store updated model version k.SetModelVersion(ctx, modelVersion) diff --git a/x/model/types/product.pb.go b/x/model/types/product.pb.go index 9b20f41b9..207556873 100644 --- a/x/model/types/product.pb.go +++ b/x/model/types/product.pb.go @@ -23,10 +23,9 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Product struct { - Pid int32 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - PartNumber string `protobuf:"bytes,3,opt,name=partNumber,proto3" json:"partNumber,omitempty"` - SchemaVersion uint32 `protobuf:"varint,4,opt,name=schemaVersion,proto3" json:"schemaVersion,omitempty"` + Pid int32 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + PartNumber string `protobuf:"bytes,3,opt,name=partNumber,proto3" json:"partNumber,omitempty"` } func (m *Product) Reset() { *m = Product{} } @@ -83,13 +82,6 @@ func (m *Product) GetPartNumber() string { return "" } -func (m *Product) GetSchemaVersion() uint32 { - if m != nil { - return m.SchemaVersion - } - return 0 -} - func init() { proto.RegisterType((*Product)(nil), "zigbeealliance.distributedcomplianceledger.model.Product") } @@ -97,23 +89,21 @@ func init() { func init() { proto.RegisterFile("model/product.proto", fileDescriptor_84a2bcf6440d083f) } var fileDescriptor_84a2bcf6440d083f = []byte{ - // 241 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xbf, 0x4a, 0xc5, 0x30, - 0x14, 0xc6, 0x1b, 0xef, 0x55, 0x31, 0x70, 0x41, 0xe2, 0xd2, 0x29, 0x14, 0x71, 0xe8, 0xd2, 0x46, - 0xf0, 0x0d, 0x1c, 0x1c, 0x45, 0x3a, 0x38, 0x38, 0x99, 0x3f, 0x87, 0xde, 0x40, 0xd3, 0x84, 0x34, - 0x01, 0xf5, 0x29, 0x7c, 0x2c, 0xc7, 0x3b, 0x3a, 0x4a, 0xfb, 0x22, 0x62, 0x82, 0x58, 0xb7, 0x8f, - 0xdf, 0xe1, 0x7c, 0xf0, 0xfb, 0xf0, 0x85, 0xb1, 0x0a, 0x06, 0xe6, 0xbc, 0x55, 0x51, 0x86, 0xd6, - 0x79, 0x1b, 0x2c, 0xb9, 0x7e, 0xd3, 0xbd, 0x00, 0xe0, 0xc3, 0xa0, 0xf9, 0x28, 0xa1, 0x55, 0x7a, - 0x0a, 0x5e, 0x8b, 0x18, 0x40, 0x49, 0x6b, 0x5c, 0xa6, 0x03, 0xa8, 0x1e, 0x7c, 0x9b, 0xfe, 0x2f, - 0x23, 0x3e, 0x7d, 0xc8, 0x15, 0xe4, 0x1c, 0x6f, 0x9c, 0x56, 0x25, 0xaa, 0x50, 0x7d, 0xdc, 0xfd, - 0x44, 0x42, 0xf0, 0x76, 0xe4, 0x06, 0xca, 0xa3, 0x0a, 0xd5, 0x67, 0x5d, 0xca, 0x84, 0x62, 0xec, - 0xb8, 0x0f, 0xf7, 0xd1, 0x08, 0xf0, 0xe5, 0x26, 0x5d, 0x56, 0x84, 0x5c, 0xe1, 0xdd, 0x24, 0xf7, - 0x60, 0xf8, 0x23, 0xf8, 0x49, 0xdb, 0xb1, 0xdc, 0x56, 0xa8, 0xde, 0x75, 0xff, 0xe1, 0xed, 0xf3, - 0xc7, 0x4c, 0xd1, 0x61, 0xa6, 0xe8, 0x6b, 0xa6, 0xe8, 0x7d, 0xa1, 0xc5, 0x61, 0xa1, 0xc5, 0xe7, - 0x42, 0x8b, 0xa7, 0xbb, 0x5e, 0x87, 0x7d, 0x14, 0xad, 0xb4, 0x86, 0x65, 0x9b, 0xe6, 0x57, 0x87, - 0xad, 0x74, 0x9a, 0x3f, 0x9f, 0x26, 0x0b, 0xb1, 0x17, 0x96, 0x27, 0x09, 0xaf, 0x0e, 0x26, 0x71, - 0x92, 0x16, 0xb9, 0xf9, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x55, 0xdc, 0xff, 0x72, 0x28, 0x01, 0x00, - 0x00, + // 219 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0xcf, 0xbd, 0x4a, 0xc5, 0x30, + 0x1c, 0x05, 0xf0, 0xc6, 0xeb, 0x07, 0x66, 0x92, 0xb8, 0x74, 0x0a, 0x17, 0xa7, 0xbb, 0x34, 0x11, + 0x7c, 0x03, 0x07, 0x47, 0x95, 0x8e, 0x4e, 0xe6, 0xe3, 0x4f, 0x0d, 0x24, 0x4d, 0x48, 0x13, 0x50, + 0x9f, 0xc2, 0xc7, 0x72, 0xec, 0xe8, 0x28, 0xed, 0x8b, 0x88, 0x09, 0x62, 0xb7, 0xc3, 0x09, 0xf9, + 0xf3, 0x3b, 0xf8, 0xd2, 0x79, 0x0d, 0x96, 0x87, 0xe8, 0x75, 0x56, 0x89, 0x85, 0xe8, 0x93, 0x27, + 0xd7, 0xef, 0x66, 0x90, 0x00, 0xc2, 0x5a, 0x23, 0x46, 0x05, 0x4c, 0x9b, 0x29, 0x45, 0x23, 0x73, + 0x02, 0xad, 0xbc, 0x0b, 0xb5, 0xb5, 0xa0, 0x07, 0x88, 0xac, 0xfc, 0xbf, 0x7a, 0xc0, 0x67, 0x8f, + 0xf5, 0x04, 0xb9, 0xc0, 0xbb, 0x60, 0x74, 0x8b, 0xf6, 0xe8, 0x70, 0xd2, 0xff, 0x46, 0x42, 0xf0, + 0xf1, 0x28, 0x1c, 0xb4, 0x47, 0x7b, 0x74, 0x38, 0xef, 0x4b, 0x26, 0x14, 0xe3, 0x20, 0x62, 0xba, + 0xcf, 0x4e, 0x42, 0x6c, 0x77, 0xe5, 0x65, 0xd3, 0xdc, 0x3e, 0x7f, 0x2e, 0x14, 0xcd, 0x0b, 0x45, + 0xdf, 0x0b, 0x45, 0x1f, 0x2b, 0x6d, 0xe6, 0x95, 0x36, 0x5f, 0x2b, 0x6d, 0x9e, 0xee, 0x06, 0x93, + 0x5e, 0xb2, 0x64, 0xca, 0x3b, 0x5e, 0x9d, 0xdd, 0x1f, 0x94, 0x6f, 0xa0, 0xdd, 0xbf, 0xb4, 0xab, + 0x54, 0xfe, 0xca, 0xeb, 0xd8, 0xf4, 0x16, 0x60, 0x92, 0xa7, 0x65, 0xeb, 0xcd, 0x4f, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x2c, 0x1b, 0x69, 0x2b, 0x02, 0x01, 0x00, 0x00, } func (m *Product) Marshal() (dAtA []byte, err error) { @@ -136,11 +126,6 @@ func (m *Product) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.SchemaVersion != 0 { - i = encodeVarintProduct(dAtA, i, uint64(m.SchemaVersion)) - i-- - dAtA[i] = 0x20 - } if len(m.PartNumber) > 0 { i -= len(m.PartNumber) copy(dAtA[i:], m.PartNumber) @@ -191,9 +176,6 @@ func (m *Product) Size() (n int) { if l > 0 { n += 1 + l + sovProduct(uint64(l)) } - if m.SchemaVersion != 0 { - n += 1 + sovProduct(uint64(m.SchemaVersion)) - } return n } @@ -315,25 +297,6 @@ func (m *Product) Unmarshal(dAtA []byte) error { } m.PartNumber = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaVersion", wireType) - } - m.SchemaVersion = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProduct - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SchemaVersion |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipProduct(dAtA[iNdEx:]) diff --git a/x/pki/client/cli/tx_add_noc_x_509_cert.go b/x/pki/client/cli/tx_add_noc_x_509_cert.go index eb82c3277..65c67dede 100644 --- a/x/pki/client/cli/tx_add_noc_x_509_cert.go +++ b/x/pki/client/cli/tx_add_noc_x_509_cert.go @@ -52,7 +52,7 @@ func CmdAddNocX509Cert() *cobra.Command { cmd.Flags().StringP(FlagCertificate, FlagCertificateShortcut, "", "PEM encoded certificate (string or path to file containing data)") - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") cli.AddTxFlagsToCmd(cmd) diff --git a/x/pki/client/cli/tx_add_noc_x_509_root_cert.go b/x/pki/client/cli/tx_add_noc_x_509_root_cert.go index 89122bbab..916c10c47 100644 --- a/x/pki/client/cli/tx_add_noc_x_509_root_cert.go +++ b/x/pki/client/cli/tx_add_noc_x_509_root_cert.go @@ -51,7 +51,7 @@ func CmdAddNocX509RootCert() *cobra.Command { cmd.Flags().StringP(FlagCertificate, FlagCertificateShortcut, "", "PEM encoded certificate (string or path to file containing data)") - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") cli.AddTxFlagsToCmd(cmd) diff --git a/x/pki/client/cli/tx_add_pki_revocation_distribution_point.go b/x/pki/client/cli/tx_add_pki_revocation_distribution_point.go index c29652538..7ae91dfc0 100644 --- a/x/pki/client/cli/tx_add_pki_revocation_distribution_point.go +++ b/x/pki/client/cli/tx_add_pki_revocation_distribution_point.go @@ -85,7 +85,7 @@ func CmdAddPkiRevocationDistributionPoint() *cobra.Command { cmd.Flags().StringVar(&dataDigest, FlagDataDigest, "", "Digest of the entire contents of the associated file downloaded from the DataURL. Must be omitted if RevocationType is 1. Must be provided if and only if the DataFileSize field is present") cmd.Flags().Uint32Var(&dataDigestType, FlagDataDigestType, 0, "The type of digest used in the DataDigest field from the list of [1, 7, 8, 10, 11, 12] (IANA Named Information Hash Algorithm Registry). Must be provided if and only if the DataDigest field is present") //TODO: will give error if omitted cmd.Flags().Uint32Var(&revocationType, FlagRevocationType, 1, "The type of file found at the DataURL for this entry. Supported types: 1 - RFC5280 Certificate Revocation List (CRL)") - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") flags.AddTxFlagsToCmd(cmd) diff --git a/x/pki/client/cli/tx_add_x_509_cert.go b/x/pki/client/cli/tx_add_x_509_cert.go index 057830f97..117d11830 100644 --- a/x/pki/client/cli/tx_add_x_509_cert.go +++ b/x/pki/client/cli/tx_add_x_509_cert.go @@ -53,7 +53,7 @@ func CmdAddX509Cert() *cobra.Command { cmd.Flags().StringP(FlagCertificate, FlagCertificateShortcut, "", "PEM encoded certificate (string or path to file containing data)") - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") cli.AddTxFlagsToCmd(cmd) diff --git a/x/pki/client/cli/tx_propose_add_x_509_root_cert.go b/x/pki/client/cli/tx_propose_add_x_509_root_cert.go index d22543a37..fec6ce2a9 100644 --- a/x/pki/client/cli/tx_propose_add_x_509_root_cert.go +++ b/x/pki/client/cli/tx_propose_add_x_509_root_cert.go @@ -59,7 +59,7 @@ func CmdProposeAddX509RootCert() *cobra.Command { "PEM encoded certificate (string or path to file containing data)") cmd.Flags().String(FlagInfo, "", FlagInfoUsage) cmd.Flags().Int32(FlagVid, 0, "Model vendor ID (positive non-zero uint16)") - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") cli.AddTxFlagsToCmd(cmd) diff --git a/x/pki/client/cli/tx_update_pki_revocation_distribution_point.go b/x/pki/client/cli/tx_update_pki_revocation_distribution_point.go index 3ae44e63e..cfbfa75ae 100644 --- a/x/pki/client/cli/tx_update_pki_revocation_distribution_point.go +++ b/x/pki/client/cli/tx_update_pki_revocation_distribution_point.go @@ -75,7 +75,7 @@ func CmdUpdatePkiRevocationDistributionPoint() *cobra.Command { cmd.Flags().Uint64Var(&dataFileSize, FlagDataFileSize, 0, "Total size in bytes of the file found at the DataURL. Must be omitted if RevocationType is 1") cmd.Flags().StringVar(&dataDigest, FlagDataDigest, "", "Digest of the entire contents of the associated file downloaded from the DataURL. Must be omitted if RevocationType is 1. Must be provided if and only if the DataFileSize field is present") cmd.Flags().Uint32Var(&dataDigestType, FlagDataDigestType, 0, "The type of digest used in the DataDigest field from the list of [1, 7, 8, 10, 11, 12] (IANA Named Information Hash Algorithm Registry). Must be provided if and only if the DataDigest field is present") //TODO: will give error if omitted - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") flags.AddTxFlagsToCmd(cmd) diff --git a/x/pki/handler_test.go b/x/pki/handler_test.go index 3030afc57..98ff976ee 100644 --- a/x/pki/handler_test.go +++ b/x/pki/handler_test.go @@ -619,8 +619,7 @@ func TestHandler_ApproveAddX509RootCert_ForEnoughApprovals(t *testing.T) { require.Equal(t, testconstants.RootSubject, approvedCertificate.Subject) require.Equal(t, testconstants.RootSubjectKeyID, approvedCertificate.SubjectKeyId) require.Equal(t, testconstants.RootSerialNumber, approvedCertificate.SerialNumber) - // Check that `schemaVersion` should be changed to 1 - require.Equal(t, schemaVersion+1, approvedCertificate.SchemaVersion) + require.Equal(t, schemaVersion, approvedCertificate.SchemaVersion) require.True(t, approvedCertificate.IsRoot) require.Empty(t, approvedCertificate.RootSubject) require.Empty(t, approvedCertificate.RootSubjectKeyId) diff --git a/x/pki/handler_update_revocation_test.go b/x/pki/handler_update_revocation_test.go index c362ab090..c37e69e1d 100644 --- a/x/pki/handler_update_revocation_test.go +++ b/x/pki/handler_update_revocation_test.go @@ -367,6 +367,7 @@ func TestHandler_UpdatePkiRevocationDistributionPoint_PAA_VID(t *testing.T) { name string updatedRevocation types.MsgUpdatePkiRevocationDistributionPoint err error + schemaVersion uint32 }{ { name: "Valid: PAAWithVid", @@ -377,8 +378,8 @@ func TestHandler_UpdatePkiRevocationDistributionPoint_PAA_VID(t *testing.T) { Label: addedRevocation.Label, DataURL: addedRevocation.DataURL, IssuerSubjectKeyID: addedRevocation.IssuerSubjectKeyID, - SchemaVersion: 2, }, + schemaVersion: uint32(0), }, { name: "Valid: MinimalParams", @@ -387,8 +388,9 @@ func TestHandler_UpdatePkiRevocationDistributionPoint_PAA_VID(t *testing.T) { Vid: addedRevocation.Vid, Label: addedRevocation.Label, IssuerSubjectKeyID: addedRevocation.IssuerSubjectKeyID, - SchemaVersion: 2, + SchemaVersion: 1, }, + schemaVersion: uint32(1), }, { name: "Valid: AllParams", @@ -398,8 +400,9 @@ func TestHandler_UpdatePkiRevocationDistributionPoint_PAA_VID(t *testing.T) { Label: addedRevocation.Label, DataURL: addedRevocation.DataURL + "/new", IssuerSubjectKeyID: addedRevocation.IssuerSubjectKeyID, - SchemaVersion: 2, + SchemaVersion: 999999999, }, + schemaVersion: uint32(999999999), }, } for _, tc := range cases { @@ -427,7 +430,7 @@ func TestHandler_UpdatePkiRevocationDistributionPoint_PAA_VID(t *testing.T) { require.Equal(t, updatedPoint.Label, addedRevocation.Label) require.Equal(t, updatedPoint.IssuerSubjectKeyID, addedRevocation.IssuerSubjectKeyID) require.Equal(t, updatedPoint.RevocationType, addedRevocation.RevocationType) - require.Equal(t, updatedPoint.SchemaVersion, uint32(2)) + require.Equal(t, updatedPoint.SchemaVersion, tc.schemaVersion) compareUpdatedStringFields(t, addedRevocation.DataURL, tc.updatedRevocation.DataURL, updatedPoint.DataURL) compareUpdatedStringFields(t, addedRevocation.DataDigest, tc.updatedRevocation.DataDigest, updatedPoint.DataDigest) diff --git a/x/pki/keeper/msg_server_add_noc_x_509_cert.go b/x/pki/keeper/msg_server_add_noc_x_509_cert.go index 52d661dc8..e7ce3effd 100644 --- a/x/pki/keeper/msg_server_add_noc_x_509_cert.go +++ b/x/pki/keeper/msg_server_add_noc_x_509_cert.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" pkitypes "github.com/zigbee-alliance/distributed-compliance-ledger/types/pki" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/x509" @@ -99,7 +98,7 @@ func (k msgServer) AddNocX509Cert(goCtx context.Context, msg *types.MsgAddNocX50 rootCert.SubjectKeyID, msg.Signer, accountVid, - common.GetSchemaVersionOrDefault(msg), + msg.SchemaVersion, ) // Add a NOC certificate to the list of NOC certificates with the same VID diff --git a/x/pki/keeper/msg_server_add_noc_x_509_root_cert.go b/x/pki/keeper/msg_server_add_noc_x_509_root_cert.go index f4ac3c022..57b851c65 100644 --- a/x/pki/keeper/msg_server_add_noc_x_509_root_cert.go +++ b/x/pki/keeper/msg_server_add_noc_x_509_root_cert.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" pkitypes "github.com/zigbee-alliance/distributed-compliance-ledger/types/pki" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/x509" @@ -82,7 +81,7 @@ func (k msgServer) AddNocX509RootCert(goCtx context.Context, msg *types.MsgAddNo x509Certificate.SerialNumber, msg.Signer, signerVid, - common.GetSchemaVersionOrDefault(msg), + msg.SchemaVersion, ) // Add a NOC root certificate to the list of NOC root certificates with the same VID diff --git a/x/pki/keeper/msg_server_add_pki_revocation_distribution_point.go b/x/pki/keeper/msg_server_add_pki_revocation_distribution_point.go index 85f053cfc..f90f1b89b 100644 --- a/x/pki/keeper/msg_server_add_pki_revocation_distribution_point.go +++ b/x/pki/keeper/msg_server_add_pki_revocation_distribution_point.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" pkitypes "github.com/zigbee-alliance/distributed-compliance-ledger/types/pki" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/x509" @@ -75,7 +74,7 @@ func (k msgServer) AddPkiRevocationDistributionPoint(goCtx context.Context, msg DataDigest: msg.DataDigest, DataDigestType: msg.DataDigestType, RevocationType: msg.RevocationType, - SchemaVersion: common.GetSchemaVersionOrDefault(msg), + SchemaVersion: msg.SchemaVersion, } k.SetPkiRevocationDistributionPoint(ctx, pkiRevocationDistributionPoint) diff --git a/x/pki/keeper/msg_server_add_x_509_cert.go b/x/pki/keeper/msg_server_add_x_509_cert.go index ed6990a63..201622a97 100644 --- a/x/pki/keeper/msg_server_add_x_509_cert.go +++ b/x/pki/keeper/msg_server_add_x_509_cert.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" pkitypes "github.com/zigbee-alliance/distributed-compliance-ledger/types/pki" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/x509" @@ -99,7 +98,7 @@ func (k msgServer) AddX509Cert(goCtx context.Context, msg *types.MsgAddX509Cert) rootCert.Subject, rootCert.SubjectKeyId, msg.Signer, - common.GetSchemaVersionOrDefault(msg), + msg.SchemaVersion, ) // append new certificate to list of certificates with the same Subject/SubjectKeyId combination and store updated list diff --git a/x/pki/keeper/msg_server_propose_add_x_509_root_cert.go b/x/pki/keeper/msg_server_propose_add_x_509_root_cert.go index 248401be7..64974dd5f 100644 --- a/x/pki/keeper/msg_server_propose_add_x_509_root_cert.go +++ b/x/pki/keeper/msg_server_propose_add_x_509_root_cert.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" pkitypes "github.com/zigbee-alliance/distributed-compliance-ledger/types/pki" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/x509" ) @@ -95,7 +94,7 @@ func (k msgServer) ProposeAddX509RootCert(goCtx context.Context, msg *types.MsgP Owner: msg.Signer, Approvals: []*types.Grant{}, Vid: msg.Vid, - SchemaVersion: common.GetSchemaVersionOrDefault(msg), + SchemaVersion: msg.SchemaVersion, } proposedCertificate.Approvals = append(proposedCertificate.Approvals, &grant) diff --git a/x/pki/keeper/msg_server_update_pki_revocation_distribution_point.go b/x/pki/keeper/msg_server_update_pki_revocation_distribution_point.go index 722bb6c4f..a433728fd 100644 --- a/x/pki/keeper/msg_server_update_pki_revocation_distribution_point.go +++ b/x/pki/keeper/msg_server_update_pki_revocation_distribution_point.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" pkitypes "github.com/zigbee-alliance/distributed-compliance-ledger/types/pki" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types" "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/x509" @@ -63,7 +62,7 @@ func (k msgServer) UpdatePkiRevocationDistributionPoint(goCtx context.Context, m pkiRevocationDistributionPoint.DataDigestType = msg.DataDigestType } - pkiRevocationDistributionPoint.SchemaVersion = common.GetSchemaVersionOrDefault(msg) + pkiRevocationDistributionPoint.SchemaVersion = msg.SchemaVersion revocationList, isFound := k.GetPkiRevocationDistributionPointsByIssuerSubjectKeyID(ctx, msg.IssuerSubjectKeyID) if isFound { diff --git a/x/vendorinfo/client/cli/tx_vendor_info.go b/x/vendorinfo/client/cli/tx_vendor_info.go index 1567487d5..edf498f25 100644 --- a/x/vendorinfo/client/cli/tx_vendor_info.go +++ b/x/vendorinfo/client/cli/tx_vendor_info.go @@ -61,7 +61,7 @@ func CmdCreateVendorInfo() *cobra.Command { cmd.Flags().StringVarP(&vendorLandingPageURL, FlagVendorLandingPageURL, FlagVendorLandingPageURLShortcut, "", "Landing Page URL for the Vendor") cli.AddTxFlagsToCmd(cmd) - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") _ = cmd.MarkFlagRequired(FlagVID) _ = cmd.MarkFlagRequired(FlagVendorName) @@ -121,7 +121,7 @@ func CmdUpdateVendorInfo() *cobra.Command { "", "Company Preferred Name") cmd.Flags().StringVarP(&vendorLandingPageURL, FlagVendorLandingPageURL, FlagVendorLandingPageURLShortcut, "", "Landing Page URL for the Vendor") - cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version") + cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version") cli.AddTxFlagsToCmd(cmd) diff --git a/x/vendorinfo/keeper/msg_server_vendor_info.go b/x/vendorinfo/keeper/msg_server_vendor_info.go index 0800b4755..57186deb4 100644 --- a/x/vendorinfo/keeper/msg_server_vendor_info.go +++ b/x/vendorinfo/keeper/msg_server_vendor_info.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zigbee-alliance/distributed-compliance-ledger/x/common" "github.com/zigbee-alliance/distributed-compliance-ledger/x/vendorinfo/types" ) @@ -34,7 +33,7 @@ func (k msgServer) CreateVendorInfo(goCtx context.Context, msg *types.MsgCreateV CompanyLegalName: msg.CompanyLegalName, CompanyPreferredName: msg.CompanyPreferredName, VendorLandingPageURL: msg.VendorLandingPageURL, - SchemaVersion: common.GetSchemaVersionOrDefault(msg), + SchemaVersion: msg.SchemaVersion, } k.SetVendorInfo( @@ -91,7 +90,7 @@ func (k msgServer) UpdateVendorInfo(goCtx context.Context, msg *types.MsgUpdateV vendorInfo.VendorLandingPageURL = msg.VendorLandingPageURL } - vendorInfo.SchemaVersion = common.GetSchemaVersionOrDefault(msg) + vendorInfo.SchemaVersion = msg.SchemaVersion k.SetVendorInfo(ctx, vendorInfo)