Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ts client #98

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
cosmossdk.io/errors v1.0.0-beta.7
cosmossdk.io/math v1.0.1
github.com/FairBlock/DistributedIBE v0.0.0-20230528025616-f58fb2b93eaf
github.com/armon/go-metrics v0.4.1
github.com/cometbft/cometbft v0.37.2
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-sdk v0.47.3
Expand Down Expand Up @@ -47,7 +48,6 @@ require (
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/OneOfOne/xxhash v1.2.8 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/aws/aws-sdk-go v1.44.203 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
Expand Down
164 changes: 49 additions & 115 deletions ts-client/fairyring.keyshare/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import { msgTypes } from './registry';
import { IgniteClient } from "../client"
import { MissingWalletError } from "../helpers"
import { Api } from "./rest";
import { MsgCreateAuthorizedAddress } from "./types/fairyring/keyshare/tx";
import { MsgRegisterValidator } from "./types/fairyring/keyshare/tx";
import { MsgDeleteAuthorizedAddress } from "./types/fairyring/keyshare/tx";
import { MsgCreateGeneralKeyShare } from "./types/fairyring/keyshare/tx";
import { MsgUpdateAuthorizedAddress } from "./types/fairyring/keyshare/tx";
import { MsgDeleteGeneralKeyShare } from "./types/fairyring/keyshare/tx";
import { MsgCreateLatestPubKey } from "./types/fairyring/keyshare/tx";
import { MsgUpdateGeneralKeyShare } from "./types/fairyring/keyshare/tx";
import { MsgUpdateAuthorizedAddress } from "./types/fairyring/keyshare/tx";
import { MsgCreateAuthorizedAddress } from "./types/fairyring/keyshare/tx";
import { MsgCreateGeneralKeyShare } from "./types/fairyring/keyshare/tx";
import { MsgRegisterValidator } from "./types/fairyring/keyshare/tx";
import { MsgSendKeyshare } from "./types/fairyring/keyshare/tx";

import { AggregatedKeyShare as typeAggregatedKeyShare} from "./types"
Expand All @@ -38,28 +36,16 @@ import { IBCInfo as typeIBCInfo} from "./types"
import { CounterPartyIBCInfo as typeCounterPartyIBCInfo} from "./types"
import { ValidatorSet as typeValidatorSet} from "./types"

export { MsgCreateAuthorizedAddress, MsgRegisterValidator, MsgDeleteAuthorizedAddress, MsgCreateGeneralKeyShare, MsgUpdateAuthorizedAddress, MsgDeleteGeneralKeyShare, MsgCreateLatestPubKey, MsgUpdateGeneralKeyShare, MsgSendKeyshare };

type sendMsgCreateAuthorizedAddressParams = {
value: MsgCreateAuthorizedAddress,
fee?: StdFee,
memo?: string
};

type sendMsgRegisterValidatorParams = {
value: MsgRegisterValidator,
fee?: StdFee,
memo?: string
};
export { MsgDeleteAuthorizedAddress, MsgCreateLatestPubKey, MsgUpdateAuthorizedAddress, MsgCreateAuthorizedAddress, MsgCreateGeneralKeyShare, MsgRegisterValidator, MsgSendKeyshare };

type sendMsgDeleteAuthorizedAddressParams = {
value: MsgDeleteAuthorizedAddress,
fee?: StdFee,
memo?: string
};

type sendMsgCreateGeneralKeyShareParams = {
value: MsgCreateGeneralKeyShare,
type sendMsgCreateLatestPubKeyParams = {
value: MsgCreateLatestPubKey,
fee?: StdFee,
memo?: string
};
Expand All @@ -70,20 +56,20 @@ type sendMsgUpdateAuthorizedAddressParams = {
memo?: string
};

type sendMsgDeleteGeneralKeyShareParams = {
value: MsgDeleteGeneralKeyShare,
type sendMsgCreateAuthorizedAddressParams = {
value: MsgCreateAuthorizedAddress,
fee?: StdFee,
memo?: string
};

type sendMsgCreateLatestPubKeyParams = {
value: MsgCreateLatestPubKey,
type sendMsgCreateGeneralKeyShareParams = {
value: MsgCreateGeneralKeyShare,
fee?: StdFee,
memo?: string
};

type sendMsgUpdateGeneralKeyShareParams = {
value: MsgUpdateGeneralKeyShare,
type sendMsgRegisterValidatorParams = {
value: MsgRegisterValidator,
fee?: StdFee,
memo?: string
};
Expand All @@ -95,36 +81,28 @@ type sendMsgSendKeyshareParams = {
};


type msgCreateAuthorizedAddressParams = {
value: MsgCreateAuthorizedAddress,
};

type msgRegisterValidatorParams = {
value: MsgRegisterValidator,
};

type msgDeleteAuthorizedAddressParams = {
value: MsgDeleteAuthorizedAddress,
};

type msgCreateGeneralKeyShareParams = {
value: MsgCreateGeneralKeyShare,
type msgCreateLatestPubKeyParams = {
value: MsgCreateLatestPubKey,
};

type msgUpdateAuthorizedAddressParams = {
value: MsgUpdateAuthorizedAddress,
};

type msgDeleteGeneralKeyShareParams = {
value: MsgDeleteGeneralKeyShare,
type msgCreateAuthorizedAddressParams = {
value: MsgCreateAuthorizedAddress,
};

type msgCreateLatestPubKeyParams = {
value: MsgCreateLatestPubKey,
type msgCreateGeneralKeyShareParams = {
value: MsgCreateGeneralKeyShare,
};

type msgUpdateGeneralKeyShareParams = {
value: MsgUpdateGeneralKeyShare,
type msgRegisterValidatorParams = {
value: MsgRegisterValidator,
};

type msgSendKeyshareParams = {
Expand Down Expand Up @@ -161,34 +139,6 @@ export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "ht

return {

async sendMsgCreateAuthorizedAddress({ value, fee, memo }: sendMsgCreateAuthorizedAddressParams): Promise<DeliverTxResponse> {
if (!signer) {
throw new Error('TxClient:sendMsgCreateAuthorizedAddress: 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.msgCreateAuthorizedAddress({ value: MsgCreateAuthorizedAddress.fromPartial(value) })
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo)
} catch (e: any) {
throw new Error('TxClient:sendMsgCreateAuthorizedAddress: Could not broadcast Tx: '+ e.message)
}
},

async sendMsgRegisterValidator({ value, fee, memo }: sendMsgRegisterValidatorParams): Promise<DeliverTxResponse> {
if (!signer) {
throw new Error('TxClient:sendMsgRegisterValidator: 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.msgRegisterValidator({ value: MsgRegisterValidator.fromPartial(value) })
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo)
} catch (e: any) {
throw new Error('TxClient:sendMsgRegisterValidator: Could not broadcast Tx: '+ e.message)
}
},

async sendMsgDeleteAuthorizedAddress({ value, fee, memo }: sendMsgDeleteAuthorizedAddressParams): Promise<DeliverTxResponse> {
if (!signer) {
throw new Error('TxClient:sendMsgDeleteAuthorizedAddress: Unable to sign Tx. Signer is not present.')
Expand All @@ -203,17 +153,17 @@ export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "ht
}
},

async sendMsgCreateGeneralKeyShare({ value, fee, memo }: sendMsgCreateGeneralKeyShareParams): Promise<DeliverTxResponse> {
async sendMsgCreateLatestPubKey({ value, fee, memo }: sendMsgCreateLatestPubKeyParams): Promise<DeliverTxResponse> {
if (!signer) {
throw new Error('TxClient:sendMsgCreateGeneralKeyShare: Unable to sign Tx. Signer is not present.')
throw new Error('TxClient:sendMsgCreateLatestPubKey: 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.msgCreateGeneralKeyShare({ value: MsgCreateGeneralKeyShare.fromPartial(value) })
let msg = this.msgCreateLatestPubKey({ value: MsgCreateLatestPubKey.fromPartial(value) })
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo)
} catch (e: any) {
throw new Error('TxClient:sendMsgCreateGeneralKeyShare: Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:sendMsgCreateLatestPubKey: Could not broadcast Tx: '+ e.message)
}
},

Expand All @@ -231,45 +181,45 @@ export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "ht
}
},

async sendMsgDeleteGeneralKeyShare({ value, fee, memo }: sendMsgDeleteGeneralKeyShareParams): Promise<DeliverTxResponse> {
async sendMsgCreateAuthorizedAddress({ value, fee, memo }: sendMsgCreateAuthorizedAddressParams): Promise<DeliverTxResponse> {
if (!signer) {
throw new Error('TxClient:sendMsgDeleteGeneralKeyShare: Unable to sign Tx. Signer is not present.')
throw new Error('TxClient:sendMsgCreateAuthorizedAddress: 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.msgDeleteGeneralKeyShare({ value: MsgDeleteGeneralKeyShare.fromPartial(value) })
let msg = this.msgCreateAuthorizedAddress({ value: MsgCreateAuthorizedAddress.fromPartial(value) })
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo)
} catch (e: any) {
throw new Error('TxClient:sendMsgDeleteGeneralKeyShare: Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:sendMsgCreateAuthorizedAddress: Could not broadcast Tx: '+ e.message)
}
},

async sendMsgCreateLatestPubKey({ value, fee, memo }: sendMsgCreateLatestPubKeyParams): Promise<DeliverTxResponse> {
async sendMsgCreateGeneralKeyShare({ value, fee, memo }: sendMsgCreateGeneralKeyShareParams): Promise<DeliverTxResponse> {
if (!signer) {
throw new Error('TxClient:sendMsgCreateLatestPubKey: Unable to sign Tx. Signer is not present.')
throw new Error('TxClient:sendMsgCreateGeneralKeyShare: 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.msgCreateLatestPubKey({ value: MsgCreateLatestPubKey.fromPartial(value) })
let msg = this.msgCreateGeneralKeyShare({ value: MsgCreateGeneralKeyShare.fromPartial(value) })
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo)
} catch (e: any) {
throw new Error('TxClient:sendMsgCreateLatestPubKey: Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:sendMsgCreateGeneralKeyShare: Could not broadcast Tx: '+ e.message)
}
},

async sendMsgUpdateGeneralKeyShare({ value, fee, memo }: sendMsgUpdateGeneralKeyShareParams): Promise<DeliverTxResponse> {
async sendMsgRegisterValidator({ value, fee, memo }: sendMsgRegisterValidatorParams): Promise<DeliverTxResponse> {
if (!signer) {
throw new Error('TxClient:sendMsgUpdateGeneralKeyShare: Unable to sign Tx. Signer is not present.')
throw new Error('TxClient:sendMsgRegisterValidator: 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.msgUpdateGeneralKeyShare({ value: MsgUpdateGeneralKeyShare.fromPartial(value) })
let msg = this.msgRegisterValidator({ value: MsgRegisterValidator.fromPartial(value) })
return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo)
} catch (e: any) {
throw new Error('TxClient:sendMsgUpdateGeneralKeyShare: Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:sendMsgRegisterValidator: Could not broadcast Tx: '+ e.message)
}
},

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


msgCreateAuthorizedAddress({ value }: msgCreateAuthorizedAddressParams): EncodeObject {
try {
return { typeUrl: "/fairyring.keyshare.MsgCreateAuthorizedAddress", value: MsgCreateAuthorizedAddress.fromPartial( value ) }
} catch (e: any) {
throw new Error('TxClient:MsgCreateAuthorizedAddress: Could not create message: ' + e.message)
}
},

msgRegisterValidator({ value }: msgRegisterValidatorParams): EncodeObject {
try {
return { typeUrl: "/fairyring.keyshare.MsgRegisterValidator", value: MsgRegisterValidator.fromPartial( value ) }
} catch (e: any) {
throw new Error('TxClient:MsgRegisterValidator: Could not create message: ' + e.message)
}
},

msgDeleteAuthorizedAddress({ value }: msgDeleteAuthorizedAddressParams): EncodeObject {
try {
return { typeUrl: "/fairyring.keyshare.MsgDeleteAuthorizedAddress", value: MsgDeleteAuthorizedAddress.fromPartial( value ) }
Expand All @@ -312,11 +246,11 @@ export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "ht
}
},

msgCreateGeneralKeyShare({ value }: msgCreateGeneralKeyShareParams): EncodeObject {
msgCreateLatestPubKey({ value }: msgCreateLatestPubKeyParams): EncodeObject {
try {
return { typeUrl: "/fairyring.keyshare.MsgCreateGeneralKeyShare", value: MsgCreateGeneralKeyShare.fromPartial( value ) }
return { typeUrl: "/fairyring.keyshare.MsgCreateLatestPubKey", value: MsgCreateLatestPubKey.fromPartial( value ) }
} catch (e: any) {
throw new Error('TxClient:MsgCreateGeneralKeyShare: Could not create message: ' + e.message)
throw new Error('TxClient:MsgCreateLatestPubKey: Could not create message: ' + e.message)
}
},

Expand All @@ -328,27 +262,27 @@ export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "ht
}
},

msgDeleteGeneralKeyShare({ value }: msgDeleteGeneralKeyShareParams): EncodeObject {
msgCreateAuthorizedAddress({ value }: msgCreateAuthorizedAddressParams): EncodeObject {
try {
return { typeUrl: "/fairyring.keyshare.MsgDeleteGeneralKeyShare", value: MsgDeleteGeneralKeyShare.fromPartial( value ) }
return { typeUrl: "/fairyring.keyshare.MsgCreateAuthorizedAddress", value: MsgCreateAuthorizedAddress.fromPartial( value ) }
} catch (e: any) {
throw new Error('TxClient:MsgDeleteGeneralKeyShare: Could not create message: ' + e.message)
throw new Error('TxClient:MsgCreateAuthorizedAddress: Could not create message: ' + e.message)
}
},

msgCreateLatestPubKey({ value }: msgCreateLatestPubKeyParams): EncodeObject {
msgCreateGeneralKeyShare({ value }: msgCreateGeneralKeyShareParams): EncodeObject {
try {
return { typeUrl: "/fairyring.keyshare.MsgCreateLatestPubKey", value: MsgCreateLatestPubKey.fromPartial( value ) }
return { typeUrl: "/fairyring.keyshare.MsgCreateGeneralKeyShare", value: MsgCreateGeneralKeyShare.fromPartial( value ) }
} catch (e: any) {
throw new Error('TxClient:MsgCreateLatestPubKey: Could not create message: ' + e.message)
throw new Error('TxClient:MsgCreateGeneralKeyShare: Could not create message: ' + e.message)
}
},

msgUpdateGeneralKeyShare({ value }: msgUpdateGeneralKeyShareParams): EncodeObject {
msgRegisterValidator({ value }: msgRegisterValidatorParams): EncodeObject {
try {
return { typeUrl: "/fairyring.keyshare.MsgUpdateGeneralKeyShare", value: MsgUpdateGeneralKeyShare.fromPartial( value ) }
return { typeUrl: "/fairyring.keyshare.MsgRegisterValidator", value: MsgRegisterValidator.fromPartial( value ) }
} catch (e: any) {
throw new Error('TxClient:MsgUpdateGeneralKeyShare: Could not create message: ' + e.message)
throw new Error('TxClient:MsgRegisterValidator: Could not create message: ' + e.message)
}
},

Expand Down
20 changes: 8 additions & 12 deletions ts-client/fairyring.keyshare/registry.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import { GeneratedType } from "@cosmjs/proto-signing";
import { MsgCreateAuthorizedAddress } from "./types/fairyring/keyshare/tx";
import { MsgRegisterValidator } from "./types/fairyring/keyshare/tx";
import { MsgDeleteAuthorizedAddress } from "./types/fairyring/keyshare/tx";
import { MsgCreateGeneralKeyShare } from "./types/fairyring/keyshare/tx";
import { MsgUpdateAuthorizedAddress } from "./types/fairyring/keyshare/tx";
import { MsgDeleteGeneralKeyShare } from "./types/fairyring/keyshare/tx";
import { MsgCreateLatestPubKey } from "./types/fairyring/keyshare/tx";
import { MsgUpdateGeneralKeyShare } from "./types/fairyring/keyshare/tx";
import { MsgUpdateAuthorizedAddress } from "./types/fairyring/keyshare/tx";
import { MsgCreateAuthorizedAddress } from "./types/fairyring/keyshare/tx";
import { MsgCreateGeneralKeyShare } from "./types/fairyring/keyshare/tx";
import { MsgRegisterValidator } from "./types/fairyring/keyshare/tx";
import { MsgSendKeyshare } from "./types/fairyring/keyshare/tx";

const msgTypes: Array<[string, GeneratedType]> = [
["/fairyring.keyshare.MsgCreateAuthorizedAddress", MsgCreateAuthorizedAddress],
["/fairyring.keyshare.MsgRegisterValidator", MsgRegisterValidator],
["/fairyring.keyshare.MsgDeleteAuthorizedAddress", MsgDeleteAuthorizedAddress],
["/fairyring.keyshare.MsgCreateGeneralKeyShare", MsgCreateGeneralKeyShare],
["/fairyring.keyshare.MsgUpdateAuthorizedAddress", MsgUpdateAuthorizedAddress],
["/fairyring.keyshare.MsgDeleteGeneralKeyShare", MsgDeleteGeneralKeyShare],
["/fairyring.keyshare.MsgCreateLatestPubKey", MsgCreateLatestPubKey],
["/fairyring.keyshare.MsgUpdateGeneralKeyShare", MsgUpdateGeneralKeyShare],
["/fairyring.keyshare.MsgUpdateAuthorizedAddress", MsgUpdateAuthorizedAddress],
["/fairyring.keyshare.MsgCreateAuthorizedAddress", MsgCreateAuthorizedAddress],
["/fairyring.keyshare.MsgCreateGeneralKeyShare", MsgCreateGeneralKeyShare],
["/fairyring.keyshare.MsgRegisterValidator", MsgRegisterValidator],
["/fairyring.keyshare.MsgSendKeyshare", MsgSendKeyshare],

];
Expand Down
Loading
Loading