toTransaction method

ETHTransaction? toTransaction()

Implementation

ETHTransaction? toTransaction() {
  if (ETHTransactionType.values.any((e) => e.prefix == type)) {
    final type = ETHTransactionType.fromPrefix(this.type);
    return ETHTransaction(
      chainId: chainId ?? BigInt.zero,
      data: BytesUtils.fromHexString(input),
      gasLimit: BigInt.from(gas),
      nonce: nonce,
      value: value,
      accessList: accessList,
      authorizationList: authorizationList,
      blobVersionedHashes:
          blobVersionedHashes
              ?.map((e) => BytesUtils.fromHexString(e))
              .toList(),
      maxFeePerBlobGas: maxFeePerBlobGas,
      signature: toSignature(),
      from: ETHAddress(from),
      gasPrice:
          type == ETHTransactionType.eip2930 ||
                  type == ETHTransactionType.legacy
              ? (gasPrice == null ? null : BigInt.from(gasPrice!))
              : null,
      maxFeePerGas: maxFeePerGas == null ? null : BigInt.from(maxFeePerGas!),
      maxPriorityFeePerGas:
          maxPriorityFeePerGas == null
              ? null
              : BigInt.from(maxPriorityFeePerGas!),
      to: to == null ? null : ETHAddress(to!),
      type: type,
    );
  }
  return null;
}