Skip to content

dataSuffix field unused when data is null #4343

@nikhilkumar1612

Description

@nikhilkumar1612

Check existing issues

Viem Version

2.46.1

Current Behavior

dataSuffix field is not respected when data field is null.

import { Attribution } from "ox/erc8021";
import { createWalletClient, http, parseUnits, zeroAddress } from "viem";
import { privateKeyToAccount } from "viem/accounts"
import { base } from "viem/chains";

const main = async () => {
    const account = privateKeyToAccount("");
    const dataSuffix = Attribution.toDataSuffix({
        codes: ["my-code"]
    });

    console.log("dataSuffix: ", dataSuffix);
    const wallet = createWalletClient({
        account,
        transport: http(""),
        chain: base,
        dataSuffix
    });

    // below transaction adds dataSuffix to `data` field
    const tx = await wallet.sendTransaction({
        to: zeroAddress,
        value: parseUnits('0', 18),
        data: "0x"
    });

    // below transaction does not respect the dataSuffix field:
    // const tx1 = await wallet.sendTransaction({
    //     to: zeroAddress,
    //     value: parseUnits('0', 18),
    // });

    console.log("tx: ", tx);
}
main();

Expected Behavior

dataSuffix field should be appended to transaction's data even when data is undefined or null

Steps To Reproduce

https://gist.github.com/nikhilkumar1612/573f940083a06070adcf5eb370bbdb44

Link to Minimal Reproducible Example

https://gist.github.com/nikhilkumar1612/573f940083a06070adcf5eb370bbdb44

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions