Skip to content

Commit 41fa557

Browse files
committed
refactor(useAddOrUpdateGrants): use proper fromPartial helpers to create Encode Objects
1 parent f2173f9 commit 41fa557

File tree

1 file changed

+11
-10
lines changed
  • src/hooks/authGrants/useAddOrUpdateGrants

1 file changed

+11
-10
lines changed

src/hooks/authGrants/useAddOrUpdateGrants/utils.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import {
1515
BasicAllowance,
1616
} from 'cosmjs-types/cosmos/feegrant/v1beta1/feegrant';
1717
import EnvConfig from 'config/EnvConfig';
18-
import {MsgRevoke} from 'cosmjs-types/cosmos/authz/v1beta1/tx';
18+
import {MsgGrant, MsgRevoke} from 'cosmjs-types/cosmos/authz/v1beta1/tx';
19+
import {
20+
MsgGrantAllowance,
21+
MsgRevokeAllowance,
22+
} from 'cosmjs-types/cosmos/feegrant/v1beta1/tx';
1923

2024
/**
2125
* Build a MsgRevokeAllowanceEncode object.
@@ -33,11 +37,10 @@ export const buildRevokeAllowanceEncode = ({
3337
granter: string;
3438
}): MsgRevokeAllowanceEncodeObject => ({
3539
typeUrl: '/cosmos.feegrant.v1beta1.MsgRevokeAllowance',
36-
// replace with MsgRevokeAllowanceEncode.fromPartial
37-
value: {
40+
value: MsgRevokeAllowance.fromPartial({
3841
grantee,
3942
granter,
40-
},
43+
}),
4144
});
4245

4346
/**
@@ -73,15 +76,14 @@ export const buildGrantAllowanceEncode = ({
7376

7477
return {
7578
typeUrl: '/cosmos.feegrant.v1beta1.MsgGrantAllowance',
76-
// replace with MsgGrantAllowance.fromPartial
77-
value: {
79+
value: MsgGrantAllowance.fromPartial({
7880
grantee,
7981
granter,
8082
allowance: Any.fromPartial({
8183
typeUrl: '/cosmos.feegrant.v1beta1.AllowedMsgAllowance',
8284
value: AllowedMsgAllowance.encode(allowance).finish(),
8385
}),
84-
},
86+
}),
8587
};
8688
};
8789

@@ -123,12 +125,11 @@ export const buildGrantMsgEncodes = ({
123125

124126
return {
125127
typeUrl: '/cosmos.authz.v1beta1.MsgGrant',
126-
// replace with MsgGrant.fromPartial
127-
value: {
128+
value: MsgGrant.fromPartial({
128129
grantee,
129130
granter,
130131
grant: _grant,
131-
},
132+
}),
132133
};
133134
});
134135
};

0 commit comments

Comments
 (0)