-
Notifications
You must be signed in to change notification settings - Fork 9
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
Use sim for data fetching #16
base: main
Are you sure you want to change the base?
Conversation
@ilamanov is attempting to deploy a commit to the fiveoutofnine's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
||
// data.columns will be ['block_number', 'from_addr', 'to_addr', 'value', 'message', 'msg_time', 'txn_hash'] | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm now just manually extracting the fields of row
here but the proper way to do it is by parsing the following types:
// This contains the query result from database, based on the connected query component and
// parameters in the request.
message QueryResponse {
// The header for the result set, i.e. the column names.
repeated string columns = 1;
message Row {
repeated Value value = 1;
}
// The result rows.
repeated Row rows = 2;
// If true, the result set was truncated due to exceeding the maximum allowed size.
bool truncated = 3;
// The time it took to execute the query in milliseconds.
uint64 execution_time_ms = 4;
}
message Value {
oneof value {
uint64 uint64 = 1;
int64 int64 = 2;
// These 2 fields are decimal strings like "43981".
string uint256 = 3;
string int256 = 4;
// These 3 fields are 0x-prefixed hex strings like "0xabcd".
string address = 5;
string bytes32 = 6;
string bytes = 7;
string string = 8;
bool bool = 9;
uint32 uint32 = 10;
int32 int32 = 11;
float float32 = 12;
double float64 = 13;
// This field is a decimal string like "3.14".
string big_decimal = 14;
string json = 15;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also request a proto directly from our backend by using protobufs or even a compressed JSON via the 'Accept-Encoding': '*'
header in your JSON request
// data.columns will be ['block_number', 'from_addr', 'to_addr', 'value', 'message', 'msg_time', 'txn_hash'] | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return rows.map((row: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same type parsing is required here as above
We use 2 pretty simple API endpoints for
fetchRecentMessages
and :fetchConversation
.The backend of these API endpoints is this canvas built using https://sim.io:
https://studio.sim.io/sim/canvases/9bd2632b-a0f4-40db-84c1-985c866e997e
Demo
demo-tx-cool.mp4