From b6f7983f60d5926897711cb81d1d9d7fcef21458 Mon Sep 17 00:00:00 2001 From: Sasuke <177417590+sasuke0787@users.noreply.github.com> Date: Fri, 20 Jun 2025 09:23:18 -0400 Subject: [PATCH 1/9] creating transaction hub --- src/components/txs/CwReauthForm.svelte | 23 +++ src/components/txs/RevokeForm.svelte | 23 +++ src/components/txs/TransactionHub.svelte | 108 +++++++++++ src/components/txs/VouchForm.svelte | 235 +++++++++++++++++++++++ 4 files changed, 389 insertions(+) create mode 100644 src/components/txs/CwReauthForm.svelte create mode 100644 src/components/txs/RevokeForm.svelte create mode 100644 src/components/txs/TransactionHub.svelte create mode 100644 src/components/txs/VouchForm.svelte diff --git a/src/components/txs/CwReauthForm.svelte b/src/components/txs/CwReauthForm.svelte new file mode 100644 index 00000000..43e82ea3 --- /dev/null +++ b/src/components/txs/CwReauthForm.svelte @@ -0,0 +1,23 @@ + + +
+ +

{$_('txs.type_selector.cwreauth')}

+

This transaction type will be implemented in a future update.

+

Please check back later.

