fix(permits/store): validate permit exists before setting as active in setActivePermitHash#241
Conversation
…ermitHash Previously setActivePermitHash would accept any string as the active hash without verifying that a corresponding permit entry exists in the store. This caused getActivePermitHash to return a non-null value while getActivePermit returned undefined, creating inconsistent state that tricked callers into believing an active permit was configured when none was available. The fix throws if the referenced permit does not exist.
🦋 Changeset detectedLatest commit: 7d22ae1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@amathxbt is attempting to deploy a commit to the Fhenix Team on Vercel. A member of the Team first needs to authorize it. |
Validate that a permit exists before setting it as active in the setActivePermitHash function.
architect-dev
left a comment
There was a problem hiding this comment.
We're having trouble with our CI pipeline requiring secrets from within this PR, thats why the Test CI is failing for you. We're investigating if we can fix this issue.
The PR looks good, thanks very much
| // Validate the permit exists before marking it as active. | ||
| // Setting a stale or non-existent hash causes getActivePermit to silently | ||
| // return undefined while getActivePermitHash returns a non-null value, | ||
| // misleading callers into thinking an active permit is still configured. |
There was a problem hiding this comment.
Please remove commented annotation
There was a problem hiding this comment.
Please remove commented annotation
Working on both sides
Well deserved I love the amazing way your telling feedback to your contributors gonna work on you guys harder thanks again |
Summary
setActivePermitHashinpackages/sdk/permits/store.tsunconditionally sets the givenhashas the active permit for an account without verifying that a permit with that hash actually exists in the store.Bug
If a caller passes a non-existent or stale
hash, the store ends up in an inconsistent state:getActivePermitHash(chainId, account)getActivePermit(chainId, account)undefined(permit not found)Code that gates permit generation on
getActivePermitHash() != nullwill never generate a new permit becausegetActivePermitHashkeeps returning the stale value. This silently breaks any UI flow that relies on the active permit hash to detect whether a valid permit exists.Fix
Throw synchronously if the referenced permit does not exist in the store, making the invalid call surface immediately rather than corrupting state silently.