From ae0600a0d847dd6f994dce931e05106e03b7747e Mon Sep 17 00:00:00 2001 From: dgeorgiev Date: Mon, 25 Mar 2024 12:31:20 +0000 Subject: [PATCH 1/2] [WTCH-195] Add catching DataKeyNotExistException for getting DataEntry from contract --- gradle.properties | 2 +- .../sdk/contract/core/state/ContractStateReaderIml.kt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index f12f95b..7107a92 100644 --- a/gradle.properties +++ b/gradle.properties @@ -35,7 +35,7 @@ mockkVersion=1.12.3 springMockkVersion=3.1.1 # WE SDK -weNodeClientVersion=1.1.0 +weNodeClientVersion=1.2.9-db0566e3-SNAPSHOT # GitHub properties gitHubProject = "waves-enterprise/we-contract-sdk" diff --git a/we-contract-sdk-core/src/main/kotlin/com/wavesenterprise/sdk/contract/core/state/ContractStateReaderIml.kt b/we-contract-sdk-core/src/main/kotlin/com/wavesenterprise/sdk/contract/core/state/ContractStateReaderIml.kt index 0e339d3..710e33e 100644 --- a/we-contract-sdk-core/src/main/kotlin/com/wavesenterprise/sdk/contract/core/state/ContractStateReaderIml.kt +++ b/we-contract-sdk-core/src/main/kotlin/com/wavesenterprise/sdk/contract/core/state/ContractStateReaderIml.kt @@ -13,6 +13,7 @@ import com.wavesenterprise.sdk.contract.core.state.mapping.ReadMappingForType import com.wavesenterprise.sdk.contract.core.state.mapping.ReadMappingForTypeReference import com.wavesenterprise.sdk.node.domain.DataEntry import com.wavesenterprise.sdk.node.domain.contract.ContractId +import com.wavesenterprise.sdk.node.exception.specific.DataKeyNotExistException import java.util.Optional class ContractStateReaderIml( @@ -90,7 +91,11 @@ class ContractStateReaderIml( } private fun getKeyValue(key: String): DataEntry? = - backingMap[key] ?: nodeContractStateValuesProvider.getForKeyAsNullable(contractId, key)?.also { backingMap[key] = it } + try { + backingMap[key] ?: nodeContractStateValuesProvider.getForKeyAsNullable(contractId, key)?.also { backingMap[key] = it } + } catch (ex: DataKeyNotExistException) { + null + } private fun getNullableValue(key: String, valueType: Class): T? = getKeyValue(key)?.run { From 8c519498b83773e93d18ea00c51e85636e6a8228 Mon Sep 17 00:00:00 2001 From: dgeorgiev Date: Thu, 28 Mar 2024 14:59:26 +0300 Subject: [PATCH 2/2] Set latest we-node-client version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 7107a92..f7109f7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -35,7 +35,7 @@ mockkVersion=1.12.3 springMockkVersion=3.1.1 # WE SDK -weNodeClientVersion=1.2.9-db0566e3-SNAPSHOT +weNodeClientVersion=1.3.1 # GitHub properties gitHubProject = "waves-enterprise/we-contract-sdk"