Skip to content

feat(abstract-eth): expose getSignablePayload for ETH coin classes (CGD-1083)#8826

Merged
0xPrabh merged 1 commit into
masterfrom
prabhsharan/cgd-1083-eth-signable-payload-v2
May 22, 2026
Merged

feat(abstract-eth): expose getSignablePayload for ETH coin classes (CGD-1083)#8826
0xPrabh merged 1 commit into
masterfrom
prabhsharan/cgd-1083-eth-signable-payload-v2

Conversation

@0xPrabh
Copy link
Copy Markdown
Contributor

@0xPrabh 0xPrabh commented May 21, 2026

Description

Overrides getSignablePayload(serializedTx) on AbstractEthLikeCoin so that ETH and all ETH-like coins return the correct 32-byte keccak256 signing digest, rather than falling through to the base-class no-op that returns raw serialized bytes.

This is required to unblock AKM's external signing endpoint (POST /sign), which needs the correct hash to sign — not the raw transaction bytes.

Changes

  • AbstractEthLikeCoin.getSignablePayload — new override: deserializes via the transaction builder, casts to EthTransaction, and returns tx.signablePayload
  • EthLikeTransactionData interface — adds getSignablePayload(): Buffer
  • EthTransactionData — implements getSignablePayload() via tx.getMessageToSign(true) (keccak256 hash, same primitive used internally for TSS signing)
  • Transaction.signablePayload getter — overrides BaseTransaction's NotImplementedError default; throws InvalidTransactionError if no transaction data is set
  • EthLikeToken.getSignablePayload — preserves pre-PR behavior (returns raw serialized bytes); tokens are out of scope for this ticket
  • Inherited by all non-token AbstractEthLikeNewCoins descendants (Eth, Polygon, Arbeth, Opeth, BSC, AvaxC, EVM, etc.) and legacy AbstractEthLikeCoin descendants (Rbtc, Celo, Etc)

Issue

CGD-1083 (unblocks WCN-397)

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Unit tests added in:

  • modules/abstract-eth/test/unit/transaction.ts — throws on empty tx; returns 32-byte hash for unsigned tx
  • modules/sdk-coin-eth/test/unit/transaction.ts — hash pinned against txData.id fixture for both Legacy and EIP1559; distinct-payload check between tx types
  • modules/sdk-coin-eth/test/unit/eth.ts — end-to-end coin.getSignablePayload(serializedTx) for Legacy and EIP1559 via Teth

Existing TSS signing flows are unaffected — they use signableHex from the unsigned tx object directly (abstractEthLikeNewCoins.ts:2444), not getSignablePayload.

@0xPrabh 0xPrabh requested a review from a team as a code owner May 21, 2026 14:13
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 21, 2026

CGD-1083

@0xPrabh 0xPrabh force-pushed the prabhsharan/cgd-1083-eth-signable-payload-v2 branch from dbc8c82 to 14a7783 Compare May 21, 2026 14:47
@0xPrabh 0xPrabh marked this pull request as draft May 21, 2026 14:47
@0xPrabh 0xPrabh marked this pull request as ready for review May 22, 2026 06:05
Copy link
Copy Markdown
Contributor

@venkateshv1266 venkateshv1266 left a comment

Choose a reason for hiding this comment

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

🔴 Token coins throw on getSignablePayload — contradicts PR description

modules/abstract-eth/src/ethLikeToken.ts:406-408: EthLikeToken.getTransactionBuilder() is stubbed to throw new Error('Method not implemented'). Because EthLikeToken extends AbstractEthLikeNewCoins extends AbstractEthLikeCoin, it inherits the new override at abstractEthLikeCoin.ts:234-239, whose first line is this.getTransactionBuilder(). Calling <token>.getSignablePayload(serializedTx) now throws 'Method not implemented'.

Why this blocks: The PR description explicitly lists tokens as inheritors of this behavior ("Inherited by all AbstractEthLikeNewCoins descendants (Eth, Polygon, Arbeth, Opeth, BSC, AvaxC, EVM, tokens, etc.)"). Today the base-class default at least returned a Buffer (broken UTF-8, but non-throwing); now any ERC-20 path through AKM's /sign will hard-fail with an opaque error.

Suggested fix: Either

  • (a) override getSignablePayload on EthLikeToken to construct a vanilla ETH-coin builder — the wire-level tx is just an ETH tx, the token semantics live in the calldata; or
  • (b) explicitly throw a clear NotImplementedError so callers can fall back, and update the PR description to exclude tokens.

In either case, please add a token unit test mirroring the new eth.ts end-to-end tests (e.g. tdai) so this regression is caught by CI.

@0xPrabh 0xPrabh force-pushed the prabhsharan/cgd-1083-eth-signable-payload-v2 branch 2 times, most recently from 326f673 to 0547142 Compare May 22, 2026 07:04
@0xPrabh 0xPrabh requested a review from venkateshv1266 May 22, 2026 07:10
Override `getSignablePayload` on `AbstractEthLikeCoin` to return the
keccak256 hash of the unsigned transaction (via `getMessageToSign(true)`)
rather than raw serialized bytes. This exposes the correct bytes AKM
needs for its external POST /sign endpoint.

Changes:
- Add `getSignablePayload(): Buffer` to `EthLikeTransactionData` interface
  and implement it in `EthTransactionData` using `tx.getMessageToSign(true)`
- Add `get signablePayload(): Buffer` to the `Transaction` class, delegating
  to `EthTransactionData.getSignablePayload()`
- Override `getSignablePayload(serializedTx)` in `AbstractEthLikeCoin`,
  rebuilding via the transaction builder and returning `tx.signablePayload`
- Add unit tests covering Legacy and EIP1559 transaction types, and
  empty-transaction error handling

Ticket: CGD-1083
@0xPrabh 0xPrabh force-pushed the prabhsharan/cgd-1083-eth-signable-payload-v2 branch from 0547142 to 765df32 Compare May 22, 2026 07:16
@0xPrabh 0xPrabh merged commit 642859b into master May 22, 2026
22 checks passed
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