[2] Add TUI messages#103
Conversation
| @as("version") envioVersion: string, | ||
| @as("apiToken") hasApiToken: bool, | ||
| usesHyperSync: bool, | ||
| config: ConfigYAML.t, |
There was a problem hiding this comment.
@DZakh note I aded "usesHyperSync" field so no extra parsing is needed on the server side yet. I'm still sending across the reduced ConfigYAML (redacted addresses and rpc secrets etc) to allow us to parse info if we need for messaging later on.
| | Err(_) => | ||
| <Message message={kind: Destructive, content: "Failed to load messages from envio server"} /> | ||
| }} |
There was a problem hiding this comment.
Do we actually want to show that there's a failure? It's not important to display if there is but my only concern is it would go by undetected as it would present the same as no messages at all.
There was a problem hiding this comment.
Maybe we should implement something like envio.dev/app/hyperindex/send-error and integrate it with Sentry?
2c4e448 to
9012eab
Compare
c0c4c8e to
293939a
Compare
| Dotenv.initialize() | ||
|
|
There was a problem hiding this comment.
Dotenv now gets initialized in the Env.res file before safe Env.
| S.object(s => { | ||
| s.tag("kind", "Rpc") | ||
| //Do not share users private rpc details | ||
| Rpc(Js.Nullable.Null->Utils.magic) | ||
| }), |
There was a problem hiding this comment.
@DZakh maybe you have some wisdom for how this should look? I want to be able to serialize this to share that it is using an RPC without any of the other values associated with the provider (in this case just a URL)
It's obviously not deserializeable with the same schema but currently don't need deserialization
bd8e843 to
e2a4082
Compare
0a0284f to
eb25e09
Compare
| envioVersion: s.field("version", S.string), | ||
| hasApiToken: s.fieldOr("apiToken", S.bool, false), | ||
| usesHyperSync: s.field("usesHyperSync", S.bool), | ||
| config: s.field("config", ConfigYAML.schema), |
There was a problem hiding this comment.
| envioVersion: s.field("version", S.string), | |
| hasApiToken: s.fieldOr("apiToken", S.bool, false), | |
| usesHyperSync: s.field("usesHyperSync", S.bool), | |
| config: s.field("config", ConfigYAML.schema), | |
| envioVersion: s.field("version", S.string), | |
| apiToken: s.field("apiToken", S.option<S.string>), // Send the token itself | |
| hyperSync: s.field("hyperSync", S.bool), // I don't like the uses prefix for some reason :) How about simply sending hyperSync or poweredByHyperSync? | |
| // config: s.field("config", ConfigYAML.schema), | |
| // Instead of the schema we decided to send: | |
| ecosystem: s.field("ecosystem", S.union([S.literal("evm"), S.literal("fuel")])), | |
| chainIds: s.field("chainIds", S.array(S.int)) |
| PersistedState.getPersistedState()->Belt.Result.mapWithDefault("unknown", ps => | ||
| ps.envioVersion | ||
| ) |
There was a problem hiding this comment.
Maybe we should better send it as optional?
There was a problem hiding this comment.
Sure, it just needs to be updated on the server as well
| let makeAppState = (globalState: GlobalState.t): EnvioInkApp.appState => { | ||
| open Belt | ||
| { | ||
| config: globalState.config->ConfigYAML.fromConfig(~shouldRemoveAddresses=true), |
There was a problem hiding this comment.
Let's not send config and remove all the parsing
* Add hypersync api key environment variable * Make env api token optional and default in client
Rename hypersyncApiToken to envioApiToken
eb25e09 to
9a1b3eb
Compare
There was a problem hiding this comment.
Looks good. The only think I'd like to have is a white colored message.
And, also I think it's good to design messages compatible to Ink API:
type message = {
kind: "text"
color: "primary" | "secondary" | "info" | "danger" | ...
content: string
}
So it's easier to understand which color the notification will has, and gives us a possibility to add more complex notifications in the future.
And I left a comment on the ecosystem format we want to pass, which will also require change in the PR.
| } | ||
| } | ||
|
|
||
| type messageKind = | @as("warning") Warning | @as("destructive") Destructive | @as("info") Info |
There was a problem hiding this comment.
Let's also add a general message to use it as fallback, in case we want to add a new kind in the future. For example, we can have it white.
| } | ||
|
|
||
| let messageSchema = S.object(s => { | ||
| kind: s.field("kind", S.union([S.literal(Warning), S.literal(Destructive), S.literal(Info)])), |
There was a problem hiding this comment.
| kind: s.field("kind", S.union([S.literal(Warning), S.literal(Destructive), S.literal(Info)])), | |
| kind: s.field("kind", S.union([S.literal(Warning), S.literal(Destructive), S.literal(Info), S.string->S.variant(_ => General)])), |
There was a problem hiding this comment.
Ah, well, we can handle it on the server, since we know the version. But I think it's still nice to have a white colored message.
| | Warning => Secondary | ||
| | Info => Info | ||
| | Destructive => Danger |
There was a problem hiding this comment.
Let's use the same names as Ink does, so it makes more sense? 🤔
There was a problem hiding this comment.
Yeah lets do that 👍🏼
9a1b3eb to
1c71612
Compare
| let toTheme = (color: messageColor): Style.chalkTheme => | ||
| switch color { |
There was a problem hiding this comment.
They are not the same underlying string though...


See screenshots below demoing multiple messages of different types, failure to load message and current message that is deployed with the API