Skip to content

feat: add evm chain support#2098

Open
Nick-1979 wants to merge 62 commits intomainfrom
ethSupport00
Open

feat: add evm chain support#2098
Nick-1979 wants to merge 62 commits intomainfrom
ethSupport00

Conversation

@Nick-1979
Copy link
Member

@Nick-1979 Nick-1979 commented Jan 6, 2026

Summary by CodeRabbit

  • New Features

    • Add full Ethereum/EVM support: create/import Ethereum accounts, sign & send ETH/ERC‑20 transactions, view Etherscan-backed tx history, and fetch EVM assets/NFTs.
  • Improvements

    • Unified address handling across UI (receive, send, account flows) with chain-aware validation and visuals.
    • New account-type selector and refined dark theme highlight.
  • Dependencies

    • Added Ethereum tooling and icon packages to enable EVM features.

@Nick-1979 Nick-1979 self-assigned this Jan 6, 2026
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: 2

🤖 Fix all issues with AI agents
In `@packages/extension-polkagate/src/fullscreen/sendFund/useParaSpellFeeCall.ts`:
- Around line 64-82: The stale paraSpellState issue is caused by leaving
previous paraSpellTransaction/paraSpellFee in state while builder.build() runs;
at the start of the effect (before calling builder.build()) clear/reset the
paraSpell-related state via setParaSpellState to remove paraSpellTransaction and
paraSpellFee (e.g., set to null/undefined or an empty object), keep the existing
cancelled flag logic, and ensure any subsequent setParaSpellState((pre) => ({
...(pre||{}), paraSpellTransaction: tx })) only sets the new tx when not
cancelled so old values cannot persist if the new build fails.
- Around line 102-108: The error fallback for ParaspellFees used in
setParaSpellState omits required fields on originFee (it currently sets only
originFee: { fee: BN_ZERO }), causing a type mismatch with ParaspellFees /
TXcmFeeBase; update the fallback to include the required properties (e.g.,
originFee: { fee: BN_ZERO, sufficient: false, balanceAfter: 0n } or another
appropriate default) or explicitly cast the object as ParaspellFees to satisfy
the type checker; locate the update in the setParaSpellState call and adjust the
originFee shape (and destinationFee if used) so it matches the ParaspellFees
interface.
🧹 Nitpick comments (1)
packages/extension-polkagate/src/fullscreen/sendFund/useParaSpellFeeCall.ts (1)

66-111: Parallel build() and getTransferInfo() can produce partial state.

Since both calls fire independently, one can succeed while the other fails — leaving paraSpellTransaction set but paraSpellFee zeroed (or vice versa). Ensure the consumer checks that both paraSpellTransaction and a valid paraSpellFee are present before allowing the user to submit.

Comment on lines +64 to +82
let cancelled = false;

