Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
7824683
Switch off stacktrace trim in surefire plugin
vsbogd Oct 18, 2019
a256b18
Test mocks refactoring
vsbogd Oct 21, 2019
7d8611c
Implement sending empty payment to daemon
vsbogd Oct 22, 2019
3e51f97
Change paymentGroupId type to byte[]
vsbogd Oct 22, 2019
884a8f8
Send payment for predefined channel
vsbogd Oct 23, 2019
10d142c
Move Utils into *.common package
vsbogd Oct 23, 2019
a331a57
Add wrapException unit test
vsbogd Oct 23, 2019
1242e1f
Add bytes32ToStr, strToBytes32 unit tests
vsbogd Oct 23, 2019
a8a2176
Unit test addressToStr
vsbogd Oct 23, 2019
852ab50
Add ECKeyPair constructor
vsbogd Oct 23, 2019
28c310a
Remove cyclic dependency between *.client and *.mpe packages
vsbogd Oct 23, 2019
31104fb
Set group name to the ServiceClient
vsbogd Oct 23, 2019
4fc193c
Fix payment amount calculation
vsbogd Oct 23, 2019
b56f5ab
Add diagram of new interfaces and classes
vsbogd Oct 23, 2019
b6b1cb2
Add javadoc for the *.client package.
vsbogd Oct 23, 2019
b524d72
Ensure javadoc doesn't contain warnings
vsbogd Oct 24, 2019
0baa9c6
Recompile protobuf only when it changes
vsbogd Oct 24, 2019
31737e0
Add daemon state service mock
vsbogd Oct 24, 2019
65bb836
Handle payment channel state kept in daemon
vsbogd Oct 24, 2019
9148b81
Remove failing on javadoc warnings from CI
vsbogd Oct 24, 2019
5dccd6e
Move daemon mock into separate file and package
vsbogd Oct 24, 2019
1ed49d5
Move state service messages signing into separate class
vsbogd Oct 24, 2019
9773e1a
Rename ContractPaymentChannelProvider
vsbogd Oct 24, 2019
3dad963
Use bigIntToBytes32 and bytes32ToBigInt to convert payment details
vsbogd Oct 24, 2019
3557c52
Move test environment setup to the separate class
vsbogd Oct 28, 2019
a536490
Formatting changes
vsbogd Oct 28, 2019
7af4b9e
Move daemon protobuf to ./target directory
vsbogd Oct 28, 2019
fdb32d2
Trim zero chars in bytesToStr()
vsbogd Oct 29, 2019
0c3effd
Add URI API unit test
vsbogd Oct 29, 2019
26a539d
Test web3j API
vsbogd Oct 29, 2019
95f5c69
Add configuration and sdk to bootstrap service client easy
vsbogd Oct 29, 2019
5b6e3d3
Test state request message signing procedure
vsbogd Oct 30, 2019
e2e209d
Fix price model deserialization issue
vsbogd Oct 30, 2019
b0824c9
Add Address type to fix mess of 0x and not prefixed address strings
vsbogd Oct 30, 2019
f614529
Add SDK shutdown method
vsbogd Oct 30, 2019
b1e462f
Add example of service call using SDK
vsbogd Oct 30, 2019
183e607
Replace some TODOs by FIXME
vsbogd Oct 30, 2019
4c22e78
Mock ethereum block number
vsbogd Oct 31, 2019
e58250f
Add FIXME
vsbogd Oct 31, 2019
1c6947c
Pass channel id only in PaymentChannelStateService API
vsbogd Oct 31, 2019
f832ed6
Remove signer from payment strategy parameters
vsbogd Oct 31, 2019
34d6ae4
Split configuration and dependency factory
vsbogd Oct 31, 2019
4f80c48
Add class diagram in plantuml format
vsbogd Nov 1, 2019
cab34ef
Update class diagram
vsbogd Nov 1, 2019
28433eb
Move Payment to the daemon package
vsbogd Nov 1, 2019
9aeee30
Rename get_contracts.sh to get_dependencies.sh
vsbogd Nov 1, 2019
1948bfd
Add ExampleService example
vsbogd Nov 8, 2019
fbc3cee
Fix bytes32ToStr for 32 byte length string case
vsbogd Nov 8, 2019
cd4682e
Replace endpoints for example by Ropsten
vsbogd Nov 9, 2019
4b67df7
Test MPE payment signing
vsbogd Nov 9, 2019
5255a8a
Reproduce snet-cli wallet generation procedure
vsbogd Nov 9, 2019
502a761
Make utility classes constructors private
vsbogd Nov 9, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
command: |
curl -L https://get.web3j.io | bash
source $HOME/.web3j/source.sh
./get_contracts.sh
./get_dependencies.sh
# run tests!
- run:
name: Run tests
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.svg binary
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ hs_err_pid*

# maven build files
target

# vim specific files
*.swp
.vim-project
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

## Class diagram

