Commit f3cc2f0
authored
feat(interactive-idl): split tx simulation and execution (#1072)
## Description
Add a "Simulate" button to the interactive IDL instruction UI so users
can simulate an instruction against the RPC without broadcasting.
Extract separate `useExecuteTransaction` and `useSimulateTransaction`
hooks with phase-tagged result types from `useInstruction`.
- Add a `Simulate` button to `InteractInstruction`.
- Add switch for enabling/disabling simulation during `Execute` action.
- Extract transaction logic from `use-instruction.ts` into
`model/transaction/`: `useExecuteTransaction`, `useSimulateTransaction`,
`formatTransactionError`, `serializeTransactionMessage`, and
discriminated result types in `types.ts`.
- Tag execution results by phase (`broadcast_failed`,
`pre_broadcast_failed`) and simulation results by phase
(`rpc_simulation_failed`, `simulation_execution_failed`).
- Replace `TxSuccessStatus` with `TxExecutionStatus` add
`TxSimulationStatus`.
- Move the UTC time format into shared helper `formatLogTimestamp`.
- Split `InstructionActivity` into `InstructionExecutionActivity` and
`InstructionSimulationActivity`. `InteractWithIdlView` renders one or
the other based on the last action taken.
- Rename `invoke`->`execute` to keep it consistent with ui.
- Add analytics event for simulation.
- Fix nulls/any in `use-instruction.ts` and `InstructionActivity.tsx`
and drop them from the eslint legacy-file exclusions.
## Type of change
- [x] New feature
## Screenshots
<img width="880" height="607" alt="image"
src="https://github.com/user-attachments/assets/e3444232-b753-4b84-b7c4-3c44b45cbbf4"
/>
| | |
| :---: | :---: |
| <img width="552" height="441" alt="image"
src="https://github.com/user-attachments/assets/edcd18ca-5808-4035-8b57-1a44012f8eac"
/> | <img width="500" alt="image"
src="https://github.com/user-attachments/assets/0c4b8ec8-300a-4db5-be65-0f8d01ebfaf1"
/> |
| <img width="536" height="543" alt="image"
src="https://github.com/user-attachments/assets/81347345-f0bb-49e0-bc61-4d59c6449e7c"
/> | <img width="540" height="670" alt="image"
src="https://github.com/user-attachments/assets/e31aa2b4-3530-4fd5-9c23-543dbb5a8f57"
/> |
## Testing
#### Programs with IDL:
_References to Vercel Preview will be added once deployment is
finished._
- LMB
[BUYuxRfhCMWavaUWxhGtPP3ksKEDZxCD5gzknk3JfAya](https://explorer-git-fork-hoodieshq-feat-inter-e206b3-solana-foundation.vercel.app/address/ProgM6JCCvbYkfKqJYHePx4xxSUSqJp7rh8Lyv7nk7S/idl)
- Voting
[AXcxp15oz1L4YYtqZo6Qt6EkUj1jtLR6wXYqaJvn4oye](https://explorer-git-fork-hoodieshq-feat-inter-e206b3-solana-foundation.vercel.app/address/AXcxp15oz1L4YYtqZo6Qt6EkUj1jtLR6wXYqaJvn4oye/idl)
- Blog
[4ypHLeD2zDinCMiuHnwpRTwygKDxR5Sn6wbVHy4mbnvE](https://explorer-git-fork-hoodieshq-feat-inter-e206b3-solana-foundation.vercel.app/address/4ypHLeD2zDinCMiuHnwpRTwygKDxR5Sn6wbVHy4mbnvE/idl)
- PMP
[ProgM6JCCvbYkfKqJYHePx4xxSUSqJp7rh8Lyv7nk7S](https://explorer-git-fork-hoodieshq-feat-inter-e206b3-solana-foundation.vercel.app/address/ProgM6JCCvbYkfKqJYHePx4xxSUSqJp7rh8Lyv7nk7S/idl)
<!--
-
[LMB](https://explorer-git-feat-interactive-idl-tx-simulation-hoodies.vercel.app/address/BUYuxRfhCMWavaUWxhGtPP3ksKEDZxCD5gzknk3JfAya/idl?cluster=devnet)
-
[Voting](https://explorer-git-feat-interactive-idl-tx-simulation-hoodies.vercel.app/address/AXcxp15oz1L4YYtqZo6Qt6EkUj1jtLR6wXYqaJvn4oye/?cluster=devnet)
-
[Blog](https://explorer-git-feat-interactive-idl-tx-simulation-hoodies.vercel.app/address/4ypHLeD2zDinCMiuHnwpRTwygKDxR5Sn6wbVHy4mbnvE/?cluster=devnet)
-
[PMP](https://explorer-git-feat-interactive-idl-tx-simulation-hoodies.vercel.app/address/ProgM6JCCvbYkfKqJYHePx4xxSUSqJp7rh8Lyv7nk7S/idl?cluster=devnet)
-->
#### Cases:
- Successful simulation (create a valid ix)
- Failed simulation (create an invalid ix, e.g. simulate same initialize
ix twice)
- Successful execution (create valid ix)
- Failed instruction after broadcast (create invalid ix, click execute,
sign with wallet. This will produce error logs with failed tx)
- Failed instruction before broadcast (e.g. click execute, but reject
signing by wallet)
- Execute with simulation enabled
- Execute with simulation disabled
## Related Issues
- Closes
[HOO-225](https://linear.app/solana-fndn/issue/HOO-225/refactor-use-instruction-and-move-layer-to-send-and-simulate)
- Closes
[HOO-226](https://linear.app/solana-fndn/issue/HOO-226/allow-to-simulate-instruction-as-well-as-execution)
## Checklist
<!-- Verify that you have completed the following before requesting
review -->
- [x] My code follows the project's style guidelines
- [x] I have added tests that prove my fix/feature works
- [x] All tests pass locally and in CI
- [x] I have run `build:info` script to update build information
- [x] CI/CD checks pass
- [x] I have included screenshots for protocol screens (if applicable)
## Additional Notes
<!-- Add any other context about the PR here -->
<!-- For Solana Verify (Verified Builds) related changes, note that bugs
should be reported to disclosures@solana.org -->1 parent 8039c67 commit f3cc2f0
49 files changed
Lines changed: 2417 additions & 633 deletions
File tree
- app
- entities/program-logs
- model
- __tests__
- ui
- __stories__
- features
- cu-profiling/ui
- idl
- interactive-idl
- lib
- model
- transaction
- __tests__
- ui
- __stories__
- __tests__
- model
- instruction-simulation/ui/__stories__
- transaction/ui
- utils
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 1 | + | |
15 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
16 | 14 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
43 | 22 | | |
44 | 23 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
This file was deleted.
0 commit comments