forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement web3_clientVersion (paritytech#7580)
Implements the `web3_clientVersion` method. This is a common requirement for external Ethereum libraries when querying a client. Fixes paritytech/contract-issues#26. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
title: implement web3_clientVersion | ||
doc: | ||
- audience: Runtime Dev | ||
description: |- | ||
Implements the `web3_clientVersion` method. This is a common requirement for external Ethereum libraries when querying a client. | ||
|
||
Reference issue with more details: https://github.com/paritytech/contract-issues/issues/26. | ||
crates: | ||
- name: pallet-revive-eth-rpc | ||
bump: minor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// This file is part of Substrate. | ||
|
||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
use std::process::Command; | ||
|
||
/// Get the current branch and commit hash. | ||
fn main() { | ||
let output = Command::new("rustc") | ||
.arg("--version") | ||
.output() | ||
.expect("cannot get the current rustc version"); | ||
// Exports the default rustc --version output: | ||
// e.g. rustc 1.83.0 (90b35a623 2024-11-26) | ||
// into the usual Ethereum web3_clientVersion format | ||
// e.g. rustc1.83.0 | ||
let rustc_version = String::from_utf8_lossy(&output.stdout) | ||
.split_whitespace() | ||
.take(2) | ||
.collect::<Vec<_>>() | ||
.join(""); | ||
let target = std::env::var("TARGET").unwrap_or_else(|_| "unknown".to_string()); | ||
|
||
let repo = git2::Repository::open("../../../..").expect("should be a repository"); | ||
let head = repo.head().expect("should have head"); | ||
let commit = head.peel_to_commit().expect("should have commit"); | ||
let branch = head.shorthand().unwrap_or("unknown").to_string(); | ||
let id = &commit.id().to_string()[..7]; | ||
println!("cargo:rustc-env=GIT_REVISION={branch}-{id}"); | ||
println!("cargo:rustc-env=RUSTC_VERSION={rustc_version}"); | ||
println!("cargo:rustc-env=TARGET={target}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters