Skip to content

Commit

Permalink
Update GRCP status entries (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartolomej authored Aug 9, 2023
1 parent d5cd71a commit f34e745
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 97 deletions.
18 changes: 2 additions & 16 deletions frontend/src/components/status/GrcpStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,9 @@ function GrcpStatusIcon(props: { statusCode: GrcpStatusCode | undefined }) {
switch (props.statusCode) {
case GrcpStatusCode.GRCP_STATUS_OK:
return <SealedIcon />;
case GrcpStatusCode.GRCP_STATUS_CANCELLED:
case GrcpStatusCode.GRCP_STATUS_INVALID_ARGUMENT:
case GrcpStatusCode.GRCP_STATUS_DEADLINE_EXCEEDED:
case GrcpStatusCode.GRCP_STATUS_NOT_FOUND:
case GrcpStatusCode.GRCP_STATUS_ALREADY_EXISTS:
case GrcpStatusCode.GRCP_STATUS_PERMISSION_DENIED:
case GrcpStatusCode.GRCP_STATUS_RESOURCE_EXHAUSTED:
case GrcpStatusCode.GRCP_STATUS_FAILED_PRECONDITION:
case GrcpStatusCode.GRCP_STATUS_ABORTED:
case GrcpStatusCode.GRCP_STATUS_OUT_OF_RANGE:
case GrcpStatusCode.GRCP_STATUS_UNIMPLEMENTED:
case GrcpStatusCode.GRCP_STATUS_INTERNAL:
case GrcpStatusCode.GRCP_STATUS_UNAVAILABLE:
case GrcpStatusCode.GRCP_STATUS_DATA_LOSS:
case GrcpStatusCode.GRCP_STATUS_UNAUTHENTICATED:
case GrcpStatusCode.GRCP_STATUS_FAILED:
return <ExpiredIcon />;
case GrcpStatusCode.GRCP_STATUS_UNKNOWN:
case GrcpStatusCode.UNRECOGNIZED:
default:
return <UnknownIcon />;
}
Expand Down
34 changes: 3 additions & 31 deletions frontend/src/components/status/GrcpStatusBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,49 +29,21 @@ export const GrcpStatusBadge: FunctionComponent<GrcpStatusBadgeProps> = ({

function getBackground(statusCode: GrcpStatusCode | undefined) {
switch (statusCode) {
case GrcpStatusCode.GRCP_STATUS_ABORTED:
case GrcpStatusCode.GRCP_STATUS_CANCELLED:
case GrcpStatusCode.GRCP_STATUS_UNAVAILABLE:
case GrcpStatusCode.GRCP_STATUS_UNAUTHENTICATED:
case GrcpStatusCode.GRCP_STATUS_DEADLINE_EXCEEDED:
case GrcpStatusCode.GRCP_STATUS_ALREADY_EXISTS:
case GrcpStatusCode.GRCP_STATUS_FAILED_PRECONDITION:
case GrcpStatusCode.GRCP_STATUS_INVALID_ARGUMENT:
case GrcpStatusCode.GRCP_STATUS_OUT_OF_RANGE:
case GrcpStatusCode.GRCP_STATUS_INTERNAL:
case GrcpStatusCode.GRCP_STATUS_UNIMPLEMENTED:
case GrcpStatusCode.GRCP_STATUS_DATA_LOSS:
case GrcpStatusCode.GRCP_STATUS_PERMISSION_DENIED:
case GrcpStatusCode.GRCP_STATUS_RESOURCE_EXHAUSTED:
case GrcpStatusCode.GRCP_STATUS_FAILED:
return "#dd868b";
case GrcpStatusCode.GRCP_STATUS_OK:
return "#A2CE8D";
case GrcpStatusCode.GRCP_STATUS_UNKNOWN:
default:
return "#D0D2D6";
}
}

function getTextColor(statusCode: GrcpStatusCode | undefined) {
switch (statusCode) {
case GrcpStatusCode.GRCP_STATUS_ABORTED:
case GrcpStatusCode.GRCP_STATUS_CANCELLED:
case GrcpStatusCode.GRCP_STATUS_UNAVAILABLE:
case GrcpStatusCode.GRCP_STATUS_UNAUTHENTICATED:
case GrcpStatusCode.GRCP_STATUS_DEADLINE_EXCEEDED:
case GrcpStatusCode.GRCP_STATUS_ALREADY_EXISTS:
case GrcpStatusCode.GRCP_STATUS_FAILED_PRECONDITION:
case GrcpStatusCode.GRCP_STATUS_INVALID_ARGUMENT:
case GrcpStatusCode.GRCP_STATUS_OUT_OF_RANGE:
case GrcpStatusCode.GRCP_STATUS_INTERNAL:
case GrcpStatusCode.GRCP_STATUS_UNIMPLEMENTED:
case GrcpStatusCode.GRCP_STATUS_DATA_LOSS:
case GrcpStatusCode.GRCP_STATUS_PERMISSION_DENIED:
case GrcpStatusCode.GRCP_STATUS_RESOURCE_EXHAUSTED:
return "#FFFFF";
case GrcpStatusCode.GRCP_STATUS_OK:
return "#218300";
case GrcpStatusCode.GRCP_STATUS_UNKNOWN:
case GrcpStatusCode.GRCP_STATUS_FAILED:
return "#FFFFF";
default:
return "#D0D2D6";
}
Expand Down
36 changes: 3 additions & 33 deletions frontend/src/utils/flow-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,10 @@ export class FlowUtils {
switch (statusCode) {
case GrcpStatusCode.GRCP_STATUS_OK:
return "Ok";
case GrcpStatusCode.GRCP_STATUS_CANCELLED:
return "Cancelled";
case GrcpStatusCode.GRCP_STATUS_UNKNOWN:
return "Unknown";
case GrcpStatusCode.GRCP_STATUS_INVALID_ARGUMENT:
return "Invalid argument";
case GrcpStatusCode.GRCP_STATUS_DEADLINE_EXCEEDED:
return "Deadline exceeded";
case GrcpStatusCode.GRCP_STATUS_NOT_FOUND:
return "Not found";
case GrcpStatusCode.GRCP_STATUS_ALREADY_EXISTS:
return "Already exists";
case GrcpStatusCode.GRCP_STATUS_PERMISSION_DENIED:
return "Permission denied";
case GrcpStatusCode.GRCP_STATUS_RESOURCE_EXHAUSTED:
return "Resource exhausted";
case GrcpStatusCode.GRCP_STATUS_FAILED_PRECONDITION:
return "Failed precondition";
case GrcpStatusCode.GRCP_STATUS_ABORTED:
return "Aborted";
case GrcpStatusCode.GRCP_STATUS_OUT_OF_RANGE:
return "Out of range";
case GrcpStatusCode.GRCP_STATUS_UNIMPLEMENTED:
return "Unimplemented";
case GrcpStatusCode.GRCP_STATUS_INTERNAL:
return "Internal";
case GrcpStatusCode.GRCP_STATUS_UNAVAILABLE:
return "Unavailable";
case GrcpStatusCode.GRCP_STATUS_DATA_LOSS:
return "Data loss";
case GrcpStatusCode.GRCP_STATUS_UNAUTHENTICATED:
return "Unauthenticated";
case GrcpStatusCode.GRCP_STATUS_FAILED:
return "Failed";
default:
return "-";
return "?";
}
}

Expand Down
19 changes: 2 additions & 17 deletions shared/proto/entities/transactions.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,10 @@ enum ExecutionStatusCode {
EXECUTION_STATUS_EXPIRED = 5;
}

// https://grpc.github.io/grpc/core/md_doc_statuscodes.html
// https://github.com/onflow/flow-go/issues/4494#issuecomment-1601995168
enum GrcpStatusCode {
GRCP_STATUS_OK = 0;
GRCP_STATUS_CANCELLED = 1;
GRCP_STATUS_UNKNOWN = 2;
GRCP_STATUS_INVALID_ARGUMENT = 3;
GRCP_STATUS_DEADLINE_EXCEEDED = 4;
GRCP_STATUS_NOT_FOUND = 5;
GRCP_STATUS_ALREADY_EXISTS = 6;
GRCP_STATUS_PERMISSION_DENIED = 7;
GRCP_STATUS_RESOURCE_EXHAUSTED = 8;
GRCP_STATUS_FAILED_PRECONDITION = 9;
GRCP_STATUS_ABORTED = 10;
GRCP_STATUS_OUT_OF_RANGE = 11;
GRCP_STATUS_UNIMPLEMENTED = 12;
GRCP_STATUS_INTERNAL = 13;
GRCP_STATUS_UNAVAILABLE = 14;
GRCP_STATUS_DATA_LOSS = 15;
GRCP_STATUS_UNAUTHENTICATED = 16;
GRCP_STATUS_FAILED = 1;
}

message Transaction {
Expand Down
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,7 @@
"@fingerprintjs/fingerprintjs" "^3.3.6"
"@flowser/backend" "0.0.1"
"@flowser/shared" "0.0.1"
"@onflow/cadence-parser" "^0.26.0"
"@onflow/fcl" "^1.2.0"
"@onflow/types" "^1.0.3"
"@sentry/electron" "^4.0.2"
Expand Down Expand Up @@ -1429,6 +1430,7 @@
"react-timeago" "^6.2.1"
"sqlite3" "^5.0.11"
"typescript" "^4.4.3"
"usehooks-ts" "^2.9.1"
"wait-on" "^6.0.1"
"web-vitals" "^1.1.2"
"yup" "^0.32.11"
Expand Down

0 comments on commit f34e745

Please sign in to comment.