Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Commit

Permalink
adapting to latest versions
Browse files Browse the repository at this point in the history
  • Loading branch information
aaitor committed Aug 14, 2020
1 parent 0f35937 commit 05328e8
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
git clone https://github.com/keyko-io/nevermined-tools
rm -rf ~/.nevermined/nevermined-contracts/artifacts || true
cd nevermined-tools
sudo bash -x start_nevermined.sh --no-commons --no-faucet --no-dashboard --latest 2>&1 > start_nevermined.log &
sudo bash -x start_nevermined.sh --no-commons --no-faucet --latest 2>&1 > start_nevermined.log &
cd ..
- name: Install Java and Maven
Expand Down
55 changes: 34 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
History
=======
### Changelog

0.2.3 (June, 2020)
-------------------------
* DDOs will be registered using the complete metadata url instead of a did token
All notable changes to this project will be documented in this file. Dates are displayed in UTC.

0.2.2 (June, 2020)
-------------------------
* [#12](https://github.com/keyko-io/nevermined-sdk-java/pull/12) Improving Rinkeby support
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v0.2.2](https://github.com/keyko-io/nevermind-sdk-java/compare/v0.2.1...v0.2.2)

0.2.1 (May, 2020)
-------------------------
* [#11](https://github.com/keyko-io/nevermined-sdk-java/pull/11) Access method fails because is using old Secret Store format
> 19 June 2020
- Improving Rinkeby support [`#12`](https://github.com/keyko-io/nevermind-sdk-java/pull/12)
- Including support to rinkeby network via a new version of common-utils library [`2946e82`](https://github.com/keyko-io/nevermind-sdk-java/commit/2946e82e9415ff8c1e45af1eb0965cbd529e5aee)
- new version [`2c204fb`](https://github.com/keyko-io/nevermind-sdk-java/commit/2c204fb676ef0161e6b5477b948b76c464eedc47)
- fixing tests [`48d772a`](https://github.com/keyko-io/nevermind-sdk-java/commit/48d772a7e62a3d06c402c54fc5cda7e6b5eadd04)

0.2.0 (May, 2020)
-------------------------
* [#8](https://github.com/keyko-io/nevermined-sdk-java/issues/8) Modify the publishing & consume flow for making RSA the default auth method
* [#9](https://github.com/keyko-io/nevermined-sdk-java/issues/9) Integration of new access gateway flow that grants permissions
#### [v0.2.1](https://github.com/keyko-io/nevermind-sdk-java/compare/v0.2.0...v0.2.1)

> 24 May 2020
0.1.0 (April, 2020)
-------------------------
* Renaming to Nevermined
* [#2](https://github.com/keyko-io/nevermined-sdk-java/issues/2) Improve the order flow to make use of direct calls instead of flowables
* [#4](https://github.com/keyko-io/nevermined-sdk-java/issues/4) Changing did prefix to `did:nv`
* [#5](https://github.com/keyko-io/nevermined-sdk-java/issues/5) Integration tests are not using examples from the Spec repo
- Fixing access method that was using old secret store files format [`#11`](https://github.com/keyko-io/nevermind-sdk-java/pull/11)
- fixing access method that was using old secret store files format [`5103a88`](https://github.com/keyko-io/nevermind-sdk-java/commit/5103a88ceb49856a840eb74aade06b1c1507214b)
- updating web3j [`8c1573d`](https://github.com/keyko-io/nevermind-sdk-java/commit/8c1573d1dde3361f233cf025a2e94625cb4e7bd4)
- fixing changelog [`7c64a00`](https://github.com/keyko-io/nevermind-sdk-java/commit/7c64a00afc8cae146bbb10a233380a524f6122f4)

#### [v0.2.0](https://github.com/keyko-io/nevermind-sdk-java/compare/v0.1.0...v0.2.0)

> 20 May 2020
- Adaptation to new access flow [`#10`](https://github.com/keyko-io/nevermind-sdk-java/pull/10)
- Renaming and v0.2.0 [`#7`](https://github.com/keyko-io/nevermind-sdk-java/pull/7)
- DDO Improvements [`#6`](https://github.com/keyko-io/nevermind-sdk-java/pull/6)
- Feature/consume without flowable [`#3`](https://github.com/keyko-io/nevermind-sdk-java/pull/3)
- Update templates [`#1`](https://github.com/keyko-io/nevermind-sdk-java/pull/1)
- renaming and v0.2.0 [`016b028`](https://github.com/keyko-io/nevermind-sdk-java/commit/016b0281bba51a9b806e63ee5655bd5b2479e32d)
- adaptation to new access flow [`8a0acfa`](https://github.com/keyko-io/nevermind-sdk-java/commit/8a0acfac60563771855752bff04ca2b78e4cffb6)
- first implementation of direct order [`1b23465`](https://github.com/keyko-io/nevermind-sdk-java/commit/1b234657d95f3d4ade2326e6f96ca71324cd2059)

#### v0.1.0

> 24 April 2020
- first commit [`1193e68`](https://github.com/keyko-io/nevermind-sdk-java/commit/1193e68758b49621c3fac9156b18ecde2abe0a2c)
- re-adapting to previous versions [`8e81f9d`](https://github.com/keyko-io/nevermind-sdk-java/commit/8e81f9d68212b152a6a1fc389c869cfc0e2c394c)
- renaming [`758e6e4`](https://github.com/keyko-io/nevermind-sdk-java/commit/758e6e41e4ec1c679468bfe42ed6ba0afdc44557)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

## Table of Contents

* [Keyko Java API for Ocean](#keyko-java-api-for-ocean)
* [Keyko Java API for Nevermined](#keyko-java-api-for-nevermined)
* [Table of Contents](#table-of-contents)
* [Features](#features)
* [Installation](#installation)
Expand Down Expand Up @@ -46,7 +46,7 @@ Typically in Maven you can add nevermined sdk as a dependency:
<dependency>
<groupId>io.keyko.nevermined</groupId>
<artifactId>api</artifactId>
<version>0.2.0</version>
<version>0.3.0</version>
</dependency>
```

Expand Down Expand Up @@ -84,7 +84,7 @@ contract.LockRewardCondition.address="0x4999A8428d1D42fc955FbBC2f1E22323a55B6f86
contract.AccessSecretStoreCondition.address="0x3Ef2ebF03002D828943EB1AbbFC470D1A53c6B21"
contract.EscrowReward.address="0xE6E685823Ddd2e0D0B29917D84D687E5431136F6"
contract.EscrowAccessSecretStoreTemplate.address="0x3c83D8E1F1BF33Ebb1E8D5A2ac56cE482e54caCd"
contract.OceanToken.address="0xEEE56e2a630DD29F9A628d618E58bb173911F393"
contract.NeverminedToken.address="0xEEE56e2a630DD29F9A628d618E58bb173911F393"
contract.Dispenser.address="0x85cCa2B01adddCA8Df221e6027EE0D7716224202"
contract.DIDRegistry.address="0xfeA10BBb093d7fcb1EDf575Aa7e28d37b9DcFcE9"
contract.ConditionStoreManager.address="0x645439117eB378a6d35148452E287a038666Ed67"
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.keyko.nevermined</groupId>
<artifactId>api</artifactId>
<version>0.2.3</version>
<version>0.3.0</version>
<packaging>jar</packaging>
<name>Nevermined Data Platform Java SDK</name>
<url>https://github.com/keyko-io/nevermined-sdk-java</url>
Expand All @@ -26,7 +26,7 @@
<web3j.version>4.5.18</web3j.version>
<common-utils.version>0.3.0</common-utils.version>

<nevermined.contracts.version>0.3.1</nevermined.contracts.version>
<nevermined.contracts.version>0.4.1</nevermined.contracts.version>
<ocean.secretstore.version>0.1.4</ocean.secretstore.version>
<eddsa.version>0.3.0</eddsa.version>
<jackson.version>2.9.8</jackson.version>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/keyko/nevermined/api/NeverminedAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class NeverminedAPI {
private ConditionsManager conditionsManager;
private TemplatesManager templatesManager;

private OceanToken tokenContract;
private NeverminedToken tokenContract;
private Dispenser dispenser;
private DIDRegistry didRegistryContract;
private EscrowAccessSecretStoreTemplate escrowAccessSecretStoreTemplate;
Expand Down Expand Up @@ -170,7 +170,7 @@ public static NeverminedAPI getInstance(Properties properties) throws Initializa
neverminedAPI.accessSecretStoreCondition = initializationHelper.loadAccessSecretStoreCondition(neverminedAPI.keeperService);
neverminedAPI.escrowReward = initializationHelper.loadEscrowReward(neverminedAPI.keeperService);
neverminedAPI.dispenser = initializationHelper.loadDispenserContract(neverminedAPI.keeperService);
neverminedAPI.tokenContract = initializationHelper.loadOceanTokenContract(neverminedAPI.keeperService);
neverminedAPI.tokenContract = initializationHelper.loadNeverminedTokenContract(neverminedAPI.keeperService);
neverminedAPI.templateStoreManagerContract = initializationHelper.loadTemplateStoreManagerContract(neverminedAPI.keeperService);
neverminedAPI.agreementStoreManagerContract = initializationHelper.loadAgreementStoreManager(neverminedAPI.keeperService);
neverminedAPI.conditionStoreManager = initializationHelper.loadConditionStoreManager(neverminedAPI.keeperService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class NeverminedConfig {
public static final String ESCROW_ACCESS_SS_CONDITIONS_ADDRESS = "contract.EscrowAccessSecretStoreTemplate.address";
public static final String TEMPLATE_STORE_MANAGER_ADDRESS = "contract.TemplateStoreManager.address";
public static final String ACCESS_SS_CONDITIONS_ADDRESS = "contract.AccessSecretStoreCondition.address";
public static final String TOKEN_ADDRESS = "contract.OceanToken.address";
public static final String TOKEN_ADDRESS = "contract.NeverminedToken.address";
public static final String DISPENSER_ADDRESS = "contract.Dispenser.address";
public static final String COMPUTE_EXECUTION_CONDITION_ADDRESS = "contract.ComputeExecutionCondition.address";
public static final String ESCROW_COMPUTE_EXECUTION_CONDITION_ADDRESS = "contract.EscrowComputeExecutionTemplate.address";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ public AssetsManager getAssetsManager(KeeperService keeperService, MetadataApiSe
}

/**
* Loads the OceanToken contract from Keeper
* Loads the NeverminedToken contract from Keeper
*
* @param keeper the keeper Service
* @return an instance of OceanToken contract deployed in keeper
* @return an instance of NeverminedToken contract deployed in keeper
* @throws IOException IOException
* @throws CipherException CipherException
*/
public OceanToken loadOceanTokenContract(KeeperService keeper) throws IOException, CipherException {
public NeverminedToken loadNeverminedTokenContract(KeeperService keeper) throws IOException, CipherException {

return OceanToken.load(
return NeverminedToken.load(
neverminedConfig.getTokenAddress(),
keeper.getWeb3(),
// keeper.getCredentials(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class AgreementsImpl implements AgreementsAPI {
* Constructor
*
* @param agreementsManager the accountsManager
* @param neverminedManager an instance of oceanManager
* @param neverminedManager an instance of neverminedManager
*/
public AgreementsImpl(AgreementsManager agreementsManager, NeverminedManager neverminedManager) {
this.neverminedManager = neverminedManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static AccountsManager getInstance(KeeperService keeperService, MetadataA

/**
* Returns the list of ethereum accounts registered in the Keeper node
* If getBalance is true, get the ethereum and ocean balance of each account
* If getBalance is true, get the ethereum and nevermined balance of each account
*
* @return List of accounts
* @throws EthereumException if the EVM throws an exception
Expand Down Expand Up @@ -103,11 +103,11 @@ public BigInteger getEthAccountBalance(String accountAddress) throws EthereumExc

/**
* Given an account returns the Ocean balance
* Contract: OceanToken
* Contract: NeverminedToken
* Method: balanceOf
*
* @param accountAddress account
* @return ocean balance
* @return nevermined balance
* @throws EthereumException if the EVM throws an exception
*/
public BigInteger getOceanAccountBalance(String accountAddress) throws EthereumException {
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/io/keyko/nevermined/manager/BaseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public abstract class BaseManager {
private SecretStoreDto secretStoreDto;
private EvmDto evmDto;
private SecretStoreManager secretStoreManager;
protected OceanToken tokenContract;
protected NeverminedToken tokenContract;
protected Dispenser dispenser;
protected DIDRegistry didRegistry;
protected LockRewardCondition lockRewardCondition;
Expand Down Expand Up @@ -144,7 +144,7 @@ public List<AssetMetadata.File> getDecriptedSecretStoreMetadataFiles(DDO ddo, in

}

public boolean tokenApprove(OceanToken tokenContract, String spenderAddress, String price) throws TokenApproveException {
public boolean tokenApprove(NeverminedToken tokenContract, String spenderAddress, String price) throws TokenApproveException {

String checksumAddress = Keys.toChecksumAddress(spenderAddress);

Expand Down Expand Up @@ -332,20 +332,20 @@ public BaseManager setEvmDto(EvmDto evmDto) {
}

/**
* It sets the OceanToken stub instance
* It sets the NeverminedToken stub instance
*
* @param contract OceanToken instance
* @param contract NeverminedToken instance
* @return BaseManager instance
*/
public BaseManager setTokenContract(OceanToken contract) {
public BaseManager setTokenContract(NeverminedToken contract) {
this.tokenContract = contract;
return this;
}

/**
* It sets the OceanToken stub instance
* It sets the NeverminedToken stub instance
*
* @param contract OceanToken instance
* @param contract NeverminedToken instance
* @return BaseManager instance
*/
public BaseManager setTemplateStoreManagerContract(TemplateStoreManager contract) {
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/io/keyko/nevermined/models/Balance.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Balance {
public enum Unit {
DROP("drop", 0),
VODKA("vodka", 0),
OCEAN("ocean", 18);
NVN("nvn", 18);

private String name;
private BigInteger factor;
Expand Down Expand Up @@ -42,17 +42,17 @@ public BigInteger getDrops() {
return drops;
}

public BigDecimal getOceanTokens() {
return dropsToOcean(this.drops);
public BigDecimal getNeverminedTokens() {
return dropsToNevermined(this.drops);
}


public static BigDecimal dropsToOcean(BigInteger drops) {
return new BigDecimal(drops).divide(new BigDecimal(Unit.OCEAN.factor));
public static BigDecimal dropsToNevermined(BigInteger drops) {
return new BigDecimal(drops).divide(new BigDecimal(Unit.NVN.factor));
}

public static BigInteger oceanToDrops(BigInteger ocean) {
return ocean.multiply(Unit.OCEAN.factor);
public static BigInteger neverminedToDrops(BigInteger nevermined) {
return nevermined.multiply(Unit.NVN.factor);
}

@Override
Expand Down
16 changes: 12 additions & 4 deletions src/test/java/io/keyko/nevermined/api/AssetsApiIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.logging.log4j.Logger;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

import java.io.InputStream;
Expand Down Expand Up @@ -107,7 +108,7 @@ public static void setUp() throws Exception {
properties.put(NeverminedConfig.ESCROW_ACCESS_SS_CONDITIONS_ADDRESS, config.getString("contract.EscrowAccessSecretStoreTemplate.address"));
properties.put(NeverminedConfig.ACCESS_SS_CONDITIONS_ADDRESS, config.getString("contract.AccessSecretStoreCondition.address"));
properties.put(NeverminedConfig.TEMPLATE_STORE_MANAGER_ADDRESS, config.getString("contract.TemplateStoreManager.address"));
properties.put(NeverminedConfig.TOKEN_ADDRESS, config.getString("contract.OceanToken.address"));
properties.put(NeverminedConfig.TOKEN_ADDRESS, config.getString("contract.NeverminedToken.address"));
properties.put(NeverminedConfig.DISPENSER_ADDRESS, config.getString("contract.Dispenser.address"));
properties.put(NeverminedConfig.PROVIDER_ADDRESS, config.getString("provider.address"));

Expand Down Expand Up @@ -168,17 +169,21 @@ public void orderComputingService() throws Exception {
assertEquals(ddo.id, resolvedDDO.id);
assertTrue(resolvedDDO.services.size() == 4);

Flowable<OrderResult> response = neverminedAPIConsumer.getAssetsAPI().order(did, Service.DEFAULT_COMPUTING_INDEX);
OrderResult result = neverminedAPIConsumer.getAssetsAPI().orderDirect(did, Service.DEFAULT_COMPUTING_INDEX);

// Flowable<OrderResult> response = neverminedAPIConsumer.getAssetsAPI().order(did, Service.DEFAULT_COMPUTING_INDEX);
TimeUnit.SECONDS.sleep(2l);

OrderResult result = response.blockingFirst();
// OrderResult result = response.blockingFirst();
assertNotNull(result.getServiceAgreementId());
assertEquals(true, result.isAccessGranted());

}



// This test only makes sense if is executed in combination with the events handler
// Disabling by default because in the integration tests, the events handler is not executed
@Ignore
@Test
public void order() throws Exception {

Expand Down Expand Up @@ -273,6 +278,9 @@ public void consumeBinaryDirectly() throws Exception {
assertEquals(consumedAssetsBefore + 1, consumedAssetsAfter);
}

// This test only makes sense if is executed in combination with the events handler
// Disabling by default because in the integration tests, the events handler is not executed
@Ignore
@Test
public void consumeBinary() throws Exception {

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/keyko/nevermined/api/ConditionsApiIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static void setUp() throws Exception {
properties.put(NeverminedConfig.ESCROWREWARD_CONDITIONS_ADDRESS, config.getString("contract.EscrowReward.address"));
properties.put(NeverminedConfig.ACCESS_SS_CONDITIONS_ADDRESS, config.getString("contract.AccessSecretStoreCondition.address"));
properties.put(NeverminedConfig.TEMPLATE_STORE_MANAGER_ADDRESS, config.getString("contract.TemplateStoreManager.address"));
properties.put(NeverminedConfig.TOKEN_ADDRESS, config.getString("contract.OceanToken.address"));
properties.put(NeverminedConfig.TOKEN_ADDRESS, config.getString("contract.NeverminedToken.address"));
properties.put(NeverminedConfig.DISPENSER_ADDRESS, config.getString("contract.Dispenser.address"));
properties.put(NeverminedConfig.PROVIDER_ADDRESS, config.getString("provider.address"));

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/keyko/nevermined/api/PermissionsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void setUp() throws Exception {
properties.put(NeverminedConfig.ESCROW_ACCESS_SS_CONDITIONS_ADDRESS, config.getString("contract.EscrowAccessSecretStoreTemplate.address"));
properties.put(NeverminedConfig.ACCESS_SS_CONDITIONS_ADDRESS, config.getString("contract.AccessSecretStoreCondition.address"));
properties.put(NeverminedConfig.TEMPLATE_STORE_MANAGER_ADDRESS, config.getString("contract.TemplateStoreManager.address"));
properties.put(NeverminedConfig.TOKEN_ADDRESS, config.getString("contract.OceanToken.address"));
properties.put(NeverminedConfig.TOKEN_ADDRESS, config.getString("contract.NeverminedToken.address"));
properties.put(NeverminedConfig.DISPENSER_ADDRESS, config.getString("contract.Dispenser.address"));
properties.put(NeverminedConfig.PROVIDER_ADDRESS, config.getString("provider.address"));

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/io/keyko/nevermined/api/TokensApiIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void transfer() throws Exception {
log.debug("Balance Before is: " + balanceBefore);
log.debug("Balance After is: " + balanceAfter);

assertEquals(-1, balanceBefore.getOceanTokens().compareTo(balanceAfter.getOceanTokens()));
assertEquals(-1, balanceBefore.getNeverminedTokens().compareTo(balanceAfter.getNeverminedTokens()));

}

Expand All @@ -73,8 +73,8 @@ public void requestTokens() throws Exception {

log.debug("Balance after: " + balanceAfter.toString());

BigDecimal before= balanceBefore.getOceanTokens();
BigDecimal after= balanceAfter.getOceanTokens();
BigDecimal before= balanceBefore.getNeverminedTokens();
BigDecimal after= balanceAfter.getNeverminedTokens();
assertEquals(0, after.compareTo(before.add(BigDecimal.ONE)));
}

Expand Down

0 comments on commit 05328e8

Please sign in to comment.