Skip to content

Commit

Permalink
refactore
Browse files Browse the repository at this point in the history
  • Loading branch information
N3TC4T committed Feb 8, 2022
1 parent 387a9a5 commit fe1087c
Show file tree
Hide file tree
Showing 40 changed files with 315 additions and 609 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Python

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
node:
Expand All @@ -14,20 +14,20 @@ jobs:
python-version: [3.6, 3.7, 3.8, 3.9]
runs-on: ${{ matrix.os }}
steps:
- name: Fix Windows Git autocrlf
run: git config --global core.autocrlf false
if: matrix.os == 'windows-latest'
- uses: actions/checkout@v2
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install -r requirements.txt
- run: python3 -m flake8 --exclude="./samples/, ./dist/, ./build/, ./tests/"
- run: python3 test.py tests/
env:
XUMM_APIKEY: aaaaaaaa-cccc-eeee-1111-333333333333
XUMM_APISECRET: bbbbbbbb-dddd-ffff-2222-444444444444
- name: Fix Windows Git autocrlf
run: git config --global core.autocrlf false
if: matrix.os == 'windows-latest'
- uses: actions/checkout@v2
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install -e ".[develop]"
- run: python3 -m flake8
- run: python3 test.py tests/
env:
XUMM_APIKEY: aaaaaaaa-cccc-eeee-1111-333333333333
XUMM_APISECRET: bbbbbbbb-dddd-ffff-2222-444444444444
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,16 @@ venv
/xumm_sdk_py.egg-info
.env
.pypirc
README.html
README.html

# virtualenv
.Python
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
pyvenv.cfg
.venv
pip-selfcheck.json
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ Instead of providing a `txjson` transaction, a transaction formatted as HEX blob

```python
sdk.payload.get(
payload: Union[str, CreatedPayload],
return_errors: bool = False
payload: Union[str, CreatedPayload]
): -> XummPayload
```

