Skip to content

Commit

Permalink
Merge pull request #974 from dfinity/tl/ankr_to_publicnode
Browse files Browse the repository at this point in the history
Switching from Ankr to PublicNode as the single EVM RPC service
  • Loading branch information
THLO authored Sep 17, 2024
2 parents 959f8e6 + a13fdf9 commit 8683603
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion rust/basic_ethereum/basic_ethereum.did
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ service : (opt InitArg) -> {
ethereum_address : (owner: opt principal) -> (text);

// Returns the balance of the given Ethereum address.
get_balance : (address: text) -> (Wei);
// If no address is provided, the address derived from the caller's principal is used.
get_balance : (address: opt text) -> (Wei);

// Returns the transaction count for the Ethereum address derived for the given principal.
//
Expand Down
5 changes: 3 additions & 2 deletions rust/basic_ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ pub async fn ethereum_address(owner: Option<Principal>) -> String {
}

#[update]
pub async fn get_balance(address: String) -> Nat {
let _caller = validate_caller_not_anonymous();
pub async fn get_balance(address: Option<String>) -> Nat {
let address = address.unwrap_or(ethereum_address(None).await);

let json = format!(
r#"{{ "jsonrpc": "2.0", "method": "eth_getBalance", "params": ["{}", "latest"], "id": 1 }}"#,
address
Expand Down
4 changes: 2 additions & 2 deletions rust/basic_ethereum/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ impl State {
pub fn single_evm_rpc_service(&self) -> RpcServices {
match self.ethereum_network {
EthereumNetwork::Mainnet => {
RpcServices::EthMainnet(Some(vec![EthMainnetService::Ankr]))
RpcServices::EthMainnet(Some(vec![EthMainnetService::PublicNode]))
}
EthereumNetwork::Sepolia => {
RpcServices::EthSepolia(Some(vec![EthSepoliaService::Ankr]))
RpcServices::EthSepolia(Some(vec![EthSepoliaService::PublicNode]))
}
}
}
Expand Down

0 comments on commit 8683603

Please sign in to comment.