-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from onflow/get-execution-data
Examples use-cases - get execution data
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...in/java/org/onflow/examples/java/getExecutionData/GetExecutionDataAccessAPIConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.onflow.examples.java.getExecutionData; | ||
|
||
import org.onflow.flow.sdk.FlowAccessApi; | ||
import org.onflow.flow.sdk.FlowExecutionResult; | ||
import org.onflow.flow.sdk.FlowId; | ||
|
||
public class GetExecutionDataAccessAPIConnector { | ||
private final FlowAccessApi accessAPI; | ||
|
||
public GetExecutionDataAccessAPIConnector(FlowAccessApi accessAPI) { | ||
this.accessAPI = accessAPI; | ||
} | ||
|
||
public FlowExecutionResult getExecutionDataByBlockId(FlowId blockId) { | ||
FlowAccessApi.AccessApiCallResponse<FlowExecutionResult> response = accessAPI.getExecutionResultByBlockId(blockId); | ||
if (response instanceof FlowAccessApi.AccessApiCallResponse.Success) { | ||
return ((FlowAccessApi.AccessApiCallResponse.Success<FlowExecutionResult>) response).getData(); | ||
} else { | ||
FlowAccessApi.AccessApiCallResponse.Error errorResponse = (FlowAccessApi.AccessApiCallResponse.Error) response; | ||
throw new RuntimeException(errorResponse.getMessage(), errorResponse.getThrowable()); | ||
} | ||
} | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
.../kotlin/org/onflow/examples/kotlin/getExecutionData/GetExecutionDataAccessAPIConnector.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.onflow.examples.kotlin.getExecutionData | ||
|
||
import org.onflow.flow.sdk.* | ||
|
||
internal class GetExecutionDataAccessAPIConnector(private val accessAPI: FlowAccessApi) { | ||
fun getExecutionDataByBlockId(blockId: FlowId): FlowExecutionResult { | ||
return when (val response = accessAPI.getExecutionResultByBlockId(blockId)) { | ||
is FlowAccessApi.AccessApiCallResponse.Success -> response.data | ||
is FlowAccessApi.AccessApiCallResponse.Error -> throw Exception(response.message, response.throwable) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters