Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PKG -- [transport-grpc] Add blockId to transaction status #1206

Merged
merged 16 commits into from
Jun 1, 2022
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
5 changes: 5 additions & 0 deletions .changeset/green-berries-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@onflow/transport-grpc": minor
---

Added blockId to transport-grpc transaction status
5 changes: 5 additions & 0 deletions .changeset/mean-students-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@onflow/protobuf": minor
---

Updated & regenerated protobuf definitions to match current access node specification
1 change: 1 addition & 0 deletions docs/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,7 @@ A builder function that returns the status of transaction.

| Name | Type | Description |
| ------------------------ | ------------------------------------------ | --------------------------------------------------------------- |
| `blockId` | string | ID of the block that contains the transaction. |
| `events` | [[EventObject]](#event-object) | An array of events that were emitted during the transaction. |
| `status` | [TransactionStatus](#transaction-statuses) | The status of the transaction on the blockchain. |
| `statusString` **alpha** | [TransactionStatus](#transaction-statuses) | The `status` as as descriptive text (e.g. "FINALIZED"). |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const STATUS_MAP = {
}

const u8ToHex = (u8, context) => context.Buffer.from(u8).toString("hex")
const nonEmptyU8ToHex = (u8, context) =>
!u8.reduce((empty, b) => empty && !b, true) ? u8ToHex(u8, context) : null
const hexBuffer = (hex, context) => context.Buffer.from(hex, "hex")

export async function sendGetTransactionStatus(ix, context = {}, opts = {}) {
Expand Down Expand Up @@ -47,7 +49,7 @@ export async function sendGetTransactionStatus(ix, context = {}, opts = {}) {
let ret = context.response()
ret.tag = ix.tag
ret.transactionStatus = {
blockId: null,
blockId: nonEmptyU8ToHex(res.getBlockId_asU8(), context),
status: res.getStatus(),
statusString: STATUS_MAP[res.getStatus()],
statusCode: res.getStatusCode(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Get Transaction Status", () => {
const unaryMock = jest.fn()

const returnedTransactionStatus = {
blockId: null,
blockId: "aafb34",
status: 2,
statusString: "FINALIZED",
statusCode: 0,
Expand All @@ -49,6 +49,7 @@ describe("Get Transaction Status", () => {
}

unaryMock.mockReturnValue({
getBlockId_asU8: () => hexStrToUInt8Array("aafb34"),
getStatus: () => 2,
getStatusCode: () => 0,
getErrorMessage: () => "No Error",
Expand Down