Skip to content

Commit

Permalink
feat: add evm badge for evm-like contracts and transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
tx-nikola authored and petarTxFusion committed Dec 18, 2024
1 parent 5fc513a commit ef161c3
Show file tree
Hide file tree
Showing 64 changed files with 633 additions and 169 deletions.
2 changes: 2 additions & 0 deletions packages/api/src/address/address.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ describe("AddressController", () => {
blockNumber: addressBalances.blockNumber,
balances: addressBalances.balances,
totalTransactions: totalTxCount,
isEvmLike: addressRecord.isEvmLike,
});
});

Expand All @@ -163,6 +164,7 @@ describe("AddressController", () => {
blockNumber: addressRecord.createdInBlockNumber,
balances: defaultBalancesResponse.balances,
totalTransactions: totalTxCount,
isEvmLike: addressRecord.isEvmLike,
});
});
});
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/address/address.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class AddressController {
creatorTxHash: addressRecord.creatorTxHash,
totalTransactions,
creatorAddress: addressRecord.creatorAddress,
isEvmLike: addressRecord.isEvmLike,
};
}

Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/address/address.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ export class Address extends BaseEntity {

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

@Column({ type: "boolean", nullable: true })
public readonly isEvmLike?: boolean;
}
7 changes: 7 additions & 0 deletions packages/api/src/address/dtos/contract.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ export class ContractDto extends BaseAddressDto {
example: "0xd754Ff5e8a6f257E162F72578A4bB0493c0681d8",
})
public readonly creatorAddress: string;

