Skip to content

Fix typos #744

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# web3swift
**web3swift** is an iOS toolbelt for interaction with the Ethereum network.

## Social medias
## Social media
[Join our discord](https://discord.gg/8bHCNmhS7x) or [Telegram](https://t.me/web3swift) if you need support or want to contribute to web3swift development!

![matter-github-swift](https://github.com/web3swift-team/web3swift/blob/develop/web3swift-logo.png)
Expand Down Expand Up @@ -44,20 +44,20 @@

## Core features

- [x] :zap: Swift implementation of [web3.js](https://github.com/ethereum/web3.js/) functionality
- [x] :thought_balloon: Interaction with remote node via **JSON RPC**
- [x] :zap: Swift implementation of [web3.js](https://github.com/ethereum/web3.js/) functionality
- [x] :thought_balloon: Interaction with remote node via **JSON RPC**
- [x] 🔐 Local **keystore management** (`geth` compatible)
- [x] 🤖 Smart-contract **ABI parsing**
- [x] 🤖 Smart-contract **ABI parsing**
- [x] 🔓**ABI decoding** (V2 is supported with return of structures from public functions. Part of 0.4.22 Solidity compiler)
- [x] 🕸Ethereum Name Service **(ENS) support** - a secure & decentralised way to address resources both on and off the blockchain using simple, human-readable names
- [x] :arrows_counterclockwise: **Smart contracts interactions** (read/write)
- [x] :arrows_counterclockwise: **Smart contracts interactions** (read/write)
- [x] ⛩ **Infura support**
- [x] ⚒ **Parsing TxPool** content into native values (ethereum addresses and transactions) - easy to get pending transactions
- [x] 🖇 **Event loops** functionality
- [x] 🕵️‍♂️ Possibility to **add or remove "middleware" that intercepts**, modifies and even **cancel transaction** workflow on stages "before assembly", "after assembly" and "before submission"
- [x] ✅**Literally following the standards** (BIP, EIP, etc):
- [x] **[BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) (HD Wallets), [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) (Seed phrases), [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) (Key generation prefixes)**
- [x] **[EIP-20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md)** (Standart interface for tokens - ERC-20), **[EIP-67](https://github.com/ethereum/EIPs/issues/67)** (Standard URI scheme), **[EIP-155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md)** (Replay attacks protection), **[EIP-2718](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2718.md)** (Typed Transaction Envelope), **[EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md)** (Gas Fee market change)
- [x] **[EIP-20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md)** (Standard interface for tokens - ERC-20), **[EIP-67](https://github.com/ethereum/EIPs/issues/67)** (Standard URI scheme), **[EIP-155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md)** (Replay attacks protection), **[EIP-2718](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2718.md)** (Typed Transaction Envelope), **[EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md)** (Gas Fee market change)
- [x] **And many others** *(For details about this EIP's look at [Documentation page](https://github.com/web3swift-team/web3swift/blob/master/Documentation/))*: EIP-681, EIP-721, EIP-165, EIP-777, EIP-820, EIP-888, EIP-1400, EIP-1410, EIP-1594, EIP-1643, EIP-1644, EIP-1633, EIP-721, EIP-1155, EIP-1376, ST-20
- [x] **RLP encoding**
- [x] Base58 encoding scheme
Expand Down
6 changes: 3 additions & 3 deletions Sources/Core/EthereumABI/ABIElements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ extension ABI.Element.Function {

var returnArray = [String: Any]()

// set infomation
// set information
returnArray["_abortedByRequire"] = true
returnArray["_errorMessageFromRequire"] = message

Expand Down Expand Up @@ -340,8 +340,8 @@ extension ABI.Element.Constructor {

/// Generic input decoding function.
/// - Parameters:
/// - rawData: data to decode. Must match the followin criteria: `data.count == 0 || data.count % 32 == 4`.
/// - methodEncoding: 4 bytes represeting method signature like `0xFFffFFff`. Can be ommited to avoid checking method encoding.
/// - rawData: data to decode. Must match the following criteria: `data.count == 0 || data.count % 32 == 4`.
/// - methodEncoding: 4 bytes representing method signature like `0xFFffFFff`. Can be omitted to avoid checking method encoding.
/// - inputs: expected input types. Order must be the same as in function declaration.
/// - Returns: decoded dictionary of input arguments mapped to their indices and arguments' names if these are not empty.
/// If decoding of at least one argument fails, `rawData` size is invalid or `methodEncoding` doesn't match - `nil` is returned.
Expand Down
6 changes: 3 additions & 3 deletions Sources/Web3Core/Contract/ContractProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public protocol ContractProtocol {
/// - bytecode: bytecode to deploy.
/// - constructor: constructor of the smart contract bytecode is related to. Used to encode `parameters`.
/// - parameters: parameters for `constructor`.
/// - extraData: any extra data. It can be encoded input arguments for a constuctor but then you should set `constructor` and
/// - extraData: any extra data. It can be encoded input arguments for a constructor but then you should set `constructor` and
/// `parameters` to be `nil`.
/// - Returns: Encoded data for a given parameters, which is should be assigned to ``CodableTransaction.data`` property
func deploy(bytecode: Data,
Expand Down Expand Up @@ -185,7 +185,7 @@ public protocol ContractProtocol {
extension ContractProtocol {

/// Overloading of ``ContractProtocol/deploy(bytecode:constructor:parameters:extraData:)`` to allow
/// omitting evertyhing but `bytecode`.
/// omitting everything but `bytecode`.
///
/// See ``ContractProtocol/deploy(bytecode:constructor:parameters:extraData:)`` for details.
func deploy(_ bytecode: Data,
Expand Down Expand Up @@ -252,7 +252,7 @@ extension DefaultContractProtocol {
/// - extraData: Any additional data that needs to be encoded
/// - Returns: preset CodableTransaction with filled date
///
/// Returned transaction have filled following priperties:
/// Returned transaction have filled following properties:
/// - to: contractAddress
/// - value: 0
/// - data: parameters + extraData
Expand Down
4 changes: 2 additions & 2 deletions Sources/Web3Core/EthereumABI/ABIDecoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ extension ABIDecoder {
guard let valueUnwrapped = v, let consumedUnwrapped = c else {return (nil, nil)}
toReturn.append(valueUnwrapped)
// When decoding a tuple that is not static or an array with a subtype that is not static,
// the second value in the tuple returned by decodeSignleType is a pointer to the next element,
// the second value in the tuple returned by decodeSingleType is a pointer to the next element,
// NOT the length of the consumed element. So when decoding such an element, consumed should
// be set to consumedUnwrapped, NOT incremented by consumedUnwrapped.
switch subTypes[i] {
Expand Down Expand Up @@ -196,7 +196,7 @@ extension ABIDecoder {
let dataSlice = data[pointer ..< pointer + type.memoryUsage]
let bn = BigUInt(dataSlice)
if bn > UInt64.max || bn >= data.count {
// there are ERC20 contracts that use bytes32 intead of string. Let's be optimistic and return some data
// there are ERC20 contracts that use bytes32 instead of string. Let's be optimistic and return some data
if case .string = type {
let nextElement = pointer + type.memoryUsage
let preambula = BigUInt(32).abiEncode(bits: 256)!
Expand Down
10 changes: 5 additions & 5 deletions Sources/Web3Core/EthereumABI/ABIElements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ extension ABI.Element.Function {
/// - Parameters:
/// - data: bytes returned by a function call;
/// - errors: optional dictionary of known errors that could be returned by the function you called. Used to decode the error information.
/// - Returns: a dictionary containing decoded data mappend to indices and names of returned values if these are not `nil`.
/// - Returns: a dictionary containing decoded data mapped to indices and names of returned values if these are not `nil`.
/// If `data` is an error response returns dictionary containing all available information about that specific error. Read more for details.
///
/// Return cases:
Expand Down Expand Up @@ -373,7 +373,7 @@ extension ABI.Element.Function {
/// "error_arg2_name": error_arg2, // Otherwise, you can query them by position index.
/// ...]
///
/// /// or if custo error found but decoding failed
/// /// or if custom error found but decoding failed
/// ["_success": false,
/// "_abortedByRevertOrRequire": true,
/// // "_error" can contain value like `MyCustomError(uint256, address senderAddress)`
Expand All @@ -389,7 +389,7 @@ extension ABI.Element.Function {
}

/// Explanation of this condition:
/// When `revert(string)` or `require(false, string)` are called in soliditiy they produce
/// When `revert(string)` or `require(false, string)` are called in solidity they produce
/// an error, specifically an instance of default `Error(string)` type.
/// 1) The total number of bytes returned are at least 100.
/// 2) The function selector for `Error(string)` is `08C379A0`;
Expand Down Expand Up @@ -438,8 +438,8 @@ extension ABI.Element.Constructor {

/// Generic input decoding function.
/// - Parameters:
/// - rawData: data to decode. Must match the followin criteria: `data.count == 0 || data.count % 32 == 4`.
/// - methodEncoding: 4 bytes represeting method signature like `0xFFffFFff`. Can be ommited to avoid checking method encoding.
/// - rawData: data to decode. Must match the following criteria: `data.count == 0 || data.count % 32 == 4`.
/// - methodEncoding: 4 bytes representing method signature like `0xFFffFFff`. Can be omitted to avoid checking method encoding.
/// - inputs: expected input types. Order must be the same as in function declaration.
/// - Returns: decoded dictionary of input arguments mapped to their indices and arguments' names if these are not empty.
/// If decoding of at least one argument fails, `rawData` size is invalid or `methodEncoding` doesn't match - `nil` is returned.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Web3Core/EthereumABI/Sequence+ABIExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public extension Sequence where Element == ABI.Element {
/// Filters out ``ABI/Element/Constructor``.
/// If there are multiple of them the first encountered will be returned and if there are none a default constructor will be returned
/// that accepts no input parameters.
/// - Returns: the first ``ABI/Element/Constructor`` or default contructor with no input parameters.
/// - Returns: the first ``ABI/Element/Constructor`` or default constructor with no input parameters.
func getConstructor() -> ABI.Element.Constructor {
for case let .constructor(constructor) in self {
return constructor
Expand Down
6 changes: 3 additions & 3 deletions Sources/Web3Core/EthereumAddress/EthereumAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public struct EthereumAddress: Equatable {
}
}

/// Validates and checksumms given `addr`.
/// Validates and checksums given `addr`.
/// If given string is not an address, incomplete address or is invalid validation will fail and `nil` will be returned.
/// - Parameter addr: address in string format, case insensitive, `0x` prefix is not required.
/// - Returns: validates and checksumms the address. Returns `nil` if checksumm has failed or given string cannot be
/// - Returns: validates and checksums the address. Returns `nil` if checksum has failed or given string cannot be
/// represented as `ASCII` data. Otherwise, checksummed address is returned with `0x` prefix.
public static func toChecksumAddress(_ addr: String) -> String? {
let address = addr.lowercased().stripHexPrefix()
Expand Down Expand Up @@ -91,7 +91,7 @@ public struct EthereumAddress: Equatable {
}

/// In swift structs it's better to implement initializers in extension
/// Since it's make available syntetized initializer then for free.
/// Since it's make available synthesized initializer then for free.
extension EthereumAddress {
public init?(_ addressString: String, type: AddressType = .normal, ignoreChecksum: Bool = false) {
switch type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ extension APIRequest {

/// This bit of code is purposed to work with literal types that comes in ``Response`` in hexString type.
/// Currently it's just `Data` and any kind of Integers `(U)Int`, `Big(U)Int`.
if let LiteralType = Result.self as? LiteralInitiableFromString.Type {
if let LiteralType = Result.self as? LiteralInitableFromString.Type {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please undo this changes, as they affecting code, rather then comments and should be reviewed separately.

guard let responseAsString = try? JSONDecoder().decode(APIResponse<String>.self, from: data) else { throw Web3Error.dataError }
guard let literalValue = LiteralType.init(from: responseAsString.result) else { throw Web3Error.dataError }
/// `literalValue` conforms `LiteralInitiableFromString`, that conforming to an `APIResponseType` type, so it's never fails.
/// `literalValue` conforms `LiteralInitableFromString`, that conforming to an `APIResponseType` type, so it's never fails.
guard let result = literalValue as? Result else { throw Web3Error.typeError }
return APIResponse(id: responseAsString.id, jsonrpc: responseAsString.jsonrpc, result: result)
}
Expand Down
14 changes: 7 additions & 7 deletions Sources/Web3Core/EthereumNetwork/Request/APIRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public typealias TransactionHash = Hash // 64 chars length without 0x
/// #### ``APIResultType``
/// This protocol responsible for any **nonliteral** type that could be stored within `APIResponse<Result>` generic struct. This protocol have no requirements except it conforms `Decodable` protocol. So any decodable type **could be** extended to conforms it.
///
/// #### ``LiteralInitiableFromString``
/// #### ``LiteralInitableFromString``
/// This protocol responsible for any literal types that could be stored within `APIResponse<Result>`. This protocol conforms `APIResultType` and it adds some requirements to it, like initializer from hex string. Despite that a given type could be extended to implement such initializer ==this should be done on a user side== because to make it work it requires some work within `sendRequest` method to be done.
///
/// #### ``IntegerInitableWithRadix``
Expand Down Expand Up @@ -95,7 +95,7 @@ public enum APIRequest {
/// Estimate required gas amount for transaction
/// - Parameters:
/// - TransactionParameters: parameters of planned transaction
/// - BlockNumber: block where it should be evalueated
/// - BlockNumber: block where it should be evaluated
case estimateGas(CodableTransaction, BlockNumber)

/// Send raw transaction
Expand All @@ -114,7 +114,7 @@ public enum APIRequest {
case getTransactionByHash(Hash)

/// Get transaction receipt
/// - Paramters:
/// - Parameters:
/// - Hash: transaction hash ID
case getTransactionReceipt(Hash)

Expand All @@ -131,10 +131,10 @@ public enum APIRequest {

/// Call a given contract
///
/// Mostly could be used for intreacting with a contracts, but also could be used for simple transaction sending
/// Mostly could be used for interacting with a contracts, but also could be used for simple transaction sending
/// - Parameters:
/// - TransactionParameters: transaction to be sent into chain
/// - BlockNumber: block where it should be evalueated
/// - BlockNumber: block where it should be evaluated
case call(CodableTransaction, BlockNumber)

/// Get a transaction counts on a given block
Expand All @@ -149,7 +149,7 @@ public enum APIRequest {

/// Get a balance of a given address
/// - Parameters:
/// - Address: address which balance would be recieved
/// - Address: address which balance would be received
/// - BlockNumber: block to check
case getBalance(Address, BlockNumber)

Expand Down Expand Up @@ -190,7 +190,7 @@ public enum APIRequest {
/// - BlockNumber: Highest block of the requested range.
/// - [Double]: A monotonically increasing list of percentile values.
/// For each block in the requested range, the transactions will be sorted in ascending order
/// by effective tip per gas and the coresponding effective tip for the percentile will be determined, accounting for gas consumed."
/// by effective tip per gas and the corresponding effective tip for the percentile will be determined, accounting for gas consumed."
case feeHistory(BigUInt, BlockNumber, [Double])

// MARK: - Personal Ethereum API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

extension RequestParameter: Encodable {
/**
This encoder encodes `RequestParameter` assotiated value ignoring self value
This encoder encodes `RequestParameter` associated value ignoring self value

This is required to encode mixed types array, like

Expand Down Expand Up @@ -48,7 +48,7 @@ extension RequestParameter: Encodable {

case is CodableTransaction.Type: try enumContainer.encode(rawValue as! CodableTransaction)
case is EventFilterParameters.Type: try enumContainer.encode(rawValue as! EventFilterParameters)
default: break /// can't be executed, coz possible `self.rawValue` types are strictly defined in it's inplementation.`
default: break /// can't be executed, coz possible `self.rawValue` types are strictly defined in it's implementation.`
}
// swiftlint:enable force_cast
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import Foundation
import BigInt

extension Int: LiteralInitiableFromString { }
extension Int: LiteralInitableFromString { }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please undo this changes, as they affecting code, rather then comments and should be reviewed separately.


extension UInt: LiteralInitiableFromString { }
extension UInt: LiteralInitableFromString { }

extension BigInt: LiteralInitiableFromString { }
extension BigInt: LiteralInitableFromString { }

extension BigUInt: LiteralInitiableFromString { }
extension BigUInt: LiteralInitableFromString { }

extension Data: LiteralInitiableFromString {
extension Data: LiteralInitableFromString {
public static func fromHex(_ hex: String) -> Data? {
let string = hex.lowercased().stripHexPrefix()
let array = [UInt8](hex: string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ extension String: APIResultType { }
///
/// You better not use it in any other part of a bit of code except `APIResponse<T>` decoding.
///
/// This protocols intention is to work around that Ethereum API cases, when almost all numbers are comming as strings.
/// This protocols intention is to work around that Ethereum API cases, when almost all numbers are coming as strings.
/// More than that their notation (e.g. 0x12d) are don't fit with the default Numeric decoders behaviours.
/// So to work around that for generic cases we're going to force decode `APIResponse.result` field as `String`
/// and then initiate it
protocol LiteralInitiableFromString: APIResultType {
protocol LiteralInitableFromString: APIResultType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please undo this changes, as they affecting code, rather then comments and should be reviewed separately.

init?(from hexString: String)
}

extension LiteralInitiableFromString where Self: IntegerInitableWithRadix {
extension LiteralInitableFromString where Self: IntegerInitableWithRadix {
/// This initializer is intended to init `(U)Int` from hex string with `0x` prefix.
init?(from hexString: String) {
guard hexString.hasPrefix("0x") else { return nil }
Expand Down
4 changes: 2 additions & 2 deletions Sources/Web3Core/KeystoreManager/IBAN.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public struct IBAN {

internal static func decodeToInts(_ iban: String) -> String {
let uppercasedIBAN = iban.replacingOccurrences(of: " ", with: "").uppercased()
let begining = String(uppercasedIBAN[0..<4])
let beginning = String(uppercasedIBAN[0..<4])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please undo this changes, as they affecting code, rather then comments and should be reviewed separately.

let end = String(uppercasedIBAN[4...])
let IBAN = end + begining
let IBAN = end + beginning
var arrayOfInts = [Int]()
for ch in IBAN {
guard let dataPoint = String(ch).data(using: .ascii) else {return ""}
Expand Down
Loading