From ce4a7a8ffa7098fd9cb19e651c7d1c1ca37bfd63 Mon Sep 17 00:00:00 2001 From: clint Date: Wed, 20 Dec 2023 23:30:27 +0800 Subject: [PATCH] Checked spelling --- .github/workflows/typos.yml | 16 ++++++++++++++++ account/account.go | 8 ++++---- curve/curve.go | 2 +- curve/curve_test.go | 2 +- hash/hash.go | 6 +++--- hash/hash_test.go | 4 ++-- rpc/json_test.go | 2 +- rpc/types.go | 6 +++--- rpc/types_block.go | 4 ++-- rpc/types_block_transaction.go | 2 +- rpc/types_contract.go | 2 +- rpc/types_transaction.go | 4 ++-- rpc/types_transaction_receipt.go | 8 ++++---- rpc/write_test.go | 4 ++-- typed/typed.go | 2 +- 15 files changed, 44 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/typos.yml diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml new file mode 100644 index 00000000..1deddd31 --- /dev/null +++ b/.github/workflows/typos.yml @@ -0,0 +1,16 @@ +# https://github.com/crate-ci/typos/blob/master/docs/github-action.md + +name: Typos + +on: [pull_request] + +jobs: + run: + name: Spell check with Typos + runs-on: ubuntu-latest + steps: + - name: clone repo + uses: actions/checkout@v4 + + - name: check spelling + uses: crate-ci/typos@master diff --git a/account/account.go b/account/account.go index 2c63d82d..7dde9bdc 100644 --- a/account/account.go +++ b/account/account.go @@ -14,9 +14,9 @@ import ( ) var ( - ErrNotAllParametersSet = errors.New("Not all neccessary parameters have been set") - ErrTxnTypeUnSupported = errors.New("Unsupported transction type") - ErrTxnVersionUnSupported = errors.New("Unsupported transction version") + ErrNotAllParametersSet = errors.New("Not all necessary parameters have been set") + ErrTxnTypeUnSupported = errors.New("Unsupported transaction type") + ErrTxnVersionUnSupported = errors.New("Unsupported transaction version") ErrFeltToBigInt = errors.New("Felt to BigInt error") ) @@ -939,7 +939,7 @@ func FmtCallDataCairo0(callArray []rpc.FunctionCall) []*felt.Felt { return calldata } -// FmtCallDataCairo2 generates the calldata for the given function calls for Cairo 2 contracs. +// FmtCallDataCairo2 generates the calldata for the given function calls for Cairo 2 contracts. // // Parameters: // - fnCalls: a slice of rpc.FunctionCall containing the function calls. diff --git a/curve/curve.go b/curve/curve.go index ae4b0d69..01278ae8 100644 --- a/curve/curve.go +++ b/curve/curve.go @@ -2,7 +2,7 @@ package curve /* Although the library adheres to the 'elliptic/curve' interface. - All testing has been done against library function explicity. + All testing has been done against library function explicitly. It is recommended to use in the same way(i.e. `curve.Sign` and not `ecdsa.Sign`). */ import ( diff --git a/curve/curve_test.go b/curve/curve_test.go index 6964915d..6bb216e5 100644 --- a/curve/curve_test.go +++ b/curve/curve_test.go @@ -333,7 +333,7 @@ func TestGeneral_HashAndSign(t *testing.T) { big.NewInt(1953658213), }) if err != nil { - t.Errorf("Hasing elements: %v\n", err) + t.Errorf("Hashing elements: %v\n", err) } priv, _ := Curve.GetRandomPrivateKey() diff --git a/hash/hash.go b/hash/hash.go index b669753b..48187fbf 100644 --- a/hash/hash.go +++ b/hash/hash.go @@ -69,7 +69,7 @@ func CalculateTransactionHashCommon( // The hash is calculated using the PoseidonArray function from the Curve package. // The elements used in the hash calculation include the contract class version, constructor entry point, external entry point, L1 handler entry point, ABI, and Sierra program. // The ABI is converted to bytes and then hashed using the StarknetKeccak function from the Curve package. -// Finally, the ContractClassVersionHash, ExternalHash, L1HandleHash, ConstructorHash, ABIHash, and SierraProgamHash are combined using the PoseidonArray function from the Curve package. +// Finally, the ContractClassVersionHash, ExternalHash, L1HandleHash, ConstructorHash, ABIHash, and SierraProgramHash are combined using the PoseidonArray function from the Curve package. // // Parameters: // - contract: A contract class object of type rpc.ContractClass. @@ -84,14 +84,14 @@ func ClassHash(contract rpc.ContractClass) (*felt.Felt, error) { ConstructorHash := hashEntryPointByType(contract.EntryPointsByType.Constructor) ExternalHash := hashEntryPointByType(contract.EntryPointsByType.External) L1HandleHash := hashEntryPointByType(contract.EntryPointsByType.L1Handler) - SierraProgamHash := curve.Curve.PoseidonArray(contract.SierraProgram...) + SierraProgramHash := curve.Curve.PoseidonArray(contract.SierraProgram...) ABIHash, err := curve.Curve.StarknetKeccak([]byte(contract.ABI)) if err != nil { return nil, err } // https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/transactions/#deploy_account_hash_calculation - return curve.Curve.PoseidonArray(ContractClassVersionHash, ExternalHash, L1HandleHash, ConstructorHash, ABIHash, SierraProgamHash), nil + return curve.Curve.PoseidonArray(ContractClassVersionHash, ExternalHash, L1HandleHash, ConstructorHash, ABIHash, SierraProgramHash), nil } // hashEntryPointByType calculates the hash of an entry point by type. diff --git a/hash/hash_test.go b/hash/hash_test.go index f6dc989a..efb4afc9 100644 --- a/hash/hash_test.go +++ b/hash/hash_test.go @@ -11,10 +11,10 @@ import ( "github.com/test-go/testify/require" ) -// TestUnmarshalCasmClassHash is a test function that tests the unmarshaling of a CasmClass hash. +// TestUnmarshalCasmClassHash is a test function that tests the unmarshalling of a CasmClass hash. // // It reads the content of the "./tests/hello_starknet_compiled.casm.json" file and unmarshals it into a contracts.CasmClass variable. -// The function returns an assertion error if there is an error reading the file or unmarshaling the content. +// The function returns an assertion error if there is an error reading the file or unmarshalling the content. // Parameters: // - t: A testing.T object used for running the test and reporting any failures. // Returns: diff --git a/rpc/json_test.go b/rpc/json_test.go index 619d5c00..deaa692e 100644 --- a/rpc/json_test.go +++ b/rpc/json_test.go @@ -73,7 +73,7 @@ func TestJSONMultiTypeArrayWithDuck(t *testing.T) { } } -// TestJSONMixingStructWithMap tests the JSON unmarshaling of a struct that mixes fields and a map. +// TestJSONMixingStructWithMap tests the JSON unmarshalling of a struct that mixes fields and a map. // // This function checks if the JSON content can be successfully unmarshaled into a struct that contains // a mixture of fields and a map (map[string]interface{}). diff --git a/rpc/types.go b/rpc/types.go index e0fc7d47..bea6b7f0 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -142,7 +142,7 @@ func (s SyncStatus) MarshalJSON() ([]byte, error) { // -data: It takes a byte slice as input representing the JSON data to be unmarshaled. // // Returns: -// - error: an error if the unmarshaling fails +// - error: an error if the unmarshalling fails func (s *SyncStatus) UnmarshalJSON(data []byte) error { return json.Unmarshal(data, s) @@ -213,7 +213,7 @@ const ( // Parameters: // - data: It takes a byte slice as a parameter, which represents the JSON data to be unmarshalled // Returns: -// - error: an error if the unmarshaling fails +// - error: an error if the unmarshalling fails func (ts *TxnExecutionStatus) UnmarshalJSON(data []byte) error { unquoted, err := strconv.Unquote(string(data)) if err != nil { @@ -270,7 +270,7 @@ const ( // Parameters: // - data: It takes a byte slice as a parameter, which represents the JSON data to be unmarshalled // Returns: -// - error: an error if the unmarshaling fails +// - error: an error if the unmarshalling fails func (ts *TxnFinalityStatus) UnmarshalJSON(data []byte) error { unquoted, err := strconv.Unquote(string(data)) if err != nil { diff --git a/rpc/types_block.go b/rpc/types_block.go index 34150cfe..73e1848d 100644 --- a/rpc/types_block.go +++ b/rpc/types_block.go @@ -70,12 +70,12 @@ const ( // UnmarshalJSON unmarshals the JSON representation of a BlockStatus. // // It takes in a byte slice containing the JSON data to be unmarshaled. -// The function returns an error if there is an issue unmarshaling the data. +// The function returns an error if there is an issue unmarshalling the data. // // Parameters: // - data: It takes a byte slice as a parameter, which represents the JSON data to be unmarshaled // Returns: -// - error: an error if the unmarshaling fails +// - error: an error if the unmarshalling fails func (bs *BlockStatus) UnmarshalJSON(data []byte) error { unquoted, err := strconv.Unquote(string(data)) if err != nil { diff --git a/rpc/types_block_transaction.go b/rpc/types_block_transaction.go index fb734cfb..c3913bce 100644 --- a/rpc/types_block_transaction.go +++ b/rpc/types_block_transaction.go @@ -176,7 +176,7 @@ func (txns *BlockTransactions) UnmarshalJSON(data []byte) error { // - t: The interface{} to be unmarshalled // Returns: // - BlockTransaction: a BlockTransaction -// - error: an error if the unmarshaling process fails +// - error: an error if the unmarshalling process fails func unmarshalBlockTxn(t interface{}) (BlockTransaction, error) { switch casted := t.(type) { case map[string]interface{}: diff --git a/rpc/types_contract.go b/rpc/types_contract.go index 7dc88b25..47933f9e 100644 --- a/rpc/types_contract.go +++ b/rpc/types_contract.go @@ -202,7 +202,7 @@ type StructABIEntry struct { // The event name Name string `json:"name"` - // todo(minumum size should be 1) + // todo(minimum size should be 1) Size uint64 `json:"size"` Members []Member `json:"members"` diff --git a/rpc/types_transaction.go b/rpc/types_transaction.go index 96e26660..5afb6efc 100644 --- a/rpc/types_transaction.go +++ b/rpc/types_transaction.go @@ -263,7 +263,7 @@ func (txn *UnknownTransaction) UnmarshalJSON(data []byte) error { // - t: The interface{} to be unmarshalled // Returns: // - Transaction: a Transaction object -// - error: an error if the unmarshaling process fails +// - error: an error if the unmarshalling process fails func unmarshalTxn(t interface{}) (Transaction, error) { switch casted := t.(type) { case map[string]interface{}: @@ -321,7 +321,7 @@ func unmarshalTxn(t interface{}) (Transaction, error) { // - v: The interface{} value to be marshaled // - dst: The interface{} value to be unmarshaled // Returns: -// - error: An error if the marshaling or unmarshaling process fails +// - error: An error if the marshaling or unmarshalling process fails func remarshal(v interface{}, dst interface{}) error { data, err := json.Marshal(v) if err != nil { diff --git a/rpc/types_transaction_receipt.go b/rpc/types_transaction_receipt.go index c3daf2f1..d4969d41 100644 --- a/rpc/types_transaction_receipt.go +++ b/rpc/types_transaction_receipt.go @@ -85,12 +85,12 @@ const ( // // If none of the supported values match the input data, the function returns an error. // -// nil if the unmarshaling is successful. +// nil if the unmarshalling is successful. // // Parameters: // - data: It takes a byte slice as input representing the JSON data to be unmarshaled // Returns: -// - error: an error if the unmarshaling fails +// - error: an error if the unmarshalling fails func (tt *TransactionType) UnmarshalJSON(data []byte) error { unquoted, err := strconv.Unquote(string(data)) if err != nil { @@ -468,7 +468,7 @@ type UnknownTransactionReceipt struct{ TransactionReceipt } // Parameters: // - data: It takes a byte slice as a parameter, which represents the JSON data to be unmarshalled // Returns: -// - error: an error if the unmarshaling fails +// - error: an error if the unmarshalling fails func (tr *UnknownTransactionReceipt) UnmarshalJSON(data []byte) error { var dec map[string]interface{} if err := json.Unmarshal(data, &dec); err != nil { @@ -489,7 +489,7 @@ func (tr *UnknownTransactionReceipt) UnmarshalJSON(data []byte) error { // - t: The interface{} to be unmarshalled // Returns: // - TransactionReceipt: a TransactionReceipt -// - error: an error if the unmarshaling fails +// - error: an error if the unmarshalling fails func unmarshalTransactionReceipt(t interface{}) (TransactionReceipt, error) { switch casted := t.(type) { case map[string]interface{}: diff --git a/rpc/write_test.go b/rpc/write_test.go index 2b90b8de..25a73aa9 100644 --- a/rpc/write_test.go +++ b/rpc/write_test.go @@ -77,7 +77,7 @@ func TestDeclareTransaction(t *testing.T) { t.Fatal("should be able to read file", err) } var declareTx AddDeclareTxnInput - require.Nil(t, json.Unmarshal(declareTxJSON, &declareTx), "Error unmarshalling decalreTx") + require.Nil(t, json.Unmarshal(declareTxJSON, &declareTx), "Error unmarshalling declareTx") test.DeclareTx = declareTx } @@ -178,7 +178,7 @@ func TestAddInvokeTransaction(t *testing.T) { } } -func TestAddDeployAccountTansaction(t *testing.T) { +func TestAddDeployAccountTransaction(t *testing.T) { testConfig := beforeEach(t) diff --git a/typed/typed.go b/typed/typed.go index 67373bcf..9e5c8d1f 100644 --- a/typed/typed.go +++ b/typed/typed.go @@ -77,7 +77,7 @@ func strToFelt(str string) *felt.Felt { f.SetBytes(b.Bytes()) return f } - // TODO: revisit conversation on seperate 'ShortString' conversion + // TODO: revisit conversation on separate 'ShortString' conversion if asciiRegexp.MatchString(str) { hexStr := hex.EncodeToString([]byte(str)) if b, ok := new(big.Int).SetString(hexStr, 16); ok {