Skip to content

Commit 8683603

Browse files
authored
Merge pull request #974 from dfinity/tl/ankr_to_publicnode
Switching from Ankr to PublicNode as the single EVM RPC service
2 parents 959f8e6 + a13fdf9 commit 8683603

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

rust/basic_ethereum/basic_ethereum.did

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ service : (opt InitArg) -> {
4343
ethereum_address : (owner: opt principal) -> (text);
4444

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

4849
// Returns the transaction count for the Ethereum address derived for the given principal.
4950
//

rust/basic_ethereum/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ pub async fn ethereum_address(owner: Option<Principal>) -> String {
3737
}
3838

3939
#[update]
40-
pub async fn get_balance(address: String) -> Nat {
41-
let _caller = validate_caller_not_anonymous();
40+
pub async fn get_balance(address: Option<String>) -> Nat {
41+
let address = address.unwrap_or(ethereum_address(None).await);
42+
4243
let json = format!(
4344
r#"{{ "jsonrpc": "2.0", "method": "eth_getBalance", "params": ["{}", "latest"], "id": 1 }}"#,
4445
address

rust/basic_ethereum/src/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ impl State {
5050
pub fn single_evm_rpc_service(&self) -> RpcServices {
5151
match self.ethereum_network {
5252
EthereumNetwork::Mainnet => {
53-
RpcServices::EthMainnet(Some(vec![EthMainnetService::Ankr]))
53+
RpcServices::EthMainnet(Some(vec![EthMainnetService::PublicNode]))
5454
}
5555
EthereumNetwork::Sepolia => {
56-
RpcServices::EthSepolia(Some(vec![EthSepoliaService::Ankr]))
56+
RpcServices::EthSepolia(Some(vec![EthSepoliaService::PublicNode]))
5757
}
5858
}
5959
}

0 commit comments

Comments
 (0)