Expand All @@ -103,8 +102,6 @@ You can `get()` a payload by:
payload = sdk.payload.get(created)
```

If a payload can't be fetched (eg. doesn't exist), `None` will be returned, unless a second param (boolean) is provided to get the SDK to throw an Error in case a payload can't be retrieved:

```python
sdk.payload.get('aaaaaaaa-bbbb-cccc-dddd-1234567890ab', True)
```
Expand All @@ -113,8 +110,7 @@ sdk.payload.get('aaaaaaaa-bbbb-cccc-dddd-1234567890ab', True)

```python
sdk.payload.create (
payload: create_payload,
return_errors: bool = False
payload: create_payload
): -> Union[CreatedPayload, None]
```

Expand Down Expand Up @@ -147,8 +143,7 @@ Alternatively user routing / instruction flows can be custom built using the QR

```python
sdk.payload.cancel(
payload: Union[str, XummPayload, CreatedPayload],
return_errors: bool = False
payload: Union[str, XummPayload, CreatedPayload]
): -> Union[DeletedPayload, None]
```

Expand Down Expand Up @@ -240,14 +235,14 @@ Your XUMM APP storage is stored at the XUMM API backend, meaning it persists unt
This data is private, and accessible only with your own API credentials. This private JSON data can be used to store credentials / config / bootstrap info / ... for your headless application (eg. POS device).

```python
storage_set = await sdk.storage.set({name: 'Wietse', age: 32, male: True})
storage_set = await sdk.storage.set({'name': 'Wietse', 'age': 32, 'male': True})
print(storage_set)
# True
```

```python
storage_get = sdk.storage.get()
print(storage_get)
print(storage_get.data)
# { 'name': 'Wietse', 'age': 32, 'male': True }
```

Expand All @@ -259,7 +254,7 @@ print(storage_delete)

```python
storage_get_after_delete = sdk.storage.get()
print(storage_get_after_delete)
print(storage_get_after_delete.data)
# None
```

Expand Down Expand Up @@ -346,11 +341,11 @@ Returns: [`<XrplTransaction>`](https://github.com/XRPL-Labs/xumm-sdk-py/blob/mai

## Development

### Run

Build, run, show debug output & watch `dist/samples/dev.py`, compiled from `samples/dev.py` using `python3`. The `samples/dev.py` file is **not included by default**.
### Install requirments

[Here's a sample `samples/dev.py` file](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/samples/dev.py).
```bash
pip install -e ".[develop]"
```

### Build

Expand All @@ -376,4 +371,14 @@ DEBUG=xumm-sdk* python3 main.py

### Lint & test

Lint the code using `python3 -m flake8 --output-file=./logs/linter.txt --exclude="./samples/, ./build/, ./dist/, ./tests/"`, run tests (pytest) using `python3 test.py tests/`
Lint the code using:

```bash
python3 -m flake8
```

For running test:

```bash
python3 test.py tests/
```
18 changes: 8 additions & 10 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The full process for cutting a release is as follows:
`bumpversion --current-version 1.0.0 minor setup.py xumm/__init__.py`

2. Change the version in the setup.py file:
`VERSION = "1.0.0"`
`VERSION = "1.0.0"`

3. Add, and commit the changes, push up the branch, and open a PR:
`git add .`
Expand All @@ -25,19 +25,18 @@ The full process for cutting a release is as follows:

``

4. Once the PR is merged, checkout the `main` branch:
5. Once the PR is merged, checkout the `main` branch:
`git checkout main`

5. Delete `main` branch (Optional):
6. Delete `main` branch (Optional):
`git branch -d 1.0.0`

5. Make a new Git tag that matches the new version (make sure it is associated with the right commit SHA): FIXUP
7. Make a new Git tag that matches the new version (make sure it is associated with the right commit SHA): FIXUP
`git tag -a 1.0.0 -m "cut 1.0.0"`

7. Push up the tag from `main`:
8. Push up the tag from `main`:
`git push origin 1.0.0`


## Packaging & Releasing

Update pip build (optional)
Expand All @@ -50,8 +49,8 @@ Build Repo

```
dist/
xumm-sdk-py-dangell-1.0.0-py3-none-any.whl
xumm-sdk-py-dangell-1.0.0.tar.gz
xumm-sdk-py-1.0.0-py3-none-any.whl
xumm-sdk-py-1.0.0.tar.gz
```

Install Twine
Expand All @@ -70,11 +69,10 @@ Check Distribution

`twine check dist/*`


Push on Staging

`twine upload --skip-existing --config-file="./.pypirc" -r testpypi dist/*`

Push to Production

`twine upload --config-file="./.pypirc" -r dist/*`
`twine upload --config-file="./.pypirc" -r dist/*`
45 changes: 0 additions & 45 deletions samples/dev.py

This file was deleted.

1 change: 1 addition & 0 deletions samples/fixtures/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .sample_payload import payload as sample_payload
41 changes: 41 additions & 0 deletions samples/fixtures/sample_payload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python
# coding: utf-8

import binascii
from uuid import uuid4

payload = {
'custom_meta': {
'instruction': 'Hey! Please sign for:\n\nThis\nand\nthat 🍻',
'blob': {
'myOwnProp': 'Whereever',
'clientCountry': 'Moon',
},
'identifier': str(uuid4())
},
'options': {
'submit': True,
'multisign': False,
'expire': 500,
'return_url': {
'app': 'https://example.com/callback?payload={id}&blob={txblob}',
'web': 'https://example.com/callback?identifier={cid}&tx={txid}'
}
},
'txjson': {
'TransactionType' : 'Payment',
'Destination' : 'rPEPPER7kfTD9w2To4CQk6UCfuHM9c6GDY',
'DestinationTag': 495,
'Amount': '1337',
'LastLedgerSequence': 20,
'Fee': '12',
'Memos': [
{
'Memo': {
'MemoData': binascii.hexlify('Sample XUMM payload'.encode('utf8')).decode('utf-8').upper(),
'MemoFormat': binascii.hexlify('some/memo'.encode('utf8')).decode('utf-8').upper(),
}
}
]
}
}
31 changes: 0 additions & 31 deletions samples/main.py

This file was deleted.

42 changes: 42 additions & 0 deletions samples/misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python
# coding: utf-8
import logging
import asyncio

import xumm

class MiscExample:
def __init__(self):
logging.debug('')
self.sdk = xumm.XummSdk('API_KEY', 'API_SECRET')
self.logger = logging.getLogger(self.__module__)
self.logger.setLevel(level=logging.DEBUG)

async def run(self):
# send ping to the backend and print application name
ping_response = self.sdk.ping()
self.logger.info("Ping response: application name: %s" % ping_response.application.name)

# get curated assets and print available currencies count
curated_assets_response = self.sdk.get_curated_assets()
self.logger.info("Curated_assets response: currencies count %s" % str(len(curated_assets_response.currencies)))


# get kyc status of a xrpl address
address = "rDWLGshgAxSX2G4TEv3gA6QhtLgiXrWQXB"
kyc_status_response = self.sdk.get_kyc_status(address)
self.logger.info("Kyc status for account %s: %s" % (address, kyc_status_response))


# get transaction by hash from ledger
tx_hash = "017DED8F5E20F0335C6F56E3D5EE7EF5F7E83FB81D2904072E665EEA69402567"
get_tx_response = self.sdk.get_transaction(tx_hash)
self.logger.info("transaction balance changes: %s" % get_tx_response.balance_changes)


if __name__ == "__main__":
example = MiscExample()

loop = asyncio.get_event_loop()
loop.run_until_complete(example.run())

Loading

0 comments on commit fe1087c

Please sign in to comment.