Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
example updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Synesso committed Mar 7, 2018
1 parent 21189cf commit 1e2d605
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
45 changes: 19 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,61 +34,57 @@ In your `build.sbt`
```
resolvers += "scala-stellar-sdk-repo" at "https://dl.bintray.com/synesso/mvn"
libraryDependencies += "stellar.scala.sdk" %% "scala-stellar-sdk" % "0.0.1.5"
libraryDependencies += "stellar.scala.sdk" %% "scala-stellar-sdk" % "0.1.0"
```

## Examples

All of the following examples use the [Ammonite REPL](http://ammonite.io/). After launching `amm`, fetch and import the
The following examples use the [Ammonite REPL](http://ammonite.io/). After launching `amm`, fetch and import the
Stellar SDK for Scala.

```
interp.repositories() ++= Seq(coursier.MavenRepository("https://dl.bintray.com/synesso/mvn/"))
import $ivy.`stellar.scala.sdk::scala-stellar-sdk:0.0.1.5`
import $ivy.`stellar.scala.sdk::scala-stellar-sdk:0.1.0`
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent._
import stellar.sdk._
import stellar.sdk.resp._
```

### Accounts

#### Creating and funding a test account
### Creating and funding a test account

```
val kp = KeyPair.random
TestNetwork.fund(kp) // Future[FundTestAccountResp]
```

#### Checking the status of an account
### Checking the status of an account

```
TestNetwork.account(kp) // Future[AccountResp]
```

#### Fetch data for an account
### Funding a new account with a create account operation

```
TestNetwork.accountData(kp, "data_key") // Future[String]
```
implicit val network = TestNetwork
val funder: KeyPair = kp // funded account from first example
val toCreate = KeyPair.random
### Assets
for {
account <- TestNetwork.account(funder)
txn <- Future.fromTry {
Transaction(Account(funder, sequenceNumber))
.add(CreateAccountOperation(toCreate, Amount.lumens(1)))
.sign(source)
} yield txn.submit
}
#### Fetching a stream of all assets

```
TestNetwork.assets // Future[Stream[AssetResp]]
```

#### Filtering assets by code or issuer, or both.

```
TestNetwork.assets(code = Some("ETH"))
TestNetwork.assets(issuer = Some("GAE325UC3T63ROIUFBBRNMWGM7AY2NI5C2YO55IPLRKCF3UECXLXKNNZ"))
TestNetwork.assets(code = Some("ETH"), issuer = Some("GAE325UC3T63ROIUFBBRNMWGM7AY2NI5C2YO55IPLRKCF3UECXLXKNNZ"))
```
Additional examples can be found in the `/examples` folder.



Expand All @@ -97,7 +93,7 @@ TestNetwork.assets(code = Some("ETH"), issuer = Some("GAE325UC3T63ROIUFBBRNMWGM7
```
[✓] Operations
[✓] Transactions
[🚀] Horizon Endpoints
[ ] Horizon Endpoints
[✓] Account details
[✓] Assets
[✓] Unfiltered
Expand Down Expand Up @@ -179,6 +175,3 @@ TestNetwork.assets(code = Some("ETH"), issuer = Some("GAE325UC3T63ROIUFBBRNMWGM7
[ ] Federation
```

### todo

* all txns require an account, so account can record the network it came from.
15 changes: 15 additions & 0 deletions examples/06-find_assets.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// filters assets by issuer, code or both

import scala.concurrent.ExecutionContext.Implicits.global

import stellar.sdk._


TestNetwork.assets(code = Some("ETH"))
.foreach(_.foreach(println))

TestNetwork.assets(issuer = Some("GAE325UC3T63ROIUFBBRNMWGM7AY2NI5C2YO55IPLRKCF3UECXLXKNNZ"))
.foreach(_.foreach(println))

TestNetwork.assets(code = Some("ETH"), issuer = Some("GAE325UC3T63ROIUFBBRNMWGM7AY2NI5C2YO55IPLRKCF3UECXLXKNNZ"))
.foreach(_.foreach(println))

0 comments on commit 1e2d605

Please sign in to comment.