-
Notifications
You must be signed in to change notification settings - Fork 114
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
base: main
Are you sure you want to change the base?
Conversation
API E2E Test Results207 tests 207 ✅ 19s ⏱️ Results for commit e0fe9ea. ♻️ This comment has been updated with latest results. |
Unit Test Results 4 files 263 suites 11m 46s ⏱️ Results for commit e0fe9ea. ♻️ This comment has been updated with latest results. |
Visit the preview URL for this PR: |
There was a problem hiding this 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.
Its implemented |
@@ -10,6 +10,9 @@ export const normalizeAddressTransformer: ValueTransformer = { | |||
if (!hex) { | |||
return null; | |||
} | |||
if (hexTransformer.from(hex) === "0x") { |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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....
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it optional?
There was a problem hiding this comment.
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 }) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 }) | ||
: ""; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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"); |
What ❔
Add badge that shows "EVM" for evm-like contracts and transactions.
Checklist