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

Use sim for data fetching #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ilamanov
Copy link

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

Copy link

vercel bot commented Aug 29, 2024

@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
Copy link
Author

@ilamanov ilamanov Aug 29, 2024

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;
  }
}

Copy link
Author

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) => {
Copy link
Author

@ilamanov ilamanov Aug 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant