Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #217 from EOSIO/develop
Browse files Browse the repository at this point in the history
Release v0.1.3
  • Loading branch information
Brandon Fancher authored Sep 5, 2019
2 parents 3aaec2f + a610d36 commit e573789
Show file tree
Hide file tree
Showing 236 changed files with 4,778 additions and 363 deletions.
2 changes: 1 addition & 1 deletion EosioSwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'EosioSwift'
s.version = '0.1.2'
s.version = '0.1.3'
s.summary = 'EOSIO SDK for Swift - API for integrating with EOSIO-based blockchains.'
s.homepage = 'https://github.com/EOSIO/eosio-swift'
s.license = { :type => 'MIT', :text => <<-LICENSE
Expand Down
4 changes: 4 additions & 0 deletions EosioSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
B4178067226E472E00084A6E /* DynamicKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4178066226E472E00084A6E /* DynamicKey.swift */; };
B42C0EFB2268F86200E7A28F /* ResolverExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B42C0EFA2268F86200E7A28F /* ResolverExtensions.swift */; };
B44461632267CE37002C77C9 /* EosioTransactionPromises.swift in Sources */ = {isa = PBXBuildFile; fileRef = B44461622267CE37002C77C9 /* EosioTransactionPromises.swift */; };
B46535962305B33A001B0DBD /* EosioInt64.swift in Sources */ = {isa = PBXBuildFile; fileRef = B46535952305B33A001B0DBD /* EosioInt64.swift */; };
B466F0962229DA870082DC4E /* EosioSerializationProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B466F0952229DA870082DC4E /* EosioSerializationProviderProtocol.swift */; };
B47513D6227A43B8006CF07A /* EosioUInt64.swift in Sources */ = {isa = PBXBuildFile; fileRef = B47513D5227A43B8006CF07A /* EosioUInt64.swift */; };
B4892C6D221E0CAA0050FA72 /* RequestModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4892C6C221E0CAA0050FA72 /* RequestModels.swift */; };
Expand Down Expand Up @@ -125,6 +126,7 @@
B4178066226E472E00084A6E /* DynamicKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicKey.swift; sourceTree = "<group>"; };
B42C0EFA2268F86200E7A28F /* ResolverExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResolverExtensions.swift; sourceTree = "<group>"; };
B44461622267CE37002C77C9 /* EosioTransactionPromises.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EosioTransactionPromises.swift; sourceTree = "<group>"; };
B46535952305B33A001B0DBD /* EosioInt64.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EosioInt64.swift; sourceTree = "<group>"; };
B466F0952229DA870082DC4E /* EosioSerializationProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EosioSerializationProviderProtocol.swift; sourceTree = "<group>"; };
B47513D5227A43B8006CF07A /* EosioUInt64.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EosioUInt64.swift; sourceTree = "<group>"; };
B4892C6C221E0CAA0050FA72 /* RequestModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestModels.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -290,6 +292,7 @@
B4A80E28221F15F200C5134D /* RpcProviderResponseModels.swift */,
8F49E8CE225E6E6A00082631 /* RpcProviderRequestModels.swift */,
B47513D5227A43B8006CF07A /* EosioUInt64.swift */,
B46535952305B33A001B0DBD /* EosioInt64.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -580,6 +583,7 @@
8F49E8CF225E6E6A00082631 /* RpcProviderRequestModels.swift in Sources */,
2856028F22182EFA00642377 /* EosioTransactionAbis.swift in Sources */,
B4E8F6BC2232020100FA7E63 /* RIPEMD160.swift in Sources */,
B46535962305B33A001B0DBD /* EosioInt64.swift in Sources */,
8F6B04B822287A5300215CD0 /* EosioName.swift in Sources */,
B466F0962229DA870082DC4E /* EosioSerializationProviderProtocol.swift in Sources */,
8F6B04B922287A5300215CD0 /* ZAssert.swift in Sources */,
Expand Down
58 changes: 58 additions & 0 deletions EosioSwift/EosioRpcProvider/Models/EosioInt64.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// EosioInt64.swift
// EosioSwift

// Created by Steve McCoole on 8/15/19
// Copyright (c) 2017-2019 block.one and its contributors. All rights reserved.
//

import Foundation

