Skip to content

Commit

Permalink
fix(nep330): Fallback to CARGO_PKG_REPOSITORY and `CARGO_PKG_VERSIO…
Browse files Browse the repository at this point in the history
…N` when `NEP330_*` variables are not provided (#1215)

To avoid problems on manual `cargo build` and older versions of cargo-near (<0.7.0) that do not provide `NEP330_*` environment variables
  • Loading branch information
dj8yfo committed Jul 5, 2024
1 parent 3b455e7 commit 3133c48
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions near-sdk-macros/src/core_impl/contract_metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ struct Standard {
impl ContractMetadata {
fn populate(mut self) -> Self {
if self.link.is_none() {
let field_val = std::env::var("NEP330_LINK").unwrap_or(String::from(""));
let field_val = std::env::var("NEP330_LINK")
.or(std::env::var("CARGO_PKG_REPOSITORY"))
.unwrap_or(String::from(""));
if !field_val.is_empty() {
self.link = Some(field_val);
}
}
if self.version.is_none() {
let field_val = std::env::var("NEP330_VERSION").unwrap_or(String::from(""));
let field_val = std::env::var("NEP330_VERSION")
.or(std::env::var("CARGO_PKG_VERSION"))
.unwrap_or(String::from(""));
if !field_val.is_empty() {
self.version = Some(field_val);
}
Expand Down

0 comments on commit 3133c48

Please sign in to comment.