![Class diagram](https://www.plantuml.com/plantuml/svg/VP9HJy8m58NV-olkupJ07v0G0aOpZMWOFXaVBkrbDAajQMz75lM_kusH30O-zlRqdFkTT1eOFSSl8mHhDWIPjdaqw3MN2s9umW8XktyMGbiclq59y4AC2XapTXvpWcy1i2wPFZuX9qxUbob4hs_knA-G1aE0TBS9Pu_4kSduPpIwA6mzbfJhmBwSEyiU9JUfhplMpg8PP-GBBQaLOJsTrCjScC_AL2KP-ueJdCzJDO3s50xYL3MhNm1-ywxGYdoJtLeVxpffnr7IgU2u_hcLw7atHLoLzseO3c-lgg7Nyd_gBd5BCZUQxA7gLGtuw7SouxXE7gALTPdZ-HQj9JE0rGIaivLlb5LMHGvGEAqWR2ChjxSBj-_sCSD09o7YDB9feI_g4TP0VPcOabNLf_u3)
[Source code](https://www.planttext.com/?text=VP9HJy8m58NV-olkupJ07v0G0aOpZMWOFXaVBkrbDAajQMz75lM_kusH30O-zlRqdFkTT1eOFSSl8mHhDWIPjdaqw3MN2s9umW8XktyMGbiclq59y4AC2XapTXvpWcy1i2wPFZuX9qxUbob4hs_knA-G1aE0TBS9Pu_4kSduPpIwA6mzbfJhmBwSEyiU9JUfhplMpg8PP-GBBQaLOJsTrCjScC_AL2KP-ueJdCzJDO3s50xYL3MhNm1-ywxGYdoJtLeVxpffnr7IgU2u_hcLw7atHLoLzseO3c-lgg7Nyd_gBd5BCZUQxA7gLGtuw7SouxXE7gALTPdZ-HQj9JE0rGIaivLlb5LMHGvGEAqWR2ChjxSBj-_sCSD09o7YDB9feI_g4TP0VPcOabNLf_u3)
![Class diagram](./docs/class-diagram.svg)
[Source code](./docs/class-diagram.plantuml)

## How to build

Install dependencies for the first time:
```
curl -L https://get.web3j.io | bash
source $HOME/.web3j/source.sh
./get_contracts.sh
./get_dependencies.sh
```

Build and test:
Expand Down
152 changes: 152 additions & 0 deletions docs/class-diagram.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
@startuml

title SingularityNet Java SDK

package io.singularitynet.sdk.ethereum {

interface WithAddress {
Address getAddress();
}

interface Signer {
byte[] sign(byte[] message);
}
WithAddress <|-- Signer

class PrivateKeyIdentity
Signer <|.. PrivateKeyIdentity

class MnemonicIdentity
PrivateKeyIdentity <|-- MnemonicIdentity

}


package io.singularitynet.sdk.registry {

interface MetadataStorage {
byte[] get(URI uri);
}
class IpfsMetadataStorage
MetadataStorage <|.. IpfsMetadataStorage

class RegistryContract {
Optional<OrganizationRegistration> getOrganizationById(String orgId);
Optional<ServiceRegistration> getServiceRegistrationById(String orgId, String serviceId);
}

interface MetadataProvider {
ServiceMetadata getServiceMetadata();
}
class RegistryMetadataProvider
MetadataProvider <|.. RegistryMetadataProvider
RegistryMetadataProvider *-- RegistryContract
RegistryMetadataProvider *-- MetadataStorage

}

package io.singularitynet.sdk.daemon {

interface DaemonConnection {
<T> T getGrpcStub(Function<Channel, T> constructor);
void setClientCallsInterceptor(ClientInterceptor interceptor);
void shutdownNow();
}

class FirstEndpointDaemonConnection
DaemonConnection <|.. FirstEndpointDaemonConnection
FirstEndpointDaemonConnection o-- MetadataProvider

class PaymentChannelStateService {
PaymentChannelStateReply getChannelState(BigInteger channelId);
}
PaymentChannelStateService o-- Signer
PaymentChannelStateService -- DaemonConnection

interface Payment {
void toMetadata(Metadata headers);
}

}

package io.singularitynet.sdk.mpe {
class MultiPartyEscrowContract {
Optional<PaymentChannel> getChannelById(BigInteger channelId);
Address getContractAddress();
}

interface PaymentChannelProvider {
PaymentChannel getChannelById(BigInteger channelId);
}

class AskDaemonFirstPaymentChannelProvider
PaymentChannelProvider <|.. AskDaemonFirstPaymentChannelProvider
AskDaemonFirstPaymentChannelProvider *-- MultiPartyEscrowContract
AskDaemonFirstPaymentChannelProvider *-- PaymentChannelStateService

class EscrowPayment
Payment ()- EscrowPayment

}

package io.singularitynet.sdk.client {

interface Configuration {
String getEthereumJsonRpcEndpoint();
URL getIpfsUrl();
SignerType getSignerType();
String getSignerMnemonic();
byte[] getSignerPrivateKey();
}

class JsonConfiguration
Configuration <|.. JsonConfiguration

interface DependencyFactory {
Web3j getWeb3j();
ContractGasProvider getContractGasProvider(Web3j web3j);
IPFS getIpfs();
Signer getSigner();
}

class ConfigurationDependencyFactory
DependencyFactory <|.. ConfigurationDependencyFactory

interface PaymentStrategy {
<ReqT, RespT> Payment getPayment(GrpcCallParameters<ReqT, RespT> parameters, ServiceClient serviceClient);
}

class FixedPaymentChannelPaymentStrategy
PaymentStrategy <|.. FixedPaymentChannelPaymentStrategy

class Sdk {
Sdk(Configuration config);
Sdk(DependencyFactory factory);

ServiceClient newServiceClient(String orgId, String serviceId, String endpointGroupName, PaymentStrategy paymentStrategy);
void shutdown();
}
Sdk -- Configuration
Sdk -- ServiceClient
Sdk -- DependencyFactory

interface ServiceClient {
MetadataProvider getMetadataProvider();
PaymentChannelProvider getPaymentChannelProvider();
Signer getSigner();
T getGrpcStub(Function<Channel, T> constructor);
void shutdownNow();
}

class BaseServiceClient
ServiceClient <|.. BaseServiceClient
BaseServiceClient *-- DaemonConnection
BaseServiceClient *-- MetadataProvider
BaseServiceClient *-- PaymentChannelProvider
BaseServiceClient *-- PaymentStrategy
BaseServiceClient *-- Signer

}

@enduml

Loading