-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(near-contract-standards): add build_info
field
#1297
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
@@ -1,17 +1,171 @@ | ||
pub use build_info::BuildInfo; | ||
use near_sdk::serde::{Deserialize, Serialize}; | ||
|
||
/// The contract source metadata is a standard interface that allows auditing and viewing source code for a deployed smart contract. | ||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] | ||
/// The struct provides information about deployed contract's source code and supported standards. | ||
/// | ||
/// Contract source metadata follows [**NEP-330 standard**](https://github.com/near/NEPs/blob/master/neps/nep-0330.md) for smart contracts | ||
/// | ||
/// See documentation of [`near_api::types::contract::ContractSourceMetadata`](https://docs.rs/near-api/latest/near_api/types/contract/struct.ContractSourceMetadata.html) | ||
/// and [`near_api::Contract::contract_source_metadata`](https://docs.rs/near-api/latest/near_api/struct.Contract.html#method.contract_source_metadata) | ||
/// on how to query this piece of data from a contract via `near_api` crate | ||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] | ||
#[serde(crate = "near_sdk::serde")] | ||
pub struct ContractSourceMetadata { | ||
/// Optional version identifier, typically a semantic version | ||
/// | ||
/// ## Examples: | ||
/// | ||
/// ```rust,no_run | ||
/// # let version: Option<String> = | ||
/// // Semantic version | ||
/// Some("1.0.0".into()) | ||
/// # ; | ||
/// ``` | ||
/// ```rust,no_run | ||
/// # let version: Option<String> = | ||
/// // Git commit | ||
/// Some("39f2d2646f2f60e18ab53337501370dc02a5661c".into()) | ||
/// # ; | ||
/// ``` | ||
pub version: Option<String>, | ||
/// Optional URL to source code repository/tree | ||
/// | ||
/// ## Examples: | ||
/// | ||
/// ```rust,no_run | ||
/// # let link: Option<String> = | ||
/// // GitHub URL | ||
/// Some("https://github.com/org/repo/tree/8d8a8a0fe86a1d8eb3bce45f04ab1a65fecf5a1b".into()) | ||
/// # ; | ||
/// ``` | ||
/// ```rust,no_run | ||
/// # let link: Option<String> = | ||
/// // GitHub URL | ||
/// Some("https://github.com/near-examples/nft-tutorial".into()) | ||
/// # ; | ||
/// ``` | ||
/// ```rust,no_run | ||
/// # let link: Option<String> = | ||
/// // IPFS CID | ||
/// Some("bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq".into()) | ||
/// # ; | ||
/// ``` | ||
pub link: Option<String>, | ||
/// List of supported NEAR standards (NEPs) with their versions | ||
/// | ||
/// This field is an addition of **1.1.0** **NEP-330** revision | ||
/// | ||
/// ## Examples: | ||
/// | ||
/// This field will always include NEP-330 itself: | ||
/// ```rust,no_run | ||
/// # use near_contract_standards::contract_metadata::Standard; | ||
/// # let link: Vec<Standard> = | ||
/// // this is always at least 1.1.0 | ||
/// vec![Standard { standard: "nep330".into(), version: "1.1.0".into() }] | ||
/// # ; | ||
/// ``` | ||
/// ```rust,no_run | ||
/// # use near_contract_standards::contract_metadata::Standard; | ||
/// # let link: Vec<Standard> = | ||
/// vec![Standard { standard: "nep330".into(), version: "1.2.0".into() }] | ||
/// # ; | ||
/// ``` | ||
// it's a guess it was added as 1.1.0 of nep330, [nep330 1.1.0 standard recording](https://www.youtube.com/watch?v=pBLN9UyE6AA) actually discusses nep351 | ||
pub standards: Vec<Standard>, | ||
/// Optional details that are required for formal contract WASM build reproducibility verification | ||
/// | ||
/// This field is an addition of **1.2.0** **NEP-330** revision | ||
pub build_info: Option<BuildInfo>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] | ||
/// NEAR Standard implementation descriptor following [NEP-330](https://github.com/near/NEPs/blob/master/neps/nep-0330.md) | ||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] | ||
#[serde(crate = "near_sdk::serde")] | ||
pub struct Standard { | ||
/// Standard name in lowercase NEP format | ||
/// | ||
/// ## Examples: | ||
/// | ||
/// ```rust,no_run | ||
/// # let standard: String = | ||
/// // for fungible tokens | ||
/// "nep141".into() | ||
/// # ; | ||
/// ``` | ||
pub standard: String, | ||
/// Implemented standard version using semantic versioning | ||
/// | ||
/// ## Examples: | ||
/// | ||
/// ```rust,no_run | ||
/// # let version: String = | ||
/// // for initial release | ||
/// "1.0.0".into() | ||
/// # ; | ||
/// ``` | ||
pub version: String, | ||
} | ||
|
||
mod build_info { | ||
use near_sdk::serde::{Deserialize, Serialize}; | ||
|
||
/// Defines all required details for formal WASM build reproducibility verification | ||
/// according to [**NEP-330 standard 1.2.0 revision**](https://github.com/near/NEPs/blob/master/neps/nep-0330.md) | ||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] | ||
#[serde(crate = "near_sdk::serde")] | ||
pub struct BuildInfo { | ||
/// Reference to a reproducible build environment docker image | ||
/// | ||
/// ## Examples: | ||
/// | ||
/// ```rust,no_run | ||
/// # let build_environment: String = | ||
/// "sourcescan/cargo-near:0.13.3-rust-1.84.0@sha256:722198ddb92d1b82cbfcd3a4a9f7fba6fd8715f4d0b5fb236d8725c4883f97de".into() | ||
/// # ; | ||
/// ``` | ||
pub build_environment: String, | ||
/// The exact command that was used to build the contract, with all the flags | ||
/// | ||
/// ## Examples: | ||
/// | ||
/// ```rust,no_run | ||
/// # let build_command: Vec<String> = | ||
/// vec![ | ||
/// "cargo".into(), | ||
/// "near".into(), | ||
/// "build".into(), | ||
/// "non-reproducible-wasm".into(), | ||
/// "--locked".into() | ||
/// ] | ||
/// # ; | ||
/// ``` | ||
pub build_command: Vec<String>, | ||
/// Relative path to contract crate within the source code | ||
/// | ||
/// ## Examples: | ||
/// | ||
/// ```rust,no_run | ||
/// # let contract_path: String = | ||
/// "near/omni-prover/wormhole-omni-prover-proxy".into() | ||
/// # ; | ||
/// ``` | ||
/// ```rust,no_run | ||
/// # let contract_path: String = | ||
/// // root of a repo | ||
/// "".into() | ||
/// # ; | ||
/// ``` | ||
pub contract_path: String, | ||
/// Reference to the source code snapshot that was used to build the contract | ||
/// | ||
/// ## Examples: | ||
/// | ||
/// ```rust,no_run | ||
/// # let source_code_snapshot: String = | ||
/// "git+https://github.com/org/repo?rev=8d8a8a0fe86a1d8eb3bce45f04ab1a65fecf5a1b".into() | ||
/// # ; | ||
/// ``` | ||
pub source_code_snapshot: String, | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a chance that it will be moved, and it will ruin the doc. :(
But probably, nothing we can do except to remember for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a link to an example but as a permanent link (to a hash), so it stay at least partially correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g.:
https://github.com/near/near-api-rs/blob/797f9fcb5e8fae3be8883d382968331888809f62/examples/contract_source_metadata.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akorchyn that's a reason not to move or commit reminder to
near-api-rs
to also update backlink update atnear-sdk-rs
wherever public import path ofContractSourceMetadata
andnear_api::Contract::contract_source_metadata
changes. . I don't want to ruin the illusion of seamlessly jumping the cozy docs.rs website.