/// Meta type that can hold a 64 bit signed value that can come from the server as a Int64 or a String.
public enum EosioInt64: Codable {
/// Value as a `Int64`.
case int64(Int64)
/// Value as a `String`.
case string(String)

public var value: Int64 {
switch self {
case .int64(let value):
return value
case .string(let str):
let val: Int64? = Int64(str)
return val ?? 0
}
}

/// Initialize from a decoder, attempting to decode as a `Int64` first. If that is unsuccessful, attempt to decode as `String`.
///
/// - Parameter decoder: Decoder to read from.
/// - Throws: DecodingError if the value cannot be decoded as `Int64` or `String`.
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
do {
self = try .int64(container.decode(Int64.self))
} catch DecodingError.typeMismatch {
do {
self = try .string(container.decode(String.self))
} catch DecodingError.typeMismatch {
throw DecodingError.typeMismatch(EosioInt64.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Encoded payload not of an expected type"))
}
}
}

/// Encode to an encoder, attempting to encode as a `Int64` first. If that is unsuccessful, attempt to encode as `String`.
///
/// - Parameter encoder: Encoder to encode to.
/// - Throws: EncodingError if the value cannot be encoded as `Int64` or `String`.
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case .int64(let int64):
try container.encode(int64)
case .string(let string):
try container.encode(string)
}
}
}
4 changes: 2 additions & 2 deletions EosioSwift/EosioRpcProvider/Models/EosioUInt64.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public enum EosioUInt64: Codable {
}
}

/// Initialize from a decoder, attempting to decode as a `UInt64` first. If that is unsuccessful, atttempt to decode as `String`.
/// Initialize from a decoder, attempting to decode as a `UInt64` first. If that is unsuccessful, attempt to decode as `String`.
///
/// - Parameter decoder: Decoder to read from.
/// - Throws: DecodingError if the value cannot be decoded as `UInt64` or `String`.
Expand All @@ -42,7 +42,7 @@ public enum EosioUInt64: Codable {
}
}

