Skip to content

Commit

Permalink
add support for protocol 22-rc3
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-rogobete committed Nov 4, 2024
1 parent 2edc0fa commit 3e70dac
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The Soneso open source stellar SDK for iOS & Mac provides APIs to build tran
#### Prepare for Protocol 22 update:

```swift
.package(url: "https://github.com/Soneso/stellar-ios-mac-sdk", exact: "3.0.1-beta.1"),
.package(url: "https://github.com/Soneso/stellar-ios-mac-sdk", exact: "3.0.1-beta.2"),
```

If not loading (err: `cannot use bare repository`), then remove:
Expand Down Expand Up @@ -54,7 +54,7 @@ end
use_frameworks!

target '<Your Target Name>' do
pod 'stellar-ios-mac-sdk', '~> 3.0.1-beta.1'
pod 'stellar-ios-mac-sdk', '~> 3.0.1-beta.2'
end
```

Expand Down Expand Up @@ -87,7 +87,7 @@ github "soneso/stellar-ios-mac-sdk" ~> 3.0.0
#### Prepare for Protocol 22:

```ogdl
github "soneso/stellar-ios-mac-sdk" ~> 3.0.1-beta.1
github "soneso/stellar-ios-mac-sdk" ~> 3.0.1-beta.2
```

Run `carthage update` to build the framework and drag the build `stellar-ios-mac-sdk.framework` into your Xcode project.
Expand Down
2 changes: 1 addition & 1 deletion stellar-ios-mac-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "stellar-ios-mac-sdk"
s.version = "3.0.1-beta.1"
s.version = "3.0.1-beta.2"
s.summary = "Fully featured iOS and macOS SDK that provides APIs to build transactions and connect to Horizon server for the Stellar ecosystem."
s.module_name = 'stellarsdk'
s.swift_version = '5.0'
Expand Down
6 changes: 3 additions & 3 deletions stellarsdk/stellarsdk/soroban/responses/EventInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class EventInfo: NSObject, Decodable {
/// The transaction which triggered this event.
public var txHash:String

/// for paging , only available for protocol version < 22
public var pagingToken:String?
/// for paging
public var pagingToken:String


private enum CodingKeys: String, CodingKey {
Expand Down Expand Up @@ -71,7 +71,7 @@ public class EventInfo: NSObject, Decodable {
value = try values.decode(String.self, forKey: .value)
valueXdr = try SCValXDR.fromXdr(base64: value)
txHash = try values.decode(String.self, forKey: .txHash)
pagingToken = try values.decodeIfPresent(String.self, forKey: .pagingToken) // protocol version < 22
pagingToken = try values.decodeIfPresent(String.self, forKey: .pagingToken) ?? id
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class TransactionInfo: NSObject, Decodable {
public var ledger:Int

/// The unix timestamp of when the transaction was included in the ledger.
public var createdAt:String
public var createdAt:Int

/// hex-encoded transaction hash string. Only available for protocol version >= 22
public var txHash:String?
Expand Down Expand Up @@ -106,15 +106,15 @@ public class TransactionInfo: NSObject, Decodable {
resultMetaXdr = try values.decode(String.self, forKey: .resultMetaXdr)
diagnosticEventsXdr = try values.decodeIfPresent([String].self, forKey: .diagnosticEventsXdr)
ledger = try values.decode(Int.self, forKey: .ledger)
var createdAtVal:String?
var createdAtIntVal:Int?
do {
createdAtVal = try values.decodeIfPresent(String.self, forKey: .createdAt) // protocol >= 22
createdAtIntVal = try values.decodeIfPresent(Int.self, forKey: .createdAt)
} catch {}
if (createdAtVal != nil) {
createdAt = createdAtVal!
if (createdAtIntVal != nil) {
createdAt = createdAtIntVal!
} else {
let createAtInt = try values.decode(Int.self, forKey: .createdAt) // protocol version <= 22
createdAt = String(createAtInt)
let createStringAt = try values.decode(String.self, forKey: .createdAt)
createdAt = Int(createStringAt) ?? 0
}

txHash = try values.decodeIfPresent(String.self, forKey: .txHash) // protocol version >= 22
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,28 @@ public class GetVersionInfoResponse: NSObject, Decodable {
let values = try decoder.container(keyedBy: CodingKeys.self)
version = try values.decode(String.self, forKey: .version)

var commitHashVal = try values.decodeIfPresent(String.self, forKey: .commitHash)
let commitHashVal = try values.decodeIfPresent(String.self, forKey: .commitHash)
if (commitHashVal == nil) {
commitHash = try values.decode(String.self, forKey: .commitHashP21) // protocol version < 22
} else {
commitHash = commitHashVal!
}

var buildTimeStampVal = try values.decodeIfPresent(String.self, forKey: .buildTimeStamp)
let buildTimeStampVal = try values.decodeIfPresent(String.self, forKey: .buildTimeStamp)
if (buildTimeStampVal == nil) {
buildTimeStamp = try values.decode(String.self, forKey: .buildTimeStampP21) // protocol version < 22
} else {
buildTimeStamp = buildTimeStampVal!
}

var captiveCoreVersionVal = try values.decodeIfPresent(String.self, forKey: .captiveCoreVersion)
let captiveCoreVersionVal = try values.decodeIfPresent(String.self, forKey: .captiveCoreVersion)
if (captiveCoreVersionVal == nil) {
captiveCoreVersion = try values.decode(String.self, forKey: .captiveCoreVersionP21) // protocol version < 22
} else {
captiveCoreVersion = captiveCoreVersionVal!
}

var protocolVersionVal = try values.decodeIfPresent(Int.self, forKey: .protocolVersion)
let protocolVersionVal = try values.decodeIfPresent(Int.self, forKey: .protocolVersion)
if (protocolVersionVal == nil) {
protocolVersion = try values.decode(Int.self, forKey: .protocolVersionP21) // protocol version < 22
} else {
Expand Down

0 comments on commit 3e70dac

Please sign in to comment.