Skip to content

Commit bfd31d9

Browse files
committed
using msgType from event in _handleMsgGrant
1 parent 8a128f6 commit bfd31d9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/mappings/authz/grants.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { CosmosEvent, CosmosMessage } from "@subql/types-cosmos";
2-
import { GenericAuthorization } from "cosmjs-types/cosmos/authz/v1beta1/authz";
32
import { MsgGrant } from "cosmjs-types/cosmos/authz/v1beta1/tx";
43
import { AuthzProps } from "../../types/models/Authz";
54
import { getAuthzId, getBlockId, getEventId } from "../utils/ids";
@@ -54,10 +53,21 @@ function _handleEventGrant(event: CosmosEvent): AuthzProps {
5453
function _handleMsgGrant(msg: CosmosMessage<MsgGrant>): AuthzProps {
5554
const {grant, grantee, granter} = msg.msg.decodedMsg;
5655

57-
const msgType = GenericAuthorization.decode(grant.authorization!.value).msg
5856
const expiration = grant.expiration ? new Date(Number(grant.expiration.seconds) * 1000 + Math.floor(grant.expiration.nanos / 1_000_000)) : undefined
5957
const event = msg.block.events.find(e => e.event.type === '' && isEventOfMessageKind(e) && e.tx.hash === msg.tx.hash)!
6058

59+
let msgType: string | null = null
60+
61+
for (const {key, value} of event.event.attributes) {
62+
if (key === "msg_type_url") {
63+
msgType = parseAttribute(value)
64+
break
65+
}
66+
}
67+
68+
if (!msgType) {
69+
throw new Error(`[handleMsgGrant] msgType not found in event`);
70+
}
6171

6272
return {
6373
id: getAuthzId(

0 commit comments

Comments
 (0)