Skip to content

Commit 04ad71f

Browse files
committed
Merge branch 'wh/wallet-signer' of github.com:hyperware-ai/process_lib into wh/wallet-signer
2 parents a237fad + a235fe8 commit 04ad71f

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/eth.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,8 @@ impl Provider {
762762
loop {
763763
match self.subscribe(sub_id, filter.clone()) {
764764
Ok(()) => break, // Success, exit loop
765-
Err(e) => { // Log the actual error
765+
Err(e) => {
766+
// Log the actual error
766767
crate::print_to_terminal(
767768
print_verbosity_error,
768769
&format!(

src/wallet.rs

+17-18
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
use crate::eth::{BlockNumberOrTag, EthError, Provider};
1212
use crate::hypermap;
1313
use crate::hypermap::{namehash, valid_fact, valid_name, valid_note};
14-
use crate::signer::{EncryptedSignerData, LocalSigner, Signer, SignerError, TransactionData};
1514
use crate::println as kiprintln;
15+
use crate::signer::{EncryptedSignerData, LocalSigner, Signer, SignerError, TransactionData};
1616

1717
use alloy::rpc::types::{
18-
request::TransactionRequest, Filter, FilterBlockOption, FilterSet,
19-
TransactionReceipt,
18+
request::TransactionRequest, Filter, FilterBlockOption, FilterSet, TransactionReceipt,
2019
};
2120
use alloy_primitives::TxKind;
22-
use alloy_primitives::{Address as EthAddress, Bytes, TxHash, U256, B256};
21+
use alloy_primitives::{Address as EthAddress, Bytes, TxHash, B256, U256};
2322
use alloy_sol_types::{sol, SolCall};
2423
use serde::{Deserialize, Serialize};
2524
use std::str::FromStr;
@@ -1499,14 +1498,14 @@ pub fn set_gene<S: Signer>(
14991498
/// (e.g., via Hypermap notes like ~access-list) rather than the direct owner of the underlying NFT.
15001499
/// The TBA's own `execute` implementation is responsible for verifying the signer's authorization.
15011500
pub fn execute_via_tba_with_signer<S: Signer>(
1502-
tba_address_or_name: &str, // Address or name of the TBA to execute through
1503-
hot_wallet_signer: &S, // The signer (e.g., hot wallet) authorized to call execute
1501+
tba_address_or_name: &str, // Address or name of the TBA to execute through
1502+
hot_wallet_signer: &S, // The signer (e.g., hot wallet) authorized to call execute
15041503
target_address_or_name: &str, // Address or name of the contract to call via the TBA
1505-
call_data: Vec<u8>, // ABI-encoded data for the call to the target contract
1506-
value: U256, // ETH value to send with the call to the target contract
1504+
call_data: Vec<u8>, // ABI-encoded data for the call to the target contract
1505+
value: U256, // ETH value to send with the call to the target contract
15071506
provider: &Provider,
1508-
operation: Option<u8>, // ERC-6551 operation type (0=CALL, 1=DELEGATECALL, etc.). Defaults to 0.
1509-
gas_limit: Option<u64>, // Optional gas limit override. Defaults to 500,000.
1507+
operation: Option<u8>, // ERC-6551 operation type (0=CALL, 1=DELEGATECALL, etc.). Defaults to 0.
1508+
gas_limit: Option<u64>, // Optional gas limit override. Defaults to 500,000.
15101509
) -> Result<TxReceipt, WalletError> {
15111510
// Resolve addresses
15121511
let tba = resolve_name(tba_address_or_name, provider.chain_id)?;
@@ -1522,7 +1521,6 @@ pub fn execute_via_tba_with_signer<S: Signer>(
15221521
value
15231522
);
15241523

1525-
15261524
// Create the outer execute call directed at the TBA
15271525
let execute_call = IERC6551Account::executeCall {
15281526
to: target,
@@ -1536,25 +1534,26 @@ pub fn execute_via_tba_with_signer<S: Signer>(
15361534
let format_receipt = move |_| {
15371535
format!(
15381536
"Execute via TBA {} to target {} (Signer: {})",
1539-
tba_address_or_name, target_address_or_name, hot_wallet_signer.address()
1537+
tba_address_or_name,
1538+
target_address_or_name,
1539+
hot_wallet_signer.address()
15401540
)
15411541
};
15421542

15431543
// Prepare and send the transaction *to* the TBA, signed by the hot_wallet_signer.
15441544
// The `value` field in `prepare_and_send_tx` is U256::ZERO because the ETH transfer
15451545
// happens *inside* the TBA's execution context, funded by the TBA itself.
15461546
prepare_and_send_tx(
1547-
tba, // Transaction is sent TO the TBA address
1548-
execute_call_data, // Data is the ABI-encoded `execute` call
1549-
U256::ZERO, // Outer transaction sends no ETH directly to the TBA
1547+
tba, // Transaction is sent TO the TBA address
1548+
execute_call_data, // Data is the ABI-encoded `execute` call
1549+
U256::ZERO, // Outer transaction sends no ETH directly to the TBA
15501550
provider,
1551-
hot_wallet_signer, // Signed by the provided (potentially delegated) signer
1551+
hot_wallet_signer, // Signed by the provided (potentially delegated) signer
15521552
gas_limit.or(Some(500_000)), // Default gas limit for TBA executions
15531553
format_receipt,
15541554
)
15551555
}
15561556

1557-
15581557
/// Executes a call through a Token Bound Account (TBA)
15591558
/// Assumes the provided signer is the owner/controller authorized by the standard ERC6551 implementation.
15601559
pub fn tba_execute<S: Signer>(
@@ -1700,7 +1699,7 @@ pub fn tba_set_signer_data_key<S: Signer>(
17001699
/// and then configures the entry's TBA to use this note for alternative signature validation.
17011700
/// Requires the signature of the *owner* of the Hypermap entry.
17021701
pub fn setup_alternative_signer<S: Signer>(
1703-
entry_name: &str, // e.g., "username.hypr"
1702+
entry_name: &str, // e.g., "username.hypr"
17041703
alt_signer_address: EthAddress, // The address allowed to sign alternatively
17051704
provider: &Provider,
17061705
owner_signer: &S, // Signer holding the key that owns 'entry_name'

0 commit comments

Comments
 (0)