diff --git a/packages/client/src/helpers/authz.ts b/packages/client/src/helpers/authz.ts index d04a4292..44bfdce4 100644 --- a/packages/client/src/helpers/authz.ts +++ b/packages/client/src/helpers/authz.ts @@ -10,11 +10,12 @@ import { MsgExec } from '@/codec/cosmos/authz/v1beta1/tx' import { MessageTypeUrls } from '@/enums' // TODO: https://github.com/likecoin/iscn-js/blob/1ac7fb6f3b568e0d35e598442769a283c669c34b/src/messages/authz.ts#L98 -export function createAuthzAminoConverters(): Record { +export function createAuthzAminoConverters( + stargateRegistry: Registry, +): Record { const aminoTypes = new AminoTypes({ ...createDefaultAminoConverters(), }) - const stargateRegistry = new Registry() return { [MessageTypeUrls.Exec]: { @@ -28,8 +29,6 @@ export function createAuthzAminoConverters(): Record { } => { return { msgs: msgs.map(msg => { - stargateRegistry.register(msg.typeUrl, MsgExec) - return aminoTypes.toAmino({ typeUrl: msg.typeUrl, value: stargateRegistry.decode({ @@ -50,7 +49,17 @@ export function createAuthzAminoConverters(): Record { msgs: AminoMsg[] }): MsgExec => MsgExec.fromPartial({ - msgs: msgs.map(msg => aminoTypes.fromAmino(msg)), + msgs: msgs.map(msg => { + const res = aminoTypes.fromAmino(msg) + + return { + typeUrl: res.typeUrl, + value: stargateRegistry.encode({ + typeUrl: res.typeUrl, + value: res.value, + }), + } + }), grantee, }), }, diff --git a/packages/client/src/helpers/broadcast-maker.ts b/packages/client/src/helpers/broadcast-maker.ts index eabdfe6d..82b697a8 100644 --- a/packages/client/src/helpers/broadcast-maker.ts +++ b/packages/client/src/helpers/broadcast-maker.ts @@ -43,7 +43,7 @@ export const makeBroadcastMaker = async (config: Config, wallet: Wallet) => { }, aminoTypes: new AminoTypes({ ...createDefaultAminoConverters(), - ...createAuthzAminoConverters(), + ...createAuthzAminoConverters(stargateRegistry), }), }, )