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

Niche #1

Merged
merged 20 commits into from
Sep 17, 2024
Merged

Niche #1

merged 20 commits into from
Sep 17, 2024

Conversation

Nichebiche
Copy link
Owner

@Nichebiche Nichebiche commented Sep 17, 2024

User description

Please help me get access to my old tokens


PR Type

Enhancement, Tests, Documentation, Styling, Dependencies, Configuration changes, Error handling, Miscellaneous


Description

  • Refactored LocalScenario to extend BaseScenario for cleaner code structure.
  • Implemented new classes and features for remote associations and WebSocket management.
  • Enhanced mobile wallet adapter with remote transaction and session handling capabilities.
  • Added new UI components and styles for better user interaction and experience.
  • Updated dependencies and configurations for Android and JavaScript projects.
  • Added comprehensive documentation and license files for better project understanding and compliance.
  • Introduced error handling mechanisms and custom error classes for robust operations.
  • Conducted tests for remote authorization flows to ensure functionality.

Changes walkthrough 📝

Relevant files
Enhancement
39 files
LocalScenario.java
Refactor LocalScenario to Extend BaseScenario                       

android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/scenario/LocalScenario.java

  • Refactored LocalScenario to extend BaseScenario.
  • Removed redundant fields and methods, delegating to BaseScenario.
  • Simplified constructor by calling super constructor.
  • Adjusted session state callbacks for cleaner handling.
  • +35/-319
    RemoteAssociationScenario.java
    Implement Remote Association Scenario for Client Library 

    android/fakewallet/src/androidTest/java/com/solana/mobilewalletadapter/clientlib/scenario/RemoteAssociationScenario.java

  • Added new RemoteAssociationScenario class for handling remote
    associations.
  • Implemented connection logic with retry and timeout mechanisms.
  • Defined state management for remote session lifecycle.
  • +393/-0 
    RemoteWebSocketServerScenario.java
    Add Remote WebSocket Server Scenario for Wallet Library   

    android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/scenario/RemoteWebSocketServerScenario.java

  • Introduced RemoteWebSocketServerScenario for managing WebSocket
    connections.
  • Implemented connection retry logic and state transitions.
  • Added session establishment and teardown procedures.
  • +340/-0 
    BaseScenario.java
    Introduce BaseScenario for Common Scenario Logic                 

    android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/scenario/BaseScenario.java

  • Created BaseScenario class as a common base for scenarios.
  • Encapsulated common fields and methods for session management.
  • Provided default implementations for authorization and message
    handling.
  • +340/-0 
    WebSocketReflectorServer.java
    Implement WebSocket Reflector Server for Testing                 

    android/fakewallet/src/androidTest/java/com/solana/mobilewalletadapter/walletlib/transport/websockets/server/WebSocketReflectorServer.java

  • Added WebSocketReflectorServer for handling WebSocket connections.
  • Implemented connection management and message reflection.
  • Defined server lifecycle methods for initialization and closure.
  • +208/-0 
    ReflectorWebSocket.java
    Add ReflectorWebSocket for Client WebSocket Operations     

    android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/transport/websockets/ReflectorWebSocket.java

  • Introduced ReflectorWebSocket class for WebSocket client operations.
  • Implemented connection, message handling, and state management.
  • Provided methods for sending and receiving messages.
  • +227/-0 
    RemoteAssociationIntentCreator.java
    Create Remote Association Intent Creator for Client           

    android/fakewallet/src/androidTest/java/com/solana/mobilewalletadapter/clientlib/scenario/RemoteAssociationIntentCreator.java

  • Added RemoteAssociationIntentCreator for creating intents for remote
    associations.
  • Implemented methods to generate association URIs with necessary
    parameters.
  • Provided utility to check wallet endpoint availability.
  • +88/-0   
    RemoteAssociationUri.java
    Implement Remote Association URI Handling                               

    android/fakewallet/src/androidTest/java/com/solana/mobilewalletadapter/walletlib/association/RemoteAssociationUri.java

  • Added RemoteAssociationUri class for handling remote association URIs.
  • Implemented validation and parsing of URI components.
  • Provided method to create scenarios based on parsed URIs.
  • +76/-0   
    WebSocketsTransportContract.java
    Extend WebSocketsTransportContract with Reflector Details

    android/common/src/main/java/com/solana/mobilewalletadapter/common/WebSocketsTransportContract.java

  • Added constants for WebSocket reflector scheme and path.
  • Defined range for reflector ID and associated annotations.
  • +8/-1     
    RemoteAssociationUri.java
    Enable Remote Scenario Creation in RemoteAssociationUri   

    android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/association/RemoteAssociationUri.java

  • Updated RemoteAssociationUri to implement remote scenario creation.
  • Removed unsupported operation exception for remote associations.
  • +3/-1     
    LocalWebSocketServer.java
    Send Initial Ping on WebSocket Connection Open                     

    android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/transport/websockets/server/LocalWebSocketServer.java

    • Added logic to send an initial ping message upon connection.
    +1/-0     
    MobileWalletAdapterViewModel.kt
    Update ViewModel for Remote Scenario Support                         

    android/fakewallet/src/main/java/com/solana/mobilewalletadapter/fakewallet/MobileWalletAdapterViewModel.kt

  • Updated MobileWalletAdapterViewModel to support remote scenarios.
  • Added method to end remote sessions.
  • +8/-6     
    AssociateFragment.kt
    Enhance AssociateFragment for Remote Session Management   

    android/fakewallet/src/main/java/com/solana/mobilewalletadapter/fakewallet/ui/associate/AssociateFragment.kt

  • Added UI logic to handle remote session termination.
  • Displayed end session button for remote connections.
  • +7/-2     
    adapterRemote.ts
    Implement Remote Wallet Adapter for Mobile Wallet               

    js/packages/wallet-adapter-mobile/src/adapterRemote.ts

  • Introduced SolanaMobileWalletAdapterRemote for remote wallet
    interactions.
  • Implemented connection, authorization, and transaction methods.
  • Managed session lifecycle and error handling.
  • +539/-0 
    transact.ts
    Extend Transact Module for Remote Transactions                     

    js/packages/mobile-wallet-adapter-protocol/src/transact.ts

  • Added support for remote transactions in transactRemote.
  • Implemented session URL generation and WebSocket connection logic.
  • +235/-4 
    modal.ts
    Add Embedded Modal for QR Code Display                                     

    js/packages/wallet-adapter-mobile/src/embedded-modal/modal.ts

  • Added EmbeddedModal class for displaying QR code and connection
    status.
  • Implemented methods for modal lifecycle and event handling.
  • +145/-0 
    wallet.ts
    Implement Solana Mobile Wallet Adapter with transaction features

    js/packages/wallet-standard-mobile/src/wallet.ts

  • Implemented SolanaMobileWalletAdapterWallet class with various methods
    for wallet operations.
  • Added interfaces for AuthorizationResultCache and AddressSelector.
  • Defined constants and utility functions for transaction handling.
  • Integrated error handling for wallet operations.
  • +511/-0 
    transact.ts
    Add remote transaction handling for mobile wallets             

    js/packages/mobile-wallet-adapter-protocol-web3js/src/transact.ts

  • Added transactRemote function for remote wallet transactions.
  • Introduced Web3RemoteMobileWallet interface extending
    Web3MobileWallet.
  • Enhanced transaction handling with remote capabilities.
  • +95/-0   
    adapter.ts
    Enhance adapter with remote host authority and chain ID conversion

    js/packages/wallet-adapter-mobile/src/adapter.ts

  • Introduced clusterToChainId function for cluster to chain ID
    conversion.
  • Updated constructor to handle remoteHostAuthority.
  • Enhanced transaction method to support remote configuration.
  • +26/-3   
    bluetooth-html.ts
    Add Bluetooth connection modal HTML template                         

    js/packages/wallet-adapter-mobile/src/embedded-modal/bluetooth-html.ts

  • Added HTML template for Bluetooth connection modal.
  • Included elements for connection status and action buttons.
  • +33/-0   
    startSession.ts
    Refactor and enhance session handling with remote support

    js/packages/mobile-wallet-adapter-protocol/src/startSession.ts

  • Refactored session start logic into launchAssociation function.
  • Added startRemoteSession and getRemoteSessionUrl for remote session
    handling.
  • +47/-11 
    icon.ts
    Add wallet icon for mobile wallet adapter                               

    js/packages/wallet-standard-mobile/src/icon.ts

    • Added wallet icon as a base64 encoded SVG.
    +4/-0     
    getAssociateAndroidIntentURL.ts
    Add remote association URL generation with reflector ID   

    js/packages/mobile-wallet-adapter-protocol/src/getAssociateAndroidIntentURL.ts

  • Added getRemoteAssociateAndroidIntentURL for remote association.
  • Enhanced URL generation with reflector ID support.
  • +21/-0   
    controller.ts
    Implement modal controller for embedded wallet adapter     

    js/packages/wallet-adapter-mobile/src/embedded-modal/controller.ts

  • Implemented EmbeddedModalController for managing modal state.
  • Added methods for opening, closing, and connecting the modal.
  • +50/-0   
    reflectorId.ts
    Add reflector ID utilities for remote sessions                     

    js/packages/mobile-wallet-adapter-protocol/src/reflectorId.ts

  • Introduced ReflectorId type and utility functions.
  • Added methods for generating and validating reflector IDs.
  • +31/-0   
    createDefaultAuthorizationResultCache.ts
    Implement default authorization result cache with local storage

    js/packages/wallet-standard-mobile/src/createDefaultAuthorizationResultCache.ts

  • Implemented default authorization result cache using local storage.
  • Provided methods for setting, getting, and clearing cache.
  • +41/-0   
    qrcode-html.ts
    Add QR code connection modal HTML template                             

    js/packages/wallet-adapter-mobile/src/embedded-modal/qrcode-html.ts

  • Added HTML template for QR code connection modal.
  • Included elements for QR code display and connection instructions.
  • +12/-0   
    createDefaultAuthorizationResultCache.ts
    Implement React Native authorization result cache               

    js/packages/wallet-standard-mobile/src/forks/react-native/createDefaultAuthorizationResultCache.ts

  • Implemented React Native version of authorization result cache using
    AsyncStorage.
  • +31/-0   
    solana.ts
    Define Solana chains and utility functions for wallet adapter

    js/packages/wallet-standard-mobile/src/solana.ts

  • Defined supported Solana chains and utility functions.
  • Added function to get public key from address.
  • +26/-0   
    types.ts
    Add remote wallet association and session termination types

    js/packages/mobile-wallet-adapter-protocol/src/types.ts

  • Added RemoteWalletAssociationConfig type for remote associations.
  • Introduced TerminateSessionAPI and RemoteMobileWallet interfaces.
  • +11/-0   
    initialize.ts
    Implement mobile wallet adapter registration with support check

    js/packages/wallet-standard-mobile/src/initialize.ts

  • Implemented registerMwa function to register mobile wallet adapter.
  • Included logic to check local association support.
  • +19/-0   
    createDefaultWalletNotFoundHandler.ts
    Implement default wallet not found handler with redirect 

    js/packages/wallet-standard-mobile/src/createDefaultWalletNotFoundHandler.ts

  • Implemented default handler for wallet not found scenario.
  • Redirects to wallet URL if not found.
  • +13/-0   
    base64Utils.ts
    Add base64 utility functions for encoding and decoding     

    js/packages/wallet-standard-mobile/src/base64Utils.ts

    • Added utility functions for base64 encoding and decoding.
    +12/-0   
    index.ts
    Export adapterRemote module for wallet adapter                     

    js/packages/wallet-adapter-mobile/src/index.ts

    • Exported adapterRemote module.
    +1/-0     
    getIsSupported.ts
    Implement local association support check function             

    js/packages/wallet-standard-mobile/src/getIsSupported.ts

    • Implemented function to check local association support.
    +8/-0     
    createDefaultAddressSelector.ts
    Implement default address selector for wallet adapter       

    js/packages/wallet-standard-mobile/src/createDefaultAddressSelector.ts

    • Implemented default address selector returning the first address.
    +9/-0     
    base64Utils.ts
    Export base64 utilities for React Native environment         

    js/packages/wallet-standard-mobile/src/forks/react-native/base64Utils.ts

  • Exported base64 utility functions from js-base64 for React Native.
  • +1/-0     
    fragment_associate.xml
    Add session status and end session button to layout           

    android/fakewallet/src/main/res/layout/fragment_associate.xml

    • Added UI elements for session status and end session button.
    +24/-0   
    strings.xml
    Add session-related strings to resources                                 

    android/fakewallet/src/main/res/values/strings.xml

  • Added strings for session active label and terminate session button.
  • +4/-0     
    Tests
    1 files
    MainActivityTest.kt
    Add Test for Remote Authorization Flow in MainActivityTest

    android/fakewallet/src/androidTest/java/com/solana/mobilewalletadapter/fakewallet/MainActivityTest.kt

  • Added test for successful remote authorization flow.
  • Simulated remote reflector server for testing purposes.
  • +50/-0   
    Styling
    3 files
    styles.ts
    Add CSS styles for mobile wallet adapter modal                     

    js/packages/wallet-adapter-mobile/src/embedded-modal/styles.ts

  • Added CSS styles for mobile wallet adapter embedded modal.
  • Defined styles for modal layout, buttons, and connection status.
  • +159/-0 
    styles.css
    Add CSS styles for mobile wallet adapter components           

    js/packages/wallet-adapter-mobile/src/styles.css

  • Added CSS styles for mobile wallet adapter modal and components.
  • Defined styles for layout, buttons, and connection status.
  • +162/-0 
    styles.css
    Add CSS styles for mobile wallet adapter components           

    js/packages/wallet-adapter-mobile/styles.css

  • Added CSS styles for mobile wallet adapter modal and components.
  • Defined styles for layout, buttons, and connection status.
  • +162/-0 
    Error handling
    2 files
    errors.ts
    Define custom error classes for wallet operations               

    js/packages/wallet-standard-mobile/src/errors.ts

  • Defined custom error classes for wallet operations.
  • Included errors for connection, transaction, and message signing.
  • +79/-0   
    errors.ts
    Add reflector ID out of range error code                                 

    js/packages/mobile-wallet-adapter-protocol/src/errors.ts

  • Added error code for reflector ID out of range.
  • Updated error data type map with new error code.
  • +4/-0     
    Configuration changes
    7 files
    _app.tsx
    Register mobile wallet adapter with default configurations

    examples/example-web-app/pages/_app.tsx

  • Registered mobile wallet adapter with default configurations.
  • Integrated address selector and authorization result cache.
  • +19/-0   
    auto.ts
    Automate mobile wallet adapter registration with defaults

    js/packages/wallet-standard-mobile/src/auto.ts

  • Automated registration of mobile wallet adapter with default settings.
  • Configured default address selector and authorization cache.
  • +21/-0   
    package.json
    Add package configuration for wallet-standard-mobile         

    js/packages/wallet-standard-mobile/package.json

  • Added package metadata and configuration for wallet-standard-mobile.
  • Defined dependencies and build scripts.
  • +50/-0   
    AndroidManifest.xml
    Add network security configuration to AndroidManifest       

    android/fakewallet/src/main/AndroidManifest.xml

    • Added network security configuration to AndroidManifest.
    +2/-1     
    network_security_config.xml
    Add network security configuration XML                                     

    android/fakewallet/src/main/res/xml/network_security_config.xml

    • Added network security configuration XML file.
    +10/-0   
    tsconfig.json
    Add TypeScript configuration for wallet-standard-mobile   

    js/packages/wallet-standard-mobile/tsconfig.json

    • Added TypeScript configuration for wallet-standard-mobile.
    +8/-0     
    tsconfig.cjs.json
    Add CommonJS TypeScript configuration for wallet-standard-mobile

    js/packages/wallet-standard-mobile/tsconfig.cjs.json

  • Added CommonJS TypeScript configuration for wallet-standard-mobile.
  • +7/-0     
    Miscellaneous
    1 files
    index.ts
    Organize exports for wallet-standard-mobile package           

    js/packages/wallet-standard-mobile/src/index.ts

  • Exported wallet functions and default handlers.
  • Organized exports for wallet-standard-mobile package.
  • +5/-0     
    Dependencies
    4 files
    libs.versions.toml
    Update Android Gradle and library versions                             

    android/gradle/libs.versions.toml

  • Updated versions for Android Gradle and Kotlin plugins.
  • Updated various library versions for Android dependencies.
  • +9/-10   
    package.json
    Add wallet-standard-mobile dependency to example web app 

    examples/example-web-app/package.json

    • Added dependency link for wallet-standard-mobile.
    +2/-0     
    package.json
    Update dependencies and add qrcode package                             

    js/packages/wallet-adapter-mobile/package.json

  • Updated dependencies and added qrcode package.
  • Included @types/qrcode in devDependencies.
  • +4/-2     
    package.json
    Update mobile-wallet-adapter-protocol dependency version 

    js/packages/mobile-wallet-adapter-protocol-web3js/package.json

    • Updated dependency version for mobile-wallet-adapter-protocol.
    +1/-1     
    Documentation
    2 files
    LICENSE
    Add Apache 2.0 license for wallet-standard-mobile               

    js/packages/wallet-standard-mobile/LICENSE

    • Added Apache 2.0 license file for wallet-standard-mobile.
    +13/-0   
    README.md
    Add README for wallet-standard-mobile package                       

    js/packages/wallet-standard-mobile/README.md

    • Added README file for wallet-standard-mobile package.
    +5/-0     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    dependabot bot and others added 20 commits August 26, 2024 13:50
    Bumps com.android.tools.build:gradle from 8.5.1 to 8.5.2.
    
    ---
    updated-dependencies:
    - dependency-name: com.android.tools.build:gradle
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    #935)
    
    Bumps androidx.test:runner from 1.6.1 to 1.6.2.
    
    ---
    updated-dependencies:
    - dependency-name: androidx.test:runner
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    …in /android (#938)
    
    * chore(deps): bump org.jetbrains.kotlin.android in /android
    
    Bumps [org.jetbrains.kotlin.android](https://github.com/JetBrains/kotlin) from 2.0.10 to 2.0.20.
    - [Release notes](https://github.com/JetBrains/kotlin/releases)
    - [Changelog](https://github.com/JetBrains/kotlin/blob/v2.0.20/ChangeLog.md)
    - [Commits](JetBrains/kotlin@v2.0.10...v2.0.20)
    
    ---
    updated-dependencies:
    - dependency-name: org.jetbrains.kotlin.android
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * Update libs.versions.toml
    
    ---------
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Marco Martinez <funkatronicsmail@gmail.com>
    …pp (#936)
    
    Bumps `kotlin_version` from 2.0.10 to 2.0.20.
    
    Updates `org.jetbrains.kotlin.android` from 2.0.10 to 2.0.20
    - [Release notes](https://github.com/JetBrains/kotlin/releases)
    - [Changelog](https://github.com/JetBrains/kotlin/blob/v2.0.20/ChangeLog.md)
    - [Commits](JetBrains/kotlin@v2.0.10...v2.0.20)
    
    Updates `org.jetbrains.kotlin.plugin.compose` from 2.0.10 to 2.0.20
    - [Release notes](https://github.com/JetBrains/kotlin/releases)
    - [Changelog](https://github.com/JetBrains/kotlin/blob/v2.0.20/ChangeLog.md)
    - [Commits](JetBrains/kotlin@v2.0.10...v2.0.20)
    
    ---
    updated-dependencies:
    - dependency-name: org.jetbrains.kotlin.android
      dependency-type: direct:production
      update-type: version-update:semver-patch
    - dependency-name: org.jetbrains.kotlin.plugin.compose
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Bumps com.android.application from 8.5.2 to 8.6.0.
    
    ---
    updated-dependencies:
    - dependency-name: com.android.application
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    …#943)
    
    Bumps `androidGradlePlugin` from 8.5.2 to 8.6.0.
    
    Updates `com.android.library` from 8.5.2 to 8.6.0
    
    Updates `com.android.application` from 8.5.2 to 8.6.0
    
    ---
    updated-dependencies:
    - dependency-name: com.android.library
      dependency-type: direct:production
      update-type: version-update:semver-minor
    - dependency-name: com.android.application
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Bumps com.android.library from 8.5.2 to 8.6.0.
    
    ---
    updated-dependencies:
    - dependency-name: com.android.library
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    * pull ws lib to new branch
    
    * example web app changes
    
    * remove uneeded file
    …947)
    
    Bumps `androidxLifecycle` from 2.8.4 to 2.8.5.
    
    Updates `androidx.lifecycle:lifecycle-runtime-ktx` from 2.8.4 to 2.8.5
    
    Updates `androidx.lifecycle:lifecycle-viewmodel-ktx` from 2.8.4 to 2.8.5
    
    ---
    updated-dependencies:
    - dependency-name: androidx.lifecycle:lifecycle-runtime-ktx
      dependency-type: direct:production
      update-type: version-update:semver-patch
    - dependency-name: androidx.lifecycle:lifecycle-viewmodel-ktx
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Bumps `compose_material_version` from 1.6.8 to 1.7.0.
    
    Updates `androidx.compose.material:material` from 1.6.8 to 1.7.0
    
    Updates `androidx.compose.material:material-icons-core` from 1.6.8 to 1.7.0
    
    Updates `androidx.compose.material:material-icons-extended` from 1.6.8 to 1.7.0
    
    ---
    updated-dependencies:
    - dependency-name: androidx.compose.material:material
      dependency-type: direct:production
      update-type: version-update:semver-minor
    - dependency-name: androidx.compose.material:material-icons-core
      dependency-type: direct:production
      update-type: version-update:semver-minor
    - dependency-name: androidx.compose.material:material-icons-extended
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    …app (#949)
    
    Bumps `compose_version` from 1.6.8 to 1.7.0.
    
    Updates `androidx.compose.runtime:runtime` from 1.6.8 to 1.7.0
    
    Updates `androidx.compose.ui:ui` from 1.6.8 to 1.7.0
    
    Updates `androidx.compose.ui:ui-tooling-preview` from 1.6.8 to 1.7.0
    
    Updates `androidx.compose.ui:ui-test-junit4` from 1.6.8 to 1.7.0
    
    Updates `androidx.compose.ui:ui-tooling` from 1.6.8 to 1.7.0
    
    Updates `androidx.compose.ui:ui-test-manifest` from 1.6.8 to 1.7.0
    
    ---
    updated-dependencies:
    - dependency-name: androidx.compose.runtime:runtime
      dependency-type: direct:production
      update-type: version-update:semver-minor
    - dependency-name: androidx.compose.ui:ui
      dependency-type: direct:production
      update-type: version-update:semver-minor
    - dependency-name: androidx.compose.ui:ui-tooling-preview
      dependency-type: direct:production
      update-type: version-update:semver-minor
    - dependency-name: androidx.compose.ui:ui-test-junit4
      dependency-type: direct:production
      update-type: version-update:semver-minor
    - dependency-name: androidx.compose.ui:ui-tooling
      dependency-type: direct:production
      update-type: version-update:semver-minor
    - dependency-name: androidx.compose.ui:ui-test-manifest
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Bumps androidx.activity:activity-ktx from 1.9.1 to 1.9.2.
    
    ---
    updated-dependencies:
    - dependency-name: androidx.activity:activity-ktx
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    * Add embedded UI and QRCode rendering
    
    * Refactor embedded modal into folder
    
    * remote websocket working
    
    * remote connections workinggit status
    
    * better random
    
    * remote connections working, less gooooo
    
    * revert installed override
    
    * improving remote session UX
    
    ---------
    
    Co-authored-by: michael sulistio <michaelsulistio@gmail.com>
    Bumps androidx.lifecycle:lifecycle-runtime-ktx from 2.8.4 to 2.8.5.
    
    ---
    updated-dependencies:
    - dependency-name: androidx.lifecycle:lifecycle-runtime-ktx
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Bumps androidx.activity:activity-compose from 1.9.1 to 1.9.2.
    
    ---
    updated-dependencies:
    - dependency-name: androidx.activity:activity-compose
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Bumps [micromatch](https://github.com/micromatch/micromatch) from 4.0.5 to 4.0.8.
    - [Release notes](https://github.com/micromatch/micromatch/releases)
    - [Changelog](https://github.com/micromatch/micromatch/blob/master/CHANGELOG.md)
    - [Commits](micromatch/micromatch@4.0.5...4.0.8)
    
    ---
    updated-dependencies:
    - dependency-name: micromatch
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Bumps androidx.lifecycle:lifecycle-viewmodel-compose from 2.8.4 to 2.8.5.
    
    ---
    updated-dependencies:
    - dependency-name: androidx.lifecycle:lifecycle-viewmodel-compose
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Bumps [rexml](https://github.com/ruby/rexml) from 3.3.3 to 3.3.6.
    - [Release notes](https://github.com/ruby/rexml/releases)
    - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
    - [Commits](ruby/rexml@v3.3.3...v3.3.6)
    
    ---
    updated-dependencies:
    - dependency-name: rexml
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Bumps com.android.tools.build:gradle from 8.5.2 to 8.6.0.
    
    ---
    updated-dependencies:
    - dependency-name: com.android.tools.build:gradle
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    …945)
    
    Bumps `androidxNavigation` from 2.7.7 to 2.8.0.
    
    Updates `androidx.navigation:navigation-fragment-ktx` from 2.7.7 to 2.8.0
    
    Updates `androidx.navigation:navigation-safe-args-gradle-plugin` from 2.7.7 to 2.8.0
    
    ---
    updated-dependencies:
    - dependency-name: androidx.navigation:navigation-fragment-ktx
      dependency-type: direct:production
      update-type: version-update:semver-minor
    - dependency-name: androidx.navigation:navigation-safe-args-gradle-plugin
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Copy link
    Owner Author

    @Nichebiche Nichebiche left a comment

    Choose a reason for hiding this comment

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

    Cool

    @Nichebiche Nichebiche merged commit a843997 into Nichebiche:main Sep 17, 2024
    Copy link

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵
    🧪 PR contains tests
    🔒 Security concerns

    Sensitive information exposure:
    The implementation of remote WebSocket connections and authorization flows introduces potential security risks. Special attention should be given to the handling of authentication tokens, secure communication channels, and protection against man-in-the-middle attacks. The RemoteWebSocketServerScenario and SolanaMobileWalletAdapterWallet classes should be carefully audited for any potential vulnerabilities in their handling of sensitive data and network communications.

    ⚡ Key issues to review

    Potential Security Issue
    The RemoteWebSocketServerScenario class handles sensitive operations like authorization and connection management. A thorough security review is needed to ensure proper handling of authentication tokens, secure WebSocket connections, and protection against potential vulnerabilities.

    Complex Implementation
    The SolanaMobileWalletAdapterWallet class is a large and complex implementation with multiple responsibilities. It may benefit from further modularization and separation of concerns to improve maintainability and testability.

    Test Coverage
    The new remote authorization test case (authorizationFlow_SuccessfulRemoteAuthorization) should be thoroughly reviewed to ensure it adequately covers all aspects of the remote authorization flow, including error cases and edge scenarios.

    Copy link

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Implement a more graceful shutdown process for the ScheduledExecutorService

    Consider implementing a more graceful shutdown process for the
    ScheduledExecutorService in the close() method. The current implementation might
    lead to tasks being abruptly terminated.

    android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/scenario/RemoteWebSocketServerScenario.java [245-251]

     private void destroyResourcesOnClose() {
         mReflectorWebSocket = null;
         if (mConnectionBackoffExecutor != null) {
    -        mConnectionBackoffExecutor.shutdownNow();
    +        mConnectionBackoffExecutor.shutdown();
    +        try {
    +            if (!mConnectionBackoffExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
    +                mConnectionBackoffExecutor.shutdownNow();
    +            }
    +        } catch (InterruptedException e) {
    +            mConnectionBackoffExecutor.shutdownNow();
    +            Thread.currentThread().interrupt();
    +        }
             mConnectionBackoffExecutor = null;
         }
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: Implementing a more graceful shutdown process for the ScheduledExecutorService is a best practice that prevents abrupt task termination, enhancing application stability.

    9
    Use a more appropriate exception type for better error handling and clarity

    Consider using a more specific exception type instead of
    UnsupportedOperationException when handling URI syntax errors in the constructor.

    android/fakewallet/src/androidTest/java/com/solana/mobilewalletadapter/clientlib/scenario/RemoteAssociationScenario.java [98]

    -throw new UnsupportedOperationException("Failed assembling a WebSocket URI", e);
    +throw new IllegalArgumentException("Failed assembling a WebSocket URI", e);
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Replacing UnsupportedOperationException with IllegalArgumentException provides a more accurate representation of the error, improving error handling and clarity.

    8
    Enhancement
    Add a timeout mechanism to prevent indefinite waiting during transactions

    Consider adding a timeout mechanism to the transact method to prevent indefinite
    waiting in case of network issues or unresponsive wallet.

    js/packages/wallet-adapter-mobile/src/adapterRemote.ts [315-353]

    -private async transact<TReturn>(callback: (wallet: Web3RemoteMobileWallet) => TReturn): Promise<TReturn> {
    +private async transact<TReturn>(callback: (wallet: Web3RemoteMobileWallet) => TReturn, timeout = 30000): Promise<TReturn> {
         const walletUriBase = this._authorizationResult?.wallet_uri_base;
         const baseConfig = walletUriBase ? { baseUri: walletUriBase } : undefined;
         const remoteConfig = { ...baseConfig, remoteHostAuthority: this._hostAuthority };
         const currentConnectionGeneration = this._connectionGeneration;
         const modal = new EmbeddedDialogModal('MWA QR');
     
         if (this._wallet) {
             return callback(this._wallet);
         }
         
         try {
    +        const timeoutPromise = new Promise<never>((_, reject) => 
    +            setTimeout(() => reject(new Error('Transaction timeout')), timeout)
    +        );
             const { associationUrl, result: promise } = await transactRemote(async (wallet) => {
                 const result = await callback(wallet);
                 modal.close();
                 return result;
             }, remoteConfig);
             modal.init(associationUrl.toString());
             modal.open();
    -        return await promise;
    +        return await Promise.race([promise, timeoutPromise]);
         } catch (e) {
             modal.close();
             if (this._connectionGeneration !== currentConnectionGeneration) {
                 await new Promise(() => {}); // Never resolve.
             }
             if (
                 e instanceof Error &&
                 e.name === 'SolanaMobileWalletAdapterError' &&
                 (
                     e as SolanaMobileWalletAdapterError<
                         typeof SolanaMobileWalletAdapterErrorCode[keyof typeof SolanaMobileWalletAdapterErrorCode]
                     >
                 ).code === 'ERROR_WALLET_NOT_FOUND'
             ) {
                 await this._onWalletNotFound(this);
             }
             throw e;
         }
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: Adding a timeout mechanism is a significant improvement that prevents the application from hanging indefinitely due to network issues or an unresponsive wallet. This suggestion enhances the robustness and reliability of the code, making it a crucial improvement.

    9
    Implement a retry mechanism with exponential backoff for remote transactions

    Consider implementing a retry mechanism with exponential backoff for the transact
    method to handle temporary network issues or server unavailability.

    js/packages/wallet-adapter-mobile/src/adapterRemote.ts [315-353]

     private async transact<TReturn>(callback: (wallet: Web3RemoteMobileWallet) => TReturn): Promise<TReturn> {
         const walletUriBase = this._authorizationResult?.wallet_uri_base;
         const baseConfig = walletUriBase ? { baseUri: walletUriBase } : undefined;
         const remoteConfig = { ...baseConfig, remoteHostAuthority: this._hostAuthority };
         const currentConnectionGeneration = this._connectionGeneration;
         const modal = new EmbeddedDialogModal('MWA QR');
     
         if (this._wallet) {
             return callback(this._wallet);
         }
         
    -    try {
    -        const { associationUrl, result: promise } = await transactRemote(async (wallet) => {
    -            const result = await callback(wallet);
    +    const maxRetries = 3;
    +    let retries = 0;
    +    while (retries < maxRetries) {
    +        try {
    +            const { associationUrl, result: promise } = await transactRemote(async (wallet) => {
    +                const result = await callback(wallet);
    +                modal.close();
    +                return result;
    +            }, remoteConfig);
    +            modal.init(associationUrl.toString());
    +            modal.open();
    +            return await promise;
    +        } catch (e) {
                 modal.close();
    -            return result;
    -        }, remoteConfig);
    -        modal.init(associationUrl.toString());
    -        modal.open();
    -        return await promise;
    -    } catch (e) {
    -        modal.close();
    -        if (this._connectionGeneration !== currentConnectionGeneration) {
    -            await new Promise(() => {}); // Never resolve.
    +            if (this._connectionGeneration !== currentConnectionGeneration) {
    +                await new Promise(() => {}); // Never resolve.
    +            }
    +            if (
    +                e instanceof Error &&
    +                e.name === 'SolanaMobileWalletAdapterError' &&
    +                (
    +                    e as SolanaMobileWalletAdapterError<
    +                        typeof SolanaMobileWalletAdapterErrorCode[keyof typeof SolanaMobileWalletAdapterErrorCode]
    +                    >
    +                ).code === 'ERROR_WALLET_NOT_FOUND'
    +            ) {
    +                await this._onWalletNotFound(this);
    +                throw e;
    +            }
    +            retries++;
    +            if (retries >= maxRetries) {
    +                throw e;
    +            }
    +            await new Promise(resolve => setTimeout(resolve, 1000 * Math.pow(2, retries)));
             }
    -        if (
    -            e instanceof Error &&
    -            e.name === 'SolanaMobileWalletAdapterError' &&
    -            (
    -                e as SolanaMobileWalletAdapterError<
    -                    typeof SolanaMobileWalletAdapterErrorCode[keyof typeof SolanaMobileWalletAdapterErrorCode]
    -                >
    -            ).code === 'ERROR_WALLET_NOT_FOUND'
    -        ) {
    -            await this._onWalletNotFound(this);
    -        }
    -        throw e;
         }
    +    throw new Error('Max retries exceeded');
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Implementing a retry mechanism with exponential backoff is a valuable enhancement for handling transient network issues, improving the reliability of the transact method. This suggestion addresses potential network instability, which is crucial for maintaining a seamless user experience.

    8
    Implement a more robust method for parsing the reflector ID from the URI query string

    Consider using a more robust method for parsing the reflector ID from the URI query
    string. The current regex pattern might be prone to errors if the query string
    format changes.

    android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/scenario/RemoteWebSocketServerScenario.java [51]

    -private final Pattern idPattern = Pattern.compile("id=([0-9]*)");
    +private long parseReflectorId(URI uri) {
    +    String query = uri.getQuery();
    +    if (query != null) {
    +        for (String param : query.split("&")) {
    +            String[] pair = param.split("=");
    +            if (pair.length == 2 && "id".equals(pair[0])) {
    +                try {
    +                    return Long.parseLong(pair[1]);
    +                } catch (NumberFormatException e) {
    +                    Log.w(TAG, "Invalid reflector ID: " + pair[1]);
    +                }
    +            }
    +        }
    +    }
    +    throw new IllegalArgumentException("Reflector ID not found in URI");
    +}
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: The suggestion to use a more robust method for parsing the reflector ID enhances reliability and reduces potential errors from format changes, making it a valuable improvement.

    7
    Use a mock server for more robust remote reflector simulation in tests

    Consider using a more robust way to simulate the remote reflector server, such as
    using a mock server library or a real test server instance. This would provide a
    more realistic test environment and potentially uncover edge cases.

    android/fakewallet/src/androidTest/java/com/solana/mobilewalletadapter/fakewallet/MainActivityTest.kt [201-203]

     // simulate remote reflector server
    -val port = 8881
    -val server = WebSocketReflectorServer(port)
    -server.init()
    +val mockServer = MockWebServer()
    +mockServer.start(8881)
    +mockServer.enqueue(MockResponse().withWebSocketUpgrade(WebSocketListener()))
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Using a mock server for testing is a good practice as it can simulate more realistic network conditions and edge cases, improving the robustness of the tests. However, the existing code already provides a basic simulation, so this suggestion is an enhancement rather than a critical fix.

    7
    Replace the hardcoded backoff schedule array with an enum for improved readability and maintainability

    Consider using an enum for the connection backoff schedule instead of a hardcoded
    array. This would improve readability and make it easier to modify the schedule in
    the future.

    android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/scenario/RemoteWebSocketServerScenario.java [36]

    -private static final int[] CONNECT_BACKOFF_SCHEDULE_MS = { 150, 150, 200, 500, 500, 750, 750, 1000 }; // == 30s, which allows time for a user to choose a wallet from the disambiguation dialog, and for that wallet to start
    +private enum ConnectBackoffSchedule {
    +    ATTEMPT_1(150), ATTEMPT_2(150), ATTEMPT_3(200), ATTEMPT_4(500),
    +    ATTEMPT_5(500), ATTEMPT_6(750), ATTEMPT_7(750), ATTEMPT_8(1000);
     
    +    private final int delayMs;
    +
    +    ConnectBackoffSchedule(int delayMs) {
    +        this.delayMs = delayMs;
    +    }
    +
    +    public int getDelayMs() {
    +        return delayMs;
    +    }
    +}
    +
    • Apply this suggestion
    Suggestion importance[1-10]: 5

    Why: Using an enum for the connection backoff schedule can improve readability and maintainability, but it is not a critical change. The current array is straightforward and functional.

    5
    Possible issue
    Use a thread-safe collection for managing half-open connections

    Consider using a concurrent collection like ConcurrentHashMap for
    mHalfOpenConnections to avoid potential race conditions when accessing this map from
    different threads.

    android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/scenario/RemoteWebSocketServerScenario.java [47]

    -private final Map<Long, ReflectorWebSocket> mHalfOpenConnections = new HashMap<>();
    +private final Map<Long, ReflectorWebSocket> mHalfOpenConnections = new ConcurrentHashMap<>();
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Switching to a ConcurrentHashMap for mHalfOpenConnections addresses potential race conditions, improving thread safety and reliability in a concurrent environment.

    8
    Maintainability
    Replace magic numbers with named constants for improved code readability

    Consider using a constant for the magic number 1 in the onSessionEstablished and
    onSessionClosed methods to improve code readability and maintainability.

    android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/scenario/LocalScenario.java [115]

    -if (mClientCount.incrementAndGet() == 1) {
    +private static final int FIRST_CLIENT = 1;
     
    +if (mClientCount.incrementAndGet() == FIRST_CLIENT) {
    +
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Using a named constant instead of a magic number improves code readability and maintainability, making the code easier to understand and modify.

    7

    Copy link
    Owner Author

    @Nichebiche Nichebiche left a comment

    Choose a reason for hiding this comment

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

    Cool

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants