diff --git a/.changeset/ethereum-decode-params.md b/.changeset/ethereum-decode-params.md new file mode 100644 index 000000000..298d66a7a --- /dev/null +++ b/.changeset/ethereum-decode-params.md @@ -0,0 +1,14 @@ +--- +'@graphprotocol/graph-ts': minor +--- + +Add `ethereum.decodeParams` for decoding ABI function-parameter data + +`ethereum.decode` decodes its input as a single ABI value, which fails for +data whose top-level type is a tuple with a dynamic field (e.g. Gnosis Safe +`execTransaction`): transaction calldata and event data are encoded as ABI +function parameters and have no leading offset word. `ethereum.decodeParams` +decodes that parameter layout correctly. Use it for calldata/event data and +keep `ethereum.decode` for round-tripping `ethereum.encode` output. + +Requires a graph-node that supports mapping apiVersion `0.0.10`. diff --git a/packages/ts/chain/ethereum.ts b/packages/ts/chain/ethereum.ts index f5fc8533c..93d97ec94 100644 --- a/packages/ts/chain/ethereum.ts +++ b/packages/ts/chain/ethereum.ts @@ -9,6 +9,7 @@ export declare namespace ethereum { function hasCode(address: Address): Wrapped; function encode(token: Value): Bytes | null; function decode(types: string, data: Bytes): Value | null; + function decodeParams(types: string, data: Bytes): Value | null; } export namespace ethereum {