Skip to content

Commit 5124e4c

Browse files
authored
Merge pull request #198 from BANKEX/develop
start making a documentation, now most of the public functions have an inline description
2 parents 4e55b79 + ffbb843 commit 5124e4c

23 files changed

+596
-425
lines changed

web3swift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "web3swift"
3-
s.version = "1.0.0"
3+
s.version = "1.1.0"
44
s.summary = "Web3 implementation in vanilla Swift for iOS ans macOS"
55

66
s.description = <<-DESC

web3swift.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
4194811F203630530065A83B /* Web3+Instance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818ABD5A1FE95F8F002657BB /* Web3+Instance.swift */; };
2424
41948120203630530065A83B /* Web3+Contract.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818ABD5C1FE95FC9002657BB /* Web3+Contract.swift */; };
2525
41948121203630530065A83B /* Web3+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8104E2271FE82BDC00F952CB /* Web3+Utils.swift */; };
26-
41948122203630530065A83B /* Web3+Infura.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818ABD581FE95558002657BB /* Web3+Infura.swift */; };
2726
41948123203630530065A83B /* Web3+JSONRPC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 810B0F991FEC446B00CF0DA2 /* Web3+JSONRPC.swift */; };
2827
41948124203630530065A83B /* Web3+Structures.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81C146F61FF274B200AA943E /* Web3+Structures.swift */; };
2928
41948125203630530065A83B /* Web3+Methods.swift in Sources */ = {isa = PBXBuildFile; fileRef = 810B0F9B1FEC520500CF0DA2 /* Web3+Methods.swift */; };
@@ -90,7 +89,6 @@
9089
817EBB2520066E2B00E02EAA /* AbstractKeystore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 817EBB2420066E2B00E02EAA /* AbstractKeystore.swift */; };
9190
817EBB27200673D100E02EAA /* KeystoreV3JSONStructure.swift in Sources */ = {isa = PBXBuildFile; fileRef = 817EBB26200673D100E02EAA /* KeystoreV3JSONStructure.swift */; };
9291
817EBB2920075D2E00E02EAA /* BIP39.swift in Sources */ = {isa = PBXBuildFile; fileRef = 817EBB2820075D2E00E02EAA /* BIP39.swift */; };
93-
818ABD591FE95558002657BB /* Web3+Infura.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818ABD581FE95558002657BB /* Web3+Infura.swift */; };
9492
818ABD5B1FE95F8F002657BB /* Web3+Instance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818ABD5A1FE95F8F002657BB /* Web3+Instance.swift */; };
9593
818ABD5D1FE95FC9002657BB /* Web3+Contract.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818ABD5C1FE95FC9002657BB /* Web3+Contract.swift */; };
9694
818D16CF204D42910084D2A4 /* Web3+EventParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818D16CE204D42910084D2A4 /* Web3+EventParser.swift */; };
@@ -168,6 +166,8 @@
168166
81D7D97820A61E3800A193EC /* EventFiltering.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81D7D97720A61E3800A193EC /* EventFiltering.swift */; };
169167
81D7D97920A61E3800A193EC /* EventFiltering.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81D7D97720A61E3800A193EC /* EventFiltering.swift */; };
170168
81DDECCF1FDF004E0063684A /* Web3.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81DDECCE1FDF004E0063684A /* Web3.swift */; };
169+
81DFB3FF210775320011DC85 /* Web3+Infura.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81DFB3FE210775320011DC85 /* Web3+Infura.swift */; };
170+
81DFB400210775320011DC85 /* Web3+Infura.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81DFB3FE210775320011DC85 /* Web3+Infura.swift */; };
171171
81DFCC4C20F7546300603123 /* key.json in Resources */ = {isa = PBXBuildFile; fileRef = 81DFCC4B20F7546300603123 /* key.json */; };
172172
81EB1E4B208173D7003BD47F /* Web3+Personal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81EB1E4A208173D7003BD47F /* Web3+Personal.swift */; };
173173
81EB1E4C208173D7003BD47F /* Web3+Personal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81EB1E4A208173D7003BD47F /* Web3+Personal.swift */; };
@@ -268,7 +268,6 @@
268268
817EBB2420066E2B00E02EAA /* AbstractKeystore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AbstractKeystore.swift; sourceTree = "<group>"; };
269269
817EBB26200673D100E02EAA /* KeystoreV3JSONStructure.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeystoreV3JSONStructure.swift; sourceTree = "<group>"; };
270270
817EBB2820075D2E00E02EAA /* BIP39.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BIP39.swift; sourceTree = "<group>"; };
271-
818ABD581FE95558002657BB /* Web3+Infura.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web3+Infura.swift"; sourceTree = "<group>"; };
272271
818ABD5A1FE95F8F002657BB /* Web3+Instance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web3+Instance.swift"; sourceTree = "<group>"; };
273272
818ABD5C1FE95FC9002657BB /* Web3+Contract.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web3+Contract.swift"; sourceTree = "<group>"; };
274273
818D16CE204D42910084D2A4 /* Web3+EventParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web3+EventParser.swift"; sourceTree = "<group>"; };
@@ -313,6 +312,7 @@
313312
81D7D97420A3240900A193EC /* EthereumFilterEncodingExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EthereumFilterEncodingExtensions.swift; sourceTree = "<group>"; };
314313
81D7D97720A61E3800A193EC /* EventFiltering.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventFiltering.swift; sourceTree = "<group>"; };
315314
81DDECCE1FDF004E0063684A /* Web3.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Web3.swift; sourceTree = "<group>"; };
315+
81DFB3FE210775320011DC85 /* Web3+Infura.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3+Infura.swift"; sourceTree = "<group>"; };
316316
81DFCC4B20F7546300603123 /* key.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = key.json; path = ../../../../Desktop/key.json; sourceTree = "<group>"; };
317317
81EB1E4A208173D7003BD47F /* Web3+Personal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web3+Personal.swift"; sourceTree = "<group>"; };
318318
81FA43F32044097000EE14D5 /* web3swift-macOS_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "web3swift-macOS_Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -623,8 +623,8 @@
623623
817EBB142004FE4200E02EAA /* Web3+HttpProvider.swift */,
624624
818ABD5A1FE95F8F002657BB /* Web3+Instance.swift */,
625625
818ABD5C1FE95FC9002657BB /* Web3+Contract.swift */,
626+
81DFB3FE210775320011DC85 /* Web3+Infura.swift */,
626627
8104E2271FE82BDC00F952CB /* Web3+Utils.swift */,
627-
818ABD581FE95558002657BB /* Web3+Infura.swift */,
628628
810B0F991FEC446B00CF0DA2 /* Web3+JSONRPC.swift */,
629629
81C146F61FF274B200AA943E /* Web3+Structures.swift */,
630630
810B0F9B1FEC520500CF0DA2 /* Web3+Methods.swift */,
@@ -1010,7 +1010,6 @@
10101010
817EBB2520066E2B00E02EAA /* AbstractKeystore.swift in Sources */,
10111011
81C0FCF720441A1D00D82FAF /* TransactionSigner.swift in Sources */,
10121012
8125F06920499AC300A0F2FE /* BloomFilter.swift in Sources */,
1013-
818ABD591FE95558002657BB /* Web3+Infura.swift in Sources */,
10141013
810B0F9A1FEC446B00CF0DA2 /* Web3+JSONRPC.swift in Sources */,
10151014
81195AB020D7FF8500ABC6B1 /* Promise+Web3+Contract+GetIndexedEvents.swift in Sources */,
10161015
8113D2C61FD7E1590074282C /* LibSecp256k1Extension.swift in Sources */,
@@ -1065,6 +1064,7 @@
10651064
81A1823120D68A110016741F /* Promise+Batching.swift in Sources */,
10661065
817EBB162004FE4200E02EAA /* Web3+HttpProvider.swift in Sources */,
10671066
8103BBCC2077B84400499769 /* PlainKeystore.swift in Sources */,
1067+
81DFB3FF210775320011DC85 /* Web3+Infura.swift in Sources */,
10681068
81C0FCF220440EB500D82FAF /* Web3+Protocols.swift in Sources */,
10691069
81C0FCF420440F0900D82FAF /* Web3+Options.swift in Sources */,
10701070
81A1822E20D67BC30016741F /* Promise+Web3+Eth+GetTransactionReceipt.swift in Sources */,
@@ -1115,7 +1115,6 @@
11151115
4194811F203630530065A83B /* Web3+Instance.swift in Sources */,
11161116
41948120203630530065A83B /* Web3+Contract.swift in Sources */,
11171117
41948121203630530065A83B /* Web3+Utils.swift in Sources */,
1118-
41948122203630530065A83B /* Web3+Infura.swift in Sources */,
11191118
8125F06A20499AC300A0F2FE /* BloomFilter.swift in Sources */,
11201119
81C0FD062044A8D100D82FAF /* TransactionSigner.swift in Sources */,
11211120
41948123203630530065A83B /* Web3+JSONRPC.swift in Sources */,
@@ -1128,6 +1127,7 @@
11281127
81A1822320D678060016741F /* Promise+Web3+Eth+GetBlockNumber.swift in Sources */,
11291128
4194812B203630530065A83B /* RLP.swift in Sources */,
11301129
4194812C203630530065A83B /* KeystoreManager.swift in Sources */,
1130+
81DFB400210775320011DC85 /* Web3+Infura.swift in Sources */,
11311131
81D7D97320A31FB700A193EC /* ComparisonExtensions.swift in Sources */,
11321132
81A1823E20D79C2C0016741F /* Promise+Web3+Eth+SendRawTransaction.swift in Sources */,
11331133
81A1823D20D79C290016741F /* Promise+Web3+Eth+Call.swift in Sources */,

