Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
docs: docstring update
Browse files Browse the repository at this point in the history
  • Loading branch information
Moustikitos committed Jul 2, 2022
1 parent 90ff1af commit a1d6928
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 50 deletions.
26 changes: 6 additions & 20 deletions docs/ark/builders/v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ Build a delegate registration transaction.
def upVote(*usernames)
```

Build an upvote transaction.
Build an upvote transaction. Multiple usernames are allowed but not
necessary supported by targeted dpos blockchain.

**Arguments**:

Expand All @@ -116,7 +117,8 @@ Build an upvote transaction.
def downVote(*usernames)
```

Build a downvote transaction.
Build a downvote transaction. Multiple usernames are allowed but not
necessary supported by targeted dpos blockchain.

**Arguments**:

Expand Down Expand Up @@ -184,8 +186,9 @@ vendorField using unicode formating.

**Arguments**:

- `pairs` _iterable_ - recipient-amount pair iterable.
- `vendorField` _str_ - vendor field message.
- `*pairs` _iterable_ - recipient-amount pair iterable.
- `**kwargs` - arbitrary transaction field values.


**Returns**:
Expand Down Expand Up @@ -381,20 +384,3 @@ former delegate if any and then apply new vote.

- `dposlib.ark.tx.Transaction` - orphan transaction.

<a id="dposlib.ark.builders.v2.burn"></a>

#### burn

```python
def burn(amount, vendorField=None)
```

Build a burn transaction.
```
Args:
amount (float): transaction amount as human value.
Returns:
dposlib.ark.tx.Transaction: orphan transaction.
62 changes: 40 additions & 22 deletions docs/ark/builders/v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,43 @@
#### upVote

```python
def upVote(*usernames)
def upVote(*usernames, **weights)
```

Build an upvote transaction.

**Arguments**:

- `usernames` _iterable_ - delegate usernames as str iterable.
- `*usernames` _iterable_ - delegate usernames as str iterable.
- `**weights` _mapping_ - username with ponderation. Vote weight will be
computed in percent.


**Returns**:

- `dposlib.ark.tx.Transaction` - orphan transaction.


**Raises**:

<a id="dposlib.ark.builders.v3.downVote"></a>
- `AssertionError` - usernames and weights should not be mixed.

```python
>>> dposlib.core.upVote("alpha", "bravo", "charlie").asset
... {'votes': OrderedDict([('bravo', 33.34), ('alpha', 33.33), ('charlie', 33.33)])}
>>> dposlib.core.upVote(alpha=2, bravo=1, charlie=3).asset
... {'votes': OrderedDict([('charlie', 50.0), ('alpha', 33.33), ('bravo', 16.67)])}
```

#### downVote
<a id="dposlib.ark.builders.v3.legacyVote"></a>

#### legacyVote

```python
def downVote(*usernames)
def legacyVote(*usernames)
```

Build a downvote transaction.
Build an upvote transaction.

**Arguments**:

Expand All @@ -40,25 +54,27 @@ Build a downvote transaction.

- `dposlib.ark.tx.Transaction` - orphan transaction.

<a id="dposlib.ark.builders.v3.switchVote"></a>
<a id="dposlib.ark.builders.v3.transfer"></a>

#### switchVote
#### transfer

```python
def switchVote(tx, identifier=None)
def transfer(*pairs, **kwargs)
```

Transform a [`dposlib.ark.builders.v3.upVote`](
v3.md#dposlib.ark.builders.upVote
) transaction into a switchVote. It makes the transaction downvote
former delegate if any and then apply new vote.
Build transfer transaction. Emoji can be included in transaction
vendorField using unicode formating.


```python
>>> u"message with sparkles \u2728"
```

**Arguments**:

- `tx` _dposlib.ark.tx.Transaction_ - upVote transaction.
- `identifier` _dposlib.ark.tx.Transaction_ - any identifier accepted by
/api/wallets API endpoint. it could be a username, a wallet address
or a publicKey.
- `vendorField` _str_ - vendor field message.
- `*pairs` _iterable_ - recipient-amount pair iterable.
- `**kwargs` - arbitrary transaction field values.


**Returns**:
Expand Down Expand Up @@ -150,11 +166,13 @@ def burn(amount, vendorField=None)
```

Build a burn transaction.
```

Args:
amount (float): transaction amount as human value.
**Arguments**:

- `amount` _float_ - transaction amount as human value.


Returns:
dposlib.ark.tx.Transaction: orphan transaction.
**Returns**:

- `dposlib.ark.tx.Transaction` - orphan transaction.

3 changes: 2 additions & 1 deletion dposlib/ark/builders/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ def multiPayment(*pairs, **kwargs):
```
Args:
pairs (iterable): recipient-amount pair iterable.
vendorField (str): vendor field message.
*pairs (iterable): recipient-amount pair iterable.
**kwargs: arbitrary transaction field values.
Returns:
dposlib.ark.tx.Transaction: orphan transaction.
Expand Down
18 changes: 11 additions & 7 deletions dposlib/ark/builders/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ def upVote(*usernames, **weights):
dposlib.ark.tx.Transaction: orphan transaction.
Raises:
AssertionError: if usernames and weights are mixed.
AssertionError: usernames and weights should not be mixed.
Exemples:
>>> dposlib.core.upVote("alpha", "bravo", "charlie").asset
... {'votes': OrderedDict([('bravo', 33.34), ('alpha', 33.33), ('charlie', 33.33)])}
>>> dposlib.core.upVote(alpha=2, bravo=1, charlie=3).asset
... {'votes': OrderedDict([('charlie', 50.0), ('alpha', 33.33), ('bravo', 16.67)])}
```python
>>> dposlib.core.upVote("alpha", "bravo", "charlie").asset
... {'votes': OrderedDict([('bravo', 33.34), ('alpha', 33.33), ('charlie', 33.33)])}
>>> dposlib.core.upVote(alpha=2, bravo=1, charlie=3).asset
... {'votes': OrderedDict([('charlie', 50.0), ('alpha', 33.33), ('bravo', 16.67)])}
```
"""
assert xor(len(usernames), len(weights)), \
"give username list or a vote weight mapping"
Expand Down Expand Up @@ -91,8 +92,10 @@ def upVote(*usernames, **weights):
def legacyVote(*usernames):
"""
Build an upvote transaction.
Args:
usernames (iterable): delegate usernames as str iterable.
Returns:
dposlib.ark.tx.Transaction: orphan transaction.
"""
Expand Down Expand Up @@ -127,8 +130,9 @@ def transfer(*pairs, **kwargs):
```
Args:
pairs (iterable): recipient-amount pair iterable.
vendorField (str): vendor field message.
*pairs (iterable): recipient-amount pair iterable.
**kwargs: arbitrary transaction field values.
Returns:
dposlib.ark.tx.Transaction: orphan transaction.
Expand Down

0 comments on commit a1d6928

Please sign in to comment.