Skip to content

Commit 1432376

Browse files
committed
chore: apply spotless
1 parent d657579 commit 1432376

4 files changed

Lines changed: 39 additions & 29 deletions

File tree

core/src/main/java/org/web3j/ens/EnsResolver.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,11 @@ protected String resolveOffchain(
263263
EnsGatewayResponseDTO gatewayResponseDTO =
264264
objectMapper.readValue(gatewayResult, EnsGatewayResponseDTO.class);
265265
String callbackSelector = Numeric.toHexString(offchainLookup.getCallbackFunction());
266-
List<Type> parameters = Arrays.asList(
267-
new DynamicBytes(Numeric.hexStringToByteArray(gatewayResponseDTO.getData())),
268-
new DynamicBytes(offchainLookup.getExtraData())
269-
);
266+
List<Type> parameters =
267+
Arrays.asList(
268+
new DynamicBytes(
269+
Numeric.hexStringToByteArray(gatewayResponseDTO.getData())),
270+
new DynamicBytes(offchainLookup.getExtraData()));
270271

271272
String encodedParams = new DefaultFunctionEncoder().encodeParameters(parameters);
272273
String encodedFunction = callbackSelector + encodedParams;

core/src/main/java/org/web3j/utils/EnsUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static boolean isEIP3668(String data) {
3030
}
3131

3232
return EnsUtils.EIP_3668_CCIP_INTERFACE_ID.equals(
33-
Numeric.removeDoubleQuotes(data).substring(0, 10));
33+
Numeric.removeDoubleQuotes(data).substring(0, 10));
3434
}
3535

