Skip to content

Comments

feat: space ID support#691

Merged
kvhnuke merged 9 commits intodevop/release-v-2-7-0from
feat/space-id-support
May 29, 2025
Merged

feat: space ID support#691
kvhnuke merged 9 commits intodevop/release-v-2-7-0from
feat/space-id-support

Conversation

@kvhnuke
Copy link
Contributor

@kvhnuke kvhnuke commented May 14, 2025

Summary by CodeRabbit

  • New Features

    • Expanded name resolution to support additional blockchain networks and PaymentId-based names.
    • Broadened supported top-level domains (TLDs) significantly for domain lookups.
    • Added enhanced timeout controls for name resolution processes.
    • Introduced network provider parameter to improve address resolution accuracy.
  • Bug Fixes

    • Improved error messaging for address checking in contacts list.
  • Refactor

    • Updated name resolution logic for greater modularity and reliability across multiple chains.
    • Replaced legacy resolver implementations with modular SDK-based resolvers.
  • Tests

    • Updated and expanded tests to cover new parameters and scenarios.
  • Chores

    • Added new dependencies and updated TypeScript configuration for improved compatibility and performance.

@coderabbitai
Copy link

coderabbitai bot commented May 14, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (3)
  • main
  • develop
  • devop/vite-migrate

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce support for PaymentId name resolution and enhance the flexibility of the name resolution process by adding a providerChain (or paymentIdChain) parameter across relevant resolver methods. The SID resolver is refactored to use new modular resolvers, expand supported TLDs, and add timeout handling. Updates propagate through the extension's UI logic to utilize the new parameter, and new dependencies are added to the name-resolution package.

Changes

File(s) Change Summary
packages/extension/src/libs/name-resolver/index.ts Updated GenericNameResolver.resolveName to accept an optional providerChain parameter and forward it to the internal resolver.
packages/extension/src/providers/common/ui/send-transaction/send-contacts-list.vue Modified error logging in the isChecked function to log a more specific message without the error object.
packages/extension/src/providers/ethereum/ui/send-transaction/index.vue
packages/extension/src/providers/solana/ui/send-transaction/index.vue
packages/extension/src/ui/action/views/swap/index.vue
Updated calls to nameResolver.resolveName to pass the network provider as a third argument. In swap, also asserted non-nullability for token balance.
packages/name-resolution/package.json Added @bonfida/spl-name-service and viem to devDependencies; added @web3-name-sdk/core to dependencies.
packages/name-resolution/src/index.ts NameResolver.resolveAddress now accepts an optional paymentIdChain parameter and passes it to the SID resolver.
packages/name-resolution/src/sid/index.ts Refactored SIDResolver to use new modular resolvers, added PaymentId support, timeout handling, expanded TLDs, and updated method signatures.
packages/name-resolution/src/sid/types.ts Added protocol, PaymentIdChain enum, chain mapping, timeout presets, and expanded SIDOptions.
packages/name-resolution/src/sid/utils.ts Added isValidPaymentId utility function for PaymentId format validation.
packages/name-resolution/src/types.ts Updated BaseResolver.resolveAddress to accept optional paymentIdChain parameter.
packages/name-resolution/tests/sid.test.ts Updated tests to pass the new parameters to resolveAddress calls.
packages/name-resolution/tsconfig.json Changed TypeScript module resolution to "bundler" and module system to "ES2015".
packages/name-resolution/src/ud/index.ts Expanded supported TLDs list extensively in UDResolver.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI Component
    participant GenericNameResolver
    participant NameResolver
    participant SIDResolver
    participant Web3NameResolver
    participant SolanaNameResolver
    participant PaymentIdNameResolver

    UI->>GenericNameResolver: resolveName(name, coins, providerChain?)
    GenericNameResolver->>NameResolver: resolveAddress(name, coin, providerChain?)
    alt PaymentId format
        NameResolver->>SIDResolver: resolveAddress(name, coin, providerChain?)
        SIDResolver->>PaymentIdNameResolver: handlePaymentIdGetAddress(name, providerChain)
        PaymentIdNameResolver-->>SIDResolver: address/null
        SIDResolver-->>NameResolver: address/null
    else Solana TLD
        NameResolver->>SIDResolver: resolveAddress(name, coin, providerChain?)
        SIDResolver->>SolanaNameResolver: resolveAddress(name, coin)
        SolanaNameResolver-->>SIDResolver: address/null
        SIDResolver-->>NameResolver: address/null
    else EVM TLD
        NameResolver->>SIDResolver: resolveAddress(name, coin, providerChain?)
        SIDResolver->>Web3NameResolver: resolveAddress(name, coin)
        Web3NameResolver-->>SIDResolver: address/null
        SIDResolver-->>NameResolver: address/null
    end
    NameResolver-->>GenericNameResolver: address/null
    GenericNameResolver-->>UI: address/null
