feat: add Bitcoin and Solana support into NearIntentsProvider#814
feat: add Bitcoin and Solana support into NearIntentsProvider#814allemanfredi wants to merge 73 commits intocowprotocol:mainfrom
Conversation
…rIntentsApi and NearIntentsBridgeProvider
…he corresponding test
…ridgeProvider.import within test
…LimitEstimationForHook and getSignedHook
…AIN_TO_NATIVE_WRAPPED_TOKEN_ADDRESS to support wrapped assets, changes an import and rm the sending of native tokens within getUnsignedBridgeCall
…tus and adds const/index.tsx
…ithin getSignedHook and implements getBridgingParams
…hin COW_TRADE_EVENT_INTERFACE
…ment and a remove a useless check within getBridgingParams
…thin getBridgingParams
…ithin getSignedHook, fixes getTokenByAddressAndChainId and getIntermediateTokens
…ridgeCallWithoutHooks within NearIntentsBridgeProvider
…ithin NearIntentsBridgeProvider
…m getUnsignedBridgeCall in favour of the balance of the sell token within the cowshed account at the swap time
…within NearIntentsBridgeProvider
…irect transfer to near deposit address within NearIntentsBridgeProvider
…ype to getTokenByAddressAndChainId
…arIntentsBridgeProvider
…col/one-click-sdk-typescript within dependencies
…TS_BLOCKCHAIN_TO_NATIVE_WRAPPED_TOKEN_ADDRESS into WRAPPED_NATIVE_CURRENCIES
…ovider.ts): rm useless check
…geProvider.ts): replaces Error with BridgeProviderQuoteError within getQuote
(cherry picked from commit 01d583e)
…WrappedNativeCurrency and fixes adaptToken
…rs out native tokens from getIntermediateTokens
…waps on near intents
…bitcoin and solana
…vent using sellTokenAddress as btc or sol
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment Tip CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.OpenGrep is compatible with Semgrep configurations. Add an |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ac7e4301-8b46-4beb-a9b6-b5ffba001092
📒 Files selected for processing (6)
packages/bridging/src/providers/near-intents/NearIntentsApi.test.tspackages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.test.tspackages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.tspackages/bridging/src/providers/near-intents/const/index.tspackages/bridging/src/providers/near-intents/util.test.tspackages/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
packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts
Outdated
Show resolved
Hide resolved
…ssesEqual where possible
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.tspackages/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
packages/bridging/src/providers/near-intents/NearIntentsBridgeProvider.ts
Show resolved
Hide resolved
|
@allemanfredi could you pull the latest changes from |
… to prevent using BTC and SOL as intermediate tokens
as per title ...
Summary by CodeRabbit
New Features
Bug Fixes
Tests