Skip to content

Commit 56b0d59

Browse files
authored
Merge pull request #3 from pharms-eth/test-1115629
merge remote develop update
2 parents 915bcd9 + f6f86b3 commit 56b0d59

File tree

125 files changed

+1100
-998
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1100
-998
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Bug Report
2+
description: File a bug report.
3+
labels: ['bug']
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for taking the time to fill out this bug report!
9+
- type: textarea
10+
id: bug-description
11+
attributes:
12+
label: What happened?
13+
description: Please describe the bug.
14+
placeholder: Description of the bug.
15+
validations:
16+
required: true
17+
- type: textarea
18+
id: steps-to-reproduce
19+
attributes:
20+
label: What are the steps to reproduce?
21+
description: Please describe the steps to reproduce the bug.
22+
placeholder: |
23+
Step 1: ...
24+
Step 2: ...
25+
Step 3: ...
26+
validations:
27+
required: true
28+
- type: textarea
29+
id: expected-behavior
30+
attributes:
31+
label: What is the expected behavior?
32+
description: Please describe the behavior you expect.
33+
placeholder: I expect that...
34+
validations:
35+
required: true
36+
- type: textarea
37+
id: error-thrown
38+
attributes:
39+
label: What is the error thrown?
40+
description: Please provide the exact error thrown.
41+
placeholder: Web3Error.invalidData("Exact error message")
42+
validations:
43+
required: true
44+
- type: textarea
45+
id: source-path
46+
attributes:
47+
label: What's the stack trace said?
48+
description: Please provide the exact source path.
49+
placeholder: Sources/Core/Transaction/CodableTransaction.swift:129 func recoverPublicKey()
50+
validations:
51+
required: true
52+
- type: textarea
53+
id: os-version
54+
attributes:
55+
label: OS version
56+
description: Please specify what platform and os version you are using?
57+
placeholder: macOS 13.0.1 (22A400)
58+
validations:
59+
required: true
60+
- type: textarea
61+
id: lib-version
62+
attributes:
63+
label: Library version
64+
description: Please specify what library version you are using?
65+
placeholder: 3.0.6 or "ef06fbfc735ab687ebf89c937a9d1ffe6d81d37f" commit.
66+
validations:
67+
required: true
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Documentation Request
2+
description: Suggest documentation you would like added
3+
labels: ['documentation']
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for taking the time to fill out this documentation request!
9+
- type: textarea
10+
id: area
11+
attributes:
12+
label: What piece of the framework are having the lack of docs?
13+
description: Bring the link, either type, either method name that is having the lack of docs
14+
placeholder: "`Sources/Core/EthereumABI.swift:ABIElementPropertiesProtocol` or `ABIElementPropertiesProtocol`"
15+
validations:
16+
required: true
17+
- type: textarea
18+
id: reason
19+
attributes:
20+
label: What bit of docs would you like to have?
21+
description: A clear and concise description of why this documentation needs to be improved.
22+
placeholder: There's a lack of docs that covers both the intent of this type and the way how it should be used within client code.
23+
validations:
24+
required: true
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Feature Request
2+
description: Suggest an idea for this project
3+
labels: ['enhancement']
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for taking the time to fill out this feature request!
9+
- type: textarea
10+
id: problem
11+
attributes:
12+
label: What context is your feature request related to?
13+
description: Short context name, please do not overcomplicate neither over fractionize it.
14+
placeholder: Transaction pipeline enhancement, supported platform list extending, etc.
15+
validations:
16+
required: true
17+
- type: textarea
18+
id: solution
19+
attributes:
20+
label: What solution would you like?
21+
description: A clear and concise description of what you want to happen.
22+
placeholder: I would like that your lib has a magic "give me money" button, that provides me to just to build it, be uploaded to the AppStore and to get rich.
23+
validations:
24+
required: true
25+
- type: textarea
26+
id: context
27+
attributes:
28+
label: Any additional context?
29+
description: If there's some specs either standard for such feature invented already here's the good place to provide those.
30+
placeholder: Here's the pictures of house that i'd wanted to be able to bough after i've got rich and the my future cars list as well.

.github/workflows/macOS-11.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/macOS-12.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ on:
2222
- unstable
2323

2424
env:
25-
DEVELOPER_DIR: /Applications/Xcode_13.3.1.app/Contents/Developer
25+
DEVELOPER_DIR: /Applications/Xcode_14.1.app/Contents/Developer
2626

2727
jobs:
2828
spm:
29-
name: Swift Package Manager 5.5
29+
name: Swift Package Manager 5.7
3030
runs-on: macOS-12
3131
concurrency:
3232
group: spm-${{ github.run_id }}

Package.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33

44
import PackageDescription
55

