Skip to content

Commit

Permalink
chore: spellchecker (#166)
Browse files Browse the repository at this point in the history
* add spellchecker and run

* fix unintended

* add skiplist to spellcheck
  • Loading branch information
Vritra4 authored Nov 15, 2024
1 parent fd11008 commit 782f4ca
Show file tree
Hide file tree
Showing 77 changed files with 156 additions and 122 deletions.
6 changes: 6 additions & 0 deletions .github/config/.codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
initia
minitia
expRes
crate
Hel
ser
28 changes: 28 additions & 0 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Spell Check

on:
pull_request:

jobs:
spellcheck:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Run codespell
continue-on-error: true
run: |
sudo apt-get install codespell -y
codespell -w --ignore-words=.github/config/.codespellignore --skip="*.git,*.so,*.dylib,go.mod,go.sum,Cargo.toml"
- uses: peter-evans/[email protected]
if: github.event_name != 'pull_request'
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: fix typos"
title: "chore: fix typos"
branch: "chore/fix-typos"
delete-branch: true
body: |
This PR fixes typos in the codebase.
Please review it, and merge if everything is fine.
If there are proto changes, run `make proto-gen` and commit the changes.
2 changes: 1 addition & 1 deletion api/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestCreateAndDestroyUnmanagedVector(t *testing.T) {
var original []byte
unmanaged := newUnmanagedVector(original)
require.Equal(t, cbool(true), unmanaged.is_none)
// We must not make assumtions on the other fields in this case
// We must not make assumptions on the other fields in this case
copy := copyAndDestroyUnmanagedVector(unmanaged)
require.Nil(t, copy)
}
Expand Down
10 changes: 5 additions & 5 deletions api/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewLookup() *Lookup {
}
}

