Skip to content

Commit 6d5bd04

Browse files
committed
#524 Enable removing NOC root certificates
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com> Signed-off-by: Abdulbois <abdulbois123@gmail.com>
1 parent 9bde610 commit 6d5bd04

File tree

17 files changed

+1884
-313
lines changed

17 files changed

+1884
-313
lines changed

proto/zigbeealliance/distributedcomplianceledger/pki/tx.proto

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ service Msg {
2727
rpc RevokeNocX509RootCert(MsgRevokeNocX509RootCert) returns (MsgRevokeNocX509RootCertResponse);
2828
rpc RevokeNocX509IcaCert(MsgRevokeNocX509IcaCert) returns (MsgRevokeNocX509IcaCertResponse);
2929
rpc RemoveNocX509IcaCert (MsgRemoveNocX509IcaCert) returns (MsgRemoveNocX509IcaCertResponse);
30+
rpc RemoveNocX509RootCert (MsgRemoveNocX509RootCert) returns (MsgRemoveNocX509RootCertResponse);
3031
// this line is used by starport scaffolding # proto/tx/rpc
3132
}
3233

@@ -241,3 +242,12 @@ message MsgRemoveNocX509IcaCert {
241242
}
242243

243244
message MsgRemoveNocX509IcaCertResponse {}
245+
246+
message MsgRemoveNocX509RootCert {
247+
string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.moretags) = "validate:\"required\""];
248+
string subject = 2 [(gogoproto.moretags) = "validate:\"required,max=1024\""];
249+
string subjectKeyId = 3 [(gogoproto.moretags) = "validate:\"required,max=256\""];
250+
string serialNumber = 4;
251+
}
252+
253+
message MsgRemoveNocX509RootCertResponse {}

scripts/ignite/07.pki_types.sh

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
# messages
44
ignite scaffold --module pki message RemoveNocX509IcaCert subject subjectKeyId serialNumber --signer signer
5+
ignite scaffold --module pki message RemoveNocX509RootCert subject subjectKeyId serialNumber --signer signer

ts-client/zigbeealliance.distributedcomplianceledger.pki/module.ts

+225-192
Large diffs are not rendered by default.

ts-client/zigbeealliance.distributedcomplianceledger.pki/registry.ts

