Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 4 additions & 4 deletions flow/src/commonMain/kotlin/org/onflow/flow/FlowApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -71,7 +71,7 @@ class FlowApi(val chainId: ChainIdProvider) {
arguments: List<Cadence.Value>? = 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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions flow/src/commonMain/kotlin/org/onflow/flow/apis/BlocksApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ScriptsApi(val baseUrl: String) : ApiBase() {
arguments: List<Cadence.Value>? = null,
blockId: String? = null,
blockHeight: String? = null,
blockStatus: BlockStatus = BlockStatus.SEALED
blockStatus: BlockStatus = BlockStatus.FINAL
): Cadence.Value {
val request = ScriptsPostRequest(
script.encodeBase64(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
Expand Down
Loading