Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Refactor Swift Demo and Document #8

Merged
merged 16 commits into from
Feb 27, 2020
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
8 changes: 8 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ jobs:
steps:
- checkout

- run:
name: "Install tooling"
command: brew install swiftlint

- run:
name: "Run Node SDK Demo"
command: cd node && npm i && node src/index.js

- run:
name: "Run Swift SDK Demo"
command: cd swift && carthage bootstrap --platform mac && set -o pipefail && xcodebuild build -scheme Demo ONLY_ACTIVE_ARCH=YES
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
[submodule "Carthage/Checkouts/XpringKit"]
path = swift/Carthage/Checkouts/XpringKit
url = https://github.com/xpring-eng/XpringKit.git
[submodule "Carthage/Checkouts/grpc-swift"]
path = swift/Carthage/Checkouts/grpc-swift
url = https://github.com/grpc/grpc-swift.git
[submodule "Carthage/Checkouts/swift-protobuf"]
path = swift/Carthage/Checkouts/swift-protobuf
url = https://github.com/apple/swift-protobuf.git
4 changes: 2 additions & 2 deletions swift/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Checkouts
Carthage/Build

### CocoaPods ###
Expand Down Expand Up @@ -98,4 +98,4 @@ iOSInjectionProject/

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)

# End of https://www.gitignore.io/api/swift,xcode,carthage,cocoapods
# End of https://www.gitignore.io/api/swift,xcode,carthage,cocoapods
3 changes: 1 addition & 2 deletions swift/Cartfile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
github "xpring-eng/XpringKit"
github "apple/swift-protobuf" "1.6.0"
github "grpc/grpc-swift" "0.9.1"

2 changes: 1 addition & 1 deletion swift/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "apple/swift-protobuf" "1.6.0"
github "grpc/grpc-swift" "0.9.1"
github "xpring-eng/XpringKit" "1.0.2"
github "xpring-eng/XpringKit" "1.3.0"
1 change: 0 additions & 1 deletion swift/Carthage/Checkouts/XpringKit
Submodule XpringKit deleted from 85140b
1 change: 1 addition & 0 deletions swift/Carthage/Checkouts/XpringKit/Carthage/Build
1 change: 0 additions & 1 deletion swift/Carthage/Checkouts/grpc-swift
Submodule grpc-swift deleted from 8eac34
1 change: 0 additions & 1 deletion swift/Carthage/Checkouts/swift-protobuf
Submodule swift-protobuf deleted from 3a3594
21 changes: 20 additions & 1 deletion swift/README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
# XpringKit demo
# Swift Demo

<img src="swift-demo.png" alt="Screenshot of the Xpring SDK Demo"/>

Demonstrates [XpringKit](http://github.com/xpring-eng/xpringkit).

This demo builds using [Carthage](https://github.com/Carthage/Carthage) but it is also possible to build XpringKit with [CocoaPods](https://cocoapods.org/).

To build:
```shell
# Install required tooling
brew install carthage swiftlint

# Install dependencies
carthage bootsrap

# Run in XCode.
open XpringKit.xcodeproj
```

35 changes: 35 additions & 0 deletions swift/Sources/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Foundation
import XpringKit

// A URL to reach the remote rippled node at.
let grpcAddress = "3.14.64.116:50051"

// A wallet that exists on Testnet.
let seed = "snYP7oArxKepd3GPDcrjMsJYiJeJB";
guard let wallet = Wallet(seed: seed) else {
print("The given seed is not valid: \(seed)")
exit(0)
}

// A recipient address.
let recipientAddress = "X7cBcY4bdTTzk3LHmrKAK6GyrirkXfLHGFxzke5zTmYMfw4"
let dropsToSend: UInt64 = 10

print("\nUsing rippled node located at: \(grpcAddress)\n")
let xrpClient = XpringClient(grpcURL: grpcAddress, useNewProtocolBuffers: true)

print("Retrieving balance for \(wallet.address) ..")
let balance = try xrpClient.getBalance(for: wallet.address)

print("Balance was \(balance) drops!\n")

print("Sending:")
print("- Drops \(dropsToSend)")
print("- To: \(recipientAddress)")
print("- From: \(wallet.address)\n")
let hash = try xrpClient.send(dropsToSend, to: recipientAddress, from: wallet)

print("Hash for transaction:\n\(hash)\n")

let status = try xrpClient.getTransactionStatus(for: hash)
print("Result for transaction is:\n\(status)\n");
Loading