viem icon indicating copy to clipboard operation
viem copied to clipboard

bug: `RpcTransaction` requires `typeHex` property

Open typedarray opened this issue 3 years ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Package Version

1.2.2

Current Behavior

Creating an object with the type RpcTransaction produces a type error: 'typeHex' is declared here..

const legacyTransaction: RpcTransaction = {
  blockHash: "0xebc3644804e4040c0a74c5a5bbbc6b46a71a5d4010fe0c92ebb2fdf4a43ea5dd",
  blockNumber: "0x10f2c",
  chainId: "0x1",
  from: "0x1",
  gas: "0x4234584",
  gasPrice: "0x45",
  hash: "0xa4b1f606b66105fa45cb5db23d2f6597075701e7f0e2367f4e6a39d17a8cf98b",
  input: "0x1",
  nonce: "0x1",
  r: "0x1",
  s: "0x1",
  to: "0x1",
  transactionIndex: "0x1",
  type: "0x0",
  v: "0x1",
  value: "0x1",
}

Expected Behavior

My understanding is the the RpcTransaction type should represent a raw, unformatted transaction object received in an RPC response. The typeHex property gets added during formatting for convenience, but is not present in raw RPC responses, so it should not be present on RpcTransaction. Moreover, RpcTransaction["type"] should have the type 0x${string} | null | undefined rather than "0x0" | "0x1" | "0x2".

const legacyTransaction: RpcTransaction = {
  blockHash: "0xebc3644804e4040c0a74c5a5bbbc6b46a71a5d4010fe0c92ebb2fdf4a43ea5dd",
  blockNumber: "0x10f2c",
  chainId: "0x1",
  from: "0x1",
  gas: "0x4234584",
  gasPrice: "0x45",
  hash: "0xa4b1f606b66105fa45cb5db23d2f6597075701e7f0e2367f4e6a39d17a8cf98b",
  input: "0x1",
  nonce: "0x1",
  r: "0x1",
  s: "0x1",
  to: "0x1",
  transactionIndex: "0x1",
  type: "0x0",
  v: "0x1",
  value: "0x1",
}

Steps To Reproduce

No response

Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)

https://stackblitz.com/edit/viem-getting-started-rvmnti?file=index.ts

Anything else?

No response

typedarray avatar Jun 28 '23 21:06 typedarray

+1

itsdiay avatar Jun 28 '23 22:06 itsdiay

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread.

github-actions[bot] avatar Jun 01 '24 00:06 github-actions[bot]