Skip to content

feat: add Bitcoin and Solana support into NearIntentsProvider#814

Open
allemanfredi wants to merge 73 commits intocowprotocol:mainfrom
substance-labs:feat/add-btc-and-sol
Open

feat: add Bitcoin and Solana support into NearIntentsProvider#814
allemanfredi wants to merge 73 commits intocowprotocol:mainfrom
substance-labs:feat/add-btc-and-sol

Conversation

@allemanfredi
Copy link
Contributor

@allemanfredi allemanfredi commented Mar 4, 2026

as per title ...

Summary by CodeRabbit

  • New Features

    • Added support for Bitcoin and Solana as destination assets in NEAR Intents bridging.
  • Bug Fixes

    • Prevent using Bitcoin and Solana as source tokens to avoid invalid routes.
    • Improved token-matching and native-token handling for more reliable cross-chain resolution.
  • Tests

    • Added coverage for BTC/SOL quote flows and no-route cases; minor test cleanups.

…AIN_TO_NATIVE_WRAPPED_TOKEN_ADDRESS to support wrapped assets, changes an import and rm the sending of native tokens within getUnsignedBridgeCall
…ithin getSignedHook and implements getBridgingParams
…ment and a remove a useless check within getBridgingParams
…ithin getSignedHook, fixes getTokenByAddressAndChainId and getIntermediateTokens
…ridgeCallWithoutHooks within NearIntentsBridgeProvider
…m getUnsignedBridgeCall in favour of the balance of the sell token within the cowshed account at the swap time
…irect transfer to near deposit address within NearIntentsBridgeProvider
…col/one-click-sdk-typescript within dependencies
…TS_BLOCKCHAIN_TO_NATIVE_WRAPPED_TOKEN_ADDRESS into WRAPPED_NATIVE_CURRENCIES
allemanfredi and others added 14 commits November 9, 2025 17:33
…geProvider.ts): replaces Error with BridgeProviderQuoteError within getQuote
…rs out native tokens from getIntermediateTokens
@allemanfredi allemanfredi changed the title feat: add Bitcoin and Solana support into NearIntentProvider feat: add Bitcoin and Solana support into NearIntentsProvider Mar 4, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ded931a4-ee24-4128-ab38-de1461830150

📥 Commits

Reviewing files that changed from the base of the PR and between 7624809 and c791a86.

📒 Files selected for processing (2)
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.test.ts
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.test.ts

📝 Walkthrough

Walkthrough

Adds Bitcoin and Solana support to Near Intents: updates constants and types, extends token-resolution logic to handle BTC/SOL native sentinels across EVM and non‑EVM chains, adds an early guard rejecting BTC/SOL as sell tokens, and updates/expands tests to cover these flows.

Changes

Cohort / File(s) Summary
Configuration & Constants
packages/bridging/src/providers/near-intents/const/index.ts
Imported bitcoin, solana, and ChainId; added btc and sol to NEAR_INTENTS_SUPPORTED_NETWORKS; expanded NearBlockchainKey and mapped NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS to use bitcoin.id and solana.id.
Core Provider Logic
packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts, packages/bridging/src/providers/near-intents/util.ts
Added early guard in getQuote to throw NO_ROUTES when sellTokenAddress equals BTC_CURRENCY_ADDRESS or SOL_NATIVE_CURRENCY_ADDRESS. adaptToken and getTokenByAddressAndChainId updated to handle BTC/SOL native sentinels, use areAddressesEqual for comparisons, and preserve ETH/native sentinel behavior for EVM chains.
Tests
packages/bridging/src/providers/near-intents/NearIntentsApi.test.ts, packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.test.ts, packages/bridging/src/providers/near-intents/util.test.ts
Added/expanded tests for BTC and SOL destination quote flows (mocked API and attestator flows); added tests asserting NO_ROUTES when BTC/SOL are provided as sell tokens; updated util test data and minor whitespace tweak in API test.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Provider as NearIntentsBridgeProvider
    participant API as NearIntentsApi
    participant Attest as Attestator/RecoverAddress

    Client->>Provider: request getQuote(sellToken, buyToken, dstChain)
    alt sellToken is BTC or SOL
        Provider-->>Client: throw NO_ROUTES
    else normal flow
        Provider->>API: getTokens(chainId)
        API-->>Provider: token list
        Provider->>API: getQuote(params)
        API-->>Provider: quote (quoteHash, signature)
        Provider->>Attest: recoverDepositAddress(quoteHash)
        Attest-->>Provider: depositAddress
        Provider-->>Client: return Quote (id, signature, depositAddress, buyAmount)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 I nibble code and hop with cheer,
BTC and SOL now hop in here,
Sentinels snug where chains align,
Guards stand firm and tests define,
Hops, bytes, and carrots — celebration near! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add Bitcoin and Solana support into NearIntentsProvider' accurately captures the main objective of the pull request, which adds BTC and SOL support to the NearIntentsProvider.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.

OpenGrep is compatible with Semgrep configurations. Add an opengrep.yml or semgrep.yml configuration file to your project to enable OpenGrep analysis.

Copy link
Contributor

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ac7e4301-8b46-4beb-a9b6-b5ffba001092

📥 Commits

Reviewing files that changed from the base of the PR and between 4981e10 and 0cfa90c.

📒 Files selected for processing (6)
  • packages/bridging/src/providers/near-intents/NearIntentsApi.test.ts
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.test.ts
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts
  • packages/bridging/src/providers/near-intents/const/index.ts
  • packages/bridging/src/providers/near-intents/util.test.ts
  • packages/bridging/src/providers/near-intents/util.ts
💤 Files with no reviewable changes (1)
  • packages/bridging/src/providers/near-intents/NearIntentsApi.test.ts

… to correctly assign tokenAddress within adaptToken when chain is solana or bitcoin
@limitofzero limitofzero requested a review from a team March 5, 2026 13:26
Copy link
Contributor

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts`:
- Around line 141-147: The getIntermediateTokens flow is inconsistent:
NearIntentsBridgeProvider already rejects BTC/SOL as sell tokens (the
areAddressesEqual checks that throw BridgeProviderQuoteError), but
getIntermediateTokens can still include BTC_CURRENCY_ADDRESS or
SOL_NATIVE_CURRENCY_ADDRESS in its returned sourceTokens and thus surface routes
that will later fail; update getIntermediateTokens (or the call site that builds
sourceTokens) to filter out BTC_CURRENCY_ADDRESS and SOL_NATIVE_CURRENCY_ADDRESS
from the sourceTokens array before returning/using it so the route discovery
never includes those unsupported sell-token addresses (refer to
getIntermediateTokens and the sell-token rejection checks in
NearIntentsBridgeProvider for locating the logic).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 74c1e0d7-66c1-4af2-98ec-e220e6c34247

📥 Commits

Reviewing files that changed from the base of the PR and between 7524ede and 7624809.

📒 Files selected for processing (2)
  • packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts
  • packages/bridging/src/providers/near-intents/util.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bridging/src/providers/near-intents/util.ts

@shoom3301
Copy link
Contributor

@allemanfredi could you pull the latest changes from cowprotocol:main please?

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.

3 participants