Skip to content

Commit b58e0d0

Browse files
authored
Direct OP Withdrawal Claim button (#3123)
* Direct OP Withdrawal Claim button instead of NEXT_PUBLIC_ROLLUP_L2_WITHDRAWAL_URL env Resolves #3022 * [skip ci] fix envs preset
1 parent 909016e commit b58e0d0

20 files changed

+569
-57
lines changed

configs/app/features/rollup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const parentChain: ParentChain | undefined = (() => {
2323

2424
return {
2525
...envValue,
26-
baseUrl: baseUrl ?? envValue?.baseUrl,
26+
baseUrl: baseUrl || envValue?.baseUrl || '',
2727
};
2828
})();
2929

configs/envs/.env.optimism_sepolia

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ NEXT_PUBLIC_APP_PORT=3000
99
NEXT_PUBLIC_APP_ENV=development
1010
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws
1111

12+
NEXT_PUBLIC_ROLLUP_PARENT_CHAIN={'id':11155111,'name':'Sepolia','baseUrl':'https://eth-sepolia.blockscout.com','rpcUrls':['https://0xrpc.io/sep'],'currency':{'name':'Ether','symbol':'ETH','decimals':18},'isTestnet':true}
13+
1214
# Instance ENVs
1315
NEXT_PUBLIC_AD_BANNER_ENABLE_SPECIFY=true
1416
NEXT_PUBLIC_ADDRESS_3RD_PARTY_WIDGETS=['talentprotocol','drops','blockscoutbadges','gitpoap','efp','etherscore','webacy','humanpassport','trustblock','smartmuv','humanode','deepdao']

mocks/optimism/withdrawals.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ export const data: OptimisticL2WithdrawalsResponse = {
2121
msg_nonce: 396,
2222
msg_nonce_version: 1,
2323
status: 'Ready to prove',
24+
portal_contract_address_hash: null,
25+
msg_sender_address_hash: null,
26+
msg_target_address_hash: null,
27+
msg_data: null,
28+
msg_gas_limit: null,
29+
msg_nonce_raw: null,
30+
msg_value: null,
2431
},
2532
{
2633
challenge_period_end: null,
@@ -31,6 +38,13 @@ export const data: OptimisticL2WithdrawalsResponse = {
3138
msg_nonce: 391,
3239
msg_nonce_version: 1,
3340
status: 'Ready to prove',
41+
portal_contract_address_hash: null,
42+
msg_sender_address_hash: null,
43+
msg_target_address_hash: null,
44+
msg_data: null,
45+
msg_gas_limit: null,
46+
msg_nonce_raw: null,
47+
msg_value: null,
3448
},
3549
{
3650
challenge_period_end: '2022-11-11T12:50:02.000000Z',
@@ -41,6 +55,30 @@ export const data: OptimisticL2WithdrawalsResponse = {
4155
msg_nonce: 390,
4256
msg_nonce_version: 1,
4357
status: 'Ready for relay',
58+
portal_contract_address_hash: null,
59+
msg_sender_address_hash: null,
60+
msg_target_address_hash: null,
61+
msg_data: null,
62+
msg_gas_limit: null,
63+
msg_nonce_raw: null,
64+
msg_value: null,
65+
},
66+
{
67+
challenge_period_end: '2022-11-13T12:50:02.000000Z',
68+
from: null,
69+
l1_transaction_hash: null,
70+
l2_timestamp: null,
71+
l2_transaction_hash: '0xe14b1f46838176702244a5343629bcecf728ca2d9881d47b4ce46e00c387d7aa',
72+
msg_nonce: 388,
73+
msg_nonce_version: 3,
74+
status: 'Ready for relay',
75+
portal_contract_address_hash: '0x67aab90c548b284be30b05c376001b4db90b87ba',
76+
msg_sender_address_hash: '0x67aab90c548b284be30b05c376001b4db90b87ba',
77+
msg_target_address_hash: '0x67aab90c548b284be30b05c376001b4db90b87ba',
78+
msg_data: '0x01',
79+
msg_gas_limit: '42',
80+
msg_nonce_raw: '390',
81+
msg_value: '1000000000000000000',
4482
},
4583
],
4684
next_page_params: {

playwright/fixtures/mockEnvs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default fixture;
1818
export const ENVS_MAP: Record<string, Array<[string, string]>> = {
1919
optimisticRollup: [
2020
[ 'NEXT_PUBLIC_ROLLUP_TYPE', 'optimistic' ],
21-
[ 'NEXT_PUBLIC_ROLLUP_L1_BASE_URL', 'https://localhost:3101' ],
21+
[ 'NEXT_PUBLIC_ROLLUP_PARENT_CHAIN', '{"id":11155111,"name":"Sepolia","baseUrl":"https://localhost:3101","rpcUrls":["https://localhost:3101"],"currency":{"name":"Ether","symbol":"ETH","decimals":18},"isTestnet":true}' ],
2222
[ 'NEXT_PUBLIC_ROLLUP_L2_WITHDRAWAL_URL', 'https://localhost:3102' ],
2323
[ 'NEXT_PUBLIC_FAULT_PROOF_ENABLED', 'true' ],
2424
[ 'NEXT_PUBLIC_ROLLUP_DA_CELESTIA_CELENIUM_URL', 'https://mocha.celenium.io/blob' ],

stubs/L2.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ export const L2_WITHDRAWAL_ITEM: OptimisticL2WithdrawalsItem = {
2828
msg_nonce: 2393,
2929
msg_nonce_version: 1,
3030
status: 'Ready to prove',
31+
portal_contract_address_hash: null,
32+
msg_sender_address_hash: null,
33+
msg_target_address_hash: null,
34+
msg_data: null,
35+
msg_gas_limit: null,
36+
msg_nonce_raw: null,
37+
msg_value: null,
3138
};
3239

3340
export const L2_TXN_BATCHES_ITEM: OptimisticL2TxnBatchesItem = {

types/api/optimisticL2.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,17 @@ export type OptimismL2BatchBlocks = {
113113
} | null;
114114
};
115115

116-
export type OptimisticL2WithdrawalsItem = {
116+
export interface OptimisticL2WithdrawalClaimInfo {
117+
portal_contract_address_hash: string | null;
118+
msg_sender_address_hash: string | null;
119+
msg_target_address_hash: string | null;
120+
msg_data: string | null;
121+
msg_gas_limit: string | null;
122+
msg_nonce_raw: string | null;
123+
msg_value: string | null;
124+
}
125+
126+
export interface OptimisticL2WithdrawalsItem extends OptimisticL2WithdrawalClaimInfo {
117127
challenge_period_end: string | null;
118128
from: AddressParam | null;
119129
l1_transaction_hash: string | null;

types/api/transaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { DecodedInput } from './decodedInput';
55
import type { Fee } from './fee';
66
import type { ChainInfo, MessageStatus } from './interop';
77
import type { NovesTxTranslation } from './noves';
8-
import type { OptimisticL2WithdrawalStatus } from './optimisticL2';
8+
import type { OptimisticL2WithdrawalClaimInfo, OptimisticL2WithdrawalStatus } from './optimisticL2';
99
import type { ScrollL2BlockStatus } from './scrollL2';
1010
import type { TokenInfo } from './token';
1111
import type { TokenTransfer } from './tokenTransfer';
@@ -19,7 +19,7 @@ export type TransactionRevertReason = {
1919
export type WrappedTransactionFields = 'decoded_input' | 'fee' | 'gas_limit' | 'gas_price' | 'hash' | 'max_fee_per_gas' |
2020
'max_priority_fee_per_gas' | 'method' | 'nonce' | 'raw_input' | 'to' | 'type' | 'value';
2121

22-
export interface OpWithdrawal {
22+
export interface OpWithdrawal extends OptimisticL2WithdrawalClaimInfo {
2323
l1_transaction_hash: string;
2424
nonce: number;
2525
status: OptimisticL2WithdrawalStatus;
6.68 KB
Loading
12.7 KB
Loading
Lines changed: 95 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,114 @@
11
import { Box } from '@chakra-ui/react';
22
import React from 'react';
33

4-
import type { OptimisticL2WithdrawalStatus } from 'types/api/optimisticL2';
4+
import type { OpWithdrawal } from 'types/api/transaction';
55

6+
import * as addressMock from 'mocks/address/address';
67
import { ENVS_MAP } from 'playwright/fixtures/mockEnvs';
78
import { test, expect } from 'playwright/lib';
89

910
import TxDetailsWithdrawalStatusOptimistic from './TxDetailsWithdrawalStatusOptimistic';
1011

11-
const statuses: Array<OptimisticL2WithdrawalStatus> = [
12-
'Waiting for state root',
13-
'Ready for relay',
14-
'Relayed',
15-
];
12+
const TX_HASH = '0x7d93a59a228e97d084a635181c3053e324237d07566ec12287eae6da2bcf9456';
1613

17-
statuses.forEach((status) => {
18-
test(`status="${ status }"`, async({ render, mockEnvs }) => {
14+
const BASE_DATA: OpWithdrawal = {
15+
l1_transaction_hash: TX_HASH,
16+
nonce: 1,
17+
status: 'Waiting for state root',
18+
portal_contract_address_hash: null,
19+
msg_sender_address_hash: null,
20+
msg_target_address_hash: null,
21+
msg_data: null,
22+
msg_gas_limit: null,
23+
msg_nonce_raw: null,
24+
msg_value: null,
25+
};
26+
27+
test('status=Waiting for state root', async({ render, mockEnvs }) => {
28+
await mockEnvs(ENVS_MAP.optimisticRollup);
29+
30+
const data: OpWithdrawal = {
31+
...BASE_DATA,
32+
status: 'Waiting for state root',
33+
};
34+
35+
const component = await render(
36+
<Box p={ 2 }>
37+
<TxDetailsWithdrawalStatusOptimistic
38+
data={ data }
39+
txHash={ TX_HASH }
40+
from={ addressMock.withoutName }
41+
/>
42+
</Box>,
43+
);
44+
45+
await expect(component).toHaveScreenshot();
46+
});
47+
48+
test.describe('status=Ready for relay', () => {
49+
test('with claim button', async({ render, mockEnvs }) => {
1950
await mockEnvs(ENVS_MAP.optimisticRollup);
51+
52+
const data: OpWithdrawal = {
53+
...BASE_DATA,
54+
status: 'Ready for relay',
55+
};
56+
2057
const component = await render(
2158
<Box p={ 2 }>
22-
<TxDetailsWithdrawalStatusOptimistic status={ status } l1TxHash="0x7d93a59a228e97d084a635181c3053e324237d07566ec12287eae6da2bcf9456"/>
59+
<TxDetailsWithdrawalStatusOptimistic
60+
data={ data }
61+
txHash={ TX_HASH }
62+
from={ addressMock.withoutName }
63+
/>
2364
</Box>,
2465
);
2566

2667
await expect(component).toHaveScreenshot();
2768
});
69+
70+
test('without claim button', async({ render, mockEnvs }) => {
71+
await mockEnvs([
72+
...ENVS_MAP.optimisticRollup,
73+
[ 'NEXT_PUBLIC_ROLLUP_L2_WITHDRAWAL_URL', '' ],
74+
]);
75+
76+
const data: OpWithdrawal = {
77+
...BASE_DATA,
78+
status: 'Ready for relay',
79+
};
80+
81+
const component = await render(
82+
<Box p={ 2 }>
83+
<TxDetailsWithdrawalStatusOptimistic
84+
data={ data }
85+
txHash={ TX_HASH }
86+
from={ addressMock.withoutName }
87+
/>
88+
</Box>,
89+
);
90+
91+
await expect(component).toHaveScreenshot();
92+
});
93+
});
94+
95+
test('status=Relayed', async({ render, mockEnvs }) => {
96+
await mockEnvs(ENVS_MAP.optimisticRollup);
97+
98+
const data: OpWithdrawal = {
99+
...BASE_DATA,
100+
status: 'Relayed',
101+
};
102+
103+
const component = await render(
104+
<Box p={ 2 }>
105+
<TxDetailsWithdrawalStatusOptimistic
106+
data={ data }
107+
txHash={ TX_HASH }
108+
from={ addressMock.withoutName }
109+
/>
110+
</Box>,
111+
);
112+
113+
await expect(component).toHaveScreenshot();
28114
});

0 commit comments

Comments
 (0)