Promise.all([builder.build(), builder.getTransferInfo()])
.then(([tx, info]) => {
builder.build()
.then((tx) => {
if (cancelled) {
return;
}

setParaSpellState({
setParaSpellState((pre) => ({
...(pre || {}),
paraSpellTransaction: tx
}));
}).catch((err) => {
if (!cancelled) {
setError('Something went wrong while building transaction!');
}

console.error('building transaction error', err);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Stale paraSpellState persists across effect re-runs.

When dependencies change and the effect re-runs, the old paraSpellTransaction and paraSpellFee remain in state until the new promises resolve (or reject). If the new build() fails, the previous transaction stays in state—potentially mismatched with the current inputs. This could let a user submit a transaction built with outdated parameters.

Reset state at the top of the effect body:

Proposed fix
     const amount = transferType === 'All' ? 'ALL' : amountAsBN.toString();
 
     try {
+      setParaSpellState({});
+
       const builder = Builder({ abstractDecimals: false }/* node api/ws_url_string/ws_url_array - optional*/)
🤖 Prompt for AI Agents
In `@packages/extension-polkagate/src/fullscreen/sendFund/useParaSpellFeeCall.ts`
around lines 64 - 82, The stale paraSpellState issue is caused by leaving
previous paraSpellTransaction/paraSpellFee in state while builder.build() runs;
at the start of the effect (before calling builder.build()) clear/reset the
paraSpell-related state via setParaSpellState to remove paraSpellTransaction and
paraSpellFee (e.g., set to null/undefined or an empty object), keep the existing
cancelled flag logic, and ensure any subsequent setParaSpellState((pre) => ({
...(pre||{}), paraSpellTransaction: tx })) only sets the new tx when not
cancelled so old values cannot persist if the new build fails.

Comment on lines +102 to +108
// @ts-ignore
setParaSpellState((pre) => ({
...(pre || {}),
paraSpellFee: {
originFee: { fee: BN_ZERO }
}
}));
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for ParaspellFees type definition
echo "=== ParaspellFees type definition ==="
rg -n "type ParaspellFees|interface ParaspellFees" --type=ts -A 10

echo ""
echo "=== xcmFee type definition ==="
rg -n "type xcmFee|interface xcmFee" --type=ts -A 10

echo ""
echo "=== How paraSpellFee is accessed in the codebase ==="
rg -n "paraSpellFee" --type=ts -B 2 -A 2 | head -100

echo ""
echo "=== How originFee is accessed ==="
rg -n "\.originFee" --type=ts -B 2 -A 2

echo ""
echo "=== How destinationFee is accessed ==="
rg -n "\.destinationFee" --type=ts -B 2 -A 2

Repository: PolkaGate/extension

Length of output: 10109


🏁 Script executed:

#!/bin/bash
# Find TXcmFeeBase definition
echo "=== TXcmFeeBase type definition ==="
rg -n "type TXcmFeeBase|interface TXcmFeeBase" --type=ts -A 15

echo ""
echo "=== Check for direct access to originFee properties other than .fee ==="
rg -n "originFee\." --type=ts -B 1 -A 1 | grep -v "originFee.fee"

echo ""
echo "=== Check for direct access to originFee.sufficient ==="
rg -n "sufficient" --type=ts -B 2 -A 2

echo ""
echo "=== Check for direct access to originFee.balanceAfter ==="
rg -n "balanceAfter" --type=ts -B 2 -A 2

Repository: PolkaGate/extension

Length of output: 14976


Address type mismatch in the error fallback for ParaspellFees.

The error fallback at lines 105-107 sets originFee: { fee: BN_ZERO }, which violates the ParaspellFees interface. originFee requires TXcmFeeBase & { sufficient: boolean; balanceAfter: bigint; }, but the fallback omits sufficient and balanceAfter. While the current codebase only accesses originFee.fee (which exists) and safely handles optional destinationFee with defensive chaining, the type mismatch should be resolved to prevent future bugs if the code evolves to access these properties. Consider aligning the fallback object with the expected ParaspellFees shape or explicitly typing the error state.

🤖 Prompt for AI Agents
In `@packages/extension-polkagate/src/fullscreen/sendFund/useParaSpellFeeCall.ts`
around lines 102 - 108, The error fallback for ParaspellFees used in
setParaSpellState omits required fields on originFee (it currently sets only
originFee: { fee: BN_ZERO }), causing a type mismatch with ParaspellFees /
TXcmFeeBase; update the fallback to include the required properties (e.g.,
originFee: { fee: BN_ZERO, sufficient: false, balanceAfter: 0n } or another
appropriate default) or explicitly cast the object as ParaspellFees to satisfy
the type checker; locate the update in the setParaSpellState call and adjust the
originFee shape (and destinationFee if used) so it matches the ParaspellFees
interface.

@Nick-1979 Nick-1979 added test on testing phase and removed WIP Work In Progress labels Feb 25, 2026
@AMIRKHANEF
Copy link
Member

Issues To Fix:
1- 0x accounts can't be found on the Receive popup.

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

Labels

test on testing phase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants