Skip to content

Commit

Permalink
Generate ts-client
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemkaaas committed Nov 7, 2024
1 parent 38d604a commit ec64cd6
Show file tree
Hide file tree
Showing 15 changed files with 589 additions and 500 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { IgniteClient } from "../client"
import { MissingWalletError } from "../helpers"
import { Api } from "./rest";
import { MsgUpdateComplianceInfo } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgDeleteComplianceInfo } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgCertifyModel } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgRevokeModel } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgDeleteComplianceInfo } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgProvisionModel } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgRevokeModel } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";

import { CertifiedModel as typeCertifiedModel} from "./types"
import { ComplianceHistoryItem as typeComplianceHistoryItem} from "./types"
Expand All @@ -20,28 +20,22 @@ import { DeviceSoftwareCompliance as typeDeviceSoftwareCompliance} from "./types
import { ProvisionalModel as typeProvisionalModel} from "./types"
import { RevokedModel as typeRevokedModel} from "./types"

export { MsgUpdateComplianceInfo, MsgDeleteComplianceInfo, MsgCertifyModel, MsgRevokeModel, MsgProvisionModel };
export { MsgUpdateComplianceInfo, MsgCertifyModel, MsgDeleteComplianceInfo, MsgProvisionModel, MsgRevokeModel };

type sendMsgUpdateComplianceInfoParams = {
value: MsgUpdateComplianceInfo,
fee?: StdFee,
memo?: string
};

type sendMsgDeleteComplianceInfoParams = {
value: MsgDeleteComplianceInfo,
fee?: StdFee,
memo?: string
};

type sendMsgCertifyModelParams = {
value: MsgCertifyModel,
fee?: StdFee,
memo?: string
};

type sendMsgRevokeModelParams = {
value: MsgRevokeModel,
type sendMsgDeleteComplianceInfoParams = {
value: MsgDeleteComplianceInfo,
fee?: StdFee,
memo?: string
};
Expand All @@ -52,27 +46,33 @@ type sendMsgProvisionModelParams = {
memo?: string
};

type sendMsgRevokeModelParams = {
value: MsgRevokeModel,
fee?: StdFee,
memo?: string
};


type msgUpdateComplianceInfoParams = {
value: MsgUpdateComplianceInfo,
};

type msgDeleteComplianceInfoParams = {
value: MsgDeleteComplianceInfo,
};

type msgCertifyModelParams = {
value: MsgCertifyModel,
};

type msgRevokeModelParams = {
value: MsgRevokeModel,
type msgDeleteComplianceInfoParams = {
value: MsgDeleteComplianceInfo,
};

type msgProvisionModelParams = {
value: MsgProvisionModel,
};

type msgRevokeModelParams = {
value: MsgRevokeModel,
};


export const registry = new Registry(msgTypes);

Expand Down Expand Up @@ -117,59 +117,59 @@ export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "ht
}
},

async sendMsgDeleteComplianceInfo({ value, fee, memo }: sendMsgDeleteComplianceInfoParams): Promise<DeliverTxResponse> {
async sendMsgCertifyModel({ value, fee, memo }: sendMsgCertifyModelParams): Promise<DeliverTxResponse> {
if (!signer) {
throw new Error('TxClient:sendMsgDeleteComplianceInfo: Unable to sign Tx. Signer is not present.')
throw new Error('TxClient:sendMsgCertifyModel: Unable to sign Tx. Signer is not present.')
}
try {
const { address } = (await signer.getAccounts())[0];
const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix});
let msg = this.msgDeleteComplianceInfo({ value: MsgDeleteComplianceInfo.fromPartial(value) })
let msg = this.msgCertifyModel({ value: MsgCertifyModel.fromPartial(value) })
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo)
} catch (e: any) {
throw new Error('TxClient:sendMsgDeleteComplianceInfo: Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:sendMsgCertifyModel: Could not broadcast Tx: '+ e.message)
}
},

async sendMsgCertifyModel({ value, fee, memo }: sendMsgCertifyModelParams): Promise<DeliverTxResponse> {
async sendMsgDeleteComplianceInfo({ value, fee, memo }: sendMsgDeleteComplianceInfoParams): Promise<DeliverTxResponse> {
if (!signer) {
throw new Error('TxClient:sendMsgCertifyModel: Unable to sign Tx. Signer is not present.')
throw new Error('TxClient:sendMsgDeleteComplianceInfo: Unable to sign Tx. Signer is not present.')
}
try {
const { address } = (await signer.getAccounts())[0];
const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix});
let msg = this.msgCertifyModel({ value: MsgCertifyModel.fromPartial(value) })
let msg = this.msgDeleteComplianceInfo({ value: MsgDeleteComplianceInfo.fromPartial(value) })
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo)
} catch (e: any) {
throw new Error('TxClient:sendMsgCertifyModel: Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:sendMsgDeleteComplianceInfo: Could not broadcast Tx: '+ e.message)
}
},

