Skip to content

Commit af3cb8a

Browse files
authored
Merge pull request #102 from iExecBlockchainComputing/release/4.1.0
Release/4.1.0
2 parents 35b629c + c26ffab commit af3cb8a

34 files changed

+741
-702
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [[4.1.0]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/v4.1.0) 2024-06-17
6+
7+
### New Features
8+
9+
- Add `AbstractAssetDeploymentService` and move `getNonce` method. (#92)
10+
- Estimate gas and submit a transaction in a single method. (#97)
11+
- Add method to fetch on-chain deal without app or dataset details. (#98)
12+
- Add encodings to call PoCo assets address prediction functions. (#101)
13+
14+
### Quality
15+
16+
- Configure Gradle JVM Test Suite Plugin. (#89)
17+
- Remove unused `predictApp`, `predictDataset` and `predictWorkerpool` methods. (#93)
18+
- Remove empty `ChainStatus` interface. (#94)
19+
- Remove `com.iexec.commons.poco.notification` package. (#95)
20+
- Restrict several methods visibility in `IexecHubAbstractService`. (#96)
21+
- Avoid exceptions during `IexecHubAbstractService` and `Web3jAbstractService` objects creation. (#99)
22+
- Improve `SignatureUtils`: remove dead code and remove cleanly unused parameter in `hashAndSign`. (#100)
23+
24+
### Dependency Upgrades
25+
26+
- Upgrade to Gradle 8.7. (#90)
27+
- Upgrade to Spring Boot 2.7.18. (#91)
28+
529
## [[4.0.0]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/v4.0.0) 2024-04-12
630

731
### New features

build.gradle

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
plugins {
22
id 'java-library'
3+
id 'io.freefair.lombok' version '8.6'
34
id 'jacoco'
4-
id 'org.sonarqube' version '4.2.1.3168'
5+
id 'org.sonarqube' version '5.0.0.4638'
56
id 'maven-publish'
6-
id 'io.freefair.lombok' version '8.2.2'
77
}
88

99
group = 'com.iexec.commons'
@@ -34,7 +34,7 @@ repositories {
3434
}
3535

3636
dependencies {
37-
implementation platform('org.springframework.boot:spring-boot-dependencies:2.7.17')
37+
implementation platform('org.springframework.boot:spring-boot-dependencies:2.7.18')
3838

3939
// web3j
4040
api 'org.web3j:core:4.9.7'
@@ -55,19 +55,6 @@ dependencies {
5555

5656
// javax annotations like PostConstruct
5757
implementation 'javax.annotation:javax.annotation-api'
58-
59-
// tests
60-
testImplementation 'org.junit.jupiter:junit-jupiter'
61-
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
62-
testImplementation 'org.mockito:mockito-junit-jupiter'
63-
testImplementation 'org.assertj:assertj-core'
64-
testImplementation "org.testcontainers:junit-jupiter:$testContainersVersion"
65-
66-
// spring-test for ReflectionTestUtils
67-
testImplementation 'org.springframework:spring-test'
68-
69-
// logback
70-
testRuntimeOnly 'ch.qos.logback:logback-classic'
7158
}
7259

7360
java {
@@ -80,9 +67,26 @@ java {
8067
withSourcesJar()
8168
}
8269

70+
testing {
71+
suites {
72+
test {
73+
useJUnitJupiter()
74+
dependencies {
75+
implementation 'org.junit.jupiter:junit-jupiter'
76+
implementation 'org.mockito:mockito-junit-jupiter'
77+
implementation 'org.assertj:assertj-core'
78+
implementation "org.testcontainers:junit-jupiter:$testContainersVersion"
79+
// spring-test for ReflectionTestUtils
80+
implementation 'org.springframework:spring-test'
81+
// logback
82+
runtimeOnly 'ch.qos.logback:logback-classic'
83+
}
84+
}
85+
}
86+
}
87+
8388
tasks.withType(Test).configureEach {
8489
finalizedBy jacocoTestReport
85-
useJUnitPlatform()
8690
}
8791

8892
test {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=4.0.0
1+
version=4.1.0
22
nexusUser
33
nexusPassword

gradle/wrapper/gradle-wrapper.jar

-19.5 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ done
8383
# This is normally unused
8484
# shellcheck disable=SC2034
8585
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
8788

8889
# Use the maximum available, or set MAX_FD != -1 to use that value.
8990
MAX_FD=maximum
@@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
146147
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
148+
# shellcheck disable=SC2039,SC3045
148149
MAX_FD=$( ulimit -H -n ) ||
149150
warn "Could not query maximum file descriptor limit"
150151
esac
151152
case $MAX_FD in #(
152153
'' | soft) :;; #(
153154
*)
154155
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
156+
# shellcheck disable=SC2039,SC3045
156157
ulimit -n "$MAX_FD" ||
157158
warn "Could not set maximum file descriptor limit to $MAX_FD"
158159
esac
@@ -201,11 +202,11 @@ fi
201202
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
202203
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
203204

204-
# Collect all arguments for the java command;
205-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
206-
# shell script including quotes and variable substitutions, so put them in
207-
# double quotes to make sure that they get re-expanded; and
208-
# * put everything else in single quotes, so that it's not re-expanded.
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
209210

210211
set -- \
211212
"-Dorg.gradle.appname=$APP_BASE_NAME" \

gradlew.bat

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
4343
%JAVA_EXE% -version >NUL 2>&1
4444
if %ERRORLEVEL% equ 0 goto execute
4545

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
46+
echo. 1>&2
47+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48+
echo. 1>&2
49+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50+
echo location of your Java installation. 1>&2
5151

5252
goto fail
5353

@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5757

5858
if exist "%JAVA_EXE%" goto execute
5959

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
60+
echo. 1>&2
61+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62+
echo. 1>&2
63+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64+
echo location of your Java installation. 1>&2
6565

6666
goto fail
6767

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright 2024 IEXEC BLOCKCHAIN TECH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.iexec.commons.poco.chain;
18+
19+
import com.iexec.commons.poco.encoding.AssetDataEncoder;
20+
import lombok.extern.slf4j.Slf4j;
21+
import org.web3j.utils.Numeric;
22+
23+
import java.io.IOException;
24+
import java.math.BigInteger;
25+
import java.util.Objects;
26+
27+
@Slf4j
28+
public abstract class AbstractAssetDeploymentService {
29+
private static final String ASSET_REGISTRY_ADDRESS_INITIALIZATION_NEEDED =
30+
"Registry address has not been initialized, please call initRegistryAddress";
31+
protected final SignerService signerService;
32+
33+
private final String assetRegistrySelector;
34+
private String assetRegistryAddress;
35+
36+
protected AbstractAssetDeploymentService(SignerService signerService, String assetRegistrySelector) {
37+
this.signerService = signerService;
38+
this.assetRegistrySelector = assetRegistrySelector;
39+
}
40+
41+
public void initRegistryAddress(String iexecHubAddress) throws IOException {
42+
if (this.assetRegistryAddress != null) {
43+
return;
44+
}
45+
this.assetRegistryAddress = toEthereumAddress(signerService.sendCall(iexecHubAddress, assetRegistrySelector));
46+
}
47+
48+
public String callCreateAsset(String assetTxData) throws IOException {
49+
Objects.requireNonNull(assetRegistryAddress, ASSET_REGISTRY_ADDRESS_INITIALIZATION_NEEDED);
50+
return toEthereumAddress(signerService.sendCall(assetRegistryAddress, assetTxData));
51+
}
52+
53+
public boolean isAssetDeployed(String address) throws IOException {
54+
Objects.requireNonNull(assetRegistryAddress, ASSET_REGISTRY_ADDRESS_INITIALIZATION_NEEDED);
55+
final String isRegisteredTxData = AssetDataEncoder.encodeIsRegistered(address);
56+
return Numeric.toBigInt(signerService.sendCall(assetRegistryAddress, isRegisteredTxData)).equals(BigInteger.ONE);
57+
}
58+
59+
public String submitAssetTxData(BigInteger nonce, BigInteger gasPrice, String assetTxData) throws IOException {
60+
Objects.requireNonNull(assetRegistryAddress, ASSET_REGISTRY_ADDRESS_INITIALIZATION_NEEDED);
61+
return signerService.signAndSendTransaction(nonce, gasPrice, assetRegistryAddress, assetTxData);
62+
}
63+
64+
private String toEthereumAddress(String hexaString) {
65+
return Numeric.toHexStringWithPrefixZeroPadded(
66+
Numeric.toBigInt(hexaString), 40);
67+
}
68+
}

src/main/java/com/iexec/commons/poco/chain/ChainContributionStatus.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
1818

1919
import java.math.BigInteger;
2020

21-
public enum ChainContributionStatus implements ChainStatus {
21+
public enum ChainContributionStatus {
2222
UNSET,
2323
CONTRIBUTED,
2424
REVEALED,

src/main/java/com/iexec/commons/poco/chain/ChainDeal.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,21 @@ public boolean containsDataset() {
6262
!getChainDataset().getChainDatasetId().equals(BytesUtils.EMPTY_ADDRESS);
6363
}
6464

65+
public static ChainDeal parts2ChainDeal(String chainDealId, IexecHubContract.Deal deal, ChainCategory category) {
66+
if (deal == null || category == null) {
67+
return ChainDeal.builder().build();
68+
}
69+
return create(chainDealId, deal, category, null, null);
70+
}
71+
6572
public static ChainDeal parts2ChainDeal(String chainDealId, IexecHubContract.Deal deal, ChainApp app, ChainCategory category, ChainDataset dataset) {
6673
if (deal == null || app == null || category == null) {
6774
return ChainDeal.builder().build();
6875
}
76+
return create(chainDealId, deal, category, app, dataset);
77+
}
78+
79+
private static ChainDeal create(String chainDealId, IexecHubContract.Deal deal, ChainCategory category, ChainApp app, ChainDataset dataset) {
6980
return ChainDeal.builder()
7081
.chainDealId(chainDealId)
7182
.chainApp(app)

0 commit comments

Comments
 (0)