Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add jsx support and interactive fee token selection in StarkNet Snap #429

Merged
merged 14 commits into from
Nov 21, 2024

Conversation

khanti42
Copy link
Collaborator

@khanti42 khanti42 commented Nov 21, 2024

PR Summary

This PR implements JSX support, interactive fee token selection, and transaction state management in the StarkNet Snap package, including:

  1. JSX Support:

    • Adds JSX support across the project for building interactive UI components in Snaps.
    • Introduces several JSX-based components and fragments (e.g., ExecuteTxnUI, FeeTokenSelector, LoadingUI) to enhance user interactions.
  2. Interactive Fee Token Selection:

    • Enables interactive UI for fee token selection during transaction execution.
    • Implements event listeners to handle dynamic changes and validate fee token balances.
  3. Transaction State Management:

    • Introduces a new state manager (TransactionRequestStateManager) for handling transaction requests.
    • Facilitate transaction flow with error handling and state persistence during interactive UI event handling.

Associated PRs

This includes :

BEGIN_COMMIT_OVERRIDE
feat: Add JSX support and detection (#415, #416)
feat: Allow users to select the fee token in the execute transaction dialog (#417, #418, #419, #420)
END_COMMIT_OVERRIDE

khanti42 and others added 7 commits November 18, 2024 17:27
* chore: add jsx support in snap

* chore: fix comment

* chore: update yarn.lock
* chore: add jsx support in snap

* chore: add jsx support in snap

* feat: jsx support management

* feat: common jsx components and fragments

* chore: fix test and lint

* chore: rollback jsx support detection not here

* chore: fix comment

* chore: fix comments

* chore: fix comments

* chore: update yarn.lock

* chore: update yarn.lock

* chore: add react-dom types

* chore: fix comments

* chore: rebase wallet-ui changes happening elsewhere
* chore: add jsx support in snap

* chore: add jsx support in snap

* feat: jsx support management

* feat: common jsx components and fragments

* chore: fix test and lint

* feat: add interactive-ui for execute txn

* fix: add mutex in jsx support detection mechanism

* chore: fixture request addapted

* chore: ensure test pass

* chore: lint

* chore: remove console.log

* chore: rollback jsx support detection not here

* chore: rollback index.tsx

* chore: fix comment

* chore: fix comments

* chore: fix comments

* chore: update yarn.lock

* chore: update yarn.lock

* chore: update yarn.lock

* chore: rebase wallet-ui changes happening elsewhere

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: removed utils

* fix: implement comments

* fix: implement comments

* chore: fix comments

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/utils.test.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/types/snapState.ts

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/utils.test.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/utils.test.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: lint

---------

Co-authored-by: Stanley Yuen <[email protected]>
…419)

* chore: add jsx support in snap

* chore: add jsx support in snap

* feat: jsx support management

* feat: common jsx components and fragments

* chore: fix test and lint

* feat: add interactive-ui for execute txn

* fix: add mutex in jsx support detection mechanism

* chore: fixture request addapted

* chore: ensure test pass

* chore: lint

* feat: add interactive-ui in execute txn

* chore: remove console.log

* chore: missing helper in tests

* chore: lint

* chore: rollback jsx support detection not here

* chore: rollback index.tsx

* chore: fix comment

* chore: fix comments

* chore: fix comments

* chore: update yarn.lock

* chore: update yarn.lock

* feat: update wallet-ui message

* chore: update yarn.lock

* chore: rebase wallet-ui changes happening elsewhere

* chore: rebase wallet-ui changes happening elsewhere

* chore: fix comments

* chore: fix comments

* fix: formatter-utils

* chore: fix comments

* chore: fix comments

* chore: lint

* chore: lint

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: removed utils

* fix: implement comments

* fix: implement comments

* chore: fix comments

* chore: fix comments

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/utils.test.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/types/snapState.ts

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/utils.test.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/utils.test.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: lint

* chore: lint

* chore: fix comments

* chore: fix comments

---------

Co-authored-by: Stanley Yuen <[email protected]>
* chore: add jsx support in snap

* chore: add jsx support in snap

* feat: jsx support management

* chore: fix test and lint

* fix: add mutex in jsx support detection mechanism

* chore: ensure test pass

* feat: new init state manager class to manage state init and support check

* fix: wait for hooks in request handler

* chore: lint

* fix: set jsx support to true before showing dialog

* chore: fix comment

* fix: moved ping pong

* chore: lint

* chore: rollback state

* chore: lint

* chore: fix comments

* fix: test suits
* chore: add jsx support in snap

* chore: add jsx support in snap

* feat: jsx support management

* feat: common jsx components and fragments

* chore: fix test and lint

* feat: add interactive-ui for execute txn

* fix: add mutex in jsx support detection mechanism

* chore: fixture request addapted

* chore: ensure test pass

* chore: lint

* feat: add interactive-ui in execute txn

* chore: remove console.log

* chore: missing helper in tests

* chore: lint

* feat: event-handler in index.tsx

* feat: event controller

* feat: error handling and tests suits for event controller

* fix: test suits

* fix: signer in fee-token-selector

* chore: rollback jsx support detection not here

* chore: rollback index.tsx

* chore: lint

* chore: fix comment

* chore: fix comments

* chore: fix comments

* chore: update yarn.lock

* chore: update yarn.lock

* feat: update wallet-ui message

* chore: update yarn.lock

* chore: rebase wallet-ui changes happening elsewhere

* chore: rebase wallet-ui changes happening elsewhere

* chore: fix comments

* chore: fix comments

* fix: formatter-utils

* chore: fix comments

* chore: fix comments

* chore: lint

* chore: lint

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: lint

* chore: lint

* chore: removed utils

* feat: add comments in user-input classes

* fix: implement comments

* fix: implement comments

* chore: fix comments

* chore: fix comments

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/utils.test.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/types/snapState.ts

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/components/ExecuteTxnUI.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/utils.test.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* Update packages/starknet-snap/src/ui/utils.test.tsx

Co-authored-by: Stanley Yuen <[email protected]>

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: lint

* chore: lint

* chore: fix rebase

* chore: fix comments

* chore: fix comments

* chore: fix comments

* chore: rebase

* fix: removed user-input controller abstract class and derived ones

* chore: rollback execute-txn

* chore: update

* chore: fix comments

* chore: fix comments

* chore: refine the code

* fix: add execution test

* fix: update execute txn test

---------

Co-authored-by: Stanley Yuen <[email protected]>
@khanti42 khanti42 changed the title feat: jsx support and fee token selection mechanism in execute txn feat: add jsx support and interactive fee token selection in StarkNet Snap Nov 21, 2024
@khanti42 khanti42 marked this pull request as ready for review November 21, 2024 10:22
@khanti42 khanti42 requested a review from a team as a code owner November 21, 2024 10:22
@khanti42 khanti42 requested review from Akaryatrh and jonesho and removed request for a team November 21, 2024 10:22
@khanti42 khanti42 mentioned this pull request Nov 21, 2024
3 tasks
Copy link
Collaborator

@stanleyyconsensys stanleyyconsensys left a comment

Choose a reason for hiding this comment

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

some unuse code present, please update it

packages/starknet-snap/src/state/state-manager.ts Outdated Show resolved Hide resolved
packages/starknet-snap/src/types/snapState.ts Outdated Show resolved Hide resolved
packages/starknet-snap/src/index.test.tsx Outdated Show resolved Hide resolved
packages/starknet-snap/src/index.test.tsx Outdated Show resolved Hide resolved
packages/starknet-snap/src/index.test.tsx Outdated Show resolved Hide resolved
packages/starknet-snap/src/index.test.tsx Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Nov 21, 2024

Quality Gate Passed Quality Gate passed for 'consensys_starknet-snap-wallet-ui'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link

sonarcloud bot commented Nov 21, 2024

Quality Gate Passed Quality Gate passed for 'consensys_starknet-snap-wallet-ui'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link

sonarcloud bot commented Nov 21, 2024

Quality Gate Passed Quality Gate passed for 'consensys_starknet-snap-starknet-snap'

Issues
9 New issues
0 Accepted issues

Measures
0 Security Hotspots
1.6% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link
Collaborator

@stanleyyconsensys stanleyyconsensys left a comment

Choose a reason for hiding this comment

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

LGTM, but we have to add back some test on refinement

we are missing test for

"onInstall", "onUpdate", "user-input-event-controller"

@khanti42 khanti42 added this pull request to the merge queue Nov 21, 2024
Merged via the queue into main with commit abfc0e5 Nov 21, 2024
13 checks passed
@khanti42 khanti42 deleted the feat/snap-fee-token-selection branch November 21, 2024 11:23
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.

2 participants