/// Encode to an encoder, attempting to encode as a `UInt64` first. If that is unsuccessful, atttempt to encode as `String`.
/// Encode to an encoder, attempting to encode as a `UInt64` first. If that is unsuccessful, attempt to encode as `String`.
///
/// - Parameter encoder: Encoder to encode to.
/// - Throws: EncodingError if the value cannot be encoded as `UInt64` or `String`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public typealias EosioRpcAbiRequest = EosioAccountInfo
public struct EosioRpcCurrencyBalanceRequest: Codable {
public var code: String
public var account: String
public var symbol: String
public var symbol: String?

public init(code: String, account: String, symbol: String) {
public init(code: String, account: String, symbol: String?) {
self.code = code
self.account = account
self.symbol = symbol
Expand Down Expand Up @@ -193,6 +193,12 @@ public struct EosioRpcHistoryActionsRequest: Codable {
self.offset = offset
self.accountName = accountName
}

enum CodingKeys: String, CodingKey {
case position = "pos"
case offset
case accountName = "account_name"
}
}

/// The request struct for `get_transaction_request` RPC requests.
Expand Down
28 changes: 14 additions & 14 deletions EosioSwift/EosioRpcProvider/Models/RpcProviderResponseModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,12 @@ public struct EosioRpcAccountResponse: Decodable, EosioRpcResponseProtocol {
public var lastCodeUpdate: String = ""
public var created: String = ""
public var coreLiquidBalance: String = ""
public var ramQuota: EosioUInt64 = EosioUInt64.uint64(0)
public var netWeight: EosioUInt64 = EosioUInt64.uint64(0)
public var cpuWeight: EosioUInt64 = EosioUInt64.uint64(0)
public var ramQuota: EosioInt64 = EosioInt64.int64(0)
public var netWeight: EosioInt64 = EosioInt64.int64(0)
public var cpuWeight: EosioInt64 = EosioInt64.int64(0)
public var netLimit: [String: Any]
public var cpuLimit: [String: Any]
public var ramUsage: EosioUInt64 = EosioUInt64.uint64(0)
public var ramUsage: EosioInt64 = EosioInt64.int64(0)
public var permissions: [Permission]
public var totalResources: [String: Any]?
public var selfDelegatedBandwidth: [String: Any]?
Expand Down Expand Up @@ -368,9 +368,9 @@ public struct EosioRpcAccountResponse: Decodable, EosioRpcResponseProtocol {
lastCodeUpdate = try container.decodeIfPresent(String.self, forKey: .lastCodeUpdate) ?? ""
created = try container.decodeIfPresent(String.self, forKey: .created) ?? ""
coreLiquidBalance = try container.decodeIfPresent(String.self, forKey: .coreLiquidBalance) ?? ""
ramQuota = try container.decodeIfPresent(EosioUInt64.self, forKey: .ramQuota) ?? EosioUInt64.uint64(0)
netWeight = try container.decodeIfPresent(EosioUInt64.self, forKey: .netWeight) ?? EosioUInt64.uint64(0)
cpuWeight = try container.decodeIfPresent(EosioUInt64.self, forKey: .cpuWeight) ?? EosioUInt64.uint64(0)
ramQuota = try container.decodeIfPresent(EosioInt64.self, forKey: .ramQuota) ?? EosioInt64.int64(0)
netWeight = try container.decodeIfPresent(EosioInt64.self, forKey: .netWeight) ?? EosioInt64.int64(0)
cpuWeight = try container.decodeIfPresent(EosioInt64.self, forKey: .cpuWeight) ?? EosioInt64.int64(0)

// netLimit = try container.decodeIfPresent(JSONValue.self, forKey: .netLimit)?.toDictionary() ?? [String: Any]()

Expand All @@ -379,7 +379,7 @@ public struct EosioRpcAccountResponse: Decodable, EosioRpcResponseProtocol {
let cpuLimitContainer = try? container.nestedContainer(keyedBy: DynamicKey.self, forKey: .cpuLimit)
cpuLimit = cpuLimitContainer?.decodeDynamicKeyValues() ?? [String: Any]()

ramUsage = try container.decodeIfPresent(EosioUInt64.self, forKey: .ramUsage) ?? EosioUInt64.uint64(0)
ramUsage = try container.decodeIfPresent(EosioInt64.self, forKey: .ramUsage) ?? EosioInt64.int64(0)
permissions = try container.decodeIfPresent([Permission].self, forKey: .permissions) ?? [Permission]()
let totalResourcesContainer = try? container.nestedContainer(keyedBy: DynamicKey.self, forKey: .totalResources)
totalResources = totalResourcesContainer?.decodeDynamicKeyValues()
Expand Down Expand Up @@ -848,7 +848,7 @@ public struct EosioRpcActionsResponseActionTrReceipt: Decodable, EosioRpcRespons

public var receiver: String
public var actionDigest: String
public var globalSequence: String // Convert to BigInt
public var globalSequence: EosioUInt64
public var receiverSequence: EosioUInt64
public var authorizationSequence: [Any]
public var codeSequence: EosioUInt64
Expand All @@ -869,7 +869,7 @@ public struct EosioRpcActionsResponseActionTrReceipt: Decodable, EosioRpcRespons

receiver = try container.decode(String.self, forKey: .receiver)
actionDigest = try container.decode(String.self, forKey: .actionDigest)
globalSequence = try container.decode(String.self, forKey: .globalSequence)
globalSequence = try container.decode(EosioUInt64.self, forKey: .globalSequence)
receiverSequence = try container.decode(EosioUInt64.self, forKey: .receiveSequence)
var authorizationSequenceContainer = try? container.nestedUnkeyedContainer(forKey: .authorizationSequence)
authorizationSequence = authorizationSequenceContainer?.decodeDynamicValues() ?? [Any]()
Expand All @@ -885,7 +885,7 @@ public struct EosioRpcActionsResponseActionTraceAction: Decodable, EosioRpcRespo
public var name: String
public var authorization: [EosioRpcActionsResponseActionTraceAuth]
public var data: [String: Any]
public var hexData: String
public var hexData: String?

enum CustomCodingKeys: String, CodingKey {
case account
Expand All @@ -903,7 +903,7 @@ public struct EosioRpcActionsResponseActionTraceAction: Decodable, EosioRpcRespo
authorization = try container.decode([EosioRpcActionsResponseActionTraceAuth].self, forKey: .authorization)
let dataContainer = try? container.nestedContainer(keyedBy: DynamicKey.self, forKey: .data)
data = dataContainer?.decodeDynamicKeyValues() ?? [String: Any]()
hexData = try container.decode(String.self, forKey: .hexData)
hexData = try? container.decode(String.self, forKey: .hexData)
}
}

Expand All @@ -930,7 +930,7 @@ public struct EosioRpcActionsResponseActionTrActDeltas: Decodable, EosioRpcRespo
public var _rawResponse: Any?

public var account: String
public var delta: EosioUInt64
public var delta: EosioInt64

enum CustomCodingKeys: String, CodingKey {
case account
Expand All @@ -941,7 +941,7 @@ public struct EosioRpcActionsResponseActionTrActDeltas: Decodable, EosioRpcRespo
let container = try decoder.container(keyedBy: CustomCodingKeys.self)

account = try container.decode(String.self, forKey: .account)
delta = try container.decode(EosioUInt64.self, forKey: .delta)
delta = try container.decode(EosioInt64.self, forKey: .delta)
}
}

Expand Down
2 changes: 1 addition & 1 deletion EosioSwift/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1.2</string>
<string>0.1.3</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
Expand Down
Loading

0 comments on commit e573789

Please sign in to comment.