3636
public static String getParent(String url) {

core/src/test/java/org/web3j/ens/EnsResolverTest.java

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ void buildRequestWithDataParameterOnly() throws Exception {
288288
data = "0xd5fa2b00";
289289

290290
okhttp3.Request request = ensResolver.buildRequest(url, sender, data);
291-
291+
292292
assertEquals("https://example.com/gateway/0xd5fa2b00.json", request.url().toString());
293293
assertEquals("GET", request.method());
294294
assertNull(request.body());
@@ -301,8 +301,9 @@ void buildRequestWithSenderParameterOnly() throws Exception {
301301
data = "0xd5fa2b00";
302302

303303
okhttp3.Request request = ensResolver.buildRequest(url, sender, data);
304-
305-
assertEquals("https://example.com/gateway/0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8/lookup",
304+
305+
assertEquals(
306+
"https://example.com/gateway/0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8/lookup",
306307
request.url().toString());
307308
assertEquals("POST", request.method());
308309
assertNotNull(request.body());
@@ -329,8 +330,9 @@ void buildRequestWithBothParameters() throws Exception {
329330
data = "0xd5fa2b00";
330331

331332
okhttp3.Request request = ensResolver.buildRequest(url, sender, data);
332-
333-
assertEquals("https://example.com/gateway/0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8/0xd5fa2b00",
333+
334+
assertEquals(
335+
"https://example.com/gateway/0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8/0xd5fa2b00",
334336
request.url().toString());
335337
assertEquals("GET", request.method());
336338
assertNull(request.body());
@@ -492,7 +494,8 @@ void resolveOffchainWhenLookUpCallsOutOfLimit() throws Exception {
492494
buildResponse(200, urls.get(0), sender, data));
493495

494496
String eip3668Data = EnsUtils.EIP_3668_CCIP_INTERFACE_ID + "data";
495-
when(resolver.executeCallWithoutDecoding(any())).thenReturn(eip3668Data, eip3668Data, eip3668Data);
497+
when(resolver.executeCallWithoutDecoding(any()))
498+
.thenReturn(eip3668Data, eip3668Data, eip3668Data);
496499

497500
assertThrows(
498501
EnsResolutionException.class,
@@ -514,18 +517,21 @@ void resolveOffchainWithDynamicCallback() throws Exception {
514517

515518
// Create a custom LOOKUP_HEX with a different callback function
516519
String customCallbackSelector = "aabbccdd";
517-
String customLookupHex = LOOKUP_HEX.substring(0, 202) + customCallbackSelector + LOOKUP_HEX.substring(210);
518-
520+
String customLookupHex =
521+
LOOKUP_HEX.substring(0, 202) + customCallbackSelector + LOOKUP_HEX.substring(210);
522+
519523
// Capture the function call to verify the correct callback selector is used
520524
ArgumentCaptor<String> functionCallCaptor = ArgumentCaptor.forClass(String.class);
521-
when(resolver.executeCallWithoutDecoding(functionCallCaptor.capture())).thenReturn(RESOLVED_NAME_HEX);
525+
when(resolver.executeCallWithoutDecoding(functionCallCaptor.capture()))
526+
.thenReturn(RESOLVED_NAME_HEX);
522527

523528
String result = ensResolver.resolveOffchain(customLookupHex, resolver, 4);
524529
assertEquals("0x41563129cdbbd0c5d3e1c86cf9563926b243834d", result);
525-
530+
526531
// Verify that the captured function call starts with our custom callback selector
527532
String capturedFunctionCall = functionCallCaptor.getValue();
528-
assertTrue(capturedFunctionCall.startsWith("0x" + customCallbackSelector),
533+
assertTrue(
534+
capturedFunctionCall.startsWith("0x" + customCallbackSelector),
529535
"Function call should start with the custom callback selector");
530536
}
531537

@@ -541,27 +547,30 @@ void resolveOffchainParameterEncoding() throws Exception {
541547

542548
EnsGatewayResponseDTO responseDTO = new EnsGatewayResponseDTO(testData);
543549
String responseJson = om.writeValueAsString(responseDTO);
544-
545-
okhttp3.Response responseObj = new okhttp3.Response.Builder()
546-
.request(new okhttp3.Request.Builder().url(urls.get(0)).build())
547-
.protocol(Protocol.HTTP_2)
548-
.code(200)
549-
.body(ResponseBody.create(responseJson, JSON_MEDIA_TYPE))
550-
.message("OK")
551-
.build();
552-
550+
551+
okhttp3.Response responseObj =
552+
new okhttp3.Response.Builder()
553+
.request(new okhttp3.Request.Builder().url(urls.get(0)).build())
554+
.protocol(Protocol.HTTP_2)
555+
.code(200)
556+
.body(ResponseBody.create(responseJson, JSON_MEDIA_TYPE))
557+
.message("OK")
558+
.build();
559+
553560
ensResolver.setHttpClient(httpClientMock);
554561
when(httpClientMock.newCall(any())).thenReturn(call);
555562
when(call.execute()).thenReturn(responseObj);
556563

557564
ArgumentCaptor<String> functionCallCaptor = ArgumentCaptor.forClass(String.class);
558-
when(resolver.executeCallWithoutDecoding(functionCallCaptor.capture())).thenReturn(RESOLVED_NAME_HEX);
565+
when(resolver.executeCallWithoutDecoding(functionCallCaptor.capture()))
566+
.thenReturn(RESOLVED_NAME_HEX);
559567

560568
String result = ensResolver.resolveOffchain(LOOKUP_HEX, resolver, 4);
561569
assertEquals("0x41563129cdbbd0c5d3e1c86cf9563926b243834d", result);
562570

563571
String capturedFunctionCall = functionCallCaptor.getValue();
564-
assertTrue(capturedFunctionCall.contains(testData.substring(2)),
572+
assertTrue(
573+
capturedFunctionCall.contains(testData.substring(2)),
565574
"Function call should contain the encoded test data");
566575
}
567576

core/src/test/java/org/web3j/utils/EnsUtilsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ public void testIsEIP3668() {
6565

6666
String validDataWithQuotes = "\"0x556f1830abcdef1234567890\"";
6767
assertTrue(EnsUtils.isEIP3668(validDataWithQuotes));
68-
68+
6969
// Invalid EIP3668 data - different interface ID
7070
String invalidData = "0x123456789abcdef1234567890";
7171
assertFalse(EnsUtils.isEIP3668(invalidData));
7272

7373
String invalidDataWithQuotes = "\"0x123456789abcdef1234567890\"";
7474
assertFalse(EnsUtils.isEIP3668(invalidDataWithQuotes));
75-
75+
7676
// Edge cases
7777
assertFalse(EnsUtils.isEIP3668(null));
7878
assertFalse(EnsUtils.isEIP3668(""));

0 commit comments

Comments
 (0)