Loading

Suggested reviewers

  • SemajaM
  • olgakup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Base automatically changed from devop/packeupdates-0512 to develop May 16, 2025 21:25
@github-actions
Copy link

github-actions bot commented May 20, 2025

💼 Build Files
chrome: enkrypt-chrome-48c972f6.zip
firefox: enkrypt-firefox-48c972f6.zip

💉 Virus total analysis
chrome: 48c972f6
firefox: 48c972f6

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (7)
packages/extension/src/providers/common/ui/send-transaction/send-contacts-list.vue (1)

128-130: Consider keeping the error object in the log

The error object has been removed from the console.error call, which might make debugging more difficult if issues arise with address checking in the future.

  console.error(
    'Error checking if address is checked, probably name resolver',
+   err
  );
packages/name-resolution/src/sid/utils.ts (2)

1-2: Consider more comprehensive PaymentID validation

The regex pattern for PaymentID validation is simple but may need enhancement in the future. It doesn't validate maximum length or restrict special characters that might be invalid in certain contexts.

-const paymentIdRegex = /^[a-zA-Z0-9]+@[a-zA-Z0-9]+$/
+// Restrict length and ensure only valid characters are used
+const paymentIdRegex = /^[a-zA-Z0-9]{1,64}@[a-zA-Z0-9]{1,64}$/
export const isValidPaymentId = (id: string) => paymentIdRegex.test(id)

Consider adding additional validation in the future if there are more specific requirements for PaymentID format.


1-3: Add documentation for the PaymentID format

The utility function would benefit from JSDoc comments explaining the expected format and purpose of PaymentID.

+/**
+ * PaymentID format: alphanumeric@alphanumeric
+ * Example: user123@domain456
+ * Used for resolving payment addresses across different chains
+ */
const paymentIdRegex = /^[a-zA-Z0-9]+@[a-zA-Z0-9]+$/
export const isValidPaymentId = (id: string) => paymentIdRegex.test(id)
packages/name-resolution/src/index.ts (1)

44-44: Trailing comma added for consistency

A trailing comma was added to the callback in the resolveReverseName method, which is a minor style improvement for code consistency.

packages/name-resolution/src/sid/index.ts (3)

62-73: Graceful handling of unknown paymentIdChain values

PAYMENT_ID_CHAINS_MAP[paymentIdChain?.toLowerCase()] returns undefined for unknown keys, falling back to PaymentIdChain.Ethereum. Consider validating the input so callers get feedback when they pass an unsupported chain instead of silently hitting the Ethereum default.

A tiny enhancement:

-  chainId:
-    PAYMENT_ID_CHAINS_MAP[paymentIdChain?.toLowerCase()] ||
-    PaymentIdChain.Ethereum,
+  chainId:
+    paymentIdChain && PAYMENT_ID_CHAINS_MAP[paymentIdChain.toLowerCase()]
+      ? PAYMENT_ID_CHAINS_MAP[paymentIdChain.toLowerCase()]
+      : PaymentIdChain.Ethereum,

Optionally throw or log a warn when an unknown chain is supplied.


