Skip to content

fix: mf-6839 decode red packet transactions with 0x-prefixed calldata - #12492

Merged
guanbinrui merged 1 commit into
developfrom
fix/mf-6839-fix-red-packet-tx-decode
Sep 11, 2026
Merged

guanbinrui merged 1 commit into
developfrom
fix/mf-6839-fix-red-packet-tx-decode

Conversation

@swkatmask

@swkatmask swkatmask commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes MF-6839. ERC20 red packet creation on Polygon failed with a misleading toast: "Refund Lucky drop — Failed to refund Lucky Drop." while the dialog stayed stuck at the Confirm step.

Root cause

AccountTransaction.functionParameters returned calldata without the 0x prefix (data.slice(10)). EVMTransactionFormatter.createTransactionContext feeds it to viem's decodeAbiParameters, whose hexToBytes does hex.slice(2) unconditionally, dropping one byte and misaligning the decode → throws. The try/catch swallows it → methods: undefined, so RedPacketDescriptor.compute misses the create_red_packet branch and falls into the catch-all else = "Refund Lucky drop". Every create/claim outcome (success included) was announced as a refund.

Regression introduced by 9bff15f (migrate TransactionFormatter from abiCoder to viem): web3.js decodeParameters accepted unprefixed hex, viem requires 0x.

Verified with the repo's own viem (decodeAbiParameters over a real create_red_packet calldata, same call path as the formatter):

  • unprefixed (as shipped): throws Bytes value "1,0" is not a valid boolean
  • 0x-prefixed (fixed): decodes all 10 parameters

Note: this mislabels toasts/popup copy; it does not itself break the transaction. The corrected toast will surface the true underlying error for QA's ERC20 case if anything remains.

Changes

  1. AccountTransaction.functionParameters now returns 0x-prefixed hex (symmetric with functionSignature). Its only consumer is the formatter call site.
  2. RedPacketDescriptor: the bare else becomes else if (method?.name === 'refund'), so any future undecodable tx to the red packet contract falls through to the generic contract-interaction label instead of claiming "Refund".

Test Plan

  • Node repro against the repo's viem: old path throws, new path decodes all params (selector 0x5db05aba, 10 inputs incl. _token_addr / _total_tokens)
  • pnpm lint clean
  • Manual: create a lucky drop on Polygon (native POL) — success toast should read "Lucky drop with … POL created." instead of refund copy
  • Manual: ERC20 create on Polygon — if the tx still fails, the toast now reports "Failed to create Lucky Drop." with the real error surfaced (RPC replay of the exact create_red_packet calldata via eth_estimateGas on publicnode + drpc both return valid results, so the RPC is not the culprit)

@vercel

vercel Bot commented Sep 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
book Skipped Skipped Sep 11, 2026 7:41am UTC

Request Review

@guanbinrui
guanbinrui merged commit abc4837 into develop Sep 11, 2026
12 checks passed
@guanbinrui
guanbinrui deleted the fix/mf-6839-fix-red-packet-tx-decode branch September 11, 2026 08:01

This branch was previously deployed

1 inactive deployment
Preview — 9ff8d242 Deployed Sep 11, 2026 by vercel[bot]
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