payload.primaryType does not affect this signature or the digest: both calls receive only domain, the complete types map, and message; primaryType is merely echoed on line 35. With a payload that explicitly selects a declared type other than TronWeb’s inferred root, the command can therefore sign one type while reporting another. Please derive the type set rooted at the selected primaryType (or reject an incompatible selection) and use that same selection for signing, digesting, and reporting. #716
Activity
Stan202310 commentedon Sep 14, 2026
TronWeb derives the primaryType from types. Therefore, the types can only have one root and the corresponding sub types. You need to pass the correct types value.
ramincsy commentedon Sep 23, 2026
This primaryType mismatch is a real correctness hazard for typed-data signing — especially when callers intentionally select a non-inferred root type.
I can work on a focused fix that (1) builds the type set rooted at the supplied primaryType or rejects an incompatible selection, and (2) uses that same selection for digest, sign, and reported primaryType, with a failing fixture that currently signs the wrong root.
If there's already preferred API behavior in mind from the wallet-cli discussion, point me at it and I'll follow that.
Stan202310 commentedon Oct 9, 2026
Thanks for the suggestion, this makes sense.
Today
signTypedData(domain, types, value, privateKey)derives the primary type fromtypes: the object has to contain exactly one root type plus the struct types that root references, otherwise it fails withambiguous primary types or unused types. That is inconvenient when the payload comes from somewhere else (an EIP-712 JSON that carriesEIP712Domainor extra shared types), so an explicitprimaryTypeis a reasonable addition.We are currently investigating the best way to implement it. The private key is already the 4th positional argument on both the instance and the static method, so we want to settle on an API shape (an optional trailing parameter vs. an options object) that stays backward compatible and is shared by
signTypedData,hashTypedDataandverifyTypedDatabefore shipping anything. We'll keep this issue open and update it once the design is decided.In the meantime you can get the same result by passing only the primary type and the struct types it references: