From 880d916872de516d1bf839e6d993b3549dc36164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dj8yf0=CE=BCl?= Date: Fri, 18 Oct 2024 15:33:17 +0300 Subject: [PATCH 1/2] ci: fix clippy 1.82 (doc preambles) --- examples/src/croncat.rs | 1 + workspaces/src/network/betanet.rs | 5 +++-- workspaces/src/network/mainnet.rs | 5 +++-- workspaces/src/network/sandbox.rs | 4 +++- workspaces/src/network/testnet.rs | 5 +++-- workspaces/src/operations.rs | 4 +++- workspaces/src/result.rs | 5 ++++- workspaces/src/rpc/patch.rs | 7 ++++--- workspaces/src/rpc/query.rs | 24 +++++++++++++----------- workspaces/src/types/account.rs | 8 ++++++-- workspaces/src/types/mod.rs | 13 ++++++++++--- workspaces/src/worker/mod.rs | 6 ++++-- 12 files changed, 57 insertions(+), 30 deletions(-) diff --git a/examples/src/croncat.rs b/examples/src/croncat.rs index 4d862590..a98152e6 100644 --- a/examples/src/croncat.rs +++ b/examples/src/croncat.rs @@ -27,6 +27,7 @@ pub enum AgentStatus { /// `Agent` struct taken from [croncat repo](github.com/CronCats/contracts/) to deserialize /// into after we get the result of a transaction and converting over to this particular type. +/// /// Helpful for understanding what our output is from a contract call. For a more in depth /// look at what an `Agent` is all about, refer to the [croncat docs](https://docs.cron.cat/docs/) /// to understand further, but for this example all we care about is that an Agent is something diff --git a/workspaces/src/network/betanet.rs b/workspaces/src/network/betanet.rs index be0badd4..872a01d5 100644 --- a/workspaces/src/network/betanet.rs +++ b/workspaces/src/network/betanet.rs @@ -9,8 +9,9 @@ use std::path::PathBuf; /// URL to the betanet RPC node provided by near.org. pub const RPC_URL: &str = "https://rpc.betanet.near.org"; -/// Betanet related configuration for interacting with betanet. Look at -/// [`workspaces::betanet`] for how to spin up a [`Worker`] that can be +/// Betanet related configuration for interacting with betanet. +/// +/// Look at [`workspaces::betanet`] for how to spin up a [`Worker`] that can be /// used to interact with betanet. Note that betanet account creation /// is not currently supported, and these calls into creating a betanet /// worker is meant for retrieving data and/or making queries only. diff --git a/workspaces/src/network/mainnet.rs b/workspaces/src/network/mainnet.rs index 07b419b2..65ab7572 100644 --- a/workspaces/src/network/mainnet.rs +++ b/workspaces/src/network/mainnet.rs @@ -11,8 +11,9 @@ pub const RPC_URL: &str = "https://rpc.mainnet.near.org"; /// URL to the mainnet archival RPC node provided by near.org. pub const ARCHIVAL_URL: &str = "https://archival-rpc.mainnet.near.org"; -/// Mainnet related configuration for interacting with mainnet. Look at -/// [`workspaces::mainnet`] and [`workspaces::mainnet_archival`] for how to +/// Mainnet related configuration for interacting with mainnet. +/// +/// Look at [`workspaces::mainnet`] and [`workspaces::mainnet_archival`] for how to /// spin up a [`Worker`] that can be used to interact with mainnet. Note that /// mainnet account creation is not currently supported, and these calls into /// creating a mainnet worker is meant for retrieving data and/or making diff --git a/workspaces/src/network/sandbox.rs b/workspaces/src/network/sandbox.rs index 5f85ebab..697f48d7 100644 --- a/workspaces/src/network/sandbox.rs +++ b/workspaces/src/network/sandbox.rs @@ -20,7 +20,9 @@ use crate::{Account, Contract, Network, Worker}; // Constant taken from nearcore crate to avoid dependency const DEFAULT_DEPOSIT: NearToken = NearToken::from_near(100); -/// Local sandboxed environment/network, which can be used to test without interacting with +/// Local sandboxed environment/network +/// +/// Can be used to test without interacting with /// networks that are online such as mainnet and testnet. Look at [`workspaces::sandbox`] /// for how to spin up a sandboxed network and interact with it. /// diff --git a/workspaces/src/network/testnet.rs b/workspaces/src/network/testnet.rs index 15ed8fb7..1d55d410 100644 --- a/workspaces/src/network/testnet.rs +++ b/workspaces/src/network/testnet.rs @@ -24,8 +24,9 @@ pub const HELPER_URL: &str = "https://helper.testnet.near.org"; /// URL to the testnet archival RPC node provided by near.org. pub const ARCHIVAL_URL: &str = "https://archival-rpc.testnet.near.org"; -/// Testnet related configuration for interacting with testnet. Look at -/// [`workspaces::testnet`] and [`workspaces::testnet_archival`] for how +/// Testnet related configuration for interacting with testnet. +/// +/// Look at [`workspaces::testnet`] and [`workspaces::testnet_archival`] for how /// to spin up a [`Worker`] that can be used to run tests in testnet. /// /// [`workspaces::testnet`]: crate::testnet diff --git a/workspaces/src/operations.rs b/workspaces/src/operations.rs index 55ded649..74927640 100644 --- a/workspaces/src/operations.rs +++ b/workspaces/src/operations.rs @@ -105,7 +105,9 @@ impl Function { } /// A builder-like object that will allow specifying various actions to be performed -/// in a single transaction. For details on each of the actions, find them in +/// in a single transaction. +/// +/// For details on each of the actions, find them in /// [NEAR transactions](https://docs.near.org/docs/concepts/transaction). /// /// All actions are performed on the account specified by `receiver_id`. This object diff --git a/workspaces/src/result.rs b/workspaces/src/result.rs index 00336d17..e7cfdb4a 100644 --- a/workspaces/src/result.rs +++ b/workspaces/src/result.rs @@ -19,7 +19,9 @@ use crate::types::{CryptoHash, Gas, NearToken}; pub type Result = core::result::Result; /// Execution related info as a result of performing a successful transaction -/// execution on the network. This value can be converted into the returned +/// execution on the network. +/// +/// This value can be converted into the returned /// value of the transaction via [`ExecutionSuccess::json`] or [`ExecutionSuccess::borsh`] pub type ExecutionSuccess = ExecutionResult; @@ -29,6 +31,7 @@ pub type ExecutionSuccess = ExecutionResult; pub type ExecutionFailure = ExecutionResult; /// Struct to hold a type we want to return along w/ the execution result view. +/// /// This view has extra info about the execution, such as gas usage and whether /// the transaction failed to be processed on the chain. #[non_exhaustive] diff --git a/workspaces/src/rpc/patch.rs b/workspaces/src/rpc/patch.rs index 789eade5..d95e5be2 100644 --- a/workspaces/src/rpc/patch.rs +++ b/workspaces/src/rpc/patch.rs @@ -10,9 +10,10 @@ use crate::types::{BlockHeight, KeyType, PublicKey, SecretKey}; use crate::{AccessKey, AccountDetailsPatch, Result}; use crate::{AccountId, Contract, CryptoHash, InMemorySigner, Network, Worker}; -/// A [`Transaction`]-like object that allows us to specify details about importing -/// a contract from a different network into our sandbox local network. This creates -/// a new [`Transaction`] to be committed to the sandbox network once `transact()` +/// A [`Transaction`]-like object with details about importing a contract from a network +/// into sandbox local network. +/// +/// This creates a new [`Transaction`] to be committed to the sandbox network once `transact()` /// has been called. This does not commit any new transactions from the network /// this object is importing from. /// diff --git a/workspaces/src/rpc/query.rs b/workspaces/src/rpc/query.rs index 7467591f..14dbe85a 100644 --- a/workspaces/src/rpc/query.rs +++ b/workspaces/src/rpc/query.rs @@ -1,8 +1,9 @@ -//! This module defines a bunch of internal types used solely for querying into RPC -//! methods to retrieve info about what's on the chain. Note that the types defined -//! are exposed as-is for users to reference in their own functions or structs as -//! needed. These types cannot be created outside of workspaces. To use them, refer -//! to surface level types like [`Account`], [`Contract`] and [`Worker`]. +//! This module defines a bunch of internal types used solely for querying into +//! RPC methods to get info about what's on the chain. +//! +//! Note that the types defined are exposed as-is for users to reference in their own +//! functions or structs as needed. These types cannot be created outside of workspaces. +//! To use them, refer to surface level types like [`Account`], [`Contract`] and [`Worker`]. //! //! For example, to query into downloading contract state: //! ``` @@ -133,9 +134,10 @@ where } // Note: this trait is exposed publicly due to constraining with the impl offering `finality`. -/// Trait used as a converter from WorkspaceRequest to near-rpc request, and from near-rpc -/// response to a WorkspaceResult. Mostly used internally to facilitate syntax sugar for performing -/// RPC requests with async builders. +/// Trait used as a converter from WorkspaceRequest to near-rpc request, +/// and from near-rpc response to a WorkspaceResult. +/// +/// Mostly used internally to facilitate syntax sugar for performing RPC requests with async builders. pub trait ProcessQuery { // TODO: associated default type is unstable. So for now, will require writing // the manual impls for query_request @@ -401,10 +403,10 @@ impl ProcessQuery for GasPrice { } } -/// Query object used to query for chunk related details at a specific `ChunkReference` which -/// consists of either a chunk [`CryptoHash`], or a `BlockShardId` (which consists of [`ShardId`] -/// and either block [`CryptoHash`] or [`BlockHeight`]). +/// Query object to query for chunk related details at a specific `ChunkReference` which +/// consists of either a chunk [`CryptoHash`], or a `BlockShardId`. /// +/// `BlockShardId` consists of [`ShardId`] and either block [`CryptoHash`] or [`BlockHeight`] /// The default behavior where a `ChunkReference` is not supplied will use a `BlockShardId` /// referencing the latest block `CryptoHash` with `ShardId` of 0. pub struct QueryChunk<'a> { diff --git a/workspaces/src/types/account.rs b/workspaces/src/types/account.rs index afe7df00..241ba8e3 100644 --- a/workspaces/src/types/account.rs +++ b/workspaces/src/types/account.rs @@ -16,7 +16,9 @@ use crate::operations::{CallTransaction, CreateAccountTransaction, Transaction}; use crate::result::{Execution, ExecutionFinalResult, Result}; /// `Account` is directly associated to an account in the network provided by the -/// [`Worker`] that creates it. This type offers methods to interact with any +/// [`Worker`] that creates it. +/// +/// This type offers methods to interact with any /// network, such as creating transactions and calling into contract functions. #[derive(Clone)] pub struct Account { @@ -201,7 +203,9 @@ impl Account { } /// `Contract` is directly associated to a contract in the network provided by the -/// [`Worker`] that creates it. This type offers methods to interact with any +/// [`Worker`] that creates it. +/// +/// This type offers methods to interact with any /// network, such as creating transactions and calling into contract functions. #[derive(Clone)] pub struct Contract { diff --git a/workspaces/src/types/mod.rs b/workspaces/src/types/mod.rs index 66e02442..c04fd647 100644 --- a/workspaces/src/types/mod.rs +++ b/workspaces/src/types/mod.rs @@ -1,4 +1,6 @@ -//! Types used in the workspaces crate. A lot of these are types are copied over from near_primitives +//! Types used in the workspaces crate. +//! +//! A lot of these are types are copied over from near_primitives //! since those APIs are not yet stable. Once they are, we can directly reference them here, so no //! changes on the library consumer side is needed. Just keep using these types defined here as-is. @@ -222,7 +224,9 @@ impl BorshDeserialize for PublicKey { } } -/// Secret key of an account on chain. Usually created along with a [`PublicKey`] +/// Secret key of an account on chain. +/// +/// Usually created along with a [`PublicKey`] /// to form a keypair associated to the account. To generate a new keypair, use /// one of the creation methods found here, such as [`SecretKey::from_seed`] #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] @@ -367,7 +371,9 @@ impl From for CryptoHash { } } -/// Access key provides limited access to an account. Each access key belongs to some account and +/// Access key provides limited access to an account. +/// +/// Each access key belongs to some account and /// is identified by a unique (within the account) public key. One account may have large number of /// access keys. Access keys allow to act on behalf of the account by restricting transactions /// that can be issued. @@ -434,6 +440,7 @@ pub enum AccessKeyPermission { } /// Grants limited permission to make transactions with FunctionCallActions +/// /// The permission can limit the allowed balance to be spent on the prepaid gas. /// It also restrict the account ID of the receiver for this function call. /// It also can restrict the method name for the allowed function calls. diff --git a/workspaces/src/worker/mod.rs b/workspaces/src/worker/mod.rs index 02c3f4ee..1833c600 100644 --- a/workspaces/src/worker/mod.rs +++ b/workspaces/src/worker/mod.rs @@ -8,8 +8,10 @@ use crate::network::{Betanet, Custom, Mainnet, Sandbox, Testnet}; use crate::types::gas_meter::GasHook; use crate::{Network, Result}; -/// The `Worker` type allows us to interact with any NEAR related networks, such -/// as mainnet and testnet. This controls where the environment the worker is +/// The `Worker` type allows us to interact with any NEAR related networks, +/// such as mainnet and testnet. +/// +/// This controls where the environment the worker is /// running on top of it. Refer to this for all network related actions such as /// deploying a contract, or interacting with transactions. pub struct Worker { From a497058ae5b5d713546dd1847b8bfa3a439d3206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dj8yf0=CE=BCl?= Date: Fri, 18 Oct 2024 15:56:58 +0300 Subject: [PATCH 2/2] ci: trigger build with an extra line