Skip to content

Commit

Permalink
update for stable p20
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-rogobete committed Oct 25, 2023
1 parent a0d55aa commit 611d397
Show file tree
Hide file tree
Showing 33 changed files with 300 additions and 251 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To integrate stellar SDK into your Xcode project using CocoaPods, specify it in
use_frameworks!

target '<Your Target Name>' do
pod 'stellar-ios-mac-sdk', '~> 2.4.7'
pod 'stellar-ios-mac-sdk', '~> 2.4.8'
end
```

Expand All @@ -44,15 +44,15 @@ $ brew install carthage
To integrate stellar-ios-mac-sdk into your Xcode project using Carthage, specify it in your `Cartfile`:

```ogdl
github "soneso/stellar-ios-mac-sdk" ~> 2.4.7
github "soneso/stellar-ios-mac-sdk" ~> 2.4.8
```

Run `carthage update` to build the framework and drag the build `stellar-ios-mac-sdk.framework` into your Xcode project.

### Swift Package Manager

```swift
.package(name: "stellarsdk", url: "[email protected]:Soneso/stellar-ios-mac-sdk.git", from: "2.4.7"),
.package(name: "stellarsdk", url: "[email protected]:Soneso/stellar-ios-mac-sdk.git", from: "2.4.8"),
```

### Manual
Expand Down
4 changes: 2 additions & 2 deletions soroban.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ sorobanServer.getTransaction(transactionHash: transactionId) { (response) -> (Vo

Success!

#### Get Ledger Entry
#### Get Ledger Entries

The Soroban-RPC server also provides the possibility to request values of ledger entries directly. It will allow you to directly inspect the current state of a contract, a contract’s code, or any other ledger entry.

Expand All @@ -237,7 +237,7 @@ For example, to fetch contract wasm byte-code, use the ContractCode ledger entry
let contractCodeKey = LedgerKeyContractCodeXDR(wasmId: wasmId, bodyType: ContractEntryBodyType.dataEntry)
let ledgerKey = LedgerKeyXDR.contractCode(contractCodeKey)

sorobanServer.getLedgerEntry(base64EncodedKey:ledgerKey.xdrEncoded) { (response) -> (Void) in // ...
sorobanServer.getLedgerEntries(base64EncodedKeys:[ledgerKey.xdrEncoded]) { (response) -> (Void) in // ...
```
If you already have a contractId you can load the code as follows:

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 = "2.4.7"
s.version = "2.4.8"
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
66 changes: 36 additions & 30 deletions stellarsdk/stellarsdk.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion stellarsdk/stellarsdk/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>2.4.7</string>
<string>2.4.8</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// BumpFootprintExpirationOperationResponse.swift
// ExtendFootprintTTLOperationResponse.swift
// stellarsdk
//
// Created by Christian Rogobete on 24.07.23.
Expand All @@ -8,19 +8,24 @@

import Foundation

