From 053aa5bc6feec3dee0f0ed749903686bf03d3601 Mon Sep 17 00:00:00 2001 From: Bohan Zhang Date: Fri, 29 Mar 2024 01:41:42 +0800 Subject: [PATCH] chore: add typo checker in ci (#1159) --- .github/workflows/typo.yml | 13 +++++++++++++ .typos.toml | 1 + CHANGELOG.md | 4 ++-- README.md | 2 +- examples/fungible-token/tests/workspaces.rs | 4 ++-- examples/status-message/src/lib.rs | 2 +- .../src/core_impl/contract_metadata/mod.rs | 2 +- .../src/core_impl/info_extractor/arg_info.rs | 2 +- near-sdk/compilation_tests/function_error.rs | 2 +- near-sdk/src/collections/mod.rs | 2 +- near-sdk/src/store/vec/mod.rs | 2 +- 11 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/typo.yml create mode 100644 .typos.toml diff --git a/.github/workflows/typo.yml b/.github/workflows/typo.yml new file mode 100644 index 000000000..021c55fd4 --- /dev/null +++ b/.github/workflows/typo.yml @@ -0,0 +1,13 @@ +name: Typo Checker +on: [pull_request] + +jobs: + run: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v2 + - name: Check spelling of the entire repository + uses: crate-ci/typos@v1.11.1 + diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 000000000..d2722d35d --- /dev/null +++ b/.typos.toml @@ -0,0 +1 @@ +[default.extend-words] diff --git a/CHANGELOG.md b/CHANGELOG.md index 794fcbe71..4632fef04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -326,7 +326,7 @@ Get your fully configured development environment in under 1 minute using [GitHu * Move type aliases and core types to near-sdk to avoid coupling. [PR 415](https://github.com/near/near-sdk-rs/pull/415). * Implements new `Lazy` type under the new `unstable` feature which is a lazily loaded storage value. [PR 409](https://github.com/near/near-sdk-rs/pull/409). * fix(promise): `PromiseOrValue` now correctly sets `should_return` flag correctly on serialization. [PR 407](https://github.com/near/near-sdk-rs/pull/407). -* fix(tree_map): Correctly panic when range indices are exluded and `start > end`. [PR 392](https://github.com/near/near-sdk-rs/pull/392). +* fix(tree_map): Correctly panic when range indices are excluded and `start > end`. [PR 392](https://github.com/near/near-sdk-rs/pull/392). * Implement `FromStr` for json types to allow calling `.parse()` to convert them. * `ValidAccountId` [PR 391](https://github.com/near/near-sdk-rs/pull/391). * `Base58CryptoHash` [PR 398](https://github.com/near/near-sdk-rs/pull/398). @@ -338,7 +338,7 @@ Get your fully configured development environment in under 1 minute using [GitHu * Update syscall interface to no longer go through `BLOCKCHAIN_INTERFACE`. Instead uses `near_sdk::sys` which is under the `unstable` feature flag if needed. [PR 417](https://github.com/near/near-sdk-rs/pull/417). * Set up global allocator by default for WASM architectures. [PR 429](https://github.com/near/near-sdk-rs/pull/429). * This removes the re-export of `wee_alloc` because if this feature is enabled, the allocator will already be set. - * Deprecates `setup_alloc!` macro as this will be setup by default, as long as the `wee_alloc` feature is not specifically disabled. In this case, the allocator can be overriden to a custom one or set manually if intended. + * Deprecates `setup_alloc!` macro as this will be setup by default, as long as the `wee_alloc` feature is not specifically disabled. In this case, the allocator can be overridden to a custom one or set manually if intended. * Update `TreeMap` iterator implementation to avoid unnecessary storage reads. [PR 428](https://github.com/near/near-sdk-rs/pull/428). * Update `AccountId` to be a newtype with merged functionality from `ValidAccountId`. [PR 448](https://github.com/near/near-sdk-rs/pull/448) * Removes `ValidAccountId` to avoid having multiple types for account IDs. diff --git a/README.md b/README.md index a74408c66..e0c0019bd 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ pub struct StatusMessage { ``` ### Payable methods -We can allow methods to accept token transfer together with the function call. This is done so that contracts can define a fee in tokens that needs to be payed when they are used. By the default the methods are not payable and they will panic if someone will attempt to transfer tokens to them during the invocation. This is done for safety reason, in case someone accidentally transfers tokens during the function call. +We can allow methods to accept token transfer together with the function call. This is done so that contracts can define a fee in tokens that needs to be paid when they are used. By the default the methods are not payable and they will panic if someone will attempt to transfer tokens to them during the invocation. This is done for safety reason, in case someone accidentally transfers tokens during the function call. To declare a payable method simply use `#[payable]` decorator: ```rust diff --git a/examples/fungible-token/tests/workspaces.rs b/examples/fungible-token/tests/workspaces.rs index 9579b07e4..88ef49a08 100644 --- a/examples/fungible-token/tests/workspaces.rs +++ b/examples/fungible-token/tests/workspaces.rs @@ -180,7 +180,7 @@ async fn test_storage_deposit_refunds_excessive_deposit() -> anyhow::Result<()> assert_eq!(storage_balance_bounds.min, minimal_deposit.as_yoctonear().into()); assert_eq!(storage_balance_bounds.max, minimal_deposit.as_yoctonear().into()); - // Check that a non-registerred account does not have storage balance + // Check that a non-registered account does not have storage balance // #[derive(near_sdk::serde::Serialize, near_sdk::serde::Deserialize)] #[serde(crate = "near_sdk::serde")] @@ -190,7 +190,7 @@ async fn test_storage_deposit_refunds_excessive_deposit() -> anyhow::Result<()> } let storage_balance_bounds: Option = contract .call("storage_balance_of") - .args_json(near_sdk::serde_json::json!({"account_id": "non-registerred-account"})) + .args_json(near_sdk::serde_json::json!({"account_id": "non-registered-account"})) .view() .await? .json()?; diff --git a/examples/status-message/src/lib.rs b/examples/status-message/src/lib.rs index 2abc6d86d..142c68598 100644 --- a/examples/status-message/src/lib.rs +++ b/examples/status-message/src/lib.rs @@ -51,7 +51,7 @@ mod tests { testing_env!(context); let mut contract = StatusMessage::default(); contract.set_status("hello".to_string()); - // Flush the pending changes to avoid panic in the view method below due to the pending non-commited changes to the `store::LookupMap`: + // Flush the pending changes to avoid panic in the view method below due to the pending non-committed changes to the `store::LookupMap`: // HostError(ProhibitedInView { method_name: "storage_write" }) contract.records.flush(); assert_eq!(get_logs(), vec!["bob_near set_status with message hello"]); diff --git a/near-sdk-macros/src/core_impl/contract_metadata/mod.rs b/near-sdk-macros/src/core_impl/contract_metadata/mod.rs index 2a809ec37..75a183133 100644 --- a/near-sdk-macros/src/core_impl/contract_metadata/mod.rs +++ b/near-sdk-macros/src/core_impl/contract_metadata/mod.rs @@ -73,7 +73,7 @@ impl ContractMetadata { } } -/// Allows for the injection of the contract source metadata infomation into the contract code as +/// Allows for the injection of the contract source metadata information into the contract code as /// a constant. pub(crate) fn contract_source_metadata_const(attr: proc_macro::TokenStream) -> TokenStream { if attr.to_string().is_empty() { diff --git a/near-sdk-macros/src/core_impl/info_extractor/arg_info.rs b/near-sdk-macros/src/core_impl/info_extractor/arg_info.rs index 150a8632b..2f40f2972 100644 --- a/near-sdk-macros/src/core_impl/info_extractor/arg_info.rs +++ b/near-sdk-macros/src/core_impl/info_extractor/arg_info.rs @@ -35,7 +35,7 @@ pub struct ArgInfo { pub bindgen_ty: BindgenArgType, /// Type of serializer that we use for this argument. pub serializer_ty: SerializerType, - /// Spans of all occurences of the `Self` token, if any. + /// Spans of all occurrences of the `Self` token, if any. pub self_occurrences: Vec, /// The original `PatType` of the argument. pub original: PatType, diff --git a/near-sdk/compilation_tests/function_error.rs b/near-sdk/compilation_tests/function_error.rs index 92f461a3c..768d2befd 100644 --- a/near-sdk/compilation_tests/function_error.rs +++ b/near-sdk/compilation_tests/function_error.rs @@ -12,7 +12,7 @@ struct ErrorStruct { impl fmt::Display for ErrorStruct { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "error ocurred: {}", self.message) + write!(f, "error occurred: {}", self.message) } } diff --git a/near-sdk/src/collections/mod.rs b/near-sdk/src/collections/mod.rs index aa07b7f32..12a69df7c 100644 --- a/near-sdk/src/collections/mod.rs +++ b/near-sdk/src/collections/mod.rs @@ -32,7 +32,7 @@ //! ``` //! //! The efficiency of `LookupMap` comes at the cost, since it has fewer methods than `HashMap` and is not -//! that seemlessly integrated with the rest of the Rust standard library. +//! that seamlessly integrated with the rest of the Rust standard library. mod legacy_tree_map; #[allow(deprecated)] diff --git a/near-sdk/src/store/vec/mod.rs b/near-sdk/src/store/vec/mod.rs index c1b38758c..bca382e7c 100644 --- a/near-sdk/src/store/vec/mod.rs +++ b/near-sdk/src/store/vec/mod.rs @@ -197,7 +197,7 @@ where self.len == 0 } - /// Create new vector with zero elements. Prefixes storage accesss with the prefix provided. + /// Create new vector with zero elements. Prefixes storage access with the prefix provided. /// /// This prefix can be anything that implements [`IntoStorageKey`]. The prefix is used when /// storing and looking up values in storage to ensure no collisions with other collections.