Skip to content

Commit 6262b2e

Browse files
authored
Replace CredentialsService with SignerService (#137)
1 parent 5245441 commit 6262b2e

File tree

6 files changed

+84
-18
lines changed

6 files changed

+84
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
## [[NEXT]](https://github.com/iExecBlockchainComputing/iexec-result-proxy/releases/tag/vNEXT) 2024
66

7+
### New Features
8+
9+
- Replace `CredentialsService` with `SignerService`. (#137)
10+
711
### Bug Fixes
812

913
- Fix conditions to retrieve a JWT or to allow a result upload. (#132)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version=8.4.0
22
iexecCommonVersion=8.4.0
3-
iexecCommonsPocoVersion=3.2.0
3+
iexecCommonsPocoVersion=4.0.0-NEXT-SNAPSHOT
44

55
nexusUser
66
nexusPassword

src/main/java/com/iexec/resultproxy/chain/CredentialsService.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/main/java/com/iexec/resultproxy/chain/IexecHubService.java

Lines changed: 4 additions & 4 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,12 +18,12 @@
1818

1919
import com.iexec.commons.poco.chain.IexecHubAbstractService;
2020

21+
import com.iexec.commons.poco.chain.SignerService;
2122
import org.springframework.stereotype.Service;
2223

2324
@Service
2425
public class IexecHubService extends IexecHubAbstractService {
25-
26-
public IexecHubService(CredentialsService credentialsService, Web3jService web3jService, ChainConfig chainConfig) {
27-
super(credentialsService.getCredentials(), web3jService, chainConfig.getHubAddress());
26+
public IexecHubService(SignerService signerService, Web3jService web3jService, ChainConfig chainConfig) {
27+
super(signerService.getCredentials(), web3jService, chainConfig.getHubAddress());
2828
}
2929
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.resultproxy.chain;
18+
19+
import com.iexec.commons.poco.chain.SignerService;
20+
import org.springframework.context.annotation.Bean;
21+
import org.springframework.context.annotation.Configuration;
22+
23+
import java.security.GeneralSecurityException;
24+
25+
@Configuration
26+
public class WalletConfiguration {
27+
@Bean
28+
SignerService signerService(Web3jService web3jService, ChainConfig chainConfig) throws GeneralSecurityException {
29+
return new SignerService(web3jService.getWeb3j(), chainConfig.getId());
30+
}
31+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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.resultproxy.chain;
18+
19+
import com.iexec.commons.poco.chain.SignerService;
20+
import org.junit.jupiter.api.Test;
21+
import org.springframework.boot.context.annotation.UserConfigurations;
22+
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
23+
24+
import java.time.Duration;
25+
26+
import static org.assertj.core.api.Assertions.assertThat;
27+
28+
class WalletConfigurationTest {
29+
private final ApplicationContextRunner runner = new ApplicationContextRunner();
30+
31+
@Test
32+
void shouldCreateBeans() {
33+
runner.withBean(ChainConfig.class, 65535, true, "http://localhost:8545", "0xC129e7917b7c7DeDfAa5Fff1FB18d5D7050fE8ca", Duration.ofSeconds(5L), 1.0f, 0L)
34+
.withBean(IexecHubService.class)
35+
.withBean(Web3jService.class)
36+
.withConfiguration(UserConfigurations.of(WalletConfiguration.class))
37+
.run(context -> assertThat(context)
38+
.hasSingleBean(ChainConfig.class)
39+
.hasSingleBean(IexecHubService.class)
40+
.hasSingleBean(SignerService.class)
41+
.hasSingleBean(WalletConfiguration.class)
42+
.hasSingleBean(Web3jService.class));
43+
}
44+
}

0 commit comments

Comments
 (0)