celo-org / viem

TypeScript Interface for Ethereum
https://viem.sh
Other
0 stars 0 forks source link

Remove `feeCurrency`, `gatewayFee`, and `gatewayFeeRecipient` properties from transaction receipts #5

Closed arthurgousset closed 9 months ago

arthurgousset commented 11 months ago

Is there an existing issue for this?

Package Version

1.16.0

Description

I build the following CIP-42 transaction.

Note that I specify cUSD as the fee currency:

const transactionHash = await client.sendTransaction({
        account, // Sender
        to: "0x70997970c51812dc3a010c7d01b50e0d17dc79c8", // Recipient (illustrative address)
        value: parseEther("0.01"), // 0.01 CELO
        feeCurrency: "0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1", // cUSD fee currency
        maxFeePerGas: parseGwei("10"), // Special field for dynamic fee transaction type (EIP-1559)
        maxPriorityFeePerGas: parseGwei("10"), // Special field for dynamic fee transaction type (EIP-1559)
    });

Source: 0xarthurxyz/txtypes

When I parse (and format) the transaction receipt with:

const transactionReceipt = await publicClient.waitForTransactionReceipt({
        hash: await transactionHash,
});

printFormattedTransactionReceipt(transactionReceipt);

The feeCurrency field is undefined.

Transaction details: {
  type: '0x7c',
  status: 'success',
  transactionHash: '0x9935c26499205b028a2518cfa5a32b7ebf68533deec414c8ded9f91ae5aa5dd8',
  from: '0x303c22e6ef01cba9d03259248863836cb91336d5',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  feeCurrency: undefined
} 

This is expected, because the feeCurrency, gatewayFee, and gatewayFeeRecipient fields are never included in a transaction receipt. See here where the transaction receipt is defined in the Celo blockchain client.

That means the 3 fields can be removed from the transaction receipt

transactionReceipt: /*#__PURE__*/ defineTransactionReceipt({
    format(
      args: CeloRpcTransactionReceiptOverrides,
    ): CeloTransactionReceiptOverrides {
      return {
-        feeCurrency: args.feeCurrency,
-        gatewayFee: args.gatewayFee ? hexToBigInt(args.gatewayFee) : null,
-        gatewayFeeRecipient: args.gatewayFeeRecipient,
      }
    },
  }),

See Slack discussion with the Blockchain team here.

arthurgousset commented 11 months ago

Sprint planning:

arthurgousset commented 10 months ago

Paired on this with @nicolasbrugneaux today:

arthurgousset commented 9 months ago

Closing this because it's merged