// Get wraps the underlying DB's Get method panicing on error.
// Get wraps the underlying DB's Get method panicking on error.
func (l Lookup) Get(key []byte) []byte {
v, err := l.db.Get(key)
if err != nil {
Expand All @@ -30,21 +30,21 @@ func (l Lookup) Get(key []byte) []byte {
return v
}

// Set wraps the underlying DB's Set method panicing on error.
// Set wraps the underlying DB's Set method panicking on error.
func (l Lookup) Set(key, value []byte) {
if err := l.db.Set(key, value); err != nil {
panic(err)
}
}

// Delete wraps the underlying DB's Delete method panicing on error.
// Delete wraps the underlying DB's Delete method panicking on error.
func (l Lookup) Delete(key []byte) {
if err := l.db.Delete(key); err != nil {
panic(err)
}
}

// Iterator wraps the underlying DB's Iterator method panicing on error.
// Iterator wraps the underlying DB's Iterator method panicking on error.
func (l Lookup) Iterator(start, end []byte) dbm.Iterator {
iter, err := l.db.Iterator(start, end)
if err != nil {
Expand All @@ -54,7 +54,7 @@ func (l Lookup) Iterator(start, end []byte) dbm.Iterator {
return iter
}

// ReverseIterator wraps the underlying DB's ReverseIterator method panicing on error.
// ReverseIterator wraps the underlying DB's ReverseIterator method panicking on error.
func (l Lookup) ReverseIterator(start, end []byte) dbm.Iterator {
iter, err := l.db.ReverseIterator(start, end)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/src/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Clean {
}

fn validate_manifest(base_path: &Path) -> anyhow::Result<()> {
let manifest_path = base_path.join("Move.toml"); // manifest is in pakcage path
let manifest_path = base_path.join("Move.toml"); // manifest is in package path
if !(manifest_path.is_file()) {
bail!("move package not found in {}", base_path.display())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/gas/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! The reason why we need two different representations is that they serve different purposes:
//! - The Rust structs are used for quick (static) lookups by the gas meter and native functions
//! when calculating gas costs.
//! - The on-chain gas schedule needs to be extensible and unordered so we can upgrate it easily
//! - The on-chain gas schedule needs to be extensible and unordered so we can upgrade it easily
//! in the future.
#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion crates/gas/src/meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ struct Frame {
#[derive(Clone)]
/// The official gas meter used inside the Initia VM.
/// It maintains an internal gas counter, measured in internal gas units, and carries an environment
/// consisting all the gas parameters, which it can lookup when performing gas calcuations.
/// consisting all the gas parameters, which it can lookup when performing gas calculations.
pub struct InitiaGasMeter {
gas_params: InitiaGasParameters,
balance: InternalGas,
Expand Down
2 changes: 1 addition & 1 deletion crates/json/src/json_to_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ mod json_arg_testing {
.unwrap()
);

// invalid inner addresss
// invalid inner address
let arg = b"[\"0xgg\"]";
_ = deserialize_json_args(&code_storage, &mock_state, &ty, arg).unwrap_err();
}
Expand Down
2 changes: 1 addition & 1 deletion crates/json/src/json_to_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ mod json_arg_testing {
.unwrap()
);

// invalid inner addresss
// invalid inner address
let arg = b"[\"0xgg\"]";
_ = deserialize_json_to_value(&module_id(), &layout, arg).unwrap_err();
}
Expand Down
2 changes: 1 addition & 1 deletion crates/natives/src/function_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
safely_pop_arg,
};

// Extract Identifer from a move value of type &String
// Extract Identifier from a move value of type &String
fn identifier_from_ref(v: Value) -> SafeNativeResult<Identifier> {
let bytes = v
.value_as::<StructRef>()
Expand Down
2 changes: 1 addition & 1 deletion crates/natives/src/move_stdlib/bcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn native_serialized_size(
Err(_) => {
context.charge(gas_params.bcs_serialized_size_failure)?;

// Re-use the same abort code as bcs::to_bytes.
// Reuse the same abort code as bcs::to_bytes.
return Err(SafeNativeError::Abort {
abort_code: BCS_SERIALIZATION_FAILURE,
});
Expand Down
2 changes: 1 addition & 1 deletion crates/types/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub struct CompilerDocgenOptions {
pub landing_page_template: Option<String>,

/// Package-relative path to a file whose content is added to each generated markdown file.
/// This can contain common markdown references fpr this package (e.g. `[move-book]: <url>`).
/// This can contain common markdown references for this package (e.g. `[move-book]: <url>`).
pub references_file: Option<String>,
}

Expand Down
Binary file modified precompile/binaries/minlib/multisig.mv
Binary file not shown.
Binary file modified precompile/binaries/stdlib/minitswap.mv
Binary file not shown.
Binary file modified precompile/binaries/stdlib/multisig.mv
Binary file not shown.
6 changes: 3 additions & 3 deletions precompile/modules/initia_stdlib/doc/coin.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ Only fungible asset metadata owner can make changes.

## Function `mint`

Mint FAs as the owner of metadat object.
Mint FAs as the owner of metadata object.


<pre><code><b>public</b> <b>fun</b> <a href="coin.md#0x1_coin_mint">mint</a>(mint_cap: &<a href="coin.md#0x1_coin_MintCapability">coin::MintCapability</a>, amount: u64): <a href="fungible_asset.md#0x1_fungible_asset_FungibleAsset">fungible_asset::FungibleAsset</a>
Expand Down Expand Up @@ -506,7 +506,7 @@ Mint FAs as the owner of metadat object.

## Function `mint_to`

Mint FAs as the owner of metadat object to the primary fungible store of the given recipient.
Mint FAs as the owner of metadata object to the primary fungible store of the given recipient.


<pre><code><b>public</b> <b>fun</b> <a href="coin.md#0x1_coin_mint_to">mint_to</a>(mint_cap: &<a href="coin.md#0x1_coin_MintCapability">coin::MintCapability</a>, recipient: <b>address</b>, amount: u64)
Expand Down Expand Up @@ -539,7 +539,7 @@ Mint FAs as the owner of metadat object to the primary fungible store of the giv

## Function `burn`

Burn FAs as the owner of metadat object.
Burn FAs as the owner of metadata object.


<pre><code><b>public</b> <b>fun</b> <a href="coin.md#0x1_coin_burn">burn</a>(burn_cap: &<a href="coin.md#0x1_coin_BurnCapability">coin::BurnCapability</a>, fa: <a href="fungible_asset.md#0x1_fungible_asset_FungibleAsset">fungible_asset::FungibleAsset</a>)
Expand Down
2 changes: 1 addition & 1 deletion precompile/modules/initia_stdlib/doc/collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ Provides the count of the current selection if supply tracking is used
## Function `nfts`

get nft list from collection
if <code>start_after</code> is not none, seach nfts in range (start_after, ...]
if <code>start_after</code> is not none, search nfts in range (start_after, ...]


<pre><code>#[view]
Expand Down
2 changes: 1 addition & 1 deletion precompile/modules/initia_stdlib/doc/dex.md
Original file line number Diff line number Diff line change
Expand Up @@ -2584,7 +2584,7 @@ CONTRACT: not allow until LBP is ended

## Function `single_asset_provide_liquidity`

Signle asset provide liquidity directly
Single asset provide liquidity directly
CONTRACT: cannot provide more than the pool amount to prevent huge price impact
CONTRACT: not allow until LBP is ended

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The dispatchable_fungible_asset wraps the existing fungible_asset module and add
to customize the logic for withdraw and deposit operations. For example:

- Deflation token: a fixed percentage of token will be destructed upon transfer.
- Transfer allowlist: token can only be transfered to addresses in the allow list.
- Transfer allowlist: token can only be transferred to addresses in the allow list.
- Predicated transfer: transfer can only happen when some certain predicate has been met.
- Loyalty token: a fixed loyalty will be paid to a designated address when a fungible asset transfer happens

Expand Down Expand Up @@ -285,7 +285,7 @@ Note: it does not move the underlying object.
## Function `transfer_assert_minimum_deposit`

Transfer an <code>amount</code> of fungible asset from <code>from_store</code>, which should be owned by <code>sender</code>, to <code>receiver</code>.
The recipient is guranteed to receive asset greater than the expected amount.
The recipient is guaranteed to receive asset greater than the expected amount.
Note: it does not move the underlying object.


Expand Down
2 changes: 1 addition & 1 deletion precompile/modules/initia_stdlib/doc/ed25519.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ The size of a serialized signature, in bytes.

## Function `public_key_from_bytes`

Contructs an PublicKey struct, given 32-byte representation.
Constructs an PublicKey struct, given 32-byte representation.


<pre><code><b>public</b> <b>fun</b> <a href="ed25519.md#0x1_ed25519_public_key_from_bytes">public_key_from_bytes</a>(bytes: <a href="../../move_nursery/../move_stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;): <a href="ed25519.md#0x1_ed25519_PublicKey">ed25519::PublicKey</a>
Expand Down
2 changes: 1 addition & 1 deletion precompile/modules/initia_stdlib/doc/fungible_asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ This can only be called at object creation time as constructor_ref is only avail

## Function `is_fungible_asset`

Retrun true if given address has Metadata else return false
Return true if given address has Metadata else return false


<pre><code>#[view]
Expand Down
2 changes: 1 addition & 1 deletion precompile/modules/initia_stdlib/doc/math128.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Returns square root of x, precisely floor(sqrt(x))
<b>let</b> res = 1 &lt;&lt; ((<a href="math128.md#0x1_math128_floor_log2">floor_log2</a>(x) + 1) &gt;&gt; 1);
// We <b>use</b> standard newton-rhapson iteration <b>to</b> improve the initial approximation.
// The <a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error">error</a> term evolves <b>as</b> delta_i+1 = delta_i^2 / 2 (quadratic convergence).
// It turns out that after 5 iterations the delta is smaller than 2^-64 and thus below the treshold.
// It turns out that after 5 iterations the delta is smaller than 2^-64 and thus below the threshold.
res = (res + x / res) &gt;&gt; 1;
res = (res + x / res) &gt;&gt; 1;
res = (res + x / res) &gt;&gt; 1;
Expand Down
2 changes: 1 addition & 1 deletion precompile/modules/initia_stdlib/doc/math64.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ Returns square root of x, precisely floor(sqrt(x))
<b>let</b> res = 1 &lt;&lt; ((<a href="math64.md#0x1_math64_floor_log2">floor_log2</a>(x) + 1) &gt;&gt; 1);
// We <b>use</b> standard newton-rhapson iteration <b>to</b> improve the initial approximation.
// The <a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error">error</a> term evolves <b>as</b> delta_i+1 = delta_i^2 / 2 (quadratic convergence).
// It turns out that after 4 iterations the delta is smaller than 2^-32 and thus below the treshold.
// It turns out that after 4 iterations the delta is smaller than 2^-32 and thus below the threshold.
res = (res + x / res) &gt;&gt; 1;
res = (res + x / res) &gt;&gt; 1;
res = (res + x / res) &gt;&gt; 1;
Expand Down
4 changes: 2 additions & 2 deletions precompile/modules/initia_stdlib/doc/minitswap.md
Original file line number Diff line number Diff line change
Expand Up @@ -3962,7 +3962,7 @@ Event emitted when arb reverted
<a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error_invalid_state">error::invalid_state</a>(<a href="minitswap.md#0x1_minitswap_EEMERGENCY">EEMERGENCY</a>)
);

// check metdata
// check metadata
<b>let</b> share_token_metadata = <a href="fungible_asset.md#0x1_fungible_asset_metadata_from_asset">fungible_asset::metadata_from_asset</a>(&share_token);
<b>assert</b>!(
share_token_metadata == <a href="minitswap.md#0x1_minitswap_share_token_metadata">share_token_metadata</a>(),
Expand Down Expand Up @@ -4366,7 +4366,7 @@ Event emitted when arb reverted
// and then calculate arb fee and get actual <b>return</b> amount which is same <b>with</b> return_amount_before_swap_fee - swap_fee_amount - arb_fee_amount
// <b>to</b> make actual <b>return</b> amount <b>to</b> <b>return</b> amount, set return_amount_before_swap_fee = return_amount_before_swap_fee + return_diff
// <b>where</b> return_diff = target <b>return</b> amount - actual <b>return</b> amount
// and recalculate offer amount repeatly until <b>return</b> amount &lt;= actual <b>return</b> amount
// and recalculate offer amount repeatedly until <b>return</b> amount &lt;= actual <b>return</b> amount
// note that actual <b>return</b> is always small or equal <b>with</b> target <b>return</b> amount

// adjust fee. <b>return</b> amount before swap fee = <b>return</b> amount * 1 / (1 - f)
Expand Down
2 changes: 1 addition & 1 deletion precompile/modules/initia_stdlib/doc/nft.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ a small optimization to support either and take a fixed amount of 34-bytes.

## Struct `MutatorRef`

This enables mutating descritpion and URI by higher level services.
This enables mutating description and URI by higher level services.


<pre><code><b>struct</b> <a href="nft.md#0x1_nft_MutatorRef">MutatorRef</a> <b>has</b> drop, store
Expand Down
2 changes: 1 addition & 1 deletion precompile/modules/initia_stdlib/doc/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ The version of ref does not match with object core version.

<a id="0x1_object_MAXIMUM_OBJECT_NESTING"></a>

Maximum nesting from one object to another. That is objects can technically have infinte
Maximum nesting from one object to another. That is objects can technically have infinite
nesting, but any checks such as transfer will only be evaluated this deep.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ Transfer <code>amount</code> of fungible asset from sender's primary store to re
## Function `transfer_assert_minimum_deposit`

Transfer <code>amount</code> of fungible asset from sender's primary store to receiver's primary store.
Use the minimum deposit assertion api to make sure receipient will receive a minimum amount of fund.
Use the minimum deposit assertion api to make sure recipient will receive a minimum amount of fund.


<pre><code><b>public</b> entry <b>fun</b> <a href="primary_fungible_store.md#0x1_primary_fungible_store_transfer_assert_minimum_deposit">transfer_assert_minimum_deposit</a>&lt;T: key&gt;(sender: &<a href="../../move_nursery/../move_stdlib/doc/signer.md#0x1_signer">signer</a>, metadata: <a href="object.md#0x1_object_Object">object::Object</a>&lt;T&gt;, recipient: <b>address</b>, amount: u64, expected: u64)
Expand Down
2 changes: 1 addition & 1 deletion precompile/modules/initia_stdlib/doc/property_map.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ Maximum number of characters in a property name
## Function `burn`

Burns the entire property map
TODO: hanlde when table is not empty
TODO: handle when table is not empty


<pre><code><b>public</b> <b>fun</b> <a href="property_map.md#0x1_property_map_burn">burn</a>(ref: <a href="property_map.md#0x1_property_map_MutatorRef">property_map::MutatorRef</a>)
Expand Down
2 changes: 1 addition & 1 deletion precompile/modules/initia_stdlib/doc/stableswap.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<code>extend_ref: <a href="object.md#0x1_object_ExtendRef">object::ExtendRef</a></code>
</dt>
<dd>
Extend Refernce
Extend Reference
</dd>
<dt>
<code>ann: <a href="stableswap.md#0x1_stableswap_Ann">stableswap::Ann</a></code>
Expand Down
8 changes: 4 additions & 4 deletions precompile/modules/initia_stdlib/doc/staking.md
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ util function to convert Unbonding => UnbondingResponse for third party queriers

## Function `get_delegation`

Get delegation info of specifed addr and validator
Get delegation info of specified addr and validator


<pre><code>#[view]
Expand Down Expand Up @@ -2116,7 +2116,7 @@ Get <code>share</code> from <code><a href="staking.md#0x1_staking_Delegation">De

## Function `destroy_empty_delegation`

Destory empty delegation
Destroy empty delegation


<pre><code><b>public</b> <b>fun</b> <a href="staking.md#0x1_staking_destroy_empty_delegation">destroy_empty_delegation</a>(delegation: <a href="staking.md#0x1_staking_Delegation">staking::Delegation</a>)
Expand Down Expand Up @@ -2485,7 +2485,7 @@ Get <code>unbonding_amount</code> from <code><a href="staking.md#0x1_staking_Unb

## Function `destroy_empty_unbonding`

Destory empty unbonding
Destroy empty unbonding


<pre><code><b>public</b> <b>fun</b> <a href="staking.md#0x1_staking_destroy_empty_unbonding">destroy_empty_unbonding</a>(unbonding: <a href="staking.md#0x1_staking_Unbonding">staking::Unbonding</a>)
Expand Down Expand Up @@ -2576,7 +2576,7 @@ Deposit the unbonding into recipient's account.

## Function `withdraw_unbonding`

Withdraw specifed <code>amount</code> of unbonding_amount from the unbonding.
Withdraw specified <code>amount</code> of unbonding_amount from the unbonding.


<pre><code><b>public</b> <b>fun</b> <a href="staking.md#0x1_staking_withdraw_unbonding">withdraw_unbonding</a>(<a href="account.md#0x1_account">account</a>: &<a href="../../move_nursery/../move_stdlib/doc/signer.md#0x1_signer">signer</a>, metadata: <a href="object.md#0x1_object_Object">object::Object</a>&lt;<a href="fungible_asset.md#0x1_fungible_asset_Metadata">fungible_asset::Metadata</a>&gt;, validator: <a href="../../move_nursery/../move_stdlib/doc/string.md#0x1_string_String">string::String</a>, release_time: u64, amount: u64): <a href="staking.md#0x1_staking_Unbonding">staking::Unbonding</a>
Expand Down
6 changes: 3 additions & 3 deletions precompile/modules/initia_stdlib/sources/coin.move
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ module initia_std::coin {
// Admin operations
//

/// Mint FAs as the owner of metadat object.
/// Mint FAs as the owner of metadata object.
public fun mint(mint_cap: &MintCapability, amount: u64): FungibleAsset acquires ManagingRefs {
let metadata = mint_cap.metadata;
let metadata_addr = object::object_address(&metadata);
Expand All @@ -213,7 +213,7 @@ module initia_std::coin {
fungible_asset::mint(&refs.mint_ref, amount)
}

/// Mint FAs as the owner of metadat object to the primary fungible store of the given recipient.
/// Mint FAs as the owner of metadata object to the primary fungible store of the given recipient.
public fun mint_to(
mint_cap: &MintCapability, recipient: address, amount: u64
) acquires ManagingRefs {
Expand All @@ -229,7 +229,7 @@ module initia_std::coin {
primary_fungible_store::mint(&refs.mint_ref, recipient, amount)
}

/// Burn FAs as the owner of metadat object.
/// Burn FAs as the owner of metadata object.
public fun burn(burn_cap: &BurnCapability, fa: FungibleAsset) acquires ManagingRefs {
let metadata = burn_cap.metadata;
let metadata_addr = object::object_address(&metadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module initia_std::ed25519 {
// Functions
//

/// Contructs an PublicKey struct, given 32-byte representation.
/// Constructs an PublicKey struct, given 32-byte representation.
public fun public_key_from_bytes(bytes: vector<u8>): PublicKey {
assert!(
std::vector::length(&bytes) == PUBLIC_KEY_SIZE,
Expand Down
Loading

0 comments on commit 782f4ca

Please sign in to comment.