From 3c18630a822bb5bb4f7deaef43c9285b33616c2a Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Fri, 25 Oct 2024 16:39:02 +0900 Subject: [PATCH 1/4] Rebase main --- .../kotlin/org/onflow/flow/sdk/AsyncFlowAccessApi.kt | 6 +++--- sdk/src/main/kotlin/org/onflow/flow/sdk/FlowAccessApi.kt | 7 +++---- .../org/onflow/flow/sdk/impl/AsyncFlowAccessApiImpl.kt | 9 ++++++--- .../kotlin/org/onflow/flow/sdk/impl/FlowAccessApiImpl.kt | 9 ++++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/sdk/src/main/kotlin/org/onflow/flow/sdk/AsyncFlowAccessApi.kt b/sdk/src/main/kotlin/org/onflow/flow/sdk/AsyncFlowAccessApi.kt index edf2214..a65daa4 100644 --- a/sdk/src/main/kotlin/org/onflow/flow/sdk/AsyncFlowAccessApi.kt +++ b/sdk/src/main/kotlin/org/onflow/flow/sdk/AsyncFlowAccessApi.kt @@ -12,15 +12,15 @@ interface AsyncFlowAccessApi { fun getBlockHeaderByHeight(height: Long): CompletableFuture> - fun getLatestBlock(sealed: Boolean = true): CompletableFuture> + fun getLatestBlock(sealed: Boolean = true, fullBlockResponse: Boolean = false): CompletableFuture> fun getAccountBalanceAtLatestBlock(address: FlowAddress): CompletableFuture> fun getAccountBalanceAtBlockHeight(address: FlowAddress, height: Long): CompletableFuture> - fun getBlockById(id: FlowId): CompletableFuture> + fun getBlockById(id: FlowId, fullBlockResponse: Boolean = false): CompletableFuture> - fun getBlockByHeight(height: Long): CompletableFuture> + fun getBlockByHeight(height: Long, fullBlockResponse: Boolean = false): CompletableFuture> fun getCollectionById(id: FlowId): CompletableFuture> diff --git a/sdk/src/main/kotlin/org/onflow/flow/sdk/FlowAccessApi.kt b/sdk/src/main/kotlin/org/onflow/flow/sdk/FlowAccessApi.kt index 200cda2..9378f30 100644 --- a/sdk/src/main/kotlin/org/onflow/flow/sdk/FlowAccessApi.kt +++ b/sdk/src/main/kotlin/org/onflow/flow/sdk/FlowAccessApi.kt @@ -24,15 +24,14 @@ interface FlowAccessApi { fun getBlockHeaderByHeight(height: Long): AccessApiCallResponse - fun getLatestBlock(sealed: Boolean = true): AccessApiCallResponse + fun getLatestBlock(sealed: Boolean = true, fullBlockResponse: Boolean = false): AccessApiCallResponse + fun getBlockById(id: FlowId, fullBlockResponse: Boolean = false): AccessApiCallResponse fun getAccountBalanceAtLatestBlock(address: FlowAddress): AccessApiCallResponse fun getAccountBalanceAtBlockHeight(address: FlowAddress, height: Long): AccessApiCallResponse - fun getBlockById(id: FlowId): AccessApiCallResponse - - fun getBlockByHeight(height: Long): AccessApiCallResponse + fun getBlockByHeight(height: Long, fullBlockResponse: Boolean = false): AccessApiCallResponse fun getCollectionById(id: FlowId): AccessApiCallResponse diff --git a/sdk/src/main/kotlin/org/onflow/flow/sdk/impl/AsyncFlowAccessApiImpl.kt b/sdk/src/main/kotlin/org/onflow/flow/sdk/impl/AsyncFlowAccessApiImpl.kt index a2366fe..6365f47 100644 --- a/sdk/src/main/kotlin/org/onflow/flow/sdk/impl/AsyncFlowAccessApiImpl.kt +++ b/sdk/src/main/kotlin/org/onflow/flow/sdk/impl/AsyncFlowAccessApiImpl.kt @@ -127,7 +127,7 @@ class AsyncFlowAccessApiImpl( } } - override fun getLatestBlock(sealed: Boolean): CompletableFuture> { + override fun getLatestBlock(sealed: Boolean, fullBlockResponse: Boolean): CompletableFuture> { return try { completableFuture( try { @@ -135,6 +135,7 @@ class AsyncFlowAccessApiImpl( Access.GetLatestBlockRequest .newBuilder() .setIsSealed(sealed) + .setFullBlockResponse(fullBlockResponse) .build() ) } catch (e: Exception) { @@ -203,7 +204,7 @@ class AsyncFlowAccessApiImpl( } } - override fun getBlockById(id: FlowId): CompletableFuture> { + override fun getBlockById(id: FlowId, fullBlockResponse: Boolean): CompletableFuture> { return try { completableFuture( try { @@ -211,6 +212,7 @@ class AsyncFlowAccessApiImpl( Access.GetBlockByIDRequest .newBuilder() .setId(id.byteStringValue) + .setFullBlockResponse(fullBlockResponse) .build() ) } catch (e: Exception) { @@ -232,7 +234,7 @@ class AsyncFlowAccessApiImpl( } } - override fun getBlockByHeight(height: Long): CompletableFuture> { + override fun getBlockByHeight(height: Long, fullBlockResponse: Boolean): CompletableFuture> { return try { completableFuture( try { @@ -240,6 +242,7 @@ class AsyncFlowAccessApiImpl( Access.GetBlockByHeightRequest .newBuilder() .setHeight(height) + .setFullBlockResponse(fullBlockResponse) .build() ) } catch (e: Exception) { diff --git a/sdk/src/main/kotlin/org/onflow/flow/sdk/impl/FlowAccessApiImpl.kt b/sdk/src/main/kotlin/org/onflow/flow/sdk/impl/FlowAccessApiImpl.kt index 256ecbc..6d82f0a 100644 --- a/sdk/src/main/kotlin/org/onflow/flow/sdk/impl/FlowAccessApiImpl.kt +++ b/sdk/src/main/kotlin/org/onflow/flow/sdk/impl/FlowAccessApiImpl.kt @@ -83,12 +83,13 @@ class FlowAccessApiImpl( FlowAccessApi.AccessApiCallResponse.Error("Failed to get block header by height", e) } - override fun getLatestBlock(sealed: Boolean): FlowAccessApi.AccessApiCallResponse = + override fun getLatestBlock(sealed: Boolean, fullBlockResponse: Boolean): FlowAccessApi.AccessApiCallResponse = try { val ret = api.getLatestBlock( Access.GetLatestBlockRequest .newBuilder() .setIsSealed(sealed) + .setFullBlockResponse(fullBlockResponse) .build() ) FlowAccessApi.AccessApiCallResponse.Success(FlowBlock.of(ret.block)) @@ -123,12 +124,13 @@ class FlowAccessApiImpl( FlowAccessApi.AccessApiCallResponse.Error("Failed to get account balance at block height", e) } - override fun getBlockById(id: FlowId): FlowAccessApi.AccessApiCallResponse = + override fun getBlockById(id: FlowId, fullBlockResponse: Boolean): FlowAccessApi.AccessApiCallResponse = try { val ret = api.getBlockByID( Access.GetBlockByIDRequest .newBuilder() .setId(id.byteStringValue) + .setFullBlockResponse(fullBlockResponse) .build() ) if (ret.hasBlock()) { @@ -140,12 +142,13 @@ class FlowAccessApiImpl( FlowAccessApi.AccessApiCallResponse.Error("Failed to get block by ID", e) } - override fun getBlockByHeight(height: Long): FlowAccessApi.AccessApiCallResponse = + override fun getBlockByHeight(height: Long, fullBlockResponse: Boolean): FlowAccessApi.AccessApiCallResponse = try { val ret = api.getBlockByHeight( Access.GetBlockByHeightRequest .newBuilder() .setHeight(height) + .setFullBlockResponse(fullBlockResponse) .build() ) if (ret.hasBlock()) { From 83329dfec2fa9d8d0c1fc75d330897a1685c9f6f Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Fri, 25 Oct 2024 01:32:55 +0900 Subject: [PATCH 2/4] Add fullBlockResponse param --- .../java/getBlock/GetBlockAccessAPIConnector.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/java-example/src/main/java/org/onflow/examples/java/getBlock/GetBlockAccessAPIConnector.java b/java-example/src/main/java/org/onflow/examples/java/getBlock/GetBlockAccessAPIConnector.java index 40751b7..fc115a9 100644 --- a/java-example/src/main/java/org/onflow/examples/java/getBlock/GetBlockAccessAPIConnector.java +++ b/java-example/src/main/java/org/onflow/examples/java/getBlock/GetBlockAccessAPIConnector.java @@ -11,7 +11,8 @@ public GetBlockAccessAPIConnector(FlowAccessApi accessAPI) { public FlowBlock getLatestSealedBlock() { boolean isSealed = true; - FlowAccessApi.AccessApiCallResponse response = accessAPI.getLatestBlock(isSealed); + boolean fullBlockResponse = false; + FlowAccessApi.AccessApiCallResponse response = accessAPI.getLatestBlock(isSealed, fullBlockResponse); if (response instanceof FlowAccessApi.AccessApiCallResponse.Success) { return ((FlowAccessApi.AccessApiCallResponse.Success) response).getData(); @@ -22,7 +23,8 @@ public FlowBlock getLatestSealedBlock() { } public FlowBlock getBlockByID(FlowId blockID) { - FlowAccessApi.AccessApiCallResponse response = accessAPI.getBlockById(blockID); + boolean fullBlockResponse = false; + FlowAccessApi.AccessApiCallResponse response = accessAPI.getBlockById(blockID, fullBlockResponse); if (response instanceof FlowAccessApi.AccessApiCallResponse.Success) { return ((FlowAccessApi.AccessApiCallResponse.Success) response).getData(); @@ -33,7 +35,8 @@ public FlowBlock getBlockByID(FlowId blockID) { } public FlowBlock getBlockByHeight(long height) { - FlowAccessApi.AccessApiCallResponse response = accessAPI.getBlockByHeight(height); + boolean fullBlockResponse = false; + FlowAccessApi.AccessApiCallResponse response = accessAPI.getBlockByHeight(height, fullBlockResponse); if (response instanceof FlowAccessApi.AccessApiCallResponse.Success) { return ((FlowAccessApi.AccessApiCallResponse.Success) response).getData(); From aab430e00ac63ffa94f5cc6c8d6441df83b11dce Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Fri, 25 Oct 2024 01:49:36 +0900 Subject: [PATCH 3/4] Debugging build --- .../java/getCollection/GetCollectionAccessAPIConnectorTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java-example/src/test/java/org/onflow/examples/java/getCollection/GetCollectionAccessAPIConnectorTest.java b/java-example/src/test/java/org/onflow/examples/java/getCollection/GetCollectionAccessAPIConnectorTest.java index 6b3635f..e844ba8 100644 --- a/java-example/src/test/java/org/onflow/examples/java/getCollection/GetCollectionAccessAPIConnectorTest.java +++ b/java-example/src/test/java/org/onflow/examples/java/getCollection/GetCollectionAccessAPIConnectorTest.java @@ -34,7 +34,7 @@ public void setup() { publicKey ); - FlowAccessApi.AccessApiCallResponse response = accessAPI.getLatestBlock(true); + FlowAccessApi.AccessApiCallResponse response = accessAPI.getLatestBlock(true, false); if (response instanceof FlowAccessApi.AccessApiCallResponse.Success) { FlowBlock block = ((FlowAccessApi.AccessApiCallResponse.Success) response).getData(); collectionId = block.getCollectionGuarantees().get(0).getId(); From abffae92d6d0efb7cf620e473b7fbe8f88385f3b Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Fri, 25 Oct 2024 18:37:37 +0900 Subject: [PATCH 4/4] Rebase main --- .../GetAccountBalanceAccessAPIConnectorTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java-example/src/test/java/org/onflow/examples/java/getAccountBalance/GetAccountBalanceAccessAPIConnectorTest.java b/java-example/src/test/java/org/onflow/examples/java/getAccountBalance/GetAccountBalanceAccessAPIConnectorTest.java index 6b0eb15..dffc8f0 100644 --- a/java-example/src/test/java/org/onflow/examples/java/getAccountBalance/GetAccountBalanceAccessAPIConnectorTest.java +++ b/java-example/src/test/java/org/onflow/examples/java/getAccountBalance/GetAccountBalanceAccessAPIConnectorTest.java @@ -39,7 +39,7 @@ public void testCanFetchBalanceAtLatestBlock() { public void testCanFetchBalanceAtSpecificBlockHeight() { FlowAddress address = serviceAccount.getFlowAddress(); - FlowAccessApi.AccessApiCallResponse latestBlockResponse = accessAPI.getLatestBlock(true); + FlowAccessApi.AccessApiCallResponse latestBlockResponse = accessAPI.getLatestBlock(true, false); if (latestBlockResponse instanceof FlowAccessApi.AccessApiCallResponse.Success) { FlowBlock latestBlock = ((FlowAccessApi.AccessApiCallResponse.Success) latestBlockResponse).getData(); @@ -58,7 +58,7 @@ public void testBalancesAtLatestBlockAndSpecificHeightShouldMatch() { FlowAddress address = serviceAccount.getFlowAddress(); long balanceAtLatest = balanceAPIConnector.getBalanceAtLatestBlock(address); - FlowAccessApi.AccessApiCallResponse latestBlockResponse = accessAPI.getLatestBlock(true); + FlowAccessApi.AccessApiCallResponse latestBlockResponse = accessAPI.getLatestBlock(true, false); if (latestBlockResponse instanceof FlowAccessApi.AccessApiCallResponse.Success) { FlowBlock latestBlock = ((FlowAccessApi.AccessApiCallResponse.Success) latestBlockResponse).getData();