-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/WTCH-185' into 'dev'
[WTCH-185] Add signMessage, verifyMessageSignature to AddressService Closes WTCH-185 See merge request development/we/java-sdk/we-node-client!81
- Loading branch information
Showing
35 changed files
with
845 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
we-node-client-domain/src/main/kotlin/com/wavesenterprise/sdk/node/domain/address/Message.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.wavesenterprise.sdk.node.domain.address | ||
|
||
data class Message(val value: String) { | ||
companion object { | ||
@JvmStatic | ||
fun fromString(value: String): Message = | ||
Message(value) | ||
|
||
inline val String.message: Message get() = Message(this) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...-domain/src/main/kotlin/com/wavesenterprise/sdk/node/domain/address/SignMessageRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.wavesenterprise.sdk.node.domain.address | ||
|
||
import com.wavesenterprise.sdk.node.domain.Password | ||
|
||
data class SignMessageRequest( | ||
val message: Message, | ||
val password: Password, | ||
) |
10 changes: 10 additions & 0 deletions
10
...domain/src/main/kotlin/com/wavesenterprise/sdk/node/domain/address/SignMessageResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.wavesenterprise.sdk.node.domain.address | ||
|
||
import com.wavesenterprise.sdk.node.domain.PublicKey | ||
import com.wavesenterprise.sdk.node.domain.Signature | ||
|
||
data class SignMessageResponse( | ||
val message: Message, | ||
val publicKey: PublicKey, | ||
val signature: Signature, | ||
) |
10 changes: 10 additions & 0 deletions
10
.../main/kotlin/com/wavesenterprise/sdk/node/domain/address/VerifyMessageSignatureRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.wavesenterprise.sdk.node.domain.address | ||
|
||
import com.wavesenterprise.sdk.node.domain.PublicKey | ||
import com.wavesenterprise.sdk.node.domain.Signature | ||
|
||
data class VerifyMessageSignatureRequest( | ||
val message: Message, | ||
val publicKey: PublicKey, | ||
val signature: Signature, | ||
) |
5 changes: 5 additions & 0 deletions
5
...main/kotlin/com/wavesenterprise/sdk/node/domain/address/VerifyMessageSignatureResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.wavesenterprise.sdk.node.domain.address | ||
|
||
data class VerifyMessageSignatureResponse( | ||
val valid: Boolean, | ||
) |
3 changes: 3 additions & 0 deletions
3
we-node-client-error/src/main/kotlin/com/wavesenterprise/sdk/node/exception/NodeErrorCode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...c/main/kotlin/com/wavesenterprise/sdk/node/exception/specific/InvalidPasswordException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.wavesenterprise.sdk.node.exception.specific | ||
|
||
import com.wavesenterprise.sdk.node.exception.NodeError | ||
import com.wavesenterprise.sdk.node.exception.NodeErrorInfoHolder | ||
import com.wavesenterprise.sdk.node.exception.NodeException | ||
|
||
class InvalidPasswordException( | ||
override val nodeError: NodeError, | ||
override val cause: Exception, | ||
) : NodeException(cause), NodeErrorInfoHolder |
10 changes: 10 additions & 0 deletions
10
.../main/kotlin/com/wavesenterprise/sdk/node/exception/specific/InvalidPublicKeyException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.wavesenterprise.sdk.node.exception.specific | ||
|
||
import com.wavesenterprise.sdk.node.exception.NodeError | ||
import com.wavesenterprise.sdk.node.exception.NodeErrorInfoHolder | ||
import com.wavesenterprise.sdk.node.exception.NodeException | ||
|
||
class InvalidPublicKeyException( | ||
override val nodeError: NodeError, | ||
override val cause: Exception, | ||
) : NodeException(cause), NodeErrorInfoHolder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
.../src/main/kotlin/com/wavesenterprise/sdk/node/client/feign/address/FeignAddressService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.wavesenterprise.sdk.node.client.feign.address | ||
|
||
import com.wavesenterprise.sdk.node.client.blocking.address.AddressService | ||
import com.wavesenterprise.sdk.node.client.http.DataEntryDto.Companion.toDomain | ||
import com.wavesenterprise.sdk.node.client.http.address.AddressDto.Companion.toDomain | ||
import com.wavesenterprise.sdk.node.client.http.address.SignMessageRequestDto.Companion.toDto | ||
import com.wavesenterprise.sdk.node.client.http.address.SignMessageResponseDto.Companion.toDomain | ||
import com.wavesenterprise.sdk.node.client.http.address.VerifyMessageSignatureRequestDto.Companion.toDto | ||
import com.wavesenterprise.sdk.node.client.http.address.VerifyMessageSignatureResponseDto.Companion.toDomain | ||
import com.wavesenterprise.sdk.node.domain.Address | ||
import com.wavesenterprise.sdk.node.domain.DataEntry | ||
import com.wavesenterprise.sdk.node.domain.DataKey | ||
import com.wavesenterprise.sdk.node.domain.PublicKey | ||
import com.wavesenterprise.sdk.node.domain.address.SignMessageRequest | ||
import com.wavesenterprise.sdk.node.domain.address.SignMessageResponse | ||
import com.wavesenterprise.sdk.node.domain.address.VerifyMessageSignatureRequest | ||
import com.wavesenterprise.sdk.node.domain.address.VerifyMessageSignatureResponse | ||
import com.wavesenterprise.sdk.node.exception.specific.DataKeyNotExistsException | ||
import java.util.Optional | ||
|
||
class FeignAddressService( | ||
private val weAddressServiceApiFeign: WeAddressServiceApiFeign, | ||
) : AddressService { | ||
override fun getAddresses(): List<Address> = | ||
weAddressServiceApiFeign.getAddresses().map { it.toDomain() } | ||
|
||
override fun getAddressByPublicKey(publicKey: PublicKey): Address = | ||
weAddressServiceApiFeign.getAddressByPublicKey(publicKey.asBase58String()).toDomain() | ||
|
||
override fun getAddressValue(address: Address, key: DataKey): Optional<DataEntry> = | ||
try { | ||
weAddressServiceApiFeign.getAddressValue( | ||
address = address.asBase58String(), | ||
key = key.value, | ||
).map { it.toDomain() } | ||
} catch (ex: DataKeyNotExistsException) { | ||
Optional.empty() | ||
} | ||
|
||
override fun getAddressValues(address: Address): List<DataEntry> = | ||
weAddressServiceApiFeign.getAddressValues(address.asBase58String()).map { it.toDomain() } | ||
|
||
override fun signMessage( | ||
address: Address, | ||
request: SignMessageRequest | ||
): SignMessageResponse = | ||
weAddressServiceApiFeign.signMessage( | ||
address = address.asBase58String(), | ||
request = request.toDto(), | ||
).toDomain() | ||
|
||
override fun verifyMessageSignature( | ||
address: Address, | ||
request: VerifyMessageSignatureRequest | ||
): VerifyMessageSignatureResponse = | ||
weAddressServiceApiFeign.verifyMessageSignature( | ||
address = address.asBase58String(), | ||
request = request.toDto(), | ||
).toDomain() | ||
} |
44 changes: 44 additions & 0 deletions
44
...main/kotlin/com/wavesenterprise/sdk/node/client/feign/address/WeAddressServiceApiFeign.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.wavesenterprise.sdk.node.client.feign.address | ||
|
||
import com.wavesenterprise.sdk.node.client.http.DataEntryDto | ||
import com.wavesenterprise.sdk.node.client.http.address.AddressDto | ||
import com.wavesenterprise.sdk.node.client.http.address.SignMessageRequestDto | ||
import com.wavesenterprise.sdk.node.client.http.address.SignMessageResponseDto | ||
import com.wavesenterprise.sdk.node.client.http.address.VerifyMessageSignatureRequestDto | ||
import com.wavesenterprise.sdk.node.client.http.address.VerifyMessageSignatureResponseDto | ||
import feign.Headers | ||
import feign.Param | ||
import feign.RequestLine | ||
import java.util.Optional | ||
|
||
interface WeAddressServiceApiFeign { | ||
|
||
@RequestLine("GET /addresses") | ||
fun getAddresses(): List<String> | ||
|
||
@RequestLine("GET /addresses/publicKey/{publicKey}") | ||
fun getAddressByPublicKey(@Param("publicKey") publicKey: String): AddressDto | ||
|
||
@RequestLine("GET /addresses/data/{address}/{key}") | ||
fun getAddressValue( | ||
@Param("address") address: String, | ||
@Param("key") key: String | ||
): Optional<DataEntryDto> | ||
|
||
@RequestLine("GET /addresses/data/{address}") | ||
fun getAddressValues(@Param("address") address: String): List<DataEntryDto> | ||
|
||
@Headers("Content-Type: application/json") | ||
@RequestLine("POST /addresses/sign/{address}") | ||
fun signMessage( | ||
@Param("address") address: String, | ||
request: SignMessageRequestDto, | ||
): SignMessageResponseDto | ||
|
||
@Headers("Content-Type: application/json") | ||
@RequestLine("POST /addresses/verify/{address}") | ||
fun verifyMessageSignature( | ||
@Param("address") address: String, | ||
request: VerifyMessageSignatureRequestDto, | ||
): VerifyMessageSignatureResponseDto | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
...ent/src/main/kotlin/com/wavesenterprise/sdk/node/client/feign/node/FeignAddressService.kt
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
...rc/main/kotlin/com/wavesenterprise/sdk/node/client/feign/node/WeAddressServiceApiFeign.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.