Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for evm-like contracts and transactions #337

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

tx-nikola
Copy link
Contributor

What ❔

Add badge that shows "EVM" for evm-like contracts and transactions.

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.

@tx-nikola tx-nikola added the frontend Task requires changes to the frontend implementation label Nov 29, 2024
@tx-nikola tx-nikola self-assigned this Nov 29, 2024
Copy link

github-actions bot commented Nov 29, 2024

API E2E Test Results

207 tests   207 ✅  19s ⏱️
 14 suites    0 💤
  1 files      0 ❌

Results for commit e0fe9ea.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Nov 29, 2024

Unit Test Results

    4 files    263 suites   11m 46s ⏱️
2 126 tests 2 125 ✅ 1 💤 0 ❌
2 338 runs  2 337 ✅ 1 💤 0 ❌

Results for commit e0fe9ea.

♻️ This comment has been updated with latest results.

Copy link

Visit the preview URL for this PR:
https://staging-scan-v2--pr-337-i06qnt0i.web.app

@petarTxFusion petarTxFusion changed the title feat: add evm badge for evm-like contracts and transactions feat: add support for evm-like contracts and transactions Nov 29, 2024
@petarTxFusion petarTxFusion added the backend Task requires changes to the backend implementation label Dec 5, 2024
Copy link
Collaborator

@Romsters Romsters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use contractAddress field to store deployed contract address similar to etherscan, set to to zero address.

@petarTxFusion
Copy link

Please use contractAddress field to store deployed contract address similar to etherscan, set to to zero address.

Its implemented

@@ -10,6 +10,9 @@ export const normalizeAddressTransformer: ValueTransformer = {
if (!hex) {
return null;
}
if (hexTransformer.from(hex) === "0x") {
Copy link
Collaborator

@Romsters Romsters Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Empty string doesn't look like a valid address. I'd prefer 0x0000...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0x00 and 0x are different values. Tx with empty to field is EVM deploy tx

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this function is supposed to normalise address, so it should always return an address, I mean it should be zero address instead of empty string.

Copy link

@0xVolosnikov 0xVolosnikov Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we should process 0x differently, earlier, imo

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you keep getAddress(hexTransformer.from(hex)) wouldn't it just return a zero address?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it returns an error. I have left it like this in order to be aligned with etherscan since they are returning empty string in cases like this. We can switch to 0x000....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have much context on the PR, but from what I've understood 0x is like of special case for contract deployment (like, and "empty to field"), which is different from 0x00..00 (IIRC in early times it was used for contract deployment, but nowadays you just don't specify anything).

@@ -14,7 +14,7 @@ export class TransactionDto {
description: "The address this transaction is to",
example: "0xc7e0220d02d549c4846A6EC31D89C3B670Ebe35C",
})
public readonly to: string;
public readonly to?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it optional?

Copy link

@petarTxFusion petarTxFusion Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially we where supporting to as a null when we started with evm support. I will change that back as well as all other to fields

@@ -19,8 +19,8 @@ export class AddressTransaction extends BaseEntity {
@Column({ type: "bytea", transformer: hexTransformer })
public readonly transactionHash: string;

@Column({ type: "bytea", transformer: normalizeAddressTransformer })
public readonly address: string;
@Column({ type: "bytea", transformer: normalizeAddressTransformer, nullable: true })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it nullable?

@@ -31,4 +31,7 @@ export class AddressTransaction extends BaseEntity {

@Column({ type: "int" })
public readonly transactionIndex: number;

@Column({ type: "boolean", nullable: true })
public readonly isEvmLike?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it have to be in this table?

@Column({ type: "bytea", transformer: normalizeAddressTransformer })
public readonly to: string;
@Column({ type: "bytea", transformer: normalizeAddressTransformer, nullable: true })
public readonly to?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why optional?

const toAddress = isEvmLike ? "0x" : transactionInfo.to;
const contractAddress = isEvmLike
? getCreateAddress({ from: transactionInfo.from, nonce: transactionInfo.nonce })
: "";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why empty string and not null?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To align with etherscan where they are leaving empty string in cases like that one.

@@ -35,4 +35,7 @@ export class AddressTransaction extends BaseEntity {

@Column({ type: "int" })
public readonly transactionIndex: number;

@Column({ type: "boolean", nullable: true })
public readonly isEvmLike?: boolean;
Copy link
Collaborator

@vasyl-ivanchuk vasyl-ivanchuk Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this field should be here, as this entity is used to query address transactions based on an address and join the corresponding transaction entities, which have all the fields available:

queryBuilder.leftJoinAndSelect("addressTransaction.transaction", "transaction");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Task requires changes to the backend implementation frontend Task requires changes to the frontend implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants