feat(abstract-eth): expose getSignablePayload for ETH coin classes (CGD-1083)#8826
Draft
0xPrabh wants to merge 1 commit into
Draft
feat(abstract-eth): expose getSignablePayload for ETH coin classes (CGD-1083)#88260xPrabh wants to merge 1 commit into
0xPrabh wants to merge 1 commit into
Conversation
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
dbc8c82 to
14a7783
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Overrides
getSignablePayload(serializedTx)onAbstractEthLikeCoinso 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 toEthTransaction, and returnstx.signablePayloadEthLikeTransactionDatainterface — addsgetSignablePayload(): BufferEthTransactionData— implementsgetSignablePayload()viatx.getMessageToSign(true)(keccak256 hash, same primitive used internally for TSS signing)Transaction.signablePayloadgetter — overridesBaseTransaction'sNotImplementedErrordefault; throwsInvalidTransactionErrorif no transaction data is setAbstractEthLikeNewCoinsdescendants (Eth, Polygon, Arbeth, Opeth, BSC, AvaxC, EVM, tokens, etc.) and legacyAbstractEthLikeCoindescendants (Rbtc, Celo, Etc)Issue
CGD-1083 (unblocks WCN-397)
Type of change
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 txmodules/sdk-coin-eth/test/unit/transaction.ts— hash pinned againsttxData.idfixture for both Legacy and EIP1559; distinct-payload check between tx typesmodules/sdk-coin-eth/test/unit/eth.ts— end-to-endcoin.getSignablePayload(serializedTx)for Legacy and EIP1559 viaTethExisting TSS signing flows are unaffected — they use
signableHexfrom the unsigned tx object directly (abstractEthLikeNewCoins.ts:2444), notgetSignablePayload.