Skip to content

Commit f8fac77

Browse files
fixed browser funcs, fixed fromJson func for TransactionOptions, fixed build phases for schemas
1 parent d2df49d commit f8fac77

File tree

4 files changed

+56
-23
lines changed

4 files changed

+56
-23
lines changed

web3swift.xcodeproj/project.pbxproj

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@
1010
00E5FE8220EA3FF40030E0D6 /* web3swift_infura_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00E5FE8120EA3FF40030E0D6 /* web3swift_infura_Tests.swift */; };
1111
13AE5971A972F5B55FA6FB69 /* libPods-web3swift-iOS_Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8349531F1984454E50389370 /* libPods-web3swift-iOS_Tests.a */; };
1212
1CD91B341FD769A6007BFB45 /* web3swift_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CD91AFC1FD76910007BFB45 /* web3swift_iOS.framework */; };
13+
3AC1E7CB222D6A8C004F43D8 /* Web3+BrowserFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81C0FCF8204456E600D82FAF /* Web3+BrowserFunctions.swift */; };
14+
3AC1E7CC222D6A99004F43D8 /* Web3+ERC1376.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8083521CB142000B6BF15 /* Web3+ERC1376.swift */; };
15+
3AC1E7CD222D6A99004F43D8 /* Web3+ERC1155.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8083221CB0EF300B6BF15 /* Web3+ERC1155.swift */; };
16+
3AC1E7CE222D6A99004F43D8 /* Web3+ERC721x.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8082F21CB096D00B6BF15 /* Web3+ERC721x.swift */; };
17+
3AC1E7CF222D6A99004F43D8 /* Web3+ERC1633.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8082C21CB009A00B6BF15 /* Web3+ERC1633.swift */; };
18+
3AC1E7D0222D6A99004F43D8 /* Web3+ERC1643.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8082921CAA07000B6BF15 /* Web3+ERC1643.swift */; };
19+
3AC1E7D1222D6A99004F43D8 /* Web3+ERC1644.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8082621CA9F3100B6BF15 /* Web3+ERC1644.swift */; };
20+
3AC1E7D2222D6A99004F43D8 /* Web3+ERC1594.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8082321CA9C3B00B6BF15 /* Web3+ERC1594.swift */; };
21+
3AC1E7D3222D6A99004F43D8 /* Web3+ERC1410.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8081E21CA90BA00B6BF15 /* Web3+ERC1410.swift */; };
22+
3AC1E7D4222D6A99004F43D8 /* Web3+ERC888.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9FD21C48A570081695F /* Web3+ERC888.swift */; };
23+
3AC1E7D5222D6A99004F43D8 /* Web3+ERC1400.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9FA21C4860F0081695F /* Web3+ERC1400.swift */; };
24+
3AC1E7D6222D6A99004F43D8 /* Web3+ERC820.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9F721C47CD00081695F /* Web3+ERC820.swift */; };
25+
3AC1E7D7222D6A99004F43D8 /* Web3+ERC777.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9F421C47B4A0081695F /* Web3+ERC777.swift */; };
26+
3AC1E7D8222D6A99004F43D8 /* Web3+ERC165.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9EE21C46A140081695F /* Web3+ERC165.swift */; };
27+
3AC1E7D9222D6AA0004F43D8 /* Web3+BrowserFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81C0FCF8204456E600D82FAF /* Web3+BrowserFunctions.swift */; };
1328
4194811B203630530065A83B /* Web3+HttpProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 817EBB142004FE4200E02EAA /* Web3+HttpProvider.swift */; };
1429
4194811E203630530065A83B /* Web3.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81DDECCE1FDF004E0063684A /* Web3.swift */; };
1530
4194811F203630530065A83B /* Web3+Instance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818ABD5A1FE95F8F002657BB /* Web3+Instance.swift */; };
@@ -1156,6 +1171,7 @@
11561171
isa = PBXSourcesBuildPhase;
11571172
buildActionMask = 2147483647;
11581173
files = (
1174+
3AC1E7CB222D6A8C004F43D8 /* Web3+BrowserFunctions.swift in Sources */,
11591175
E2DCA654218C879900F94FBA /* ENS.swift in Sources */,
11601176
E2DCA655218C879900F94FBA /* ENSResolver.swift in Sources */,
11611177
E2F8082421CA9C3B00B6BF15 /* Web3+ERC1594.swift in Sources */,
@@ -1276,6 +1292,20 @@
12761292
isa = PBXSourcesBuildPhase;
12771293
buildActionMask = 2147483647;
12781294
files = (
1295+
3AC1E7D9222D6AA0004F43D8 /* Web3+BrowserFunctions.swift in Sources */,
1296+
3AC1E7CC222D6A99004F43D8 /* Web3+ERC1376.swift in Sources */,
1297+
3AC1E7CD222D6A99004F43D8 /* Web3+ERC1155.swift in Sources */,
1298+
3AC1E7CE222D6A99004F43D8 /* Web3+ERC721x.swift in Sources */,
1299+
3AC1E7CF222D6A99004F43D8 /* Web3+ERC1633.swift in Sources */,
1300+
3AC1E7D0222D6A99004F43D8 /* Web3+ERC1643.swift in Sources */,
1301+
3AC1E7D1222D6A99004F43D8 /* Web3+ERC1644.swift in Sources */,
1302+
3AC1E7D2222D6A99004F43D8 /* Web3+ERC1594.swift in Sources */,
1303+
3AC1E7D3222D6A99004F43D8 /* Web3+ERC1410.swift in Sources */,
1304+
3AC1E7D4222D6A99004F43D8 /* Web3+ERC888.swift in Sources */,
1305+
3AC1E7D5222D6A99004F43D8 /* Web3+ERC1400.swift in Sources */,
1306+
3AC1E7D6222D6A99004F43D8 /* Web3+ERC820.swift in Sources */,
1307+
3AC1E7D7222D6A99004F43D8 /* Web3+ERC777.swift in Sources */,
1308+
3AC1E7D8222D6A99004F43D8 /* Web3+ERC165.swift in Sources */,
12791309
E2DCA656218C87A500F94FBA /* ENS.swift in Sources */,
12801310
E2DCA657218C87A500F94FBA /* ENSResolver.swift in Sources */,
12811311
E2065FB82181D7D700701068 /* Promise+Web3+Eth+EstimateGas.swift in Sources */,

web3swift/HookedFunctions/Classes/Web3+BrowserFunctions.swift

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,7 @@ extension web3.BrowserFunctions {
6868

6969
public func sendTransaction(_ transactionJSON: [String: Any], password: String = "web3swift") -> [String:Any]? {
7070
guard let transaction = EthereumTransaction.fromJSON(transactionJSON) else {return nil}
71-
guard let options = Web3Options.fromJSON(transactionJSON) else {return nil}
72-
var transactionOptions = TransactionOptions()
73-
transactionOptions.from = options.from
74-
transactionOptions.to = options.to
75-
transactionOptions.value = options.value
76-
transactionOptions.gasLimit = options.gasLimit != nil ? .limited(options.gasLimit!) : .automatic
77-
transactionOptions.gasPrice = options.gasPrice != nil ? .manual(options.gasPrice!) : .automatic
71+
guard let transactionOptions = TransactionOptions.fromJSON(transactionJSON) else {return nil}
7872
return self.sendTransaction(transaction, transactionOptions: transactionOptions, password: password)
7973
}
8074

@@ -89,13 +83,7 @@ extension web3.BrowserFunctions {
8983

9084
public func estimateGas(_ transactionJSON: [String: Any]) -> BigUInt? {
9185
guard let transaction = EthereumTransaction.fromJSON(transactionJSON) else {return nil}
92-
guard let options = Web3Options.fromJSON(transactionJSON) else {return nil}
93-
var transactionOptions = TransactionOptions()
94-
transactionOptions.from = options.from
95-
transactionOptions.to = options.to
96-
transactionOptions.value = options.value
97-
transactionOptions.gasLimit = .automatic
98-
transactionOptions.gasPrice = options.gasPrice != nil ? .manual(options.gasPrice!) : .automatic
86+
guard let transactionOptions = TransactionOptions.fromJSON(transactionJSON) else {return nil}
9987
return self.estimateGas(transaction, transactionOptions: transactionOptions)
10088
}
10189

@@ -134,13 +122,7 @@ extension web3.BrowserFunctions {
134122

135123
public func signTransaction(_ transactionJSON: [String: Any], password: String = "web3swift") -> String? {
136124
guard let transaction = EthereumTransaction.fromJSON(transactionJSON) else {return nil}
137-
guard let options = Web3Options.fromJSON(transactionJSON) else {return nil}
138-
var transactionOptions = TransactionOptions()
139-
transactionOptions.from = options.from
140-
transactionOptions.to = options.to
141-
transactionOptions.value = options.value
142-
transactionOptions.gasLimit = options.gasLimit != nil ? .limited(options.gasLimit!) : .automatic
143-
transactionOptions.gasPrice = options.gasPrice != nil ? .manual(options.gasPrice!) : .automatic
125+
guard var transactionOptions = TransactionOptions.fromJSON(transactionJSON) else {return nil}
144126
if let nonceString = transactionJSON["nonce"] as? String, let nonce = BigUInt(nonceString.stripHexPrefix(), radix: 16) {
145127
transactionOptions.nonce = .manual(nonce)
146128
} else {

web3swift/Web3/Classes/Web3+Options.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ public struct TransactionOptions {
136136
guard let addressFrom = EthereumAddress(fromString) else {return nil}
137137
options.from = addressFrom
138138
}
139+
if let nonceString = json["nonce"] as? String, let nonce = BigUInt(nonceString.stripHexPrefix(), radix: 16) {
140+
options.nonce = .manual(nonce)
141+
} else {
142+
options.nonce = .pending
143+
}
144+
if let callOnBlockString = json["callOnBlock"] as? String, let callOnBlock = BigUInt(callOnBlockString.stripHexPrefix(), radix: 16) {
145+
options.callOnBlock = .exactBlockNumber(callOnBlock)
146+
} else {
147+
options.callOnBlock = .pending
148+
}
139149
return options
140150
}
141151

web3swift/Web3/Classes/Web3+Structures.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ extension TransactionOptions: Decodable {
4646
case gasPrice
4747
case gas
4848
case value
49+
case nonce
50+
case callOnBlock
4951
}
5052

5153
public init(from decoder: Decoder) throws {
@@ -83,8 +85,17 @@ extension TransactionOptions: Decodable {
8385
let value = try decodeHexToBigUInt(container, key: .value)
8486
self.value = value
8587

86-
self.nonce = .pending
87-
self.callOnBlock = .pending
88+
if let nonce = try decodeHexToBigUInt(container, key: .nonce) {
89+
self.nonce = .manual(nonce)
90+
} else {
91+
self.nonce = .pending
92+
}
93+
94+
if let callOnBlock = try decodeHexToBigUInt(container, key: .nonce) {
95+
self.callOnBlock = .exactBlockNumber(callOnBlock)
96+
} else {
97+
self.callOnBlock = .pending
98+
}
8899
}
89100
}
90101

0 commit comments

Comments
 (0)