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

feat: Send progress events from Host to Guest #10

Merged
merged 10 commits into from
Aug 26, 2024
Merged

Conversation

binarybaron
Copy link

@binarybaron binarybaron commented Aug 11, 2024

Before merging this we need to:

  • Fix tests
  • Rethink the structs Context, SwapLock, TaurEmitter, OptionalTauriHandle
  • Send event when swap lock is released to allow user to close SwapDialog in GUI
  • Make SwapStateStepper work
  • Make SwapStatusAlert work (on HistoryPage)
  • Make SwapMightBeCancelledAlert on SwapDialog work
  • Remove unused typescript types and helper functions
  • Typeshare definition for BobStateName (display function of BobState)
  • Send event from host to guest when btc lock or xmr lock tx receive confirmation

@binarybaron binarybaron marked this pull request as draft August 11, 2024 22:19
@binarybaron binarybaron force-pushed the tauri-events branch 2 times, most recently from b1d4e93 to 8d6cd69 Compare August 18, 2024 17:52
@binarybaron
Copy link
Author

This PR is getting quite large (+ big scope) while implementing important core functionality. We need to make sure the code here is rock solid.

We should try to merge this as soon as possible with a minimal feature set. Large PRs are hard to review. It's better to add more functionality later with new PRs.

@binarybaron binarybaron force-pushed the tauri-events branch 2 times, most recently from f86833f to 9f46df0 Compare August 20, 2024 12:41
@binarybaron binarybaron changed the title feat: Send events from Host to Guest feat: Send progress events from Host to Guest Aug 25, 2024
@@ -29,6 +30,14 @@ export default function InitPage() {
(state) => state.providers.selectedProvider,
);

async function init() {
await buyXmr(
providerToConcatenatedMultiAddr(selectedProvider),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be called in buy_xmr instead.

src-gui/src/renderer/rpc.ts Outdated Show resolved Hide resolved
src-gui/src/store/features/swapSlice.ts Show resolved Hide resolved
src-tauri/src/lib.rs Outdated Show resolved Hide resolved
swap/src/protocol/bob/swap.rs Outdated Show resolved Hide resolved
@binarybaron
Copy link
Author

I think the last 9 commits or so are mostly a back and forth and can be squashed

…ce Tauri events

- Implement trait-based request handling in api/request.rs
- Add Tauri bindings and event system in api/tauri_bindings.rs
- Refactor CLI command parsing and execution in cli/command.rs
- Update RPC methods to use new request handling approach
- Emit Tauri events in swap/src/protocol/bob/swap.rs
- Add typescript type bindings use typeshare crate
- Replace Electron IPC with Tauri invoke() for API calls
- Implement TauriSwapProgressEvent for state management
- Remove IpcInvokeButton, replace with PromiseInvokeButton
- Update models: new tauriModel.ts, refactor rpcModel.ts
- Simplify SwapSlice state, remove processRunning flag
- Refactor SwapStatePage to use TauriSwapProgressEvent
- Update HistoryRow and HistoryRowActions for new data structures
- Remove unused Electron-specific components (e.g., RpcStatusAlert)
- Update dependencies: React 18, Material-UI v4 to v5
- Implement typeshare for Rust/TypeScript type synchronization
- Add BobStateName enum for more precise swap state tracking
- Refactor utility functions for Tauri compatibility
- Remove JSONStream and other Electron-specific dependencies
@binarybaron binarybaron marked this pull request as ready for review August 26, 2024 14:13
Copy link

@Einliterflasche Einliterflasche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -49,45 +33,52 @@ export default function SwapStatePage({
if (swapState === null) {
return <InitPage />;
}
if (isSwapStateInitiated(swapState)) {
if (swapState.type === "Initiated") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part might benefit from using switch case

@binarybaron binarybaron merged commit e3547fb into master Aug 26, 2024
1 of 29 checks passed
binarybaron added a commit that referenced this pull request Aug 28, 2024
- Use the Request trait introduced in #10 for the RPC server
- Delegate deserialization of RPC server method parameters to serde by using structs like BuyXmrArgs
- Remove `get_raw_states` RPC server method because it's not used
- Fix RPC server tests including removing test for the "log reference id" feature which was removed as part of #10
- Rename GetCurrentSwap struct to GetCurrentSwapArgs
binarybaron added a commit that referenced this pull request Aug 28, 2024
- Use the Request trait introduced in #10 for the RPC server
- Delegate deserialization of RPC server method parameters to serde by using structs like BuyXmrArgs
- Remove `get_raw_states` RPC server method because it's not used
- Fix RPC server tests including removing test for the "log reference id" feature which was removed as part of #10
- Rename GetCurrentSwap struct to GetCurrentSwapArgs
binarybaron added a commit that referenced this pull request Aug 28, 2024
- Use the Request trait introduced in #10 for the RPC server
- Delegate deserialization of RPC server method parameters to serde by using structs like BuyXmrArgs
- Remove `get_raw_states` RPC server method because it's not used
- Fix RPC server tests including removing test for the "log reference id" feature which was removed as part of #10
- Rename GetCurrentSwap struct to GetCurrentSwapArgs
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.

2 participants