Skip to content

Commit

Permalink
feat: minor authz utils
Browse files Browse the repository at this point in the history
  • Loading branch information
bangjelkoski committed Aug 10, 2023
1 parent c8444d5 commit 72fc977
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/sdk-ts/src/core/modules/authz/msgs/MsgExec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ export default class MsgExec extends MsgBase<
const { params } = this

const message = CosmosAuthzV1Beta1Tx.MsgExec.create()
message.grantee = params.grantee

if (params.grantee) {
message.grantee = params.grantee
}

const msgs = Array.isArray(params.msgs) ? params.msgs : [params.msgs]

const actualMsgs = msgs.map((msg) => {
const msgValue = GoogleProtobufAny.Any.create()
msgValue.typeUrl = msg.toData()['@type']
Expand Down
15 changes: 15 additions & 0 deletions packages/sdk-ts/src/core/modules/authz/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import MsgExec from './msgs/MsgExec'
import { Msgs } from './../msgs'

export const msgsOrMsgExecMsgs = (
msgs: Msgs | Msgs[],
grantee?: string,
): Msgs[] => {
const actualMsgs = Array.isArray(msgs) ? msgs : [msgs]

if (!grantee) {
return actualMsgs
}

return actualMsgs.map((msg) => MsgExec.fromJSON({ grantee, msgs: msg }))
}

0 comments on commit 72fc977

Please sign in to comment.