Skip to content

Commit

Permalink
Merge pull request #728 from hyperweb-io/fix-multi-accepts-interface
Browse files Browse the repository at this point in the history
fixed multi accepts interface
  • Loading branch information
Zetazzz authored Feb 5, 2025
2 parents c9f468e + fbf92b3 commit c2967be
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion __fixtures__/v-next/outputhelperfunc/vue-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export interface UseMutationBuilderOptions<TMsg> {
clientResolver?: SigningClientResolver
) => (
signerAddress: string,
message: TMsg,
message: TMsg | TMsg[],
fee: StdFee | 'auto',
memo: string
) => Promise<DeliverTxResponse>;
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/v-next/outputicjs/cosmos/authz/v1beta1/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,14 @@ export const MsgExec = {
if (object.grantee !== undefined && object.grantee !== null) {
message.grantee = object.grantee;
}
message.msgs = object.msgs?.map(e => Sdk_MsgauthzAuthorization_FromAmino(e)) || [];
message.msgs = object.msgs?.map(e => Sdk_Msg_FromAmino(e)) || [];
return message;
},
toAmino(message: MsgExec): MsgExecAmino {
const obj: any = {};
obj.grantee = message.grantee === "" ? undefined : message.grantee;
if (message.msgs) {
obj.msgs = message.msgs.map(e => e ? Sdk_MsgauthzAuthorization_ToAmino((e as Any)) : undefined);
obj.msgs = message.msgs.map(e => e ? Sdk_Msg_ToAmino((e as Any)) : undefined);
} else {
obj.msgs = message.msgs;
}
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/v-next/outputv2/cosmos/authz/v1beta1/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,14 @@ export const MsgExec = {
if (object.grantee !== undefined && object.grantee !== null) {
message.grantee = object.grantee;
}
message.msgs = object.msgs?.map(e => Sdk_MsgauthzAuthorization_FromAmino(e)) || [];
message.msgs = object.msgs?.map(e => Sdk_Msg_FromAmino(e)) || [];
return message;
},
toAmino(message: MsgExec): MsgExecAmino {
const obj: any = {};
obj.grantee = message.grantee === "" ? undefined : message.grantee;
if (message.msgs) {
obj.msgs = message.msgs.map(e => e ? Sdk_MsgauthzAuthorization_ToAmino((e as Any)) : undefined);
obj.msgs = message.msgs.map(e => e ? Sdk_Msg_ToAmino((e as Any)) : undefined);
} else {
obj.msgs = message.msgs;
}
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/v-next/outputv3/cosmos/authz/v1beta1/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,14 @@ export const MsgExec = {
if (object.grantee !== undefined && object.grantee !== null) {
message.grantee = object.grantee;
}
message.msgs = object.msgs?.map(e => Sdk_MsgauthzAuthorization_FromAmino(e)) || [];
message.msgs = object.msgs?.map(e => Sdk_Msg_FromAmino(e)) || [];
return message;
},
toAmino(message: MsgExec, useInterfaces: boolean = true): MsgExecAmino {
const obj: any = {};
obj.grantee = message.grantee === "" ? undefined : message.grantee;
if (message.msgs) {
obj.msgs = message.msgs.map(e => e ? Sdk_MsgauthzAuthorization_ToAmino((e as Any), useInterfaces) : undefined);
obj.msgs = message.msgs.map(e => e ? Sdk_Msg_ToAmino((e as Any), useInterfaces) : undefined);
} else {
obj.msgs = message.msgs;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/ast/src/encoding/proto/from-amino/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export const fromAmino = {
anyType(args: fromAminoMethod) {
const { origName } = getFieldNames(args.field);

const interfaceName =
args.field.options["(cosmos_proto.accepts_interface)"];
const accepts_interface = args.field.options["(cosmos_proto.accepts_interface)"];
const interfaceName = accepts_interface.split(",")[0];
const interfaceFnName = getInterfaceFromAminoName(interfaceName);

let aminoFuncExpr: t.Expression = t.identifier(interfaceFnName);
Expand Down Expand Up @@ -553,8 +553,8 @@ export const arrayTypes = {
},

anyType(args: fromAminoMethod) {
const interfaceName =
args.field.options["(cosmos_proto.accepts_interface)"];
const accepts_interface = args.field.options["(cosmos_proto.accepts_interface)"];
const interfaceName = accepts_interface.split(",")[0];
const interfaceFnName = getInterfaceFromAminoName(interfaceName);

let aminoFuncExpr: t.Expression = t.identifier(interfaceFnName);
Expand Down
6 changes: 4 additions & 2 deletions packages/ast/src/encoding/proto/to-amino/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ const setValue = (args: ToAminoJSONMethod, valExpr?: t.Expression) => {

anyType(args: ToAminoJSONMethod) {
const { propName, origName } = getFieldNames(args.field);
const interfaceName = args.field.options['(cosmos_proto.accepts_interface)'];
const accepts_interface = args.field.options["(cosmos_proto.accepts_interface)"];
const interfaceName = accepts_interface.split(",")[0];
const interfaceFnName = getInterfaceToAminoName(interfaceName)

args.context.getTypeName(args.field);
Expand Down Expand Up @@ -795,7 +796,8 @@ export const arrayTypes = {
},
anyType(args: ToAminoJSONMethod) {
const { propName, origName } = getFieldNames(args.field);
const interfaceName = args.field.options['(cosmos_proto.accepts_interface)'];
const accepts_interface = args.field.options["(cosmos_proto.accepts_interface)"];
const interfaceName = accepts_interface.split(",")[0];
const interfaceFnName = getInterfaceToAminoName(interfaceName)

const isGlobalRegistry = args.context.options.interfaces?.useGlobalDecoderRegistry;
Expand Down

0 comments on commit c2967be

Please sign in to comment.