async sendMsgRevokeModel({ value, fee, memo }: sendMsgRevokeModelParams): Promise<DeliverTxResponse> {
async sendMsgProvisionModel({ value, fee, memo }: sendMsgProvisionModelParams): Promise<DeliverTxResponse> {
if (!signer) {
throw new Error('TxClient:sendMsgRevokeModel: Unable to sign Tx. Signer is not present.')
throw new Error('TxClient:sendMsgProvisionModel: Unable to sign Tx. Signer is not present.')
}
try {
const { address } = (await signer.getAccounts())[0];
const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix});
let msg = this.msgRevokeModel({ value: MsgRevokeModel.fromPartial(value) })
let msg = this.msgProvisionModel({ value: MsgProvisionModel.fromPartial(value) })
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo)
} catch (e: any) {
throw new Error('TxClient:sendMsgRevokeModel: Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:sendMsgProvisionModel: Could not broadcast Tx: '+ e.message)
}
},

async sendMsgProvisionModel({ value, fee, memo }: sendMsgProvisionModelParams): Promise<DeliverTxResponse> {
async sendMsgRevokeModel({ value, fee, memo }: sendMsgRevokeModelParams): Promise<DeliverTxResponse> {
if (!signer) {
throw new Error('TxClient:sendMsgProvisionModel: Unable to sign Tx. Signer is not present.')
throw new Error('TxClient:sendMsgRevokeModel: Unable to sign Tx. Signer is not present.')
}
try {
const { address } = (await signer.getAccounts())[0];
const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix});
let msg = this.msgProvisionModel({ value: MsgProvisionModel.fromPartial(value) })
let msg = this.msgRevokeModel({ value: MsgRevokeModel.fromPartial(value) })
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo)
} catch (e: any) {
throw new Error('TxClient:sendMsgProvisionModel: Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:sendMsgRevokeModel: Could not broadcast Tx: '+ e.message)
}
},

Expand All @@ -182,14 +182,6 @@ export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "ht
}
},

msgDeleteComplianceInfo({ value }: msgDeleteComplianceInfoParams): EncodeObject {
try {
return { typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgDeleteComplianceInfo", value: MsgDeleteComplianceInfo.fromPartial( value ) }
} catch (e: any) {
throw new Error('TxClient:MsgDeleteComplianceInfo: Could not create message: ' + e.message)
}
},

msgCertifyModel({ value }: msgCertifyModelParams): EncodeObject {
try {
return { typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgCertifyModel", value: MsgCertifyModel.fromPartial( value ) }
Expand All @@ -198,11 +190,11 @@ export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "ht
}
},

msgRevokeModel({ value }: msgRevokeModelParams): EncodeObject {
msgDeleteComplianceInfo({ value }: msgDeleteComplianceInfoParams): EncodeObject {
try {
return { typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", value: MsgRevokeModel.fromPartial( value ) }
return { typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgDeleteComplianceInfo", value: MsgDeleteComplianceInfo.fromPartial( value ) }
} catch (e: any) {
throw new Error('TxClient:MsgRevokeModel: Could not create message: ' + e.message)
throw new Error('TxClient:MsgDeleteComplianceInfo: Could not create message: ' + e.message)
}
},

Expand All @@ -214,6 +206,14 @@ export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "ht
}
},

msgRevokeModel({ value }: msgRevokeModelParams): EncodeObject {
try {
return { typeUrl: "/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", value: MsgRevokeModel.fromPartial( value ) }
} catch (e: any) {
throw new Error('TxClient:MsgRevokeModel: Could not create message: ' + e.message)
}
},

}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { GeneratedType } from "@cosmjs/proto-signing";
import { MsgUpdateComplianceInfo } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgDeleteComplianceInfo } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgCertifyModel } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgRevokeModel } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgDeleteComplianceInfo } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgProvisionModel } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";
import { MsgRevokeModel } from "./types/zigbeealliance/distributedcomplianceledger/compliance/tx";

const msgTypes: Array<[string, GeneratedType]> = [
["/zigbeealliance.distributedcomplianceledger.compliance.MsgUpdateComplianceInfo", MsgUpdateComplianceInfo],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgDeleteComplianceInfo", MsgDeleteComplianceInfo],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgCertifyModel", MsgCertifyModel],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", MsgRevokeModel],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgDeleteComplianceInfo", MsgDeleteComplianceInfo],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgProvisionModel", MsgProvisionModel],
["/zigbeealliance.distributedcomplianceledger.compliance.MsgRevokeModel", MsgRevokeModel],

];

Expand Down
Loading

0 comments on commit ec64cd6

Please sign in to comment.