public class BumpFootprintExpirationOperationResponse: OperationResponse {
public class ExtendFootprintTTLOperationResponse: OperationResponse {

public var ledgersToExpire:Int
public var extendTo:Int


// Properties to encode and decode
private enum CodingKeys: String, CodingKey {
case ledgersToExpire = "ledgers_to_expire"
case extendTo = "extend_to"
}

public required init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
ledgersToExpire = try values.decode(Int.self, forKey: .ledgersToExpire)
if let exTo = try values.decodeIfPresent(Int.self, forKey: .extendTo) {
extendTo = exTo
} else {
extendTo = try values.decode(Int.self, forKey: .ledgersToExpire)
}
try super.init(from: decoder)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public enum OperationType: Int32 {
case liquidityPoolDeposit = 22
case liquidityPoolWithdraw = 23
case invokeHostFunction = 24
case bumpFootprintExpiration = 25
case extendFootprintTTL = 25
case restoreFootprint = 26
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class OperationsFactory: NSObject {
return try jsonDecoder.decode(LiquidityPoolWithdrawOperationResponse.self, from: data)
case .invokeHostFunction:
return try jsonDecoder.decode(InvokeHostFunctionOperationResponse.self, from: data)
case .bumpFootprintExpiration:
return try jsonDecoder.decode(BumpFootprintExpirationOperationResponse.self, from: data)
case .extendFootprintTTL:
return try jsonDecoder.decode(ExtendFootprintTTLOperationResponse.self, from: data)
case .restoreFootprint:
return try jsonDecoder.decode(RestoreFootprintOperationResponse.self, from: data)
}
Expand Down
59 changes: 27 additions & 32 deletions stellarsdk/stellarsdk/responses/xdr/ContractXDR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,28 @@ public enum SCErrorCode: Int32 {

public enum ContractCostType: Int32 {
case wasmInsnExec = 0
case wasmMemAlloc = 1
case hostMemAlloc = 2
case hostMemCpy = 3
case hostMemCmp = 4
case dispatchHostFunction = 5
case visitObject = 6
case valSer = 7
case valDeser = 8
case computeSha256Hash = 9
case computeEd25519PubKey = 10
case mapEntry = 11
case vecEntry = 12
case verifyEd25519Sig = 13
case vmMemRead = 14
case vmMemWrite = 15
case vmInstantiation = 16
case vmCachedInstantiation = 17
case invokeVmFunction = 18
case computeKeccak256Hash = 19
case computeEcdsaSecp256k1Key = 20
case computeEcdsaSecp256k1Sig = 21
case recoverEcdsaSecp256k1Key = 22
case int256AddSub = 23
case int256Mul = 24
case int256Div = 25
case int256Pow = 26
case int256Shift = 27
case memAlloc = 1
case memCpy = 2
case memCmp = 3
case dispatchHostFunction = 4
case visitObject = 5
case valSer = 6
case valDeser = 7
case computeSha256Hash = 8
case computeEd25519PubKey = 9
case verifyEd25519Sig = 10
case vmInstantiation = 11
case vmCachedInstantiation = 12
case invokeVmFunction = 13
case computeKeccak256Hash = 14
case computeEcdsaSecp256k1Sig = 15
case recoverEcdsaSecp256k1Key = 16
case int256AddSub = 17
case int256Mul = 18
case int256Div = 19
case int256Pow = 20
case int256Shift = 21
case ChaCha20DrawBytes = 22
}

public enum SCErrorXDR: XDRCodable {
Expand Down Expand Up @@ -787,7 +782,7 @@ public struct SCMapEntryXDR: XDRCodable {

public enum ContractExecutableType: Int32 {
case wasm = 0
case token = 1
case stellarAsset = 1
}

public enum ContractExecutableXDR: XDRCodable {
Expand All @@ -803,15 +798,15 @@ public enum ContractExecutableXDR: XDRCodable {
case .wasm:
let wasmHash = try container.decode(WrappedData32.self)
self = .wasm(wasmHash)
case .token:
case .stellarAsset:
self = .token
}
}

public func type() -> Int32 {
switch self {
case .wasm: return ContractExecutableType.wasm.rawValue
case .token: return ContractExecutableType.token.rawValue
case .token: return ContractExecutableType.stellarAsset.rawValue
}
}

Expand Down Expand Up @@ -840,8 +835,8 @@ public enum ContractExecutableXDR: XDRCodable {
}
}

public var isToken:Bool? {
return type() == ContractExecutableType.token.rawValue
public var isStellarAsset:Bool? {
return type() == ContractExecutableType.stellarAsset.rawValue
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// BumpFootprintExpirationOpXDR.swift
// ExtendFootprintTTLOpXDR.swift
// stellarsdk
//
// Created by Christian Rogobete on 24.07.23.
Expand All @@ -8,24 +8,24 @@

import Foundation

public struct BumpFootprintExpirationOpXDR: XDRCodable {
public struct ExtendFootprintTTLOpXDR: XDRCodable {
public var ext: ExtensionPoint
public var ledgersToExpire: UInt32
public var extendTo: UInt32

public init(ext: ExtensionPoint, ledgersToExpire: UInt32) {
public init(ext: ExtensionPoint, extendTo: UInt32) {
self.ext = ext
self.ledgersToExpire = ledgersToExpire
self.extendTo = extendTo
}

public init(from decoder: Decoder) throws {
var container = try decoder.unkeyedContainer()
ext = try container.decode(ExtensionPoint.self)
ledgersToExpire = try container.decode(UInt32.self)
extendTo = try container.decode(UInt32.self)
}

public func encode(to encoder: Encoder) throws {
var container = encoder.unkeyedContainer()
try container.encode(ext)
try container.encode(ledgersToExpire)
try container.encode(extendTo)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// BumpFootprintExpirationResultXDR.swift
// ExtendFootprintTTLResultXDR.swift
// stellarsdk
//
// Created by Christian Rogobete on 24.07.23.
Expand All @@ -8,7 +8,7 @@

import Foundation

public enum BumpFootprintExpirationResultCode: Int32 {
public enum ExtendFootprintTTLResultCode: Int32 {
// codes considered as "success" for the operation
case success = 0 // success

Expand All @@ -18,7 +18,7 @@ public enum BumpFootprintExpirationResultCode: Int32 {
case insufficientRefundableFee = -3
}

public enum BumpFootprintExpirationResultXDR: XDRCodable {
public enum ExtendFootprintTTLResultXDR: XDRCodable {
case success
case malformed
case resourceLimitExceeded
Expand All @@ -27,7 +27,7 @@ public enum BumpFootprintExpirationResultXDR: XDRCodable {
public init(from decoder: Decoder) throws {
var container = try decoder.unkeyedContainer()
let discriminant = try container.decode(Int32.self)
let code = BumpFootprintExpirationResultCode(rawValue: discriminant)!
let code = ExtendFootprintTTLResultCode(rawValue: discriminant)!

switch code {
case .success:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public enum InvokeHostFunctionResultCode: Int32 {
case malformed = -1
case trapped = -2
case resourceLimitExceeded = -3
case entryExpired = -4
case entryArchived = -4
case insufficientRefundableFee = -5
}

Expand All @@ -43,7 +43,7 @@ public enum InvokeHostFunctionResultXDR: XDRCodable {
self = .trapped
case .resourceLimitExceeded:
self = .resourceLimitExceeded
case .entryExpired:
case .entryArchived:
self = .entryExpired
default:
self = .insufficientRefundableFee
Expand Down
14 changes: 7 additions & 7 deletions stellarsdk/stellarsdk/responses/xdr/LedgerEntryXDR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ public enum LedgerEntryType: Int32 {
case contractData = 6
case contractCode = 7
case configSetting = 8
case expiration = 9
case ttl = 9
}

public struct ExpirationEntryXDR: XDRCodable {
public struct TTLEntryXDR: XDRCodable {
public let keyHash: WrappedData32;
public let expirationLedgerSeq: UInt32;
public let liveUntilLedgerSeq: UInt32;


public init(keyHash: WrappedData32, expirationLedgerSeq:UInt32) {
public init(keyHash: WrappedData32, liveUntilLedgerSeq:UInt32) {
self.keyHash = keyHash
self.expirationLedgerSeq = expirationLedgerSeq
self.liveUntilLedgerSeq = liveUntilLedgerSeq
}

public init(from decoder: Decoder) throws {
var container = try decoder.unkeyedContainer()
keyHash = try container.decode(WrappedData32.self)
expirationLedgerSeq = try container.decode(UInt32.self)
liveUntilLedgerSeq = try container.decode(UInt32.self)
}

public func encode(to encoder: Encoder) throws {
var container = encoder.unkeyedContainer()
try container.encode(keyHash)
try container.encode(expirationLedgerSeq)
try container.encode(liveUntilLedgerSeq)
}
}

Expand Down
Loading

0 comments on commit 611d397

Please sign in to comment.