diff --git a/build.gradle.kts b/build.gradle.kts index dff683f..6f65ce5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,7 +22,7 @@ allprojects { } group = "org.onflow.flow" - val defaultVersion = "0.0.20" + val defaultVersion = "0.0.21" version = System.getenv("GITHUB_REF")?.split('/')?.last() ?: defaultVersion } diff --git a/flow/src/commonMain/kotlin/org/onflow/flow/FlowApi.kt b/flow/src/commonMain/kotlin/org/onflow/flow/FlowApi.kt index fac1442..b3d0b54 100644 --- a/flow/src/commonMain/kotlin/org/onflow/flow/FlowApi.kt +++ b/flow/src/commonMain/kotlin/org/onflow/flow/FlowApi.kt @@ -29,18 +29,18 @@ class FlowApi(val chainId: ChainIdProvider) { private val scriptsApi = ScriptsApi(baseUrl) private val transactionsApi = TransactionsApi(baseUrl) - suspend fun getAccount(address: String, blockHeight: String? = null, blockStatus: BlockStatus = BlockStatus.SEALED): Account { + suspend fun getAccount(address: String, blockHeight: String? = null, blockStatus: BlockStatus = BlockStatus.FINAL): Account { return accountsApi.getAccount(address, blockHeight, blockStatus) } - suspend fun getBlock(id: String? = null, blockHeight: String? = null, blockStatus: BlockStatus = BlockStatus.SEALED): Block { + suspend fun getBlock(id: String? = null, blockHeight: String? = null, blockStatus: BlockStatus = BlockStatus.FINAL): Block { return blocksApi.getBlock(id, blockHeight, blockStatus) } suspend fun getBlockHeader( id: String? = null, blockHeight: String? = null, - blockStatus: BlockStatus = BlockStatus.SEALED + blockStatus: BlockStatus = BlockStatus.FINAL ): BlockHeader { return blocksApi.getBlockHeader(id, blockHeight, blockStatus) } @@ -71,7 +71,7 @@ class FlowApi(val chainId: ChainIdProvider) { arguments: List? = null, blockId: String? = null, blockHeight: String? = null, - blockStatus: BlockStatus = BlockStatus.SEALED + blockStatus: BlockStatus = BlockStatus.FINAL ): Cadence.Value { return scriptsApi.executeScript(script, arguments, blockId, blockHeight, blockStatus) } diff --git a/flow/src/commonMain/kotlin/org/onflow/flow/apis/AccountsApi.kt b/flow/src/commonMain/kotlin/org/onflow/flow/apis/AccountsApi.kt index 3e18f64..0a474fb 100644 --- a/flow/src/commonMain/kotlin/org/onflow/flow/apis/AccountsApi.kt +++ b/flow/src/commonMain/kotlin/org/onflow/flow/apis/AccountsApi.kt @@ -37,7 +37,7 @@ internal class AccountsApi(val baseUrl: String) : ApiBase() { * @param blockStatus The status of the block to query (FINAL or SEALED). Defaults to FINAL. * @return Account */ - internal suspend fun getAccount(address: String, blockHeight: String? = null, blockStatus: BlockStatus = BlockStatus.SEALED): Account { + internal suspend fun getAccount(address: String, blockHeight: String? = null, blockStatus: BlockStatus = BlockStatus.FINAL): Account { val expand = setOf("contracts", "keys") return if (blockHeight != null) { request(address, blockHeight, expand) diff --git a/flow/src/commonMain/kotlin/org/onflow/flow/apis/BlocksApi.kt b/flow/src/commonMain/kotlin/org/onflow/flow/apis/BlocksApi.kt index 1945f93..26e32a4 100644 --- a/flow/src/commonMain/kotlin/org/onflow/flow/apis/BlocksApi.kt +++ b/flow/src/commonMain/kotlin/org/onflow/flow/apis/BlocksApi.kt @@ -54,7 +54,7 @@ internal class BlocksApi(val baseUrl: String) : ApiBase() { }.body() } - internal suspend fun getBlock(id: String? = null, blockHeight: String? = null, blockStatus: BlockStatus = BlockStatus.SEALED): Block { + internal suspend fun getBlock(id: String? = null, blockHeight: String? = null, blockStatus: BlockStatus = BlockStatus.FINAL): Block { val expand = setOf("payload") return if (id != null) { requestBlocksById(id, expand).first() @@ -68,7 +68,7 @@ internal class BlocksApi(val baseUrl: String) : ApiBase() { internal suspend fun getBlockHeader( id: String? = null, blockHeight: String? = null, - blockStatus: BlockStatus = BlockStatus.SEALED + blockStatus: BlockStatus = BlockStatus.FINAL ): BlockHeader { return getBlock(id, blockHeight, blockStatus).header } diff --git a/flow/src/commonMain/kotlin/org/onflow/flow/apis/ScriptsApi.kt b/flow/src/commonMain/kotlin/org/onflow/flow/apis/ScriptsApi.kt index 7a35d0c..d2e0271 100644 --- a/flow/src/commonMain/kotlin/org/onflow/flow/apis/ScriptsApi.kt +++ b/flow/src/commonMain/kotlin/org/onflow/flow/apis/ScriptsApi.kt @@ -56,7 +56,7 @@ class ScriptsApi(val baseUrl: String) : ApiBase() { arguments: List? = null, blockId: String? = null, blockHeight: String? = null, - blockStatus: BlockStatus = BlockStatus.SEALED + blockStatus: BlockStatus = BlockStatus.FINAL ): Cadence.Value { val request = ScriptsPostRequest( script.encodeBase64(), diff --git a/flow/src/commonMain/kotlin/org/onflow/flow/apis/TransactionsApi.kt b/flow/src/commonMain/kotlin/org/onflow/flow/apis/TransactionsApi.kt index def7aed..cb94e45 100644 --- a/flow/src/commonMain/kotlin/org/onflow/flow/apis/TransactionsApi.kt +++ b/flow/src/commonMain/kotlin/org/onflow/flow/apis/TransactionsApi.kt @@ -100,10 +100,9 @@ internal class TransactionsApi(val baseUrl: String) : ApiBase() { try { val result = getTransactionResult(transactionId) when (result.status ?: TransactionStatus.EMPTY) { - TransactionStatus.SEALED -> { - if (result.errorMessage.isNotBlank() || result.execution == TransactionExecution.failure) { - throw RuntimeException("Transaction failed: ${result.errorMessage}") - } + TransactionStatus.FINALIZED -> { + // Transaction is finalized, return immediately without checking for errors + // since finalized transactions haven't been executed yet return result } @@ -146,9 +145,9 @@ internal class TransactionsApi(val baseUrl: String) : ApiBase() { } val timeoutMessage = if (lastError != null) { - "Transaction not sealed after $maxAttempts attempts. Last error: ${lastError.message}" + "Transaction not finalized after $maxAttempts attempts. Last error: ${lastError.message}" } else { - "Transaction not sealed after $maxAttempts attempts" + "Transaction not finalized after $maxAttempts attempts" } throw RuntimeException(timeoutMessage) }