Skip to content
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
18 changes: 0 additions & 18 deletions .cruft.json

This file was deleted.

2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
Expand All @@ -31,6 +31,6 @@ jobs:
poetry run pytest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
5 changes: 0 additions & 5 deletions .isort.cfg

This file was deleted.

96 changes: 26 additions & 70 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,71 +1,27 @@
# Read up on pre-commit
# https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/

repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-yaml
- id: check-toml
- id: debug-statements
- id: check-merge-conflict

- repo: https://github.com/ambv/black
rev: 19.10b0
hooks:
- id: black
language_version: python3

- repo: https://github.com/myint/docformatter
rev: v1.3.1
hooks:
- id: docformatter
args: [
-i,
--wrap-summaries=120,
--wrap-descriptions=120,
--pre-summary-newline,
]

- repo: https://github.com/humitos/mirrors-autoflake
rev: v1.1
hooks:
- id: autoflake
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']
exclude: 'viz/__init__.py'

- repo: https://github.com/asottile/seed-isort-config
rev: v2.1.1
hooks:
- id: seed-isort-config

- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
hooks:
- id: isort

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.1
hooks:
- id: flake8
additional_dependencies: [
'pep8-naming',
'flake8-comprehensions',
'flake8-bugbear',
'flake8-pytest-style',
'flake8-variables-names',
'flake8-class-attributes-order',
'dlint',
]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.770
hooks:
- id: mypy
args: [--ignore-missing-imports, --check-untyped-defs, --disallow-incomplete-defs]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-yaml
- id: check-toml
- id: check-json
- id: debug-statements

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.10
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
hooks:
- id: mypy
args:
- --ignore-missing-imports
- --check-untyped-defs
- --disallow-incomplete-defs
15 changes: 15 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.9"

sphinx:
configuration: docs/conf.py

python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

We follow [Semantic Versions](https://semver.org/).

## Version 1.1.0

- Refactoring and support for Python from 3.8 to 3.14
- Update dependencies
- Fix docs build

## Version 1.0.2

- Add `delegate_vesting_shares` method
Expand Down
18 changes: 0 additions & 18 deletions Pipfile

This file was deleted.

106 changes: 79 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,78 @@
![Tests Status](https://github.com/VIZ-Blockchain/viz-python-lib/actions/workflows/tests.yml/badge.svg)
[![Documentation Status](https://readthedocs.org/projects/viz-python-lib/badge/?version=latest)](https://viz-python-lib.readthedocs.io/en/latest/?badge=latest)

**This library is in alpha state, API unstable**
## Usage examples

Built on top of [python-graphenelib](https://github.com/xeroc/python-graphenelib/)
Read dynamic global properties:

## Dependencies
```python
from viz import Client
from pprint import pprint

#### Linux dependencies
viz = Client(node="wss://node.viz.cx/ws")
pprint(viz.info())
```

```sh
sudo apt-get install libffi-dev libssl-dev python-dev
Award someone:

```python
from viz import Client

node = "wss://node.viz.cx/ws"
viz = Client(node=node, keys=["5...your_private_regular_key..."])
initiator = "your_account"
percent = 10.5
viz.award("id", percent, "with love", None, initiator)
```

#### Windows dependencies
Award someone with fixed reward:

Install regular version of [OpenSSL](https://slproweb.com/products/Win32OpenSSL.html) (not Light) suitable for your core processor.
```python
from viz import Client

#### MacOS dependencies
node = "wss://node.viz.cx/ws"
viz = Client(node=node, keys=["5...your_private_regular_key..."])
initiator = "your_account"
reward_amount = 3.5 # "3.50 VIZ"
max_energy = 30 # 30%
viz.fixed_award("id", reward_amount, max_energy, "with fixed reward", None, initiator)
```

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. This means that you will need to install and export some OpenSSL settings yourself, before you can install viz-python-lib:
Send a custom operation:

```sh
brew install openssl
```python
from viz import Client

node = "wss://node.viz.cx/ws"
viz = Client(node=node, keys=["5...your_private_regular_key..."])
account = "your_account"
protocol = "color.place"
json = {"x":35, "y":70, "color":"#e50000"}
viz.custom(protocol, json, None, [account])
```

and then use the following commands:
Get account with custom protocol latest block:

```sh
export CFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib"
```python
from viz import Client
from viz.account import Account
from viz.block import Block
from viz.instance import set_shared_blockchain_instance

viz = Client('wss://node.viz.cx/ws')
set_shared_blockchain_instance(viz)

protocol = "V"
account = Account('id', viz, protocol)
counter_inside_protocol = account["custom_sequence"]
last_used_in_block = account["custom_sequence_block_num"]
block = Block(last_used_in_block)
```

Any direct RPC call:

```python
viz.rpc.some_rpc_method()
```

## Installation
Expand All @@ -51,22 +94,31 @@ cd viz-python-lib/
poetry install
```

## Usage
## Development

Basic read query example:
### Dependencies

```python
from viz import Client
from pprint import pprint
#### Linux dependencies

node = 'wss://node.viz.cx/ws'
```sh
sudo apt-get install libffi-dev libssl-dev python-dev
```

viz = Client(node=node)
pprint(viz.info())
#### Windows dependencies

Install regular version of [OpenSSL](https://slproweb.com/products/Win32OpenSSL.html) (not Light) suitable for your core processor.

#### MacOS dependencies

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. This means that you will need to install and export some OpenSSL settings yourself, before you can install viz-python-lib:

```sh
brew install openssl
```

Direct RPC calls:
and then use the following commands:

```python
viz.rpc.some_rpc_method()
```sh
export CFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib"
```
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
Expand Down Expand Up @@ -58,7 +57,7 @@ def _get_project_meta():
# Used to write beautiful docstrings:
"sphinx.ext.napoleon",
# Used to include .md files:
"m2r",
"m2r2",
# Auto-generate API documentation
"autoapi.extension",
]
Expand Down
9 changes: 4 additions & 5 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# This file is used to setup env
# to generate documentation.

sphinx==2.4.4
sphinx-autoapi==1.3.0
recommonmark==0.6.0
m2r==0.2.1
tomlkit==0.5.8
sphinx>=4.0,<7.0
sphinx-autoapi>=1.8.0
m2r2>=0.3.2
tomlkit>=0.11.0
Loading