|
| 1 | +@startuml |
| 2 | + |
| 3 | +title SingularityNet Java SDK |
| 4 | + |
| 5 | +package io.singularitynet.sdk.ethereum { |
| 6 | + |
| 7 | + interface WithAddress { |
| 8 | + Address getAddress(); |
| 9 | + } |
| 10 | + |
| 11 | + interface Signer { |
| 12 | + byte[] sign(byte[] message); |
| 13 | + } |
| 14 | + WithAddress <|-- Signer |
| 15 | + |
| 16 | + class PrivateKeyIdentity |
| 17 | + Signer <|.. PrivateKeyIdentity |
| 18 | + |
| 19 | + class MnemonicIdentity |
| 20 | + PrivateKeyIdentity <|-- MnemonicIdentity |
| 21 | + |
| 22 | +} |
| 23 | + |
| 24 | + |
| 25 | +package io.singularitynet.sdk.registry { |
| 26 | + |
| 27 | + interface MetadataStorage { |
| 28 | + byte[] get(URI uri); |
| 29 | + } |
| 30 | + class IpfsMetadataStorage |
| 31 | + MetadataStorage <|.. IpfsMetadataStorage |
| 32 | + |
| 33 | + class RegistryContract { |
| 34 | + Optional<OrganizationRegistration> getOrganizationById(String orgId); |
| 35 | + Optional<ServiceRegistration> getServiceRegistrationById(String orgId, String serviceId); |
| 36 | + } |
| 37 | + |
| 38 | + interface MetadataProvider { |
| 39 | + ServiceMetadata getServiceMetadata(); |
| 40 | + } |
| 41 | + class RegistryMetadataProvider |
| 42 | + MetadataProvider <|.. RegistryMetadataProvider |
| 43 | + RegistryMetadataProvider *-- RegistryContract |
| 44 | + RegistryMetadataProvider *-- MetadataStorage |
| 45 | + |
| 46 | +} |
| 47 | + |
| 48 | +package io.singularitynet.sdk.daemon { |
| 49 | + |
| 50 | + interface DaemonConnection { |
| 51 | + <T> T getGrpcStub(Function<Channel, T> constructor); |
| 52 | + void setClientCallsInterceptor(ClientInterceptor interceptor); |
| 53 | + void shutdownNow(); |
| 54 | + } |
| 55 | + |
| 56 | + class FirstEndpointDaemonConnection |
| 57 | + DaemonConnection <|.. FirstEndpointDaemonConnection |
| 58 | + FirstEndpointDaemonConnection o-- MetadataProvider |
| 59 | + |
| 60 | + class PaymentChannelStateService { |
| 61 | + PaymentChannelStateReply getChannelState(BigInteger channelId); |
| 62 | + } |
| 63 | + PaymentChannelStateService o-- Signer |
| 64 | + PaymentChannelStateService -- DaemonConnection |
| 65 | + |
| 66 | + interface Payment { |
| 67 | + void toMetadata(Metadata headers); |
| 68 | + } |
| 69 | + |
| 70 | +} |
| 71 | + |
| 72 | +package io.singularitynet.sdk.mpe { |
| 73 | + class MultiPartyEscrowContract { |
| 74 | + Optional<PaymentChannel> getChannelById(BigInteger channelId); |
| 75 | + Address getContractAddress(); |
| 76 | + } |
| 77 | + |
| 78 | + interface PaymentChannelProvider { |
| 79 | + PaymentChannel getChannelById(BigInteger channelId); |
| 80 | + } |
| 81 | + |
| 82 | + class AskDaemonFirstPaymentChannelProvider |
| 83 | + PaymentChannelProvider <|.. AskDaemonFirstPaymentChannelProvider |
| 84 | + AskDaemonFirstPaymentChannelProvider *-- MultiPartyEscrowContract |
| 85 | + AskDaemonFirstPaymentChannelProvider *-- PaymentChannelStateService |
| 86 | + |
| 87 | + class EscrowPayment |
| 88 | + Payment ()- EscrowPayment |
| 89 | + |
| 90 | +} |
| 91 | + |
| 92 | +package io.singularitynet.sdk.client { |
| 93 | + |
| 94 | + interface Configuration { |
| 95 | + String getEthereumJsonRpcEndpoint(); |
| 96 | + URL getIpfsUrl(); |
| 97 | + SignerType getSignerType(); |
| 98 | + String getSignerMnemonic(); |
| 99 | + byte[] getSignerPrivateKey(); |
| 100 | + } |
| 101 | + |
| 102 | + class JsonConfiguration |
| 103 | + Configuration <|.. JsonConfiguration |
| 104 | + |
| 105 | + interface DependencyFactory { |
| 106 | + Web3j getWeb3j(); |
| 107 | + ContractGasProvider getContractGasProvider(Web3j web3j); |
| 108 | + IPFS getIpfs(); |
| 109 | + Signer getSigner(); |
| 110 | + } |
| 111 | + |
| 112 | + class ConfigurationDependencyFactory |
| 113 | + DependencyFactory <|.. ConfigurationDependencyFactory |
| 114 | + |
| 115 | + interface PaymentStrategy { |
| 116 | + <ReqT, RespT> Payment getPayment(GrpcCallParameters<ReqT, RespT> parameters, ServiceClient serviceClient); |
| 117 | + } |
| 118 | + |
| 119 | + class FixedPaymentChannelPaymentStrategy |
| 120 | + PaymentStrategy <|.. FixedPaymentChannelPaymentStrategy |
| 121 | + |
| 122 | + class Sdk { |
| 123 | + Sdk(Configuration config); |
| 124 | + Sdk(DependencyFactory factory); |
| 125 | + |
| 126 | + ServiceClient newServiceClient(String orgId, String serviceId, String endpointGroupName, PaymentStrategy paymentStrategy); |
| 127 | + void shutdown(); |
| 128 | + } |
| 129 | + Sdk -- Configuration |
| 130 | + Sdk -- ServiceClient |
| 131 | + Sdk -- DependencyFactory |
| 132 | + |
| 133 | + interface ServiceClient { |
| 134 | + MetadataProvider getMetadataProvider(); |
| 135 | + PaymentChannelProvider getPaymentChannelProvider(); |
| 136 | + Signer getSigner(); |
| 137 | + T getGrpcStub(Function<Channel, T> constructor); |
| 138 | + void shutdownNow(); |
| 139 | + } |
| 140 | + |
| 141 | + class BaseServiceClient |
| 142 | + ServiceClient <|.. BaseServiceClient |
| 143 | + BaseServiceClient *-- DaemonConnection |
| 144 | + BaseServiceClient *-- MetadataProvider |
| 145 | + BaseServiceClient *-- PaymentChannelProvider |
| 146 | + BaseServiceClient *-- PaymentStrategy |
| 147 | + BaseServiceClient *-- Signer |
| 148 | + |
| 149 | +} |
| 150 | + |
| 151 | +@enduml |
| 152 | + |
0 commit comments