From 36dee48bfe136d8ff6f798c3e294c7100587e99f Mon Sep 17 00:00:00 2001 From: lukachi Date: Fri, 22 Mar 2024 19:44:43 +0200 Subject: [PATCH] try decode msgs with registry wip --- packages/client/src/helpers/authz.ts | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/client/src/helpers/authz.ts b/packages/client/src/helpers/authz.ts index bc6cd49d..d04a4292 100644 --- a/packages/client/src/helpers/authz.ts +++ b/packages/client/src/helpers/authz.ts @@ -1,4 +1,5 @@ import type { AminoMsg } from '@cosmjs/amino' +import { Registry } from '@cosmjs/proto-signing/build/registry' import { type AminoConverter, AminoTypes, @@ -13,14 +14,33 @@ export function createAuthzAminoConverters(): Record { const aminoTypes = new AminoTypes({ ...createDefaultAminoConverters(), }) + const stargateRegistry = new Registry() return { [MessageTypeUrls.Exec]: { aminoType: 'cosmos-sdk/MsgExec', - toAmino: ({ msgs, grantee }: MsgExec) => ({ - msgs: msgs.map(msg => aminoTypes.toAmino(msg)), + toAmino: ({ + msgs, grantee, - }), + }: MsgExec): { + grantee: string + msgs: AminoMsg[] + } => { + return { + msgs: msgs.map(msg => { + stargateRegistry.register(msg.typeUrl, MsgExec) + + return aminoTypes.toAmino({ + typeUrl: msg.typeUrl, + value: stargateRegistry.decode({ + typeUrl: msg.typeUrl, + value: msg.value, + }), + }) + }), + grantee, + } + }, /* eslint-disable camelcase */ fromAmino: ({ msgs,