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

RELEASE 1.0.0 #19

Merged
merged 3 commits into from
Jan 31, 2022
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
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# XUMM SDK (PYTHON) [![python version](https://badge.fury.io/py/xumm-sdk-py.svg)](https://test.pypi.org/project/xumm-sdk-py-dangell7/) [![GitHub Actions Python status](https://github.com/CASL-AE/xumm-sdk-py/workflows/Python/badge.svg?branch=main)](https://github.com/CASL-AE/xumm-sdk-py/actions)
# XUMM SDK (PYTHON) [![python version](https://badge.fury.io/py/xumm-sdk-py.svg)](https://pypi.org/project/xumm-sdk-py/) [![GitHub Actions Python status](https://github.com/XRPL-Labs/xumm-sdk-py/workflows/Python/badge.svg?branch=main)](https://github.com/XRPL-Labs/xumm-sdk-py/actions)

Interact with the XUMM SDK from Python environments.

Expand Down Expand Up @@ -28,7 +28,7 @@ sdk = xumm.XummSdk('someAppKey', 'someAppSecret')
### Credentials

#### In case of backend use
The SDK will look in your environment or dotenv file (`.env`) for the `XUMM_APIKEY` and `XUMM_APISECRET` values. A `.env.sample` file is provided in this repository. A [sample dotenv file looks like this](https://github.com/CASL-AE/xumm-sdk-py/blob/main/.env.sample). Alternatively you can provide your XUMM API Key & Secret by passing them to the XummSdk constructor.
The SDK will look in your environment or dotenv file (`.env`) for the `XUMM_APIKEY` and `XUMM_APISECRET` values. A `.env.sample` file is provided in this repository. A [sample dotenv file looks like this](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/.env.sample). Alternatively you can provide your XUMM API Key & Secret by passing them to the XummSdk constructor.

If both your environment and the SDK constructor contain credentials, the values provided to the constructor will be used.

Expand All @@ -52,7 +52,7 @@ The `ping` method allows you to verify API access (valid credentials) and return
pong = sdk.ping()
```

Returns [`<ApplicationDetails>`](https://github.com/CASL-AE/xumm-sdk-py/blob/main/xumm/resource/types/meta/application_details.py#L294):
Returns [`<ApplicationDetails>`](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/xumm/resource/types/meta/application_details.py#L294):
```python
pong.quota # {}
pong.application.name # 'My XUMM APP'
Expand All @@ -71,7 +71,7 @@ populate the "Add Asset" button at the XUMM home screan.
curated_assets = sdk.get_curated_assets()
```

Returns [`<CuratedAssetsResponse>`](https://github.com/CASL-AE/xumm-sdk-py/blob/main/xumm/resource/types/meta/curated_assets_response.py#L426):
Returns [`<CuratedAssetsResponse>`](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/xumm/resource/types/meta/curated_assets_response.py#L426):
```python
curated_assets.issuers # [ 'Bitstamp', 'GateHub' ]
curated_assets.currencies # [ 'USD', 'BTC', 'EUR', 'ETH' ]
Expand Down Expand Up @@ -101,7 +101,7 @@ kyc_status = sdk.get_kyc_status('00000000-0000-0000-0000-000000000000')
kyc_status = sdk.get_kyc_status('rwu1dgaUq8DCj3ZLFXzRbc1Aco5xLykMMQ')
```

Returns [`<str of PossibleKycStatuses>`](https://github.com/CASL-AE/xumm-sdk-py/blob/main/xumm/resource/types/meta/kyc_status_response.py#L66).
Returns [`<str of PossibleKycStatuses>`](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/xumm/resource/types/meta/kyc_status_response.py#L66).

###### Notes on KYC information

Expand All @@ -120,7 +120,7 @@ live from the XRP ledger, as fetched for you by the XUMM backend.
tx_info = sdk.get_transaction(tx_hash)
```

Returns: [`<XrplTransaction>`](https://github.com/CASL-AE/xumm-sdk-py/blob/main/xumm/resource/types/meta/xrpl_transaction.py#L114).
Returns: [`<XrplTransaction>`](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/xumm/resource/types/meta/xrpl_transaction.py#L114).

#### App Storage

Expand Down Expand Up @@ -175,7 +175,7 @@ payload = {

As you can see the payload looks like a regular XRPL transaction, wrapped in an `txjson` object, omitting the mandatory `Account`, `Fee` and `Sequence` properties. They will be added containing the correct values when the payload is signed by an app user.

Optionally (besides `txjson`) a payload can contain these properties ([PY definition](https://github.com/CASL-AE/xumm-sdk-py/blob/main/xumm/resource/types/xumm_api/__init__.py#L836)):
Optionally (besides `txjson`) a payload can contain these properties ([PY definition](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/xumm/resource/types/xumm_api/__init__.py#L836)):

- `options` to define payload options like a return URL, expiration, etc.
- `custom_meta` to add metadata, user insruction, your own unique ID, ...
Expand Down Expand Up @@ -265,7 +265,7 @@ To cancel a payload, provide a payload UUID (string), a `<XummPayload>` (by perf

**Please note**: *if a user already opened the payload in XUMM APP, the payload cannot be cancelled: the user may still be resolving the payload in the XUMM App, and should have a chance to complete that process*.

A response (generic API types [here](https://github.com/CASL-AE/xumm-sdk-py/blob/main/xumm/resource/types/xumm_api/__init__.py)) looks like:
A response (generic API types [here](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/xumm/resource/types/xumm_api/__init__.py)) looks like:
```python
response.result.cancelled # bool
response.result.reason # XummCancelReason
Expand Down Expand Up @@ -303,11 +303,11 @@ sdk.payload.subscribe(

If a callback function is not provided, the subscription will stay active until the `<PayloadSubscription>.resolve()` method is called manually, eg. based on handling `<PayloadSubscription>.websocket.onmessage` events.

When a callback function is provided, for every paylaod specific event the callback function will be called with [`<SubscriptionCallbackParams>`](https://github.com/CASL-AE/xumm-sdk-py/blob/main/xumm/resource/types/payload/subscription_callback_params.py). The `<SubscriptionCallbackParams>.data` property contains parsed JSON containing event information. Either by calling `<SubscriptionCallbackParams>.resolve()` or by returning a non-void value in the *callback function* the subscription will be ended, and the `<PayloadSubscription>.resolved` promise will resolve with the value returned or passed to the `<SubscriptionCallbackParams>.resolve()` method.
When a callback function is provided, for every paylaod specific event the callback function will be called with [`<SubscriptionCallbackParams>`](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/xumm/resource/types/payload/subscription_callback_params.py). The `<SubscriptionCallbackParams>.data` property contains parsed JSON containing event information. Either by calling `<SubscriptionCallbackParams>.resolve()` or by returning a non-void value in the *callback function* the subscription will be ended, and the `<PayloadSubscription>.resolved` promise will resolve with the value returned or passed to the `<SubscriptionCallbackParams>.resolve()` method.

Resolving (by returning non-void in the callback or calling `resolve()` manually) closes the WebSocket client the XUMM SDK sets up 'under the hood'.

The [`<PayloadSubscription>`](https://github.com/CASL-AE/xumm-sdk-py/blob/main/xumm/resource/types/payload/payload_subscription.py) object looks like this:
The [`<PayloadSubscription>`](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/xumm/resource/types/payload/payload_subscription.py) object looks like this:

```python
response.payload # XummPayload
Expand All @@ -318,10 +318,10 @@ response.websocket # WSClient

Examples:

- [Async process after returning data in the callback function](https://github.com/CASL-AE/xumm-sdk-py/blob/main/samples/ws/async_callback.py)
- [Await based on returning data in the callback function](https://github.com/CASL-AE/xumm-sdk-py/blob/main/samples/ws/await_callback.py)
- [Await based on resolving a callback event](https://github.com/CASL-AE/xumm-sdk-py/blob/main/samples/ws/await_event.py)
- [Await based on resolving without using a callback function](https://github.com/CASL-AE/xumm-sdk-py/blob/main/samples/ws/await_no_callback.py)
- [Async process after returning data in the callback function](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/samples/ws/async_callback.py)
- [Await based on returning data in the callback function](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/samples/ws/await_callback.py)
- [Await based on resolving a callback event](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/samples/ws/await_event.py)
- [Await based on resolving without using a callback function](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/samples/ws/await_no_callback.py)

##### sdk.payload.create_subscribe

Expand All @@ -332,7 +332,7 @@ sdk.payload.create_and_subscribe(
): -> PayloadAndSubscription
```

The [`<PayloadAndSubscription>`](https://github.com/CASL-AE/xumm-sdk-py/blob/main/xumm/resource/types/payload/payload_and_subscription.py) object is basically a [`<PayloadSubscription>`](https://github.com/CASL-AE/xumm-sdk-py/blob/main/xumm/resource/types/payload/payload_subscription.py) object with the created payload results in the `created` property:
The [`<PayloadAndSubscription>`](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/xumm/resource/types/payload/payload_and_subscription.py) object is basically a [`<PayloadSubscription>`](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/xumm/resource/types/payload/payload_subscription.py) object with the created payload results in the `created` property:

All information that applies on [`sdk.payload.create()`](#sdkpayloadcreate) and [`sdk.payload.create_and_subscribe()`](#sdkpayloadsubscribe) applies. Differences are:

Expand Down Expand Up @@ -375,4 +375,4 @@ Lint the code using `python3 -m flake8 --output-file=./logs/linter.txt --exclude

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**.

[Here's a sample `samples/dev.py` file](https://github.com/CASL-AE/xumm-sdk-py/blob/main/samples/dev.py).
[Here's a sample `samples/dev.py` file](https://github.com/XRPL-Labs/xumm-sdk-py/blob/main/samples/dev.py).
18 changes: 9 additions & 9 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
The full process for cutting a release is as follows:

0. Checkout a new branch:
`git checkout -b 0.9.9-beta.5` # 1.0.0-release
`git checkout -b 1.0.0` # 1.0.0-release

1. Python / Pip Bumpversion

`pip3 install bumpversion`

`bumpversion --current-version 0.9.9-beta.5 minor setup.py xumm/__init__.py`
`bumpversion --current-version 1.0.0 minor setup.py xumm/__init__.py`

2. Change the version in the setup.py file:
`VERSION = "0.9.9-beta.5"`
`VERSION = "1.0.0"`

3. Add, and commit the changes, push up the branch, and open a PR:
`git add .`
`git commit -m 'RELEASE 0.9.9-beta.5'`
`git commit -m 'RELEASE 1.0.0'`
`git push --set-upstream origin HEAD`

4. Open PR request
Expand All @@ -29,13 +29,13 @@ The full process for cutting a release is as follows:
`git checkout main`

5. Delete `main` branch (Optional):
`git branch -d 0.9.9-beta.5`
`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
`git tag -a 0.9.9-beta.5 -m "cut 0.9.9-beta.5"`
`git tag -a 1.0.0 -m "cut 1.0.0"`

7. Push up the tag from `main`:
`git push origin 0.9.9-beta.5`
`git push origin 1.0.0`


## Packaging & Releasing
Expand All @@ -50,8 +50,8 @@ Build Repo

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

Install Twine
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from codecs import open

NAME = "xumm-sdk-py-dangell7"
VERSION = "0.9.9-beta.5"
VERSION = "1.0.0"
# To install the library, run the following
#
# python setup.py install
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/xumm_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
},
"error": {
"error": {
"reference": "a61ba59a-0304-44ae-a86e-d74808bd5190",
"reference": "a61ba59a-0304-44ae-a86e-efefegewgew4",
"code": 602
}
},
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/xumm_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from xumm.util import read_json

import websockets
import time

json_fixtures = read_json('./tests/fixtures/xumm_api.json')

Expand Down Expand Up @@ -39,7 +40,7 @@ async def start_server(ws, path):

async def main():
print('STARTING SOCKET')
async with websockets.serve(start_server, "localhost", 8765):
async with websockets.serve(start_server, "127.0.0.1", 8765):
print('SERVING SOCKET')
await asyncio.Future() # run forever

Expand Down
3 changes: 1 addition & 2 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def test_invalid_credentials(cls, mock_get):
sdk.ping()
cls.fail("ping() raised Exception unexpectedly!")
except Exception as e:
cls.assertEqual(e.error['reference'], cls.json_fixtures['invalidCredentials']['error']['reference'])
cls.assertEqual(e.error['code'], cls.json_fixtures['invalidCredentials']['error']['code'])
cls.assertEqual(str(e), 'Error code 813, see XUMM Dev Console, reference: 26279bfe-c7e1-4b12-a680-26119d8f5062')

@patch('xumm.client.requests.get')
def test_fetch_curated_assets(cls, mock_get):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_payload_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def test_payload_not_found_errors(cls, mock_delete):
cls.sdk.payload.cancel(payloadId, True)
cls.fail("payload_cancel() raised Exception unexpectedly!")
except Exception as e:
cls.assertEqual(e.error['reference'], cls.json_fixtures['payload']['notfound']['error']['reference'])
cls.assertEqual(e.error['code'], cls.json_fixtures['payload']['notfound']['error']['code'])
cls.assertEqual(str(e), 'Error code 404, see XUMM Dev Console, reference: a61ba59a-0304-44ae-a86e-d74808bd5190')

@patch('xumm.client.requests.delete')
@patch('xumm.client.requests.post')
Expand Down
4 changes: 1 addition & 3 deletions tests/test_payload_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,4 @@ def test_payload_create_invalid_errors(cls, mock_post):
cls.sdk.payload.create(test_fixtures.invalid_payload(), True)
cls.fail("payload_create() raised Exception unexpectedly!")
except Exception as e:
cls.assertEqual(e.error['reference'], cls.json_fixtures['payload']['error']['error']['reference'])
cls.assertEqual(e.error['code'], cls.json_fixtures['payload']['error']['error']['code'])
# cls.assertEqual(e.error['message'], cls.json_fixtures['payload']['error']['error']['message'])
cls.assertEqual(str(e), 'Error code 602, see XUMM Dev Console, reference: a61ba59a-0304-44ae-a86e-efefegewgew4')
4 changes: 1 addition & 3 deletions tests/test_payload_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,4 @@ def test_payload_get_invalid_errors(cls, mock_get):
cls.sdk.payload.get('00000000-0000-4839-af2f-f794874a80b0', True)
cls.fail("payload_get() raised Exception unexpectedly!")
except Exception as e:
cls.assertEqual(e.error['reference'], cls.json_fixtures['payload']['notfound']['error']['reference'])
cls.assertEqual(e.error['code'], cls.json_fixtures['payload']['notfound']['error']['code'])
# cls.assertEqual(e.error['message'], cls.json_fixtures['payload']['error']['error']['message'])
cls.assertEqual(str(e), 'Error code 404, see XUMM Dev Console, reference: a61ba59a-0304-44ae-a86e-d74808bd5190')
Loading