+24-22
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
11
import { GeneratedType } from "@cosmjs/proto-signing";
2-
import { MsgDeletePkiRevocationDistributionPoint } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
3-
import { MsgApproveRevokeX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
4-
import { MsgRemoveNocX509IcaCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
52
import { MsgApproveAddX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
3+
import { MsgRemoveNocX509IcaCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
4+
import { MsgRevokeNocX509IcaCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
5+
import { MsgDeletePkiRevocationDistributionPoint } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
6+
import { MsgAddNocX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
7+
import { MsgRemoveNocX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
68
import { MsgAddX509Cert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
7-
import { MsgUpdatePkiRevocationDistributionPoint } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
8-
import { MsgAssignVid } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
9-
import { MsgRemoveX509Cert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
10-
import { MsgRevokeX509Cert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
11-
import { MsgProposeRevokeX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
129
import { MsgRejectAddX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
13-
import { MsgAddNocX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
14-
import { MsgProposeAddX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
1510
import { MsgRevokeNocX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
11+
import { MsgProposeAddX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
1612
import { MsgAddPkiRevocationDistributionPoint } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
17-
import { MsgRevokeNocX509IcaCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
13+
import { MsgProposeRevokeX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
1814
import { MsgAddNocX509IcaCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
15+
import { MsgAssignVid } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
16+
import { MsgRemoveX509Cert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
17+
import { MsgRevokeX509Cert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
18+
import { MsgApproveRevokeX509RootCert } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
19+
import { MsgUpdatePkiRevocationDistributionPoint } from "./types/zigbeealliance/distributedcomplianceledger/pki/tx";
1920

2021
const msgTypes: Array<[string, GeneratedType]> = [
21-
["/zigbeealliance.distributedcomplianceledger.pki.MsgDeletePkiRevocationDistributionPoint", MsgDeletePkiRevocationDistributionPoint],
22-
["/zigbeealliance.distributedcomplianceledger.pki.MsgApproveRevokeX509RootCert", MsgApproveRevokeX509RootCert],
23-
["/zigbeealliance.distributedcomplianceledger.pki.MsgRemoveNocX509IcaCert", MsgRemoveNocX509IcaCert],
2422
["/zigbeealliance.distributedcomplianceledger.pki.MsgApproveAddX509RootCert", MsgApproveAddX509RootCert],
23+
["/zigbeealliance.distributedcomplianceledger.pki.MsgRemoveNocX509IcaCert", MsgRemoveNocX509IcaCert],
24+
["/zigbeealliance.distributedcomplianceledger.pki.MsgRevokeNocX509IcaCert", MsgRevokeNocX509IcaCert],
25+
["/zigbeealliance.distributedcomplianceledger.pki.MsgDeletePkiRevocationDistributionPoint", MsgDeletePkiRevocationDistributionPoint],
26+
["/zigbeealliance.distributedcomplianceledger.pki.MsgAddNocX509RootCert", MsgAddNocX509RootCert],
27+
["/zigbeealliance.distributedcomplianceledger.pki.MsgRemoveNocX509RootCert", MsgRemoveNocX509RootCert],
2528
["/zigbeealliance.distributedcomplianceledger.pki.MsgAddX509Cert", MsgAddX509Cert],
26-
["/zigbeealliance.distributedcomplianceledger.pki.MsgUpdatePkiRevocationDistributionPoint", MsgUpdatePkiRevocationDistributionPoint],
27-
["/zigbeealliance.distributedcomplianceledger.pki.MsgAssignVid", MsgAssignVid],
28-
["/zigbeealliance.distributedcomplianceledger.pki.MsgRemoveX509Cert", MsgRemoveX509Cert],
29-
["/zigbeealliance.distributedcomplianceledger.pki.MsgRevokeX509Cert", MsgRevokeX509Cert],
30-
["/zigbeealliance.distributedcomplianceledger.pki.MsgProposeRevokeX509RootCert", MsgProposeRevokeX509RootCert],
3129
["/zigbeealliance.distributedcomplianceledger.pki.MsgRejectAddX509RootCert", MsgRejectAddX509RootCert],
32-
["/zigbeealliance.distributedcomplianceledger.pki.MsgAddNocX509RootCert", MsgAddNocX509RootCert],
33-
["/zigbeealliance.distributedcomplianceledger.pki.MsgProposeAddX509RootCert", MsgProposeAddX509RootCert],
3430
["/zigbeealliance.distributedcomplianceledger.pki.MsgRevokeNocX509RootCert", MsgRevokeNocX509RootCert],
31+
["/zigbeealliance.distributedcomplianceledger.pki.MsgProposeAddX509RootCert", MsgProposeAddX509RootCert],
3532
["/zigbeealliance.distributedcomplianceledger.pki.MsgAddPkiRevocationDistributionPoint", MsgAddPkiRevocationDistributionPoint],
36-
["/zigbeealliance.distributedcomplianceledger.pki.MsgRevokeNocX509IcaCert", MsgRevokeNocX509IcaCert],
33+
["/zigbeealliance.distributedcomplianceledger.pki.MsgProposeRevokeX509RootCert", MsgProposeRevokeX509RootCert],
3734
["/zigbeealliance.distributedcomplianceledger.pki.MsgAddNocX509IcaCert", MsgAddNocX509IcaCert],
35+
["/zigbeealliance.distributedcomplianceledger.pki.MsgAssignVid", MsgAssignVid],
36+
["/zigbeealliance.distributedcomplianceledger.pki.MsgRemoveX509Cert", MsgRemoveX509Cert],
37+
["/zigbeealliance.distributedcomplianceledger.pki.MsgRevokeX509Cert", MsgRevokeX509Cert],
38+
["/zigbeealliance.distributedcomplianceledger.pki.MsgApproveRevokeX509RootCert", MsgApproveRevokeX509RootCert],
39+
["/zigbeealliance.distributedcomplianceledger.pki.MsgUpdatePkiRevocationDistributionPoint", MsgUpdatePkiRevocationDistributionPoint],
3840

3941
];
4042

ts-client/zigbeealliance.distributedcomplianceledger.pki/rest.ts

+2
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ export type PkiMsgRejectAddX509RootCertResponse = object;
210210

211211
export type PkiMsgRemoveNocX509IcaCertResponse = object;
212212

213+
export type PkiMsgRemoveNocX509RootCertResponse = object;
214+
213215
export type PkiMsgRemoveX509CertResponse = object;
214216

215217
export type PkiMsgRevokeNocX509IcaCertResponse = object;

ts-client/zigbeealliance.distributedcomplianceledger.pki/types/zigbeealliance/distributedcomplianceledger/pki/tx.ts

+140-1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ export interface MsgRemoveNocX509IcaCert {
217217
export interface MsgRemoveNocX509IcaCertResponse {
218218
}
219219

220+
export interface MsgRemoveNocX509RootCert {
221+
signer: string;
222+
subject: string;
223+
subjectKeyId: string;
224+
serialNumber: string;
225+
}
226+
227+
export interface MsgRemoveNocX509RootCertResponse {
228+
}
229+
220230
function createBaseMsgProposeAddX509RootCert(): MsgProposeAddX509RootCert {
221231
return { signer: "", cert: "", info: "", time: 0, vid: 0, certSchemaVersion: 0, schemaVersion: 0 };
222232
}
@@ -2646,6 +2656,123 @@ export const MsgRemoveNocX509IcaCertResponse = {
26462656
},
26472657
};
26482658

2659+
function createBaseMsgRemoveNocX509RootCert(): MsgRemoveNocX509RootCert {
2660+
return { signer: "", subject: "", subjectKeyId: "", serialNumber: "" };
2661+
}
2662+
2663+
export const MsgRemoveNocX509RootCert = {
2664+
encode(message: MsgRemoveNocX509RootCert, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
2665+
if (message.signer !== "") {
2666+
writer.uint32(10).string(message.signer);
2667+
}
2668+
if (message.subject !== "") {
2669+
writer.uint32(18).string(message.subject);
2670+
}
2671+
if (message.subjectKeyId !== "") {
2672+
writer.uint32(26).string(message.subjectKeyId);
2673+
}
2674+
if (message.serialNumber !== "") {
2675+
writer.uint32(34).string(message.serialNumber);
2676+
}
2677+
return writer;
2678+
},
2679+
2680+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgRemoveNocX509RootCert {
2681+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
2682+
let end = length === undefined ? reader.len : reader.pos + length;
2683+
const message = createBaseMsgRemoveNocX509RootCert();
2684+
while (reader.pos < end) {
2685+
const tag = reader.uint32();
2686+
switch (tag >>> 3) {
2687+
case 1:
2688+
message.signer = reader.string();
2689+
break;
2690+
case 2:
2691+
message.subject = reader.string();
2692+
break;
2693+
case 3:
2694+
message.subjectKeyId = reader.string();
2695+
break;
2696+
case 4:
2697+
message.serialNumber = reader.string();
2698+
break;
2699+
default:
2700+
reader.skipType(tag & 7);
2701+
break;
2702+
}
2703+
}
2704+
return message;
2705+
},
2706+
2707+
fromJSON(object: any): MsgRemoveNocX509RootCert {
2708+
return {
2709+
signer: isSet(object.signer) ? String(object.signer) : "",
2710+
subject: isSet(object.subject) ? String(object.subject) : "",
2711+
subjectKeyId: isSet(object.subjectKeyId) ? String(object.subjectKeyId) : "",
2712+
serialNumber: isSet(object.serialNumber) ? String(object.serialNumber) : "",
2713+
};
2714+
},
2715+
2716+
toJSON(message: MsgRemoveNocX509RootCert): unknown {
2717+
const obj: any = {};
2718+
message.signer !== undefined && (obj.signer = message.signer);
2719+
message.subject !== undefined && (obj.subject = message.subject);
2720+
message.subjectKeyId !== undefined && (obj.subjectKeyId = message.subjectKeyId);
2721+
message.serialNumber !== undefined && (obj.serialNumber = message.serialNumber);
2722+
return obj;
2723+
},
2724+
2725+
fromPartial<I extends Exact<DeepPartial<MsgRemoveNocX509RootCert>, I>>(object: I): MsgRemoveNocX509RootCert {
2726+
const message = createBaseMsgRemoveNocX509RootCert();
2727+
message.signer = object.signer ?? "";
2728+
message.subject = object.subject ?? "";
2729+
message.subjectKeyId = object.subjectKeyId ?? "";
2730+
message.serialNumber = object.serialNumber ?? "";
2731+
return message;
2732+
},
2733+
};
2734+
2735+
function createBaseMsgRemoveNocX509RootCertResponse(): MsgRemoveNocX509RootCertResponse {
2736+
return {};
2737+
}
2738+
2739+
export const MsgRemoveNocX509RootCertResponse = {
2740+
encode(_: MsgRemoveNocX509RootCertResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
2741+
return writer;
2742+
},
2743+
2744+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgRemoveNocX509RootCertResponse {
2745+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
2746+
let end = length === undefined ? reader.len : reader.pos + length;
2747+
const message = createBaseMsgRemoveNocX509RootCertResponse();
2748+
while (reader.pos < end) {
2749+
const tag = reader.uint32();
2750+
switch (tag >>> 3) {
2751+
default:
2752+
reader.skipType(tag & 7);
2753+
break;
2754+
}
2755+
}
2756+
return message;
2757+
},
2758+
2759+
fromJSON(_: any): MsgRemoveNocX509RootCertResponse {
2760+
return {};
2761+
},
2762+
2763+
toJSON(_: MsgRemoveNocX509RootCertResponse): unknown {
2764+
const obj: any = {};
2765+
return obj;
2766+
},
2767+
2768+
fromPartial<I extends Exact<DeepPartial<MsgRemoveNocX509RootCertResponse>, I>>(
2769+
_: I,
2770+
): MsgRemoveNocX509RootCertResponse {
2771+
const message = createBaseMsgRemoveNocX509RootCertResponse();
2772+
return message;
2773+
},
2774+
};
2775+
26492776
/** Msg defines the Msg service. */
26502777
export interface Msg {
26512778
ProposeAddX509RootCert(request: MsgProposeAddX509RootCert): Promise<MsgProposeAddX509RootCertResponse>;
@@ -2670,8 +2797,9 @@ export interface Msg {
26702797
AddNocX509IcaCert(request: MsgAddNocX509IcaCert): Promise<MsgAddNocX509IcaCertResponse>;
26712798
RevokeNocX509RootCert(request: MsgRevokeNocX509RootCert): Promise<MsgRevokeNocX509RootCertResponse>;
26722799
RevokeNocX509IcaCert(request: MsgRevokeNocX509IcaCert): Promise<MsgRevokeNocX509IcaCertResponse>;
2673-
/** this line is used by starport scaffolding # proto/tx/rpc */
26742800
RemoveNocX509IcaCert(request: MsgRemoveNocX509IcaCert): Promise<MsgRemoveNocX509IcaCertResponse>;
2801+
/** this line is used by starport scaffolding # proto/tx/rpc */
2802+
RemoveNocX509RootCert(request: MsgRemoveNocX509RootCert): Promise<MsgRemoveNocX509RootCertResponse>;
26752803
}
26762804

26772805
export class MsgClientImpl implements Msg {
@@ -2695,6 +2823,7 @@ export class MsgClientImpl implements Msg {
26952823
this.RevokeNocX509RootCert = this.RevokeNocX509RootCert.bind(this);
26962824
this.RevokeNocX509IcaCert = this.RevokeNocX509IcaCert.bind(this);
26972825
this.RemoveNocX509IcaCert = this.RemoveNocX509IcaCert.bind(this);
2826+
this.RemoveNocX509RootCert = this.RemoveNocX509RootCert.bind(this);
26982827
}
26992828
ProposeAddX509RootCert(request: MsgProposeAddX509RootCert): Promise<MsgProposeAddX509RootCertResponse> {
27002829
const data = MsgProposeAddX509RootCert.encode(request).finish();
@@ -2847,6 +2976,16 @@ export class MsgClientImpl implements Msg {
28472976
);
28482977
return promise.then((data) => MsgRemoveNocX509IcaCertResponse.decode(new _m0.Reader(data)));
28492978
}
2979+
2980+
RemoveNocX509RootCert(request: MsgRemoveNocX509RootCert): Promise<MsgRemoveNocX509RootCertResponse> {
2981+
const data = MsgRemoveNocX509RootCert.encode(request).finish();
2982+
const promise = this.rpc.request(
2983+
"zigbeealliance.distributedcomplianceledger.pki.Msg",
2984+
"RemoveNocX509RootCert",
2985+
data,
2986+
);
2987+
return promise.then((data) => MsgRemoveNocX509RootCertResponse.decode(new _m0.Reader(data)));
2988+
}
28502989
}
28512990

28522991
interface Rpc {

x/pki/client/cli/tx.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func GetTxCmd() *cobra.Command {
3939
cmd.AddCommand(CmdRevokeNocX509RootCert())
4040
cmd.AddCommand(CmdRevokeNocX509IcaCert())
4141
cmd.AddCommand(CmdRemoveNocX509IcaCert())
42+
cmd.AddCommand(CmdRemoveNocX509RootCert())
4243
// this line is used by starport scaffolding # 1
4344

4445
return cmd
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package cli
2+
3+
import (
4+
"strconv"
5+
6+
"github.com/cosmos/cosmos-sdk/client"
7+
"github.com/cosmos/cosmos-sdk/client/flags"
8+
"github.com/cosmos/cosmos-sdk/client/tx"
9+
"github.com/spf13/cobra"
10+
"github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types"
11+
)
12+
13+
var _ = strconv.Itoa(0)
14+
15+
func CmdRemoveNocX509RootCert() *cobra.Command {
16+
cmd := &cobra.Command{
17+
Use: "remove-noc-x-509-root-cert [subject] [subject-key-id] [serial-number]",
18+
Short: "Broadcast message RemoveNocX509RootCert",
19+
Args: cobra.ExactArgs(3),
20+
RunE: func(cmd *cobra.Command, args []string) (err error) {
21+
argSubject := args[0]
22+
argSubjectKeyId := args[1]
23+
argSerialNumber := args[2]
24+
25+
clientCtx, err := client.GetClientTxContext(cmd)
26+
if err != nil {
27+
return err
28+
}
29+
30+
msg := types.NewMsgRemoveNocX509RootCert(
31+
clientCtx.GetFromAddress().String(),
32+
argSubject,
33+
argSubjectKeyId,
34+
argSerialNumber,
35+
)
36+
if err := msg.ValidateBasic(); err != nil {
37+
return err
38+
}
39+
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
40+
},
41+
}
42+
43+
flags.AddTxFlagsToCmd(cmd)
44+
45+
return cmd
46+
}

x/pki/handler.go

+4
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
8787
case *types.MsgRemoveNocX509IcaCert:
8888
res, err := msgServer.RemoveNocX509IcaCert(sdk.WrapSDKContext(ctx), msg)
8989

90+
return sdk.WrapServiceResult(ctx, res, err)
91+
case *types.MsgRemoveNocX509RootCert:
92+
res, err := msgServer.RemoveNocX509RootCert(sdk.WrapSDKContext(ctx), msg)
93+
9094
return sdk.WrapServiceResult(ctx, res, err)
9195
// this line is used by starport scaffolding # 1
9296
default:

0 commit comments

Comments
 (0)