@ApiProperty({
type: Boolean,
description: "Is the contract EVM-like",
example: true,
})
public readonly isEvmLike: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const normalizeAddressTransformer: ValueTransformer = {
if (!hex) {
return null;
}

return getAddress(hexTransformer.from(hex));
},
};
21 changes: 19 additions & 2 deletions packages/api/src/transaction/dtos/transaction.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export class TransactionDto {
@ApiProperty({
type: String,
description: "The address this transaction is to",
example: "0xc7e0220d02d549c4846A6EC31D89C3B670Ebe35C",
example: ["0xc7e0220d02d549c4846A6EC31D89C3B670Ebe35C", null],
nullable: true,
})
public readonly to: string;
public readonly to?: string;

@ApiProperty({
type: String,
Expand Down Expand Up @@ -204,4 +205,20 @@ export class TransactionDto {
nullable: true,
})
public readonly revertReason?: string;

@ApiProperty({
type: Boolean,
description: "Is the transaction EVM-like",
example: true,
nullable: true,
})
public readonly isEvmLike?: boolean;

@ApiProperty({
type: String,
description: "Address of the first deployed EVM contract",
example: ["0xc7e0220d02d549c4846A6EC31D89C3B670Ebe35C", null],
nullable: true,
})
public readonly contractAddress?: string;
}
10 changes: 8 additions & 2 deletions packages/api/src/transaction/entities/transaction.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export class Transaction extends BaseEntity {
@Column({ generated: true, type: "bigint" })
public number: number;

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

@Index()
@Column({ type: "bytea", transformer: normalizeAddressTransformer })
Expand Down Expand Up @@ -107,6 +107,12 @@ export class Transaction extends BaseEntity {
@Column({ nullable: true })
public readonly revertReason?: string;

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

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

public get status(): TransactionStatus {
if (this.receiptStatus === 0) {
return TransactionStatus.Failed;
Expand Down
5 changes: 5 additions & 0 deletions packages/api/test/address.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ describe("AddressController (e2e)", () => {
createdInBlockNumber: 10,
creatorAddress: "0x91d0a23f34e535e44Df8Ba84c53a0945cf0eEB60",
creatorTxHash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
totalTransactions: 4,
type: "contract",
})
Expand Down Expand Up @@ -849,6 +850,7 @@ describe("AddressController (e2e)", () => {
createdInBlockNumber: 10,
creatorAddress: "0x91d0a23f34e535e44Df8Ba84c53a0945cf0eEB60",
creatorTxHash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
totalTransactions: 4,
type: "contract",
})
Expand Down Expand Up @@ -908,6 +910,7 @@ describe("AddressController (e2e)", () => {
createdInBlockNumber: 10,
creatorAddress: "0x91d0a23f34e535e44Df8Ba84c53a0945cf0eEB60",
creatorTxHash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
totalTransactions: 4,
type: "contract",
})
Expand Down Expand Up @@ -967,6 +970,7 @@ describe("AddressController (e2e)", () => {
createdInBlockNumber: 10,
creatorAddress: "0x91d0a23f34e535e44Df8Ba84c53a0945cf0eEB60",
creatorTxHash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
totalTransactions: 4,
type: "contract",
})
Expand All @@ -987,6 +991,7 @@ describe("AddressController (e2e)", () => {
createdInBlockNumber: 10,
creatorAddress: "0x91d0a23f34e535e44Df8Ba84c53a0945cf0eEB60",
creatorTxHash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
totalTransactions: 0,
type: "contract",
})
Expand Down
46 changes: 46 additions & 0 deletions packages/api/test/transaction.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3009",
maxPriorityFeePerGas: "4009",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e19",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: false,
isL1Originated: true,
l1BatchNumber: 9,
Expand Down Expand Up @@ -296,6 +298,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3008",
maxPriorityFeePerGas: "4008",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e18",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 8,
Expand Down Expand Up @@ -324,6 +328,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3007",
maxPriorityFeePerGas: "4007",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e17",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 7,
Expand Down Expand Up @@ -352,6 +358,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3006",
maxPriorityFeePerGas: "4006",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e16",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 6,
Expand Down Expand Up @@ -380,6 +388,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3005",
maxPriorityFeePerGas: "4005",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 5,
Expand Down Expand Up @@ -408,6 +418,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3004",
maxPriorityFeePerGas: "4004",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e14",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 4,
Expand Down Expand Up @@ -436,6 +448,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3003",
maxPriorityFeePerGas: "4003",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e13",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 3,
Expand Down Expand Up @@ -464,6 +478,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3002",
maxPriorityFeePerGas: "4002",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e12",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: false,
isL1Originated: true,
l1BatchNumber: 1,
Expand Down Expand Up @@ -492,6 +508,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3001",
maxPriorityFeePerGas: "4001",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e11",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: false,
isL1Originated: true,
l1BatchNumber: 1,
Expand Down Expand Up @@ -520,6 +538,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3000",
maxPriorityFeePerGas: "4000",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e10",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: false,
isL1Originated: true,
l1BatchNumber: 1,
Expand Down Expand Up @@ -558,6 +578,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3008",
maxPriorityFeePerGas: "4008",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e18",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 8,
Expand Down Expand Up @@ -586,6 +608,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3007",
maxPriorityFeePerGas: "4007",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e17",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 7,
Expand Down Expand Up @@ -614,6 +638,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3006",
maxPriorityFeePerGas: "4006",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e16",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 6,
Expand Down Expand Up @@ -698,6 +724,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3001",
maxPriorityFeePerGas: "4001",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e11",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: false,
isL1Originated: true,
l1BatchNumber: 1,
Expand Down Expand Up @@ -751,6 +779,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3001",
maxPriorityFeePerGas: "4001",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e11",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: false,
isL1Originated: true,
l1BatchNumber: 1,
Expand Down Expand Up @@ -804,6 +834,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3007",
maxPriorityFeePerGas: "4007",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e17",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 7,
Expand Down Expand Up @@ -832,6 +864,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3006",
maxPriorityFeePerGas: "4006",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e16",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 6,
Expand Down Expand Up @@ -922,6 +956,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3008",
maxPriorityFeePerGas: "4008",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e18",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 8,
Expand Down Expand Up @@ -959,6 +995,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3005",
maxPriorityFeePerGas: "4005",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 5,
Expand Down Expand Up @@ -996,6 +1034,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3003",
maxPriorityFeePerGas: "4003",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e13",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 3,
Expand Down Expand Up @@ -1033,6 +1073,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3000",
maxPriorityFeePerGas: "4000",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e10",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 1,
Expand Down Expand Up @@ -1070,6 +1112,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3009",
maxPriorityFeePerGas: "4009",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e19",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 9,
Expand Down Expand Up @@ -1107,6 +1151,8 @@ describe("TransactionController (e2e)", () => {
maxFeePerGas: "3000",
maxPriorityFeePerGas: "4000",
hash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e10",
isEvmLike: null,
contractAddress: null,
isL1BatchSealed: true,
isL1Originated: true,
l1BatchNumber: 1,
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/components/Contract.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:title="contractName ?? t('contract.title')"
:value="contractName ? undefined : contract?.address"
:is-verified="contract?.verificationInfo != null"
:is-evm-like="contract?.isEvmLike"
/>
<Spinner v-else size="md" />
<div class="tables-container">
Expand Down
8 changes: 8 additions & 0 deletions packages/app/src/components/SolidityEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ function focusEditor() {
.prism-editor__line-numbers {
@apply h-max;
}
.prism-editor__container {
@apply overflow-x-scroll;
}
.prism-editor__editor {
@apply text-nowrap;
}
}
}
</style>
2 changes: 1 addition & 1 deletion packages/app/src/components/TheFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const config = useRuntimeConfig();
const navigation = reactive([
{
label: computed(() => t("footer.nav.docs")),
url: "https://docs.zksync.io/build/tooling/zksync-block-explorers",
url: "https://docs.zksync.io/zksync-era/tooling/block-explorers",
},
{
label: computed(() => t("footer.nav.terms")),
Expand Down
Loading

0 comments on commit ef161c3

Please sign in to comment.