Skip to content

Add BCH and EVM to Bridgeless plugin#450

Merged
peachbits merged 4 commits intomasterfrom
matthew/bridgeless-bch
Apr 10, 2026
Merged

Add BCH and EVM to Bridgeless plugin#450
peachbits merged 4 commits intomasterfrom
matthew/bridgeless-bch

Conversation

@peachbits
Copy link
Copy Markdown
Contributor

@peachbits peachbits commented Mar 27, 2026

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

none

Note

Medium Risk
Adds new chain support and introduces EVM contract-call/approval transaction generation, which can affect funds flow if memo/data encoding or amount-scaling is wrong. Includes new rounding/decimal conversion logic that impacts minimum/quoted amounts across chains.

Overview
Bridgeless swaps now support Bitcoin Cash and EVM chains (Ethereum + BNB Chain) in addition to the existing Zano flows, including EVM token approvals via createEvmApprovalEdgeTransactions and ABI-encoded depositNative/depositERC20 call data placed into the spend memo.

Quote math is updated to scale native amounts across differing token decimals (new scaleNativeAmount with rounding) so min/commission checks work when bridging between chains with different precisions, and order tracking is adjusted for EVM token deposits (uses log index 1 for the nonce). Unit tests were added for scaleNativeAmount, and the changelog notes the new Bridgeless chain support.

Reviewed by Cursor Bugbot for commit 96f6760. Bugbot is set up for automated code reviews on this repo. Configure here.


Comment thread src/swap/defi/bridgeless.ts Outdated
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'

const EDGE_PLUGINID_CHAINID_MAP: Record<string, string> = {
// base: '8453', // only support btc for now
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: This comment is stale — the PR adds BCH, ETH, and BSC support, so "only support btc for now" is misleading. Consider updating to clarify why Base is excluded (e.g., // Base: not yet enabled in Bridgeless) or removing the line entirely per delete-unnecessary-code.

Comment thread src/swap/defi/bridgeless.ts Outdated
Comment on lines 261 to 277
} catch (e) {
// ignore tokens that fail validation
}
try {
if (toTokenInfoForToken == null) {
const tokenId = await getTokenId(request.toWallet, info.address)
if (
info.chain_id ===
EDGE_PLUGINID_CHAINID_MAP[
request.toWallet.currencyInfo.pluginId
] &&
tokenId === request.toTokenId
) {
toTokenInfoForToken = info
}
}
} catch (e) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: Both catch (e) blocks should use catch (e: unknown) per project TypeScript standards (catch-typing).

@peachbits peachbits requested a review from j0ntz April 9, 2026 21:12
Add bitcoin cash chain id
Add zero address constant
Use correct fetch
Reaplce switch/case with if for Zano special case
The plugin isn't handling tokenId or decimals correctly. It just kind of worked for bitcoin because the number of decimals matched on both sides of the swap. For tokenId, only the fromWallet was used so the plugin is broken if the swap goes from token->token.
@peachbits peachbits force-pushed the matthew/bridgeless-bch branch from 5d2f486 to 55cdc49 Compare April 10, 2026 19:32
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 55cdc49. Configure here.

fromAmount,
fromTokenInfo,
toChainId,
receiver: toAddress
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

EVM path uses raw address instead of hex-encoded receiver

High Severity

The EVM case passes toAddress (the raw base58 Zano address) to makeBridgelessEvmSpendInfo instead of the receiver variable computed at the top of the function. The receiver variable correctly hex-encodes Zano addresses via base16.encode(base58.decode(toAddress)). The bitcoin/BCH case correctly uses receiver, but the EVM case does not. Since the plugin requires Zano involvement, every EVM swap destination is Zano, so the smart contract will always receive the address in the wrong format, likely causing lost funds.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 55cdc49. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The Zano address is passed in directly https://docs.bridgeless.com/docs/specs/arch/signer/integration/bridging/evm/#erc20-to-asset

I will move the receiver const into the utxo block so it's not interpreted as a const for all paths

This is an arbitrary limitation. Other swaps should work (ie. bitcoin to ethereum btcx token) but they are untested.

# Conflicts:
#	CHANGELOG.md
@peachbits peachbits force-pushed the matthew/bridgeless-bch branch from a94adb2 to 96f6760 Compare April 10, 2026 20:15
@peachbits peachbits merged commit a85adb4 into master Apr 10, 2026
3 checks passed
@peachbits peachbits deleted the matthew/bridgeless-bch branch April 10, 2026 20:17
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