Skip to content

Commit

Permalink
Rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoferlund committed Nov 6, 2024
1 parent e55ebb1 commit dbc6ddf
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn get_ecdsa_key_name() -> String {
}
}

async fn create_icp_sepolia_signer() -> IcpSigner {
async fn create_icp_signer() -> IcpSigner {
let ecdsa_key_name = get_ecdsa_key_name();
IcpSigner::new(vec![], &ecdsa_key_name, None).await.unwrap()
}
Expand Down
4 changes: 2 additions & 2 deletions src/backend/src/service/get_address.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::create_icp_sepolia_signer;
use crate::create_icp_signer;
use alloy::signers::Signer;

/// Get the Ethereum address of the backend canister.
#[ic_cdk::update]
async fn get_address() -> Result<String, String> {
let signer = create_icp_sepolia_signer().await;
let signer = create_icp_signer().await;
let address = signer.address();
Ok(address.to_string())
}
4 changes: 2 additions & 2 deletions src/backend/src/service/get_balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ use alloy::{
transports::icp::IcpConfig,
};

use crate::{create_icp_sepolia_signer, get_rpc_service_sepolia};
use crate::{create_icp_signer, get_rpc_service_sepolia};

/// Request the balance of an ETH account.
#[ic_cdk::update]
async fn get_balance(address: Option<String>) -> Result<String, String> {
let address = match address {
Some(val) => val,
None => {
let signer = create_icp_sepolia_signer().await;
let signer = create_icp_signer().await;
signer.address().to_string()
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/backend/src/service/get_balance_usdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use alloy::{
transports::icp::IcpConfig,
};

use crate::{create_icp_sepolia_signer, get_rpc_service_sepolia};
use crate::{create_icp_signer, get_rpc_service_sepolia};

// Codegen from ABI file to interact with the contract.
sol!(
Expand All @@ -22,7 +22,7 @@ async fn get_balance_usdc(address: Option<String>) -> Result<String, String> {
let address = match address {
Some(val) => val,
None => {
let signer = create_icp_sepolia_signer().await;
let signer = create_icp_signer().await;
signer.address().to_string()
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/backend/src/service/send_eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use alloy::{
transports::icp::IcpConfig,
};

use crate::{create_icp_sepolia_signer, get_rpc_service_sepolia};
use crate::{create_icp_signer, get_rpc_service_sepolia};

thread_local! {
static NONCE: RefCell<Option<u64>> = const { RefCell::new(None) };
Expand Down Expand Up @@ -39,7 +39,7 @@ thread_local! {
#[ic_cdk::update]
async fn send_eth() -> Result<String, String> {
// Setup signer
let signer = create_icp_sepolia_signer().await;
let signer = create_icp_signer().await;
let address = signer.address();

// Setup provider
Expand Down
4 changes: 2 additions & 2 deletions src/backend/src/service/send_eth_with_fillers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloy::{
transports::icp::IcpConfig,
};

use crate::{create_icp_sepolia_signer, get_rpc_service_sepolia};
use crate::{create_icp_signer, get_rpc_service_sepolia};

/// This function will attempt to send 100 wei to the ethereum address of the canister.
///
Expand All @@ -33,7 +33,7 @@ use crate::{create_icp_sepolia_signer, get_rpc_service_sepolia};
#[ic_cdk::update]
async fn send_eth_with_fillers() -> Result<String, String> {
// Setup signer
let signer = create_icp_sepolia_signer().await;
let signer = create_icp_signer().await;
let address = signer.address();

// Setup provider
Expand Down
4 changes: 2 additions & 2 deletions src/backend/src/service/sign_message.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use alloy::signers::Signer;

use crate::create_icp_sepolia_signer;
use crate::create_icp_signer;

/// Let the backend canister sign a message.
#[ic_cdk::update]
async fn sign_message(message: String) -> Result<String, String> {
let signer = create_icp_sepolia_signer().await;
let signer = create_icp_signer().await;
let signature = signer.sign_message(message.as_bytes()).await.unwrap();
Ok(format!("{:?}", signature))
}
4 changes: 2 additions & 2 deletions src/backend/src/service/transfer_usdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use alloy::{
transports::icp::IcpConfig,
};

use crate::{create_icp_sepolia_signer, get_rpc_service_sepolia};
use crate::{create_icp_signer, get_rpc_service_sepolia};

thread_local! {
static NONCE: RefCell<Option<u64>> = const { RefCell::new(None) };
Expand Down Expand Up @@ -45,7 +45,7 @@ sol!(
#[ic_cdk::update]
async fn transfer_usdc() -> Result<String, String> {
// Setup signer
let signer = create_icp_sepolia_signer().await;
let signer = create_icp_signer().await;
let address = signer.address();

// Setup provider
Expand Down

0 comments on commit dbc6ddf

Please sign in to comment.