Conversation
…rom assistive tech
There was a problem hiding this comment.
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: Parallelbuild()andgetTransferInfo()can produce partial state.Since both calls fire independently, one can succeed while the other fails — leaving
paraSpellTransactionset butparaSpellFeezeroed (or vice versa). Ensure the consumer checks that bothparaSpellTransactionand a validparaSpellFeeare present before allowing the user to submit.
| 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); | ||
| }); |
There was a problem hiding this comment.
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.
| // @ts-ignore | ||
| setParaSpellState((pre) => ({ | ||
| ...(pre || {}), | ||
| paraSpellFee: { | ||
| originFee: { fee: BN_ZERO } | ||
| } | ||
| })); |
There was a problem hiding this comment.
🧩 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 2Repository: 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 2Repository: 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.
|
Issues To Fix: |
Summary by CodeRabbit
New Features
Improvements
Dependencies