-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add interactive ABI for calling contract methods #6
Conversation
This reverts commit 8e37f8f.
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.
This is super cool! Played with it and it feels really nice! Out of the scope for this PR but maybe having a drop-down or something to select desired forc/compiler version could be cool.
setResults([<>Add some code to compile.</>]); | ||
return; | ||
} | ||
|
||
setResults([<>Compiling...</>]); | ||
|
||
// TODO: Determine the URL based on the NODE_ENV. | ||
const server_uri = 'https://api.sway-playground.org/compile'; | ||
// const server_uri = 'https://127.0.0.1/compile'; |
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.
Should we keep this line seems like left from debugging
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.
This prints Compiling...
in the console that the user sees, so it's useful to keep it in :)
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.
Oh I meant line 48, but nothing important 🙌
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.
Also had a play around and it feels really cool to play with.
Great work
Agreed! #10 |
Based on the idea from https://github.com/FuelLabs/sway-playground/pull/2/files
This PR adds an "Interact" button that opens a drawer with the ability to call all of the functions in the ABI. For complex arguments (enums, structs, vectors, and options), there is a JSON editor where the user can supply the input. The JSON editor has a default value populated based on the schema of the input, making it easier to tell what a proper input should look like.
Also restyled the compile button, replaced the logo with the sway logo, and fixed a DOM error by importing
'ace-builds/webpack-resolver'
before other ace-build imports.Tested locally with the production build to make sure it's all working with the static webpack JS. It's deployed here if you want to play with it: https://sway-playground-sdankel.vercel.app/
To test it locally, just do:
Consistency with Fuel UI
I decided not to use
fuel-ui/react
since it added 4MB to the bundle size (without it, it's <2MB). Bundle size is important since it affects how fast the app feels to the users. 6MB is very large. The majority of the size came from thephosphorus
dependency infuel-ui/react
, which imports ALL of the phosphorus icons into the browser. As an alternative I used Material UI which allows you to import only the icons you need.I would like to use the shared fuel React components, but not at the cost of making the app run unnecessarily slow. I would suggest that we switch
fuel-ui/react
to use Material UI for icons (and maybe other components!?) since it makes it easy to optimize bundle size, it looks good, has great documentation, and is totally free.I did use
fuel-ui/css
for the colors.Follow up: #8
Feedback
From @SilentCicero
forc test
#7Getting to the interact panel: compile & deploy
Dry run call (default)
Live call