Skip to content

Commit 17e599d

Browse files
authored
Merge branch 'LFDT-web3j:main' into wmjae-patch
2 parents f99877b + ef3dad8 commit 17e599d

21 files changed

+622
-75
lines changed

CHANGELOG.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,35 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6-
# [4.12.4]() (Upcoming)
6+
# [4.13.1]() (2025-03-05)
77

88
### Bug Fixes
99

10+
*
11+
### Features
12+
13+
* bump snapshot version to 4.13.1 [#2160](https://github.com/hyperledger-web3j/web3j/pull/2160)
14+
15+
16+
### BREAKING CHANGES
17+
18+
*
19+
20+
# [4.13.0](https://github.com/hyperledger-web3j/web3j/releases/tag/v4.13.0) (2025-03-05)
21+
22+
### Bug Fixes
23+
24+
* fix Transaction.getChainId when v=27 must return null [#2133](https://github.com/hyperledger-web3j/web3j/pull/2133)
25+
* Fix android scripts [#2138](https://github.com/hyperledger-web3j/web3j/pull/2138)
1026
* fixed subscription id conflict [#2127](https://github.com/hyperledger/web3j/pull/2127)
27+
* Fix pipeline by disabling failing integration tests [#2159](https://github.com/hyperledger-web3j/web3j/pull/2159)
1128

1229
### Features
1330

1431
* bump snapshot version to 4.12.4 [#2132](https://github.com/hyperledger-web3j/web3j/pull/2132)
15-
* Added LineaEstimateGas api [#2150](https://github.com/hyperledger-web3j/web3j/pull/2150)
32+
* ENS - Label Hash function added [#2140](https://github.com/hyperledger-web3j/web3j/pull/2140)
33+
* Added Dynamic gas providers [#2142](https://github.com/hyperledger-web3j/web3j/pull/2142)
34+
* Added Linea RPC APIs [#2150](https://github.com/hyperledger-web3j/web3j/pull/2150)
1635

1736

1837
### BREAKING CHANGES

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Web3j: Web3 Java Ethereum Ðapp API
1+
Web3j: Web3 Java Ethereum Dapp API
22
==================================
33

44
[![Documentation Status](https://readthedocs.org/projects/web3j-docs/badge/?version=latest)](https://docs.web3j.io)
@@ -118,7 +118,7 @@ Java:
118118
<dependency>
119119
<groupId>org.web3j</groupId>
120120
<artifactId>core</artifactId>
121-
<version>4.12.2</version>
121+
<version>4.13.0</version>
122122
</dependency>
123123
```
124124

@@ -131,7 +131,7 @@ Android:
131131
<dependency>
132132
<groupId>org.web3j</groupId>
133133
<artifactId>core</artifactId>
134-
<version>4.8.9-android</version>
134+
<version>4.12.3-android</version>
135135
</dependency>
136136
```
137137

@@ -141,13 +141,13 @@ Gradle
141141
Java:
142142

143143
```groovy
144-
implementation ('org.web3j:core:4.12.2')
144+
implementation ('org.web3j:core:4.13.0')
145145
```
146146

147147
Android:
148148

149149
```groovy
150-
implementation ('org.web3j:core:4.8.9-android')
150+
implementation ('org.web3j:core:4.12.3-android')
151151
```
152152

153153
Build instructions

core/src/main/java/org/web3j/dto/EnsGatewayRequestDTO.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,32 @@
1616
public class EnsGatewayRequestDTO {
1717

1818
private String data;
19+
private String sender;
1920

2021
public EnsGatewayRequestDTO() {}
2122

2223
public EnsGatewayRequestDTO(String data) {
2324
this.data = data;
2425
}
2526

27+
public EnsGatewayRequestDTO(String data, String sender) {
28+
this.data = data;
29+
this.sender = sender;
30+
}
31+
2632
public String getData() {
2733
return data;
2834
}
2935

3036
public void setData(String data) {
3137
this.data = data;
3238
}
39+
40+
public String getSender() {
41+
return sender;
42+
}
43+
44+
public void setSender(String sender) {
45+
this.sender = sender;
46+
}
3347
}

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

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
import org.slf4j.Logger;
3131
import org.slf4j.LoggerFactory;
3232

33+
import org.web3j.abi.DefaultFunctionEncoder;
3334
import org.web3j.abi.DefaultFunctionReturnDecoder;
35+
import org.web3j.abi.datatypes.DynamicBytes;
36+
import org.web3j.abi.datatypes.Type;
3437
import org.web3j.abi.datatypes.ens.OffchainLookup;
3538
import org.web3j.crypto.Credentials;
3639
import org.web3j.crypto.Keys;
@@ -259,12 +262,16 @@ protected String resolveOffchain(
259262
ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper();
260263
EnsGatewayResponseDTO gatewayResponseDTO =
261264
objectMapper.readValue(gatewayResult, EnsGatewayResponseDTO.class);
265+
String callbackSelector = Numeric.toHexString(offchainLookup.getCallbackFunction());
266+
List<Type> parameters =
267+
Arrays.asList(
268+
new DynamicBytes(
269+
Numeric.hexStringToByteArray(gatewayResponseDTO.getData())),
270+
new DynamicBytes(offchainLookup.getExtraData()));
262271

263-
String resolvedNameHex =
264-
resolver.resolveWithProof(
265-
Numeric.hexStringToByteArray(gatewayResponseDTO.getData()),
266-
offchainLookup.getExtraData())
267-
.send();
272+
String encodedParams = new DefaultFunctionEncoder().encodeParameters(parameters);
273+
String encodedFunction = callbackSelector + encodedParams;
274+
String resolvedNameHex = resolver.executeCallWithoutDecoding(encodedFunction);
268275

269276
// This protocol can result in multiple lookups being requested by the same contract.
270277
if (EnsUtils.isEIP3668(resolvedNameHex)) {
@@ -344,19 +351,27 @@ protected Request buildRequest(String url, String sender, String data)
344351
if (data == null) {
345352
throw new EnsResolutionException("Data is null");
346353
}
347-
if (!url.contains("{sender}")) {
348-
throw new EnsResolutionException("Url is not valid, sender parameter is not exist");
349-
}
350354

351355
// URL expansion
352-
String href = url.replace("{sender}", sender).replace("{data}", data);
356+
String href = url;
357+
358+
if (url.contains("{sender}")) {
359+
href = href.replace("{sender}", sender);
360+
}
361+
362+
if (url.contains("{data}")) {
363+
href = href.replace("{data}", data);
364+
}
353365

354366
Request.Builder builder = new Request.Builder().url(href);
355367

368+
// According to ERC-3668:
369+
// - If URL contains {data}, use GET
370+
// - Otherwise, use POST with JSON payload containing data and sender
356371
if (url.contains("{data}")) {
357372
return builder.get().build();
358373
} else {
359-
EnsGatewayRequestDTO requestDTO = new EnsGatewayRequestDTO(data);
374+
EnsGatewayRequestDTO requestDTO = new EnsGatewayRequestDTO(data, sender);
360375
ObjectMapper om = ObjectMapperFactory.getObjectMapper();
361376

362377
return builder.post(RequestBody.create(om.writeValueAsString(requestDTO), JSON))

core/src/main/java/org/web3j/tx/Contract.java

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.web3j.protocol.core.DefaultBlockParameterName;
4343
import org.web3j.protocol.core.RemoteCall;
4444
import org.web3j.protocol.core.RemoteFunctionCall;
45+
import org.web3j.protocol.core.methods.request.Transaction;
4546
import org.web3j.protocol.core.methods.response.EthGetCode;
4647
import org.web3j.protocol.core.methods.response.Log;
4748
import org.web3j.protocol.core.methods.response.TransactionReceipt;
@@ -72,7 +73,6 @@ public abstract class Contract extends ManagedTransaction {
7273

7374
public static final String BIN_NOT_PROVIDED = "Bin file was not provided";
7475
public static final String FUNC_DEPLOY = "deploy";
75-
7676
protected final String contractBinary;
7777
protected String contractAddress;
7878
protected ContractGasProvider gasProvider;
@@ -392,18 +392,18 @@ TransactionReceipt executeTransaction(
392392
if (gasProvider instanceof ContractEIP1559GasProvider) {
393393
ContractEIP1559GasProvider eip1559GasProvider =
394394
(ContractEIP1559GasProvider) gasProvider;
395-
if (eip1559GasProvider.isEIP1559Enabled()) {
396-
receipt =
397-
sendEIP1559(
398-
eip1559GasProvider.getChainId(),
399-
contractAddress,
400-
data,
401-
weiValue,
402-
eip1559GasProvider.getGasLimit(funcName),
403-
eip1559GasProvider.getMaxPriorityFeePerGas(funcName),
404-
eip1559GasProvider.getMaxFeePerGas(funcName),
405-
constructor);
406-
}
395+
396+
receipt =
397+
sendEIP1559(
398+
eip1559GasProvider.getChainId(),
399+
contractAddress,
400+
data,
401+
weiValue,
402+
eip1559GasProvider.getGasLimit(
403+
getGenericTransaction(data, constructor)),
404+
eip1559GasProvider.getMaxPriorityFeePerGas(),
405+
eip1559GasProvider.getMaxFeePerGas(),
406+
constructor);
407407
}
408408

409409
if (receipt == null) {
@@ -412,8 +412,8 @@ TransactionReceipt executeTransaction(
412412
contractAddress,
413413
data,
414414
weiValue,
415-
gasProvider.getGasPrice(funcName),
416-
gasProvider.getGasLimit(funcName),
415+
gasProvider.getGasPrice(),
416+
gasProvider.getGasLimit(getGenericTransaction(data, constructor)),
417417
constructor);
418418
}
419419
} catch (JsonRpcError error) {
@@ -447,6 +447,24 @@ TransactionReceipt executeTransaction(
447447
return receipt;
448448
}
449449

450+
protected Transaction getGenericTransaction(String data, boolean constructor) {
451+
if (constructor) {
452+
return Transaction.createContractTransaction(
453+
this.transactionManager.getFromAddress(),
454+
BigInteger.ONE,
455+
gasProvider.getGasPrice(),
456+
data);
457+
} else {
458+
return Transaction.createFunctionCallTransaction(
459+
this.transactionManager.getFromAddress(),
460+
BigInteger.ONE,
461+
gasProvider.getGasPrice(),
462+
gasProvider.getGasLimit(),
463+
contractAddress,
464+
data);
465+
}
466+
}
467+
450468
protected <T extends Type> RemoteFunctionCall<T> executeRemoteCallSingleValueReturn(
451469
Function function) {
452470
return new RemoteFunctionCall<>(function, () -> executeCallSingleValueReturn(function));

core/src/main/java/org/web3j/tx/gas/ContractEIP1559GasProvider.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
import java.math.BigInteger;
1616

1717
public interface ContractEIP1559GasProvider extends ContractGasProvider {
18-
boolean isEIP1559Enabled();
19-
2018
long getChainId();
2119

22-
BigInteger getMaxFeePerGas(String contractFunc);
20+
BigInteger getMaxFeePerGas();
2321

24-
BigInteger getMaxPriorityFeePerGas(String contractFunc);
22+
BigInteger getMaxPriorityFeePerGas();
2523
}

core/src/main/java/org/web3j/tx/gas/ContractGasProvider.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414

1515
import java.math.BigInteger;
1616

17+
import org.web3j.protocol.core.methods.request.Transaction;
18+
1719
public interface ContractGasProvider {
18-
BigInteger getGasPrice(String contractFunc);
1920

20-
@Deprecated
2121
BigInteger getGasPrice();
2222

23-
BigInteger getGasLimit(String contractFunc);
23+
BigInteger getGasLimit(Transaction transaction);
2424

25-
@Deprecated
2625
BigInteger getGasLimit();
2726
}

0 commit comments

Comments
 (0)