diff --git a/we-node-client-http/we-node-client-feign-client/src/main/kotlin/com/wavesenterprise/sdk/node/client/feign/tx/FeignTxService.kt b/we-node-client-http/we-node-client-feign-client/src/main/kotlin/com/wavesenterprise/sdk/node/client/feign/tx/FeignTxService.kt index 305d3a69..fbf9068c 100644 --- a/we-node-client-http/we-node-client-feign-client/src/main/kotlin/com/wavesenterprise/sdk/node/client/feign/tx/FeignTxService.kt +++ b/we-node-client-http/we-node-client-feign-client/src/main/kotlin/com/wavesenterprise/sdk/node/client/feign/tx/FeignTxService.kt @@ -29,7 +29,7 @@ class FeignTxService( override fun txInfo(txId: TxId): Optional = weTxApiFeign.txInfo(txId.asBase58String()).map { TxInfo( - height = Height(requireNotNull(it.height) { "Height should be present when getting txInfo" }), + height = Height(checkNotNull(it.height) { "Height should be present when getting txInfo" }), tx = it.toDomain() ) } diff --git a/we-tx-signer/we-tx-signer-node/src/main/kotlin/com/wavesenterprise/sdk/tx/signer/node/credentials/ThreadLocalSignCredentialsProvider.kt b/we-tx-signer/we-tx-signer-node/src/main/kotlin/com/wavesenterprise/sdk/tx/signer/node/credentials/ThreadLocalSignCredentialsProvider.kt deleted file mode 100644 index fd67afdf..00000000 --- a/we-tx-signer/we-tx-signer-node/src/main/kotlin/com/wavesenterprise/sdk/tx/signer/node/credentials/ThreadLocalSignCredentialsProvider.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.wavesenterprise.sdk.tx.signer.node.credentials - -class ThreadLocalSignCredentialsProvider : SignCredentialsProvider, SpecifiedCredentials { - private val threadLocal: ThreadLocal = ThreadLocal() - - override fun withCredentials(creds: Credentials, fn: () -> T): T = - try { - threadLocal.set(creds) - fn() - } finally { - threadLocal.remove() - } - - override fun credentials(): Credentials = requireNotNull(threadLocal.get()) { "Credentials haven't been set" } -} diff --git a/we-tx-signer/we-tx-signer-node/src/main/kotlin/com/wavesenterprise/sdk/tx/signer/node/factory/TxServiceTxSignerFactory.kt b/we-tx-signer/we-tx-signer-node/src/main/kotlin/com/wavesenterprise/sdk/tx/signer/node/factory/TxServiceTxSignerFactory.kt new file mode 100644 index 00000000..e012d6d8 --- /dev/null +++ b/we-tx-signer/we-tx-signer-node/src/main/kotlin/com/wavesenterprise/sdk/tx/signer/node/factory/TxServiceTxSignerFactory.kt @@ -0,0 +1,17 @@ +package com.wavesenterprise.sdk.tx.signer.node.factory + +import com.wavesenterprise.sdk.node.domain.blocking.tx.TxService +import com.wavesenterprise.sdk.tx.signer.TxSigner +import com.wavesenterprise.sdk.tx.signer.node.TxServiceTxSigner +import com.wavesenterprise.sdk.tx.signer.node.credentials.Credentials +import com.wavesenterprise.sdk.tx.signer.node.credentials.DefaultSignCredentialsProvider + +class TxServiceTxSignerFactory( + private val txService: TxService, +) { + fun withCredentials(credentials: Credentials): TxSigner = + TxServiceTxSigner( + txService = txService, + signCredentialsProvider = DefaultSignCredentialsProvider(credentials), + ) +}