Display different views
- For example, I have a form where my users can enter values into an input and submit a transaction. Then, I want to display a success message once a transaction is successful.
- I have two different views. Let's call them form and success.
prompt :-
get(view, form),
show [
text('ETH -> WETH'),
input(eth, eth),
button('WRAP', [
get(input/eth, ETH),
call_fn(weth, deposit, [ value(eth(ETH)) ], []),
set(view, success).
])
].
- The prompt above is displayed only if the view is set to form.
- The view switches to success once the user clicks on the "WRAP" button and the deposit transaction is minted successfully.
prompt :-
get(view, success),
show[
text('ETH successfully swapped!'),
button('New Swap', [ set(view, form) ])
].
- The prompt above is displayed only if the view is set to success.
- When the user clicks on the "New Swap" button he will set back the view to form.
Last modified 1yr ago