Skip to content

Commit

Permalink
Merge pull request #749 from vchong/non-expiring-grants
Browse files Browse the repository at this point in the history
utils: Helpers: Support non-expiring grants
  • Loading branch information
tombeynon authored Oct 24, 2023
2 parents 338e808 + 25f7a56 commit a1fbc07
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/utils/Helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,6 @@ export function buildExecableMessage(type, typeUrl, value, shouldExec){
}

export function parseGrants(grants, grantee, granter) {
// claimGrant is removed but we track for now to allow revoke
const claimGrant = grants.find((el) => {
if (
(!el.grantee || el.grantee === grantee) &&
(!el.granter || el.granter === granter) &&
(el.authorization["@type"] ===
"/cosmos.authz.v1beta1.GenericAuthorization" &&
el.authorization.msg ===
"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward")
) {
return Date.parse(el.expiration) > new Date();
} else {
return false;
}
});
const stakeGrant = grants.find((el) => {
if (
(!el.grantee || el.grantee === grantee) &&
Expand All @@ -90,14 +75,19 @@ export function parseGrants(grants, grantee, granter) {
"/cosmos.staking.v1beta1.MsgDelegate"
))
) {
return Date.parse(el.expiration) > new Date();
if (el.expiration === null) {
return true;
} else if (Date.parse(el.expiration) > new Date()) {
return true;
} else {
return false;
}
} else {
return false;
}
})
return {
claimGrant,
stakeGrant,
stakeGrant
};
}

Expand Down

0 comments on commit a1fbc07

Please sign in to comment.