6-
#if os(macOS)
7-
let excludeFiles = [
8-
"./Browser/BrowserViewController.swift" // Because of inheriting iOS only class failed to build on macOS.
9-
]
10-
#elseif os(iOS)
11-
let excludeFiles: String = []
12-
#endif
13-
146
let package = Package(
157
name: "Web3swift",
168
platforms: [
@@ -32,7 +24,6 @@ let package = Package(
3224
.target(
3325
name: "web3swift",
3426
dependencies: ["Core", "BigInt", "secp256k1"],
35-
exclude: excludeFiles,
3627
resources: [
3728
.copy("./Browser/browser.js"),
3829
.copy("./Browser/browser.min.js"),

README.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
**web3swift** is an iOS toolbelt for interaction with the Ethereum network.
33

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

77
![matter-github-swift](https://github.com/skywinder/web3swift/blob/develop/web3swift-logo.png)
88
[![Web3swift CI](https://github.com/skywinder/web3swift/actions/workflows/ci.yml/badge.svg)](https://github.com/skywinder/web3swift/actions/workflows/ci.yml)
@@ -49,13 +49,13 @@
4949
- [x] :thought_balloon: Interaction with remote node via **JSON RPC**
5050
- [x] 🔐 Local **keystore management** (`geth` compatible)
5151
- [x] 🤖 Smart-contract **ABI parsing**
52-
- [x] 🔓**ABI deconding** (V2 is supported with return of structures from public functions. Part of 0.4.22 Solidity compiler)
52+
- [x] 🔓**ABI decoding** (V2 is supported with return of structures from public functions. Part of 0.4.22 Solidity compiler)
5353
- [x] 🕸Ethereum Name Service **(ENS) support** - a secure & decentralised way to address resources both on and off the blockchain using simple, human-readable names
5454
- [x] :arrows_counterclockwise: **Smart contracts interactions** (read/write)
5555
- [x]**Infura support**
5656
- [x]**Parsing TxPool** content into native values (ethereum addresses and transactions) - easy to get pending transactions
5757
- [x] 🖇 **Event loops** functionality
58-
- [x] 🕵️‍♂️ Possibility to **add or remove "middleware" that intercepts**, modifies and even **cancel transaction** workflow on stages "before assembly", "after assembly"and "before submission"
58+
- [x] 🕵️‍♂️ Possibility to **add or remove "middleware" that intercepts**, modifies and even **cancel transaction** workflow on stages "before assembly", "after assembly" and "before submission"
5959
- [x]**Literally following the standards** (BIP, EIP, etc):
6060
- [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)**
6161
- [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)
@@ -85,7 +85,6 @@ target '<Your Target Name>' do
8585
use_frameworks!
8686
pod 'web3swift'
8787
end
88-
8988
```
9089

9190
Then, run the following command:
@@ -114,7 +113,7 @@ import Core
114113
### Send Ether
115114
```swift
116115
let transaction: CodableTransaction = .emptyTransaction
117-
transaction.from = from ?? transaction.sender // `sender` one is if you have private key of your wallet address, so public key e.g. your wallet address could be infereted
116+
transaction.from = from ?? transaction.sender // `sender` one is if you have private key of your wallet address, so public key e.g. your wallet address could be interpreted
118117
transaction.value = value
119118
transaction.gasLimitPolicy = .manual(78423)
120119
transaction.gasPricePolicy = .manual(20000000000)
@@ -166,16 +165,30 @@ swift build
166165
Documentation is under construction👷🏻👷🏼‍♀️. We’re trying our best to comment all public API as detailed as we can, but the end it still far to come. But in one of the nearest minor updates we’ll bring DocC support of already done amount of docs. And your PR in such are more than welcome.
167166

168167
## Projects that are using web3swift
169-
Please take a look at [Our costumers](https://github.com/skywinder/web3swift/wiki/Our-Customers) wiki page.
168+
Please take a look at [Our customers](https://github.com/skywinder/web3swift/wiki/Our-Customers) wiki page.
170169

171170
## Support
172171

173-
**[Join our discord](https://discord.gg/8bHCNmhS7x) and [Telegram](https://t.me/web3swift) if you need a support or want to contribute to web3swift development!**
172+
**[Join our discord](https://discord.gg/8bHCNmhS7x) and [Telegram](https://t.me/web3swift) if you need support or want to contribute to web3swift development!**
174173

175174
- If you **need help**, please take a look at our [FAQ](https://github.com/skywinder/web3swift/wiki/FAQ "") or [open an issue](https://github.com/skywinder/web3swift/issues).
176175
- If you'd like to **see web3swift best practices**, check [Projects that using web3swift](https://github.com/skywinder/web3swift/wiki/Our-Customers).
177176
- If you **found a bug**, [open an issue](https://github.com/skywinder/web3swift/issues).
178177

178+
## Development
179+
To do local development and run the local tests, we recommend to use [ganache](https://github.com/trufflesuite/ganache) which is also used by CI when running github actions.
180+
181+
```cli
182+
// To install
183+
$ npm install ganache --global
184+
185+
// To run
186+
$ ganache
187+
```
188+
189+
This will create a local blockchain and also some test accounts that are used throughout our tests.
190+
Make sure that `ganache` is running on its default port `8546`. To change the port in test cases locate `LocalTestCase.swift` and modify the static `url` variable.
191+
179192
## Contribute
180193
Want to improve? It's awesome:
181194
Then good news for you: **We are ready to pay for your contribution via [@gitcoin bot](https://gitcoin.co/grants/358/web3swift)!**
@@ -202,8 +215,8 @@ We want to continue to do everything we can to move the needle forward.
202215
## Credits
203216

204217
- Alex Vlasov, [@shamatar](https://github.com/shamatar) - for the initial implementation
205-
- Petr Korolev, [@skywinder](https://github.com/skywinder) - botstrap and continous support
206-
- Anton Grigorev, [@baldyash](https://github.com/BaldyAsh) - core contributor, who use it and making a lot of ipmprovments
218+
- Petr Korolev, [@skywinder](https://github.com/skywinder) - bootstrap and continuous support
219+
- Anton Grigorev, [@baldyash](https://github.com/BaldyAsh) - core contributor, who use it and making a lot of improvements
207220
- Yaroslav Yashin [@yaroslavyaroslav](https://github.com/yaroslavyaroslav) - core contributor of 3.0.0 and later releases.
208221
- Thanks to [web3swift's growing list of contributors](https://github.com/skywinder/web3swift/graphs/contributors).
209222

Sources/Core/Contract/ContractProtocol.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ import BigInt
6969
public protocol ContractProtocol {
7070
/// Address of the referenced smart contract. Can be set later, e.g. if the contract is deploying and address is not yet known.
7171
var address: EthereumAddress? {get set}
72-
72+
7373
/// All ABI elements like: events, functions, constructors and errors.
7474
var abi: [ABI.Element] {get}
7575

@@ -81,13 +81,13 @@ public protocol ContractProtocol {
8181
/// - and 4 bytes signature `0xffffffff` (expected to be lowercased).
8282
/// The mapping by name (e.g. `getData`) is the one most likely expected to return arrays with
8383
/// more than one entry due to the fact that solidity allows method overloading.
84-
var methods: [String:[ABI.Element.Function]] {get}
84+
var methods: [String: [ABI.Element.Function]] {get}
8585

8686
/// All values from ``methods``.
8787
var allMethods: [ABI.Element.Function] {get}
8888

8989
/// Events filtered from ``abi`` and mapped to their unchanged ``ABI/Element/Event/name``.
90-
var events: [String:ABI.Element.Event] {get}
90+
var events: [String: ABI.Element.Event] {get}
9191

9292
/// All values from ``events``.
9393
var allEvents: [ABI.Element.Event] {get}
@@ -225,7 +225,6 @@ extension DefaultContractProtocol {
225225
let parameters = parameters,
226226
!parameters.isEmpty {
227227
guard constructor.inputs.count == parameters.count,
228-
// FIXME: This should be zipped, because Arrays don't guarantee it's elements order
229228
let encodedData = constructor.encodeParameters(parameters) else {
230229
NSLog("Constructor encoding will fail as the number of input arguments doesn't match the number of given arguments.")
231230
return nil
@@ -264,7 +263,7 @@ extension DefaultContractProtocol {
264263
let method = Data.fromHex(method) == nil ? method : method.addHexPrefix().lowercased()
265264

266265
// MARK: - Encoding ABI Data flow
267-
guard let abiMethod = methods[method]?.first,
266+
guard let abiMethod = methods[method]?.first(where: { $0.inputs.count == parameters.count }),
268267
var encodedData = abiMethod.encodeParameters(parameters) else { return nil }
269268

270269
// Extra data just appends in the end of parameters data
@@ -278,11 +277,10 @@ extension DefaultContractProtocol {
278277

279278
public func parseEvent(_ eventLog: EventLog) -> (eventName: String?, eventData: [String: Any]?) {
280279
for (eName, ev) in self.events {
281-
if (!ev.anonymous) {
280+
if !ev.anonymous {
282281
if eventLog.topics[0] != ev.topic {
283282
continue
284-
}
285-
else {
283+
} else {
286284
let logTopics = eventLog.topics
287285
let logData = eventLog.data
288286
let parsed = ev.decodeReturnedLogs(eventLogTopics: logTopics, eventLogData: logData)

Sources/Core/Contract/EthereumContract.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import BigInt
1010
/// constructor, errors and optional ``EthereumAddress`` that could be set later.
1111
public class EthereumContract: DefaultContractProtocol {
1212

13-
public var address: EthereumAddress? = nil
13+
public var address: EthereumAddress?
1414

1515
public let abi: [ABI.Element]
1616
public let methods: [String: [ABI.Element.Function]]
@@ -40,7 +40,7 @@ public class EthereumContract: DefaultContractProtocol {
4040
public convenience required init(_ abiString: String, at: EthereumAddress? = nil) throws {
4141
let jsonData = abiString.data(using: .utf8)
4242
let abi = try JSONDecoder().decode([ABI.Record].self, from: jsonData!)
43-
let abiNative = try abi.map({ (record) -> ABI.Element in
43+
let abiNative = try abi.map({ record -> ABI.Element in
4444
return try record.parse()
4545
})
4646
try self.init(abi: abiNative, at: at)

0 commit comments

Comments
 (0)