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

Add Python demo #20

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
10 changes: 9 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ jobs:

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

- run:
name: "Install Poetry"
command: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python

- run:
name: "Run Node SDK Demo"
Expand All @@ -34,3 +38,7 @@ jobs:
- run:
name: "Run Java ILP SDK Demo"
command: cd java && mvn package && mvn exec:java@ilp

- run:
name: "Run Python SDK Demo"
command: cd python && poetry install && poetry run python main.py
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Xpring-SDK-Demo

Demos for each library in [Xpring SDK](http://github.com/xpring-sdk):
- [JavaScript / Xpring-JS](http://github.com/xpring-eng/xpring-js): `node/`
- [Java / Xpring4J](http://github.com/xpring-eng/xpring4j): `java/`
- [Swift / XpringKit](http://github.com/xpring-eng/xpringkit): `swift/`
- JavaScript / [Xpring-JS](http://github.com/xpring-eng/xpring-js): [`node/`](./node)
- Java / [Xpring4J](http://github.com/xpring-eng/xpring4j): [`java/`](/.java)
- Swift / [XpringKit](http://github.com/xpring-eng/xpringkit): [`swift/`](./swift)
- Python / [xpring-py](https://github.com/thejohnfreeman/xpring-py): [`python/`](./python)

Build instructions included in each folder.

Expand Down
10 changes: 10 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Python Demo

![screenshot of demo in terminal](./python-demo.png)

Demonstrates [xpring-py](https://github.com/thejohnfreeman/xpring-py).

```
$ poetry install
$ poetry run python main.py
```
34 changes: 34 additions & 0 deletions python/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import time

import xpring
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does xpring come from?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I publish this package to PyPI: https://pypi.org/project/xpring/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a Python implementation of serialization, signing, and gRPC for XRPL. No calls to JavaScript.


url = 'test.xrp.xpring.io:50051'
seed = 'ss9unxUg8VgvDjWrogKGVDiRRz97n'
recipient = 'rNJDvXkaBRwJYdeEcx9pchE2SecMkH3FLz'
amount = '10'

print(f'Using rippled node located at: {url}')
client = xpring.Client.from_url(url)

wallet = xpring.Wallet.from_seed(seed)
address = wallet.address

print(f'Retrieving balance for {address}')
balance = client.get_balance(address)
print(f'Balance was {balance} drops!')

print('Sending:')
print(f'- Drops: {amount}')
print(f'- To: {recipient}')
print(f'- From: {address}')
signed_transaction = client.send(wallet, recipient, amount)
client.submit(signed_transaction)

txid = signed_transaction['hash']
print('Hash for transaction:')
print(txid)

time.sleep(5)
transaction_status = client.get_transaction_status(txid)
print('Result for transaction is:')
print(transaction_status.name)
16 changes: 16 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "xpring-demo"
version = "1.0.0"
description = "Demonstration of xpring-py"
authors = ["Xpring Engineering"]
license = "MIT"

[tool.poetry.dependencies]
python = "^3.6"
xpring = {version = "^0.5.0", extras = ["py"]}

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
Binary file added python/python-demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.