web3swift/Convenience/Classes/LibSecp256k1Extension.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
//
2+
// LibSecp256k1Extension.swift
3+
// web3swift-iOS
4+
//
5+
// Created by Alexander Vlasov.
6+
// Copyright © 2018 Bankex Foundation. All rights reserved.
7+
//
8+
19

210
import Foundation
311
import secp256k1_ios

web3swift/Convenience/Classes/String+Extension.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
//
2+
// String+Extension.swift
3+
// web3swift-iOS
4+
//
5+
// Created by Alexander Vlasov.
6+
// Copyright © 2018 Bankex Foundation. All rights reserved.
7+
//
8+
19
import Foundation
210

311
extension String {

web3swift/HookedFunctions/Classes/Web3+Wallet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// web3swift
44
//
55
// Created by Alexander Vlasov on 07.01.2018.
6+
// Copyright © 2018 Bankex Foundation. All rights reserved.
67
//
7-
88
import Foundation
99
import BigInt
1010
import Result

web3swift/KeystoreManager/Classes/BIP32HDNode.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// web3swift
44
//
55
// Created by Alexander Vlasov on 09.01.2018.
6+
// Copyright © 2018 Bankex Foundation. All rights reserved.
67
//
78

89
import Foundation

web3swift/KeystoreManager/Classes/EthereumAddress.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// web3swift
44
//
55
// Created by Alexander Vlasov on 07.01.2018.
6+
// Copyright © 2018 Bankex Foundation. All rights reserved.
67
//
78

89
import Foundation

web3swift/Web3/Classes/Web3+Contract.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ import BigInt
1111

1212
extension web3 {
1313

14+
/// The contract instance. Initialized in runtime from ABI string (that is a JSON array). In addition an existing contract address can be supplied to provide the default "to" address in all the following requests. ABI version is 2 by default and should not be changed.
1415
public func contract(_ abiString: String, at: EthereumAddress? = nil, abiVersion: Int = 2) -> web3contract? {
1516
return web3contract(web3: self, abiString: abiString, at: at, options: self.options, abiVersion: abiVersion)
1617
}
1718

19+
/// Web3 instance bound contract instance.
1820
public class web3contract {
1921
var contract: ContractProtocol
2022
var web3 : web3
2123
public var options: Web3Options? = nil
2224

25+
26+
/// Initialize the bound contract instance by supplying the Web3 provider bound object, ABI, Ethereum address and some default
27+
/// options for further function calls. By default the contract inherits options from the web3 object. Additionally supplied "options"
28+
/// do override inherited ones.
2329
public init?(web3 web3Instance:web3, abiString: String, at: EthereumAddress? = nil, options: Web3Options? = nil, abiVersion: Int = 2) {
2430
self.web3 = web3Instance
2531
self.options = web3.options
@@ -43,6 +49,10 @@ extension web3 {
4349
self.options = mergedOptions
4450
}
4551

52+
/// Deploys a constact instance using the previously provided (at initialization) ABI, some bytecode, constructor parameters and options.
53+
/// If extraData is supplied it is appended to encoded bytecode and constructor parameters.
54+
///
55+
/// Returns a "Transaction intermediate" object.
4656
public func deploy(bytecode: Data, parameters: [AnyObject] = [AnyObject](), extraData: Data = Data(), options: Web3Options?) -> TransactionIntermediate? {
4757

4858
let mergedOptions = Web3Options.merge(self.options, with: options)
@@ -52,6 +62,12 @@ extension web3 {
5262
return intermediate
5363
}
5464

65+
/// Creates and object responsible for calling a particular function of the contract. If method name is not found in ABI - returns nil.
66+
/// If extraData is supplied it is appended to encoded function parameters. Can be usefull if one wants to call
67+
/// the function not listed in ABI. "Parameters" should be an array corresponding to the list of parameters of the function.
68+
/// Elements of "parameters" can be other arrays or instances of String, Data, BigInt, BigUInt, Int or EthereumAddress.
69+
///
70+
/// Returns a "Transaction intermediate" object.
5571
public func method(_ method:String = "fallback", parameters: [AnyObject] = [AnyObject](), extraData: Data = Data(), options: Web3Options?) -> TransactionIntermediate? {
5672
let mergedOptions = Web3Options.merge(self.options, with: options)
5773
guard var tx = self.contract.method(method, parameters: parameters, extraData: extraData, options: mergedOptions) else {return nil}
@@ -60,10 +76,12 @@ extension web3 {
6076
return intermediate
6177
}
6278

79+
/// Parses an EventLog object by using a description from the contract's ABI.
6380
public func parseEvent(_ eventLog: EventLog) -> (eventName:String?, eventData:[String:Any]?) {
6481
return self.contract.parseEvent(eventLog)
6582
}
6683

84+
/// Creates an "EventParserProtocol" compliant object to use it for parsing particular block or transaction for events.
6785
public func createEventParser(_ eventName:String, filter:EventFilter?) -> EventParserProtocol? {
6886
let parser = EventParser(web3: self.web3, eventName: eventName, contract: self.contract, filter: filter)
6987
return parser

0 commit comments

Comments
 (0)