Skip to content

Commit

Permalink
try decode msgs with registry wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lukachi committed Mar 22, 2024
1 parent 9cddb5a commit 36dee48
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions packages/client/src/helpers/authz.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { AminoMsg } from '@cosmjs/amino'
import { Registry } from '@cosmjs/proto-signing/build/registry'
import {
type AminoConverter,
AminoTypes,
Expand All @@ -13,14 +14,33 @@ export function createAuthzAminoConverters(): Record<string, AminoConverter> {
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,
Expand Down

0 comments on commit 36dee48

Please sign in to comment.