Skip to content

Permit Management - #57

Merged
alexshchur merged 65 commits into
stagingfrom
feat/APPS-109-permit-management
Dec 9, 2025
Merged

alexshchur merged 65 commits into
stagingfrom
feat/APPS-109-permit-management

Conversation

@alexshchur

@alexshchur alexshchur commented Dec 2, 2025 •

Copy link
Copy Markdown
Contributor

This pull request introduces a new "Permits" feature to the floating button UI in the React package, adds supporting components, and improves code modularity and maintainability. The main changes include new pages for viewing, generating, and receiving permits, integration of these pages into the floating button navigation, and the addition of reusable UI components for permit creation. It also refactors imports for consistency and adds dependencies for SVG handling.

New Permits Feature Integration:

  • Added new pages for permits: PermitsListPage, GeneratePermitPage, and ReceivePermitPage, and integrated them into the floating button navigation and context (FnxFloatingButtonContext.tsx, ContentSection.tsx, MainPage.tsx, pages/index.ts). [1] [2] [3] [4] [5]

Reusable UI Components for Permit Creation:

  • Introduced modular components for the permit generation form: ExpirySection, NameSection, ReceiverSection, and SelfToggle to improve code reusability and clarity. [1] [2] [3] [4]

Floating Button UI Improvements:

  • Enhanced the floating button content section to support dynamic page content, including new permits pages and automatic height adjustment using ResizeObserver.

Codebase Maintenance and Refactoring:

  • Refactored import paths to use the @/ alias for hooks and utilities, improving consistency and maintainability across multiple files. [1] [2] [3]

Development Dependency Updates:

  • Added @svgr/core and @svgr/plugin-jsx to devDependencies in package.json to enable SVG component handling.

setDurationSeconds,
handleSubmit,
} = usePermitForm({
onSuccess: navigateToPermits, // TODO: also add toast here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt guys, should there be some toast or other kind of feedback upon creating a permit?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree, toast system would be very useful

.filter((hash) => {
const serializedPermit = allPermits[hash];
if (!serializedPermit) {
// TODO: revisit: right now, the way removal works, is that a key remains, but the value becomes undefined. https://github.com/FhenixProtocol/cofhesdk/blob/master/packages/sdk/permits/store.ts#L113

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder if we should actually delete instead?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I didn't delete was because I thought that it doesn't play nicely in reactive environments, but that was a feeling and not something I checked. If delete doesn't break anything I'm happy to add it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way if we are keeping it it should be return serializedPermit != null

Comment thread packages/sdk/permits/store.ts Outdated
state.activePermitHash[chainId][account] = otherPermitHash;
} else {
if (!force) {
// TODO: is swallowed. Fix it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see if I can deliver a fix in a separate PR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why this is being swallowed, I cant track where this is happening

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently because permit removal is wrapped with result wrapper and catchFn is not provided, it wouldn't throw any error, and if you need to handle an error you need to look into the result

here's the fix

A bit counterintuitive. I wonder if there's a way to make it more intuitive

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, seems that the result wrappers aren't as useful as I hoped they would be. Maybe its worth considering removing them.

Comment thread packages/sdk/permits/validation.ts Outdated
@alexshchur
alexshchur marked this pull request as ready for review December 3, 2025 08:46

@architect-dev architect-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally not a fan of having multiple hooks.ts files sprinkled throughout the codebase. I'd prefer to have a single hooks folder with everything contained. I'm seeing a lot of '../../../../../../hooks/useCopyFeedback' stuff which I don't like. Can be refactored later though before it goes into master.

setDurationSeconds,
handleSubmit,
} = usePermitForm({
onSuccess: navigateToPermits, // TODO: also add toast here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree, toast system would be very useful


// React to dynamic size changes inside the active page (e.g., toggling fields)
useEffect(() => {
if (!showPopupPanel) return;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary? The content panel isn't able to dynamically resize based on the child content?

.filter((hash) => {
const serializedPermit = allPermits[hash];
if (!serializedPermit) {
// TODO: revisit: right now, the way removal works, is that a key remains, but the value becomes undefined. https://github.com/FhenixProtocol/cofhesdk/blob/master/packages/sdk/permits/store.ts#L113

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I didn't delete was because I thought that it doesn't play nicely in reactive environments, but that was a feeling and not something I checked. If delete doesn't break anything I'm happy to add it

.filter((hash) => {
const serializedPermit = allPermits[hash];
if (!serializedPermit) {
// TODO: revisit: right now, the way removal works, is that a key remains, but the value becomes undefined. https://github.com/FhenixProtocol/cofhesdk/blob/master/packages/sdk/permits/store.ts#L113

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way if we are keeping it it should be return serializedPermit != null

* - Copies provided text to clipboard and exposes transient "copied" state per key.
* - Useful for lists where each row has a copy action and needs quick feedback.
*/
export function useCopyFeedback(defaultDurationMs: number = 2000) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool system, haven't ever done it this way myself but it makes sense 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you hear, @copilot ? Good job

Comment thread packages/sdk/permits/store.ts Outdated
state.activePermitHash[chainId][account] = otherPermitHash;
} else {
if (!force) {
// TODO: is swallowed. Fix it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why this is being swallowed, I cant track where this is happening

Comment thread packages/sdk/permits/validation.ts Outdated

Copilot AI commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

@alexshchur I've opened a new pull request, #58, to work on those changes. Once the pull request is ready, I'll request review from you.

@alexshchur

Copy link
Copy Markdown
Contributor Author

@architect-dev , seem to be 2 distinct issues here:

Generally not a fan of having multiple hooks.ts files sprinkled throughout the codebase. I'd prefer to have a single hooks folder with everything contained.

is it better for you like this?

I'm seeing a lot of '../../../../../../hooks/useCopyFeedback' stuff which I don't like. Can be refactored later though before it goes into master.

I came up with an alias here. Wdyt?

@alexshchur
alexshchur merged commit aceb97e into staging Dec 9, 2025
2 checks passed
@alexshchur
alexshchur deleted the feat/APPS-109-permit-management branch December 9, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants