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

1.0.0 #4

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0
4.1
58 changes: 2 additions & 56 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,6 @@ Change Log

---

## [1.0.0-beta13](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta13)
## [1.0.0.beta.1](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0.beta.1)

1. Call all completion handlers on the main thread

## [1.0.0-beta12](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta12)

1. Generate secure, 12 word, random passphrases

## [1.0.0-beta11](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta11)

1. Refactor random node selection for Linux

## [1.0.0-beta10](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta10)

1. Support Linux random

## [1.0.0-beta9](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta9)

1. Sign transactions with a key pair

## [1.0.0-beta8](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta8)

1. Public public/private key string methods

## [1.0.0-beta7](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta7)

1. Setup Package.swift library

## [1.0.0-beta6](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta6)

1. Signatures API
2. Register second secret via local transaction signing

## [1.0.0-beta5](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta5)

1. Blocks API

## [1.0.0-beta4](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta4)

1. Delegates API
2. Peers API

## [1.0.0-beta3](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta3)

1. Locally sign and broadcast transactions

## [1.0.0-beta2](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta2)

1. Crypto module to extract public/private keys from a secret
2. Securely gain access to a Lisk account via a secret passphrase
3. Full support for Swift Package Manager

## [1.0.0-beta1](https://github.com/AndrewBarba/lisk-swift-sdk/releases/tag/1.0.0-beta1)

1. Initial release.
2. Includes `APIClient` to make requests to Lisk nodes
3. `Loader` module to check node status
1. Initial version with full support for Lisk 1.0.0 API
4 changes: 2 additions & 2 deletions Lisk.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Lisk'
s.version = '1.0.0-beta13'
s.version = '1.0.0'
s.summary = 'Swift 4 library for Lisk - the cryptocurrency and blockchain application platform'
s.homepage = 'https://github.com/AndrewBarba/lisk-swift'
s.documentation_url = 'https://andrewbarba.github.io/lisk-swift/'
Expand All @@ -19,5 +19,5 @@ Pod::Spec.new do |s|
s.source_files = 'Sources/**/*.{h,swift}'
s.public_header_files = 'Sources/**/*.h'

s.dependency 'Ed25519', '~> 0.2.0'
s.dependency 'Ed25519', '~> 1.1.0'
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module CEd25519 {
umbrella "/Users/andrewbarba/Code/Lisk/lisk-swift/.build/checkouts/ed25519.git-6274347002403739230/Sources/CEd25519/include"
umbrella "/Users/andrewbarba/Code/Lisk/lisk-swift/.build/checkouts/ed25519.git--1962158432852652388/Sources/CEd25519/include"
export *
}
1,439 changes: 707 additions & 732 deletions Lisk.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

29 changes: 13 additions & 16 deletions Lisk.xcodeproj/xcshareddata/xcschemes/Lisk-Package.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Lisk::Lisk"
BuildableName = "Lisk.framework"
BlueprintName = "Lisk"
BlueprintIdentifier = "Ed25519::Ed25519"
BuildableName = "Ed25519.framework"
BlueprintName = "Ed25519"
ReferencedContainer = "container:Lisk.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -28,9 +28,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Ed25519::Ed25519"
BuildableName = "Ed25519.framework"
BlueprintName = "Ed25519"
BlueprintIdentifier = "Ed25519::CEd25519"
BuildableName = "CEd25519.framework"
BlueprintName = "CEd25519"
ReferencedContainer = "container:Lisk.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -42,9 +42,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Ed25519::CEd25519"
BuildableName = "CEd25519.framework"
BlueprintName = "CEd25519"
BlueprintIdentifier = "Lisk::Lisk"
BuildableName = "Lisk.framework"
BlueprintName = "Lisk"
ReferencedContainer = "container:Lisk.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -54,9 +54,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -76,7 +74,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -86,9 +83,9 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Lisk::Lisk"
BuildableName = "Lisk.framework"
BlueprintName = "Lisk"
BlueprintIdentifier = "Ed25519::Ed25519"
BuildableName = "Ed25519.framework"
BlueprintName = "Ed25519"
ReferencedContainer = "container:Lisk.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>Ed25519PackageDescription.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>1</integer>
</dict>
<key>Lisk-Package.xcscheme_^#shared#^_</key>
<dict>
Expand All @@ -17,7 +17,7 @@
<key>LiskPackageDescription.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>2</integer>
</dict>
<key>LiskPackageTests.xcscheme</key>
<dict>
Expand Down
24 changes: 3 additions & 21 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
{
"object": {
"pins": [
{
"package": "Bluebird",
"repositoryURL": "https://github.com/AndrewBarba/Bluebird.swift.git",
"state": {
"branch": null,
"revision": "932ddc12b9f331e52c3dcf08b6ad9c95c986897f",
"version": "2.0.1"
}
},
{
"package": "CryptoSwift",
"repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift.git",
"state": {
"branch": null,
"revision": "d0084e4a6fe9490b3baab3d3c2aad58d3a852daf",
"version": "0.8.0"
}
},
{
"package": "Ed25519",
"repositoryURL": "https://github.com/vzsg/ed25519.git",
"repositoryURL": "https://github.com/AndrewBarba/ed25519.git",
"state": {
"branch": null,
"revision": "0d2cfe8ce5e55cb3df77a846def37071b0b6ff91",
"version": "0.2.0"
"revision": "77bf751b603c573d50e45e2adb2e06776af219ae",
"version": "1.1.0"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.0
// swift-tools-version:4.1

import PackageDescription

Expand All @@ -8,7 +8,7 @@ let package = Package(
.library(name: "Lisk", targets: ["Lisk"]),
],
dependencies: [
.package(url: "https://github.com/vzsg/ed25519.git", from: "0.2.0")
.package(url: "https://github.com/AndrewBarba/ed25519.git", from: "1.1.0")
],
targets: [
.target(
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ Lisk Swift is heavily inspired by [Lisk JS](https://github.com/LiskHQ/lisk-js)
- [x] Local Signing for maximum security
- [x] Targets Lisk 1.0.0 API
- [x] Directly based on lisk-js
- [x] Swift 4.0
- [x] Swift 4.1
- [x] Unit Tests (87% coverage)
- [x] Documentation

## API

- [Accounts](https://andrewbarba.github.io/lisk-swift/Structs/Accounts.html)
- [Blocks](https://andrewbarba.github.io/lisk-swift/Structs/Blocks.html)
- [Dapps](https://andrewbarba.github.io/lisk-swift/Structs/Dapps.html)
- [Delegates](https://andrewbarba.github.io/lisk-swift/Structs/Delegates.html)
- [Loader](https://andrewbarba.github.io/lisk-swift/Structs/Loader.html)
- [Node](https://andrewbarba.github.io/lisk-swift/Structs/Node.html)
- [Peers](https://andrewbarba.github.io/lisk-swift/Structs/Peers.html)
- [Signatures](https://andrewbarba.github.io/lisk-swift/Structs/Signatures.html)
- [Transactions](https://andrewbarba.github.io/lisk-swift/Structs/Transactions.html)
Expand Down Expand Up @@ -108,30 +109,30 @@ let transactions = Transactions()
### Swift Package Manager

```swift
// swift-tools-version:4.0
// swift-tools-version:4.1

import PackageDescription

let package = Package(
name: "My Lisk App",
dependencies: [
.package(url: "https://github.com/AndrewBarba/lisk-swift.git", from: "1.0.0-beta")
.package(url: "https://github.com/AndrewBarba/lisk-swift.git", from: "1.0.0.beta")
]
)
```

### CocoaPods

> CocoaPods 1.1.0+ is required to build lisk-swift
> CocoaPods 1.5.0+ is required to build lisk-swift

```ruby
pod 'Lisk', '~> 1.0.0-beta'
pod 'Lisk', '~> 1.0.0.beta'
```

### Carthage

```ogdl
github "AndrewBarba/lisk-swift" ~> 1.0.0-beta
github "AndrewBarba/lisk-swift" ~> 1.0.0.beta
```

## Thank You
Expand Down
55 changes: 12 additions & 43 deletions Sources/API/Accounts/Accounts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Lisk
//
// Created by Andrew Barba on 12/31/17.
// Copyright © 2017 Andrew Barba. All rights reserved.
//

import Foundation
Expand All @@ -20,51 +19,21 @@ public struct Accounts: APIService {
}
}

// MARK: - Get
// MARK: - List

extension Accounts {

/// Retrieve the account info for an address
/// https://docs.lisk.io/docs/lisk-api-080-accounts#section-get-account-information-from-address
public func account(address: String, completionHandler: @escaping (Response<AccountResponse>) -> Void) {
let options = ["address": address]
client.get(path: "accounts", options: options, completionHandler: completionHandler)
}

/// Retrieve the public key of a Lisk address
/// https://docs.lisk.io/docs/lisk-api-080-accounts#section-get-account-public-key
public func publicKey(address: String, completionHandler: @escaping (Response<PublicKeyResponse>) -> Void) {
let options = ["address": address]
client.get(path: "accounts/getPublicKey", options: options, completionHandler: completionHandler)
}
}

// MARK: - Open

extension Accounts {
/// Retrieve accounts
public func accounts(address: String? = nil, publicKey: String? = nil, secondPublicKey: String? = nil, username: String? = nil, limit: Int? = nil, offset: Int? = nil, sort: APIRequest.Sort? = nil, completionHandler: @escaping (Response<AccountsResponse>) -> Void) {
var options: RequestOptions = [:]
if let value = address { options["address"] = value }
if let value = publicKey { options["publicKey"] = value }
if let value = secondPublicKey { options["secondPublicKey"] = value }
if let value = username { options["username"] = value }
if let value = limit { options["limit"] = value }
if let value = offset { options["offset"] = value }
if let value = sort?.value { options["sort"] = value }

/// Opens a new/existing Lisk account via secret passphrase
/// https://docs.lisk.io/v1.4/docs/lisk-api-080-accounts#section-get-account-information
public func open(secret: String, completionHandler: @escaping (Response<AccountResponse>) -> Void) {
do {
let (publicKey, _) = try Crypto.keys(fromSecret: secret)
let address = Crypto.address(fromPublicKey: publicKey)
self.account(address: address, completionHandler: completionHandler)
} catch {
let response = APIResponseError(message: "Invalid secret key")
completionHandler(.error(response: response))
}
}
}

// MARK: - Balance

extension Accounts {

/// Retrieve the balance of a Lisk address
/// https://docs.lisk.io/docs/lisk-api-080-accounts#section-get-account-balance
public func balance(address: String, completionHandler: @escaping (Response<BalanceResponse>) -> Void) {
let options = ["address": address]
client.get(path: "accounts/getBalance", options: options, completionHandler: completionHandler)
client.get(path: "accounts", options: options, completionHandler: completionHandler)
}
}
21 changes: 15 additions & 6 deletions Sources/API/Accounts/Models/AccountModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Lisk
//
// Created by Andrew Barba on 12/31/17.
// Copyright © 2017 Andrew Barba. All rights reserved.
//

import Foundation
Expand All @@ -14,14 +13,24 @@ extension Accounts {

public let address: String

public let balance: String
public let publicKey: String

public let unconfirmedBalance: String
public let balance: String?

public let publicKey: String
public let unconfirmedBalance: String?

public let secondPublicKey: String?

public let delegate: Delegates.DelegateModel?

// MARK: - Hashable

public let unconfirmedSignature: UInt8
public static func == (lhs: AccountModel, rhs: AccountModel) -> Bool {
return lhs.address == rhs.address
}

public let secondSignature: UInt8
public var hashValue: Int {
return address.hashValue
}
}
}
Loading