75-88: Timeout mismatch between EVM and Solana reverse resolution

getDomainName for the Web3 resolver respects the configurable timeout, but the Solana resolver call is missing one. For parity (and to avoid the Solana RPC hanging longer than intended), pass the same timeout:

-        name = await this.solanaNameResolver.getDomainName({
-          address,
-        });
+        name = await this.solanaNameResolver.getDomainName({
+          address,
+          timeout: this.timeout,
+        });

Keeps UX consistent across chains.


116-119: Minor wording nit

The comment reads “Compatible with TLD and paymentId” – there is a double space after “TLD”. Trivial but worth fixing.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 97bd787 and 1316df5.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (13)
  • packages/extension/src/libs/name-resolver/index.ts (1 hunks)
  • packages/extension/src/providers/common/ui/send-transaction/send-contacts-list.vue (1 hunks)
  • packages/extension/src/providers/ethereum/ui/send-transaction/index.vue (1 hunks)
  • packages/extension/src/providers/solana/ui/send-transaction/index.vue (1 hunks)
  • packages/extension/src/ui/action/views/swap/index.vue (2 hunks)
  • packages/name-resolution/package.json (3 hunks)
  • packages/name-resolution/src/index.ts (1 hunks)
  • packages/name-resolution/src/sid/index.ts (1 hunks)
  • packages/name-resolution/src/sid/types.ts (1 hunks)
  • packages/name-resolution/src/sid/utils.ts (1 hunks)
  • packages/name-resolution/src/types.ts (2 hunks)
  • packages/name-resolution/tests/sid.test.ts (4 hunks)
  • packages/name-resolution/tsconfig.json (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/name-resolution/src/index.ts (1)
packages/name-resolution/src/types.ts (1)
  • CoinType (4-140)
🪛 Biome (1.9.4)
packages/name-resolution/src/sid/index.ts

[error] 105-107: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 110-112: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: buildAll
  • GitHub Check: test
  • GitHub Check: test
🔇 Additional comments (20)
packages/name-resolution/package.json (3)

25-25: New dependency for Solana name resolution

Adding the Bonfida SPL Name Service library will support Solana domain name resolution for the Space ID feature.


41-41: Added viem dependency for modern Ethereum interactions

The viem library is a modern, type-safe alternative to ethers.js for Ethereum interactions, which aligns with the module resolution update in tsconfig.json.


55-55: Added Web3 Name SDK Core dependency

This is a good addition that will provide unified name resolution across multiple chains including support for PaymentID. The SDK centralizes various resolution approaches in a consistent way.

packages/name-resolution/tsconfig.json (2)

5-5: Update to modern module resolution strategy

Changing from "node" to "bundler" moduleResolution strategy will better support the package's integration with modern web bundlers and dependencies like the Web3 Name SDK. This is appropriate for a browser extension environment.


11-11: Update to ES2015 module system

This change aligns with modern JavaScript practices and allows for better tree-shaking, which is important for a browser extension to maintain small bundle sizes.

packages/extension/src/providers/ethereum/ui/send-transaction/index.vue (1)

678-694: Correctly updated name resolution with provider chain parameter

The update to resolveName now passes the network provider as a third argument, enabling proper resolution of Space IDs and other chain-specific names.

packages/name-resolution/tests/sid.test.ts (2)

14-18: Test properly updated to include the new provider chain parameters

The test case has been correctly updated to include both the "ETH" coin type and "ethereum" provider chain parameters, aligning with the implementation changes in the SID resolver.


48-52: Consistent use of provider chain parameters in negative test case

The negative test case has been consistently updated with the same parameters as the success test, ensuring proper testing of the enhanced name resolution functionality.

packages/extension/src/providers/solana/ui/send-transaction/index.vue (1)

704-720: Correctly updated name resolution with provider chain parameter for Solana

The update to resolveName now passes the network provider as a third argument, ensuring consistent name resolution behavior across different blockchain providers in the application.

packages/extension/src/ui/action/views/swap/index.vue (2)

405-425: Correctly updated name resolution with provider chain parameter in swap interface

The inputAddress function has been properly updated to pass the network provider as the third argument to resolveName, maintaining consistency with other UI components and enabling Space ID support.


775-788: Added non-nullability assertion for safer TypeScript operations

The non-nullability assertion on fromToken.value!.balance! ensures that the TypeScript compiler knows the balance value is present before converting it to a string, preventing potential runtime errors.

packages/name-resolution/src/types.ts (2)

2-2: Import statement added for SIDOptions

The import statement for SIDOptions has been correctly added. This is necessary to reference the type in the NameResolverOptions interface.


147-151: API extension with optional parameter maintains backward compatibility

The resolveAddress method in the BaseResolver abstract class has been extended with an optional paymentIdChain parameter. This change maintains backward compatibility while adding support for PaymentId name resolution.

packages/extension/src/libs/name-resolver/index.ts (2)

17-17: Added optional providerChain parameter to resolveName method

The method signature has been extended with an optional parameter that will be passed to the underlying name resolution service. This change maintains backward compatibility while adding support for chain-specific resolution.


20-21: Parameter propagation to resolveAddress

The providerChain parameter is correctly passed to the underlying resolveAddress method, ensuring the chain context is properly propagated through the resolution pipeline.

packages/name-resolution/src/index.ts (2)

48-52: Added optional paymentIdChain parameter to resolveAddress

The method signature has been extended with an optional parameter to support chain-specific PaymentId resolution. This change maintains backward compatibility while adding new functionality.


58-59: SID resolver now receives paymentIdChain parameter

The call to the SID resolver now passes the paymentIdChain parameter, enabling chain-specific resolution for PaymentId names. This is consistent with the API changes in the BaseResolver class.

packages/name-resolution/src/sid/types.ts (3)

1-7: Added timeout option to SIDOptions

The SIDOptions interface has been extended with an optional timeout property. This allows configuring custom timeout values for SID resolution requests.


9-32: Added type definitions for multi-protocol support

New types and enums have been introduced to support multiple protocols and chains for name resolution:

  • Protocol type for differentiating between EVM, Solana, and PaymentID
  • PaymentIdChain enum for identifying specific blockchain networks
  • PAYMENT_ID_CHAINS_MAP for mapping chain names to their enum values
  • Method type for representing different resolution methods

These additions provide strong typing for the PaymentId resolution implementation.


34-38:

Details

✅ Verification successful

Added timeout presets with testing value

The TIMEOUT_PRESETS constant provides standardized timeout values, including a very short one explicitly labeled for testing. These presets help maintain consistent timeout behavior across the codebase.

Note that the veryShort timeout (100ms) should only be used in testing environments as it would likely cause timeouts in production scenarios.

Verify that the veryShort timeout is not used in production code:


🏁 Script executed:

#!/bin/bash
# Search for uses of veryShort timeout in non-test files
rg -i "veryShort" --type ts --glob '!**/*.test.ts' --glob '!**/*.spec.ts'

Length of output: 172


Timeout Preset Usage Verified
Search for veryShort in all non-test TS files returned only its definition in packages/name-resolution/src/sid/types.ts. There are no other references, so the 100 ms preset remains test-only and won’t affect production code.

@kvhnuke kvhnuke changed the base branch from develop to devop/release-v-2-7-0 May 29, 2025 18:33
@kvhnuke kvhnuke merged commit 127769b into devop/release-v-2-7-0 May 29, 2025
3 of 5 checks passed
@kvhnuke kvhnuke deleted the feat/space-id-support branch May 29, 2025 18:34
@kvhnuke kvhnuke restored the feat/space-id-support branch May 29, 2025 21:31
@kvhnuke kvhnuke deleted the feat/space-id-support branch May 29, 2025 21:31
@kvhnuke kvhnuke restored the feat/space-id-support branch May 29, 2025 21:36
@coderabbitai coderabbitai bot mentioned this pull request May 29, 2025
This was referenced Sep 8, 2025
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