Skip to content

Commit

Permalink
Add a new command reject-add-x509-root-cert
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulla-ashurov committed Apr 26, 2022
1 parent 31da842 commit d8c47c4
Show file tree
Hide file tree
Showing 47 changed files with 1,413 additions and 504 deletions.
9 changes: 9 additions & 0 deletions proto/pki/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ service Msg {
rpc ProposeRevokeX509RootCert(MsgProposeRevokeX509RootCert) returns (MsgProposeRevokeX509RootCertResponse);
rpc ApproveRevokeX509RootCert(MsgApproveRevokeX509RootCert) returns (MsgApproveRevokeX509RootCertResponse);
rpc RevokeX509Cert(MsgRevokeX509Cert) returns (MsgRevokeX509CertResponse);
rpc RejectAddX509RootCert(MsgRejectAddX509RootCert) returns (MsgRejectAddX509RootCertResponse);
// this line is used by starport scaffolding # proto/tx/rpc
}

Expand Down Expand Up @@ -83,4 +84,12 @@ message MsgRevokeX509Cert {
message MsgRevokeX509CertResponse {
}

message MsgRejectAddX509RootCert {
string signer = 1;
string cert = 2;
}

message MsgRejectAddX509RootCertResponse {
}

// this line is used by starport scaffolding # proto/tx/message
1 change: 1 addition & 0 deletions scripts/starport/upgrade-0.44/07.pki_types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ starport scaffold --module pki message AddX509Cert cert --signer signer
starport scaffold --module pki message ProposeRevokeX509RootCert subject subjectKeyId --signer signer
starport scaffold --module pki message ApproveRevokeX509RootCert subject subjectKeyId --signer signer
starport scaffold --module pki message RevokeX509Cert subject subjectKeyId --signer signer
starport scaffold --module pki message RejectAddX509RootCert cert --signer signer

# CRUD data types
starport scaffold --module pki map ApprovedCertificates certs:strings --index subject,subjectKeyId --no-message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,20 @@ export default {
throw new SpVuexError('QueryClient:QueryProvisionalModelAll', 'API Node Unavailable. Could not perform query: ' + e.message);
}
},
async sendMsgRevokeModel({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgCertifyModel({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient = await initTxClient(rootGetters);
const msg = await txClient.msgRevokeModel(value);
const msg = await txClient.msgCertifyModel(value);
const result = await txClient.signAndBroadcast([msg], { fee: { amount: fee,
gas: "200000" }, memo });
return result;
}
catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgRevokeModel:Init', 'Could not initialize signing client. Wallet is required.');
throw new SpVuexError('TxClient:MsgCertifyModel:Init', 'Could not initialize signing client. Wallet is required.');
}
else {
throw new SpVuexError('TxClient:MsgRevokeModel:Send', 'Could not broadcast Tx: ' + e.message);
throw new SpVuexError('TxClient:MsgCertifyModel:Send', 'Could not broadcast Tx: ' + e.message);
}
}
},
Expand All @@ -322,35 +322,35 @@ export default {
}
}
},
async sendMsgCertifyModel({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgRevokeModel({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient = await initTxClient(rootGetters);
const msg = await txClient.msgCertifyModel(value);
const msg = await txClient.msgRevokeModel(value);
const result = await txClient.signAndBroadcast([msg], { fee: { amount: fee,
gas: "200000" }, memo });
return result;
}
catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgCertifyModel:Init', 'Could not initialize signing client. Wallet is required.');
throw new SpVuexError('TxClient:MsgRevokeModel:Init', 'Could not initialize signing client. Wallet is required.');
}
else {
throw new SpVuexError('TxClient:MsgCertifyModel:Send', 'Could not broadcast Tx: ' + e.message);
throw new SpVuexError('TxClient:MsgRevokeModel:Send', 'Could not broadcast Tx: ' + e.message);
}
}
},
async MsgRevokeModel({ rootGetters }, { value }) {
async MsgCertifyModel({ rootGetters }, { value }) {
try {
const txClient = await initTxClient(rootGetters);
const msg = await txClient.msgRevokeModel(value);
const msg = await txClient.msgCertifyModel(value);
return msg;
}
catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgRevokeModel:Init', 'Could not initialize signing client. Wallet is required.');
throw new SpVuexError('TxClient:MsgCertifyModel:Init', 'Could not initialize signing client. Wallet is required.');
}
else {
throw new SpVuexError('TxClient:MsgRevokeModel:Create', 'Could not create message: ' + e.message);
throw new SpVuexError('TxClient:MsgCertifyModel:Create', 'Could not create message: ' + e.message);
}
}
},
Expand All @@ -369,18 +369,18 @@ export default {
}
}
},
async MsgCertifyModel({ rootGetters }, { value }) {
async MsgRevokeModel({ rootGetters }, { value }) {
try {
const txClient = await initTxClient(rootGetters);
const msg = await txClient.msgCertifyModel(value);
const msg = await txClient.msgRevokeModel(value);
return msg;
}
catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgCertifyModel:Init', 'Could not initialize signing client. Wallet is required.');
throw new SpVuexError('TxClient:MsgRevokeModel:Init', 'Could not initialize signing client. Wallet is required.');
}
else {
throw new SpVuexError('TxClient:MsgCertifyModel:Create', 'Could not create message: ' + e.message);
throw new SpVuexError('TxClient:MsgRevokeModel:Create', 'Could not create message: ' + e.message);
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,18 @@ export default {
},


async sendMsgRevokeModel({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgCertifyModel({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgRevokeModel(value)
const msg = await txClient.msgCertifyModel(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgRevokeModel:Init', 'Could not initialize signing client. Wallet is required.')
throw new SpVuexError('TxClient:MsgCertifyModel:Init', 'Could not initialize signing client. Wallet is required.')
}else{
throw new SpVuexError('TxClient:MsgRevokeModel:Send', 'Could not broadcast Tx: '+ e.message)
throw new SpVuexError('TxClient:MsgCertifyModel:Send', 'Could not broadcast Tx: '+ e.message)
}
}
},
Expand All @@ -394,32 +394,32 @@ export default {
}
}
},
async sendMsgCertifyModel({ rootGetters }, { value, fee = [], memo = '' }) {
async sendMsgRevokeModel({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCertifyModel(value)
const msg = await txClient.msgRevokeModel(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgCertifyModel:Init', 'Could not initialize signing client. Wallet is required.')
throw new SpVuexError('TxClient:MsgRevokeModel:Init', 'Could not initialize signing client. Wallet is required.')
}else{
throw new SpVuexError('TxClient:MsgCertifyModel:Send', 'Could not broadcast Tx: '+ e.message)
throw new SpVuexError('TxClient:MsgRevokeModel:Send', 'Could not broadcast Tx: '+ e.message)
}
}
},

async MsgRevokeModel({ rootGetters }, { value }) {
async MsgCertifyModel({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgRevokeModel(value)
const msg = await txClient.msgCertifyModel(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgRevokeModel:Init', 'Could not initialize signing client. Wallet is required.')
throw new SpVuexError('TxClient:MsgCertifyModel:Init', 'Could not initialize signing client. Wallet is required.')
}else{
throw new SpVuexError('TxClient:MsgRevokeModel:Create', 'Could not create message: ' + e.message)
throw new SpVuexError('TxClient:MsgCertifyModel:Create', 'Could not create message: ' + e.message)

}
}
Expand All @@ -438,16 +438,16 @@ export default {
}
}
},
async MsgCertifyModel({ rootGetters }, { value }) {
async MsgRevokeModel({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCertifyModel(value)
const msg = await txClient.msgRevokeModel(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new SpVuexError('TxClient:MsgCertifyModel:Init', 'Could not initialize signing client. Wallet is required.')
throw new SpVuexError('TxClient:MsgRevokeModel:Init', 'Could not initialize signing client. Wallet is required.')
}else{
throw new SpVuexError('TxClient:MsgCertifyModel:Create', 'Could not create message: ' + e.message)
throw new SpVuexError('TxClient:MsgRevokeModel:Create', 'Could not create message: ' + e.message)

}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StdFee } from "@cosmjs/launchpad";
import { Registry, OfflineSigner, EncodeObject } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgRevokeModel } from "./types/compliance/tx";
import { MsgProvisionModel } from "./types/compliance/tx";
import { MsgCertifyModel } from "./types/compliance/tx";
import { MsgProvisionModel } from "./types/compliance/tx";
import { MsgRevokeModel } from "./types/compliance/tx";
export declare const MissingWalletError: Error;
export declare const registry: Registry;
interface TxClientOptions {
Expand All @@ -15,9 +15,9 @@ interface SignAndBroadcastOptions {
}
declare const txClient: (wallet: OfflineSigner, { addr: addr }?: TxClientOptions) => Promise<{
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }?: SignAndBroadcastOptions) => any;
msgRevokeModel: (data: MsgRevokeModel) => EncodeObject;
msgProvisionModel: (data: MsgProvisionModel) => EncodeObject;
msgCertifyModel: (data: MsgCertifyModel) => EncodeObject;
msgProvisionModel: (data: MsgProvisionModel) => EncodeObject;
msgRevokeModel: (data: MsgRevokeModel) => EncodeObject;
}>;
interface QueryClientOptions {
addr: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import { SigningStargateClient } from "@cosmjs/stargate";
import { Registry } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgRevokeModel } from "./types/compliance/tx";
import { MsgProvisionModel } from "./types/compliance/tx";
import { MsgCertifyModel } from "./types/compliance/tx";
import { MsgProvisionModel } from "./types/compliance/tx";
import { MsgRevokeModel } from "./types/compliance/tx";
const types = [
["/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", MsgRevokeModel],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgProvisionModel", MsgProvisionModel],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgCertifyModel", MsgCertifyModel],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgProvisionModel", MsgProvisionModel],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", MsgRevokeModel],
];
export const MissingWalletError = new Error("wallet is required");
export const registry = new Registry(types);
Expand All @@ -29,9 +29,9 @@ const txClient = async (wallet, { addr: addr } = { addr: "http://localhost:26657
const { address } = (await wallet.getAccounts())[0];
return {
signAndBroadcast: (msgs, { fee, memo } = { fee: defaultFee, memo: "" }) => client.signAndBroadcast(address, msgs, fee, memo),
msgRevokeModel: (data) => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", value: MsgRevokeModel.fromPartial(data) }),
msgProvisionModel: (data) => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgProvisionModel", value: MsgProvisionModel.fromPartial(data) }),
msgCertifyModel: (data) => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgCertifyModel", value: MsgCertifyModel.fromPartial(data) }),
msgProvisionModel: (data) => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgProvisionModel", value: MsgProvisionModel.fromPartial(data) }),
msgRevokeModel: (data) => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", value: MsgRevokeModel.fromPartial(data) }),
};
};
const queryClient = async ({ addr: addr } = { addr: "http://localhost:1317" }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { StdFee } from "@cosmjs/launchpad";
import { SigningStargateClient } from "@cosmjs/stargate";
import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgRevokeModel } from "./types/compliance/tx";
import { MsgProvisionModel } from "./types/compliance/tx";
import { MsgCertifyModel } from "./types/compliance/tx";
import { MsgProvisionModel } from "./types/compliance/tx";
import { MsgRevokeModel } from "./types/compliance/tx";


const types = [
["/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", MsgRevokeModel],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgProvisionModel", MsgProvisionModel],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgCertifyModel", MsgCertifyModel],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgProvisionModel", MsgProvisionModel],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", MsgRevokeModel],

];
export const MissingWalletError = new Error("wallet is required");
Expand Down Expand Up @@ -45,9 +45,9 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions =

return {
signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo),
msgRevokeModel: (data: MsgRevokeModel): EncodeObject => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", value: MsgRevokeModel.fromPartial( data ) }),
msgProvisionModel: (data: MsgProvisionModel): EncodeObject => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgProvisionModel", value: MsgProvisionModel.fromPartial( data ) }),
msgCertifyModel: (data: MsgCertifyModel): EncodeObject => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgCertifyModel", value: MsgCertifyModel.fromPartial( data ) }),
msgProvisionModel: (data: MsgProvisionModel): EncodeObject => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgProvisionModel", value: MsgProvisionModel.fromPartial( data ) }),
msgRevokeModel: (data: MsgRevokeModel): EncodeObject => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", value: MsgRevokeModel.fromPartial( data ) }),

};
};
Expand Down
Loading

0 comments on commit d8c47c4

Please sign in to comment.