+ + {#if false} + + {/if} +
diff --git a/src/components/txs/RevokeForm.svelte b/src/components/txs/RevokeForm.svelte new file mode 100644 index 00000000..a4aba651 --- /dev/null +++ b/src/components/txs/RevokeForm.svelte @@ -0,0 +1,23 @@ + + +
+ +

{$_('txs.type_selector.revoke')}

+

This transaction type will be implemented in a future update.

+

Please check back later.

+ + {#if false} + + {/if} +
diff --git a/src/components/txs/TransactionHub.svelte b/src/components/txs/TransactionHub.svelte new file mode 100644 index 00000000..fea518f8 --- /dev/null +++ b/src/components/txs/TransactionHub.svelte @@ -0,0 +1,108 @@ + + +
+
+

+ {$_('txs.transactions')} +

+
+ + +
+
+

{$_('txs.select_transaction_type')}

+
+ +
+ {#each txTypes as type} +
+ +
+ {/each} +
+
+ + {#if !$signingAccount.on_chain} + + {:else if account} + +
+ {#if selectedType === 'vouch'} + + {:else if selectedType === 'revoke'} + + {:else if selectedType === 'cwreauth'} + + {/if} +
+ {/if} +
+ + diff --git a/src/components/txs/VouchForm.svelte b/src/components/txs/VouchForm.svelte new file mode 100644 index 00000000..b65c29f8 --- /dev/null +++ b/src/components/txs/VouchForm.svelte @@ -0,0 +1,235 @@ + + + +
+
+ +
+ +
+ {#if account?.account} + {formatAccount(account.account)} + {/if} +
+
+
+
+ + {$_('txs.vouch.vouch_limit')} + {#if isLoadingVouchData} + + {/if} + +
+ {vouchLimit} + +
+
+
+ + +
+ +
+ + {#if !isReceiverValid && receiver} +

{$_('txs.vouch.invalid_address')}

+ {/if} +
+
+ +
+ + + {#if vouchLimit <= 0} +

+ {$_('txs.vouch.limit_reached')} +

+ {/if} +
+ +{#if errorMessage} +
+

{errorMessage}

+
+{/if} + +
+ + + +
+ +
+

{$_('txs.vouch.important_info')}

+ +
From 08c6a2d918c2c75c2259ed617337d768f9d95a38 Mon Sep 17 00:00:00 2001 From: Sasuke <177417590+sasuke0787@users.noreply.github.com> Date: Fri, 20 Jun 2025 09:24:18 -0400 Subject: [PATCH 2/9] adding navigation updates for transactions hub --- src/App.svelte | 2 ++ src/components/Nav.svelte | 4 ++-- src/lang/locales/en.json | 10 +++++++++- src/modules/routes.ts | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 95ce2d61..d852d96a 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -35,6 +35,7 @@ import Keygen from './components/wallet/Keygen.svelte' import AddWatchAccount from './components/wallet/AddWatchAccount.svelte' import Transactions from './components/txs/Transactions.svelte' + import TransactionHub from './components/txs/TransactionHub.svelte' import Events from './components/events/Events.svelte' import About from './components/about/About.svelte' import SearchingFullnodes from './components/layout/SearchingFullnodes.svelte' @@ -149,6 +150,7 @@ + diff --git a/src/components/Nav.svelte b/src/components/Nav.svelte index 130671fd..b19cce9b 100644 --- a/src/components/Nav.svelte +++ b/src/components/Nav.svelte @@ -43,8 +43,8 @@
  • {$_('nav.transactions')}
  • -
  • - {$_('nav.vouch')} +
  • + {$_('nav.vouch')}
  • diff --git a/src/lang/locales/en.json b/src/lang/locales/en.json index 549ea075..1662d168 100644 --- a/src/lang/locales/en.json +++ b/src/lang/locales/en.json @@ -3,7 +3,7 @@ "wallet": "Wallet", "miner": "Miner", "transactions": "Transfer", - "vouch": "Vouch", + "vouch": "Transactions", "events": "Events" }, "layout": { @@ -300,6 +300,14 @@ "balance": "Balance", "btn_onboard": "Onboard Account", "btn_transfer": "Transfer Coins", + "transactions": "Transactions", + "select_transaction_type": "Select Transaction Type", + "type_selector": { + "transfer": "Transfer", + "vouch": "Vouch", + "revoke": "Revoke Vouch", + "cwreauth": "CW Reauth" + }, "onboard": { "title": "Onboard an Account", "await": "Awaiting Tx", diff --git a/src/modules/routes.ts b/src/modules/routes.ts index d2d893c5..5a2f7030 100644 --- a/src/modules/routes.ts +++ b/src/modules/routes.ts @@ -15,4 +15,5 @@ export const routes = { swarm: '/swarm', makeWhole: '/make-whole', vouch: '/vouch', + txHub: '/transactions', } From 6c96a5b0012569f14a67a5c5df3e443d197b2680 Mon Sep 17 00:00:00 2001 From: Sasuke <177417590+sasuke0787@users.noreply.github.com> Date: Fri, 20 Jun 2025 14:00:22 -0400 Subject: [PATCH 3/9] clean up old vouch --- src-tauri/src/commands/tx.rs | 155 +++++++++---- src-tauri/src/main.rs | 2 + src/App.svelte | 2 - src/components/Nav.svelte | 3 +- src/components/txs/CwReauthForm.svelte | 116 +++++++-- src/components/txs/RevokeForm.svelte | 182 ++++++++++++++- src/components/txs/TransactionHub.svelte | 5 + src/components/vouch/Vouch.svelte | 284 ----------------------- src/lang/locales/en.json | 27 +++ src/modules/routes.ts | 1 - 10 files changed, 424 insertions(+), 353 deletions(-) delete mode 100644 src/components/vouch/Vouch.svelte diff --git a/src-tauri/src/commands/tx.rs b/src-tauri/src/commands/tx.rs index aa27bf99..e3338d74 100644 --- a/src-tauri/src/commands/tx.rs +++ b/src-tauri/src/commands/tx.rs @@ -56,32 +56,28 @@ pub async fn vouch_transaction(_sender: AccountAddress, receiver: &str) -> Resul let mut sender = Sender::from_app_cfg(&config, Some(_sender.to_string())).await?; - // Try different function paths and argument formats - let function_paths = ["0x1::vouch_txs::vouch_for"]; - - for &path in &function_paths { - // Format address as a Move address literal (with 0x prefix) - let formatted_address = format!("0x{}", receiver_account.to_hex()); - - match sender - .generic( - path, - &None, // No type arguments - &Some(formatted_address.clone()), // Use the properly formatted address - ) - .await - { - Ok(_) => { - println!("Successfully called {}", path); - return Ok(()); - } - Err(e) => { - println!("Failed to call {}: {}", path, e); - // Continue to try the next path - } + // Try the revoke vouch function path + let function_path = "0x1::vouch_txs::vouch_for"; + + // Format address as a Move address literal (with 0x prefix) + let formatted_address = format!("0x{}", receiver_account.to_hex()); + + match sender + .generic( + function_path, + &None, // No type arguments + &Some(formatted_address.clone()), // Use the properly formatted address + ) + .await + { + Ok(_) => { + println!("Successfully called {}", function_path); + return Ok(()); + } + Err(e) => { + println!("Failed to call {}: {}", function_path, e); } } - // If we get here, all attempts failed Err(CarpeError::misc( "Failed to call vouch function with any known path or argument format", @@ -103,26 +99,107 @@ pub async fn rejoin_transaction(_sender: AccountAddress) -> Result<(), CarpeErro ) .await { - Ok(_) => { - return Ok(()); - } + Ok(_) => Ok(()), Err(e) => { println!("Failed to call 0x1::filo_migration::maybe_migrate {}", e); // Continue to try the next path + Err(CarpeError::misc(&format!("Failed to migrate: {}", e))) } } +} - // If we get here, all attempts failed - Err(CarpeError::misc( - "Failed to call vouch function with any known path or argument format", - )) +#[tauri::command(async)] +pub async fn revoke_vouch_transaction( + _sender: AccountAddress, + receiver: &str, +) -> Result<(), CarpeError> { + let receiver_account = match AccountAddress::from_str(receiver) { + Ok(a) => a, + Err(e) => { + println!( + "Failed to parse receiver address: {}, trying with 0x prefix", + e + ); + AccountAddress::from_str(&format!("0x{}", receiver))? + } + }; + + let mut config = get_cfg()?; + inject_private_key_to_cfg(&mut config, _sender)?; + + let mut sender = Sender::from_app_cfg(&config, Some(_sender.to_string())).await?; + + // Try the revoke vouch function path + let function_path = "0x1::vouch_txs::revoke"; + + // Format address as a Move address literal (with 0x prefix) + let formatted_address = format!("0x{}", receiver_account.to_hex()); + + match sender + .generic( + function_path, + &None, // No type arguments + &Some(formatted_address.clone()), // Use the properly formatted address + ) + .await + { + Ok(_) => { + println!("Successfully called {}", function_path); + Ok(()) + } + Err(e) => { + println!("Failed to call {}: {}", function_path, e); + Err(CarpeError::misc(&format!("Failed to revoke vouch: {}", e))) + } + } } -// #[tauri::command(async)] -// pub async fn claim_make_whole() -> Result<(), CarpeError> { -// let tx_payload = stdlib::encode_claim_make_whole_script_function(); -// let tx_params = -// configs::get_tx_params()?; -// submit_tx::maybe_submit(tx_payload, &tx_params, None)?; -// Ok(()) -// } +#[tauri::command(async)] +pub async fn cw_reauth_transaction( + _sender: AccountAddress, + wallet_address: &str, +) -> Result<(), CarpeError> { + // Parse the wallet address + let wallet_account = match AccountAddress::from_str(wallet_address) { + Ok(a) => a, + Err(e) => { + println!( + "Failed to parse wallet address: {}, trying with 0x prefix", + e + ); + AccountAddress::from_str(&format!("0x{}", wallet_address))? + } + }; + + let mut config = get_cfg()?; + inject_private_key_to_cfg(&mut config, _sender)?; + + let mut sender = Sender::from_app_cfg(&config, Some(_sender.to_string())).await?; + + // Try the community wallet reauthorization function path + let function_path = "0x1::donor_voice_txs::vote_reauth_tx"; + + // Format address as a Move address literal (with 0x prefix) + let formatted_address = format!("0x{}", wallet_account.to_hex()); + + match sender + .generic( + function_path, + &None, // No type arguments + &Some(formatted_address.clone()), // Pass the wallet address as an argument + ) + .await + { + Ok(_) => { + println!("Successfully called {}", function_path); + Ok(()) + } + Err(e) => { + println!("Failed to call {}: {}", function_path, e); + Err(CarpeError::misc(&format!( + "Failed to reauthorize community wallet: {}", + e + ))) + } + } +} diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ada34d9c..596f8ad3 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -120,6 +120,8 @@ async fn main() { //////// Transactions //////// commands::tx::coin_transfer, commands::tx::vouch_transaction, + commands::tx::revoke_vouch_transaction, + commands::tx::cw_reauth_transaction, commands::tx::rejoin_transaction, // claim_make_whole, //////// Tower //////// diff --git a/src/App.svelte b/src/App.svelte index d852d96a..22419508 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -49,7 +49,6 @@ import { isLoading } from 'svelte-i18n' import { isBooted } from './modules/boot' import SplashScreen from './components/layout/SplashScreen.svelte' - import Vouch from './components/vouch/Vouch.svelte' // black magic with I18n here // temporarily set up here otherwise... issues @@ -149,7 +148,6 @@ - diff --git a/src/components/Nav.svelte b/src/components/Nav.svelte index b19cce9b..bc6d9d85 100644 --- a/src/components/Nav.svelte +++ b/src/components/Nav.svelte @@ -17,8 +17,7 @@ routes.keygen, routes.accountFromMnem, routes.addWatchAccount, - routes.accountDetails, - routes.vouch + routes.accountDetails ] const location_store = useLocation() diff --git a/src/components/txs/CwReauthForm.svelte b/src/components/txs/CwReauthForm.svelte index 43e82ea3..aecd51ba 100644 --- a/src/components/txs/CwReauthForm.svelte +++ b/src/components/txs/CwReauthForm.svelte @@ -1,23 +1,113 @@ -
    - -

    {$_('txs.type_selector.cwreauth')}

    -

    This transaction type will be implemented in a future update.

    -

    Please check back later.

    - - {#if false} - + + +
    + +
    + +

    + By default, this is set to your current account. You can change it to reauthorize a different community wallet. +

    +
    +
    + +
    +

    {$_('txs.cwreauth.about_title')}

    +

    {$_('txs.cwreauth.about_description')}

    +
    + +
    + +
    + +{#if errorMessage} +
    +

    {errorMessage}

    +
    +{/if} diff --git a/src/components/txs/RevokeForm.svelte b/src/components/txs/RevokeForm.svelte index a4aba651..94966fea 100644 --- a/src/components/txs/RevokeForm.svelte +++ b/src/components/txs/RevokeForm.svelte @@ -1,23 +1,181 @@ -
    - -

    {$_('txs.type_selector.revoke')}

    -

    This transaction type will be implemented in a future update.

    -

    Please check back later.

    - - {#if false} -