Skip to content
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

EIP681 bug fixes, accessibility in Function changed #35

Merged
merged 1 commit into from
Sep 14, 2018
Merged
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
16 changes: 8 additions & 8 deletions web3swift/ABIv2/Classes/ABIv2Elements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import BigInt

extension ABIv2 {
public extension ABIv2 {
// JSON Decoding
public struct Input: Decodable {
var name: String?
Expand Down Expand Up @@ -48,16 +48,16 @@ extension ABIv2 {
case event(Event)

public struct InOut {
let name: String
let type: ParameterType
public let name: String
public let type: ParameterType
}

public struct Function {
let name: String?
let inputs: [InOut]
let outputs: [InOut]
let constant: Bool
let payable: Bool
public let name: String?
public let inputs: [InOut]
public let outputs: [InOut]
public let constant: Bool
public let payable: Bool
}

public struct Constructor {
Expand Down
18 changes: 17 additions & 1 deletion web3swift/Utils/Classes/EIP681.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ extension Web3 {

var code = EIP681Code(targetAddress)
if chainIDString != nil {
chainIDString!.remove(at: chainIDString!.startIndex)
code.chainID = BigUInt(chainIDString!)
}
if tail == nil {
Expand All @@ -137,7 +138,13 @@ extension Web3 {
switch inputType {
case .address:
let val = EIP681Code.TargetAddress(value)
nativeValue = val as AnyObject
switch val {
case .ethereumAddress(let ethereumAddress):
nativeValue = ethereumAddress as AnyObject
case .ensAddress(let ens):
//TODO: - convert ens into ethereum
nativeValue = ens as AnyObject
}
case .uint(bits: _):
if let val = BigUInt(value, radix: 10) {
nativeValue = val as AnyObject
Expand All @@ -164,6 +171,15 @@ extension Web3 {
} else if let val = value.data(using: .utf8) {
nativeValue = val as AnyObject
}
case .bool:
switch value {
case "true","True","1":
nativeValue = true as AnyObject
case "false", "False", "0":
nativeValue = false as AnyObject
default:
nativeValue = true as AnyObject
}
default:
continue
}
Expand Down