Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Commit 040a107

Browse files
author
Ron Serruya
authored
Merge pull request #58 from kinecosystem/fix_docs
Fix docstrings
2 parents 711f0f6 + d6c4aa6 commit 040a107

10 files changed

+65
-59
lines changed

kin/account.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def get_balance(self):
7070
:return: the kin balance
7171
:rtype: float
7272
73-
:raises: :class:`KinErrors.AccountNotFoundError`: if the account does not exist.
73+
:raises: KinErrors.AccountNotFoundError if the account does not exist.
7474
"""
7575
return self._client.get_account_balance(self.keypair.public_address)
7676

@@ -79,16 +79,17 @@ def get_data(self):
7979
Gets this KinAccount's data
8080
8181
:return: account data
82-
:rtype: :class:`kin.AccountData`
82+
:rtype: kin.blockchain.horizon_models.AccountData
8383
84-
:raises: :class:`KinErrors.AccountNotFoundError`: if the account does not exist.
84+
:raises: KinErrors.AccountNotFoundError if the account does not exist.
8585
"""
8686
return self._client.get_account_data(self.keypair.public_address)
8787

8888
def get_status(self, verbose=False):
8989
"""
9090
Get the config and status of this KinAccount object
9191
:param bool verbose: Should the channels status be verbose
92+
:return: The config and status of this KinAccount object
9293
:rtype dict
9394
"""
9495
account_status = {
@@ -125,7 +126,7 @@ def get_transaction_builder(self, fee):
125126
"""
126127
Get a transaction builder using this account
127128
:param int fee: The fee that will be used for the transaction
128-
:return: Kin.Builder
129+
:return: kin.Builder
129130
"""
130131
return Builder(self._client.environment.name, self.horizon, fee, self.keypair.secret_seed)
131132

@@ -144,8 +145,8 @@ def create_account(self, address, starting_balance, fee, memo_text=None):
144145
:rtype: str
145146
146147
:raises: KinErrors.StellarAddressInvalidError: if the provided address has a wrong format.
147-
:raises: :class:`KinErrors.AccountExistsError`: if the account already exists.
148-
:raises: :class:`KinErrors.NotValidParamError`: if the memo is longer than MEMO_CAP characters
148+
:raises: KinErrors.AccountExistsError if the account already exists.
149+
:raises: KinErrors.NotValidParamError if the memo is longer than MEMO_CAP characters
149150
:raises: KinErrors.NotValidParamError: if the amount is too precise
150151
:raises: KinErrors.NotValidParamError: if the fee is not valid
151152
"""
@@ -176,9 +177,9 @@ def send_kin(self, address, amount, fee, memo_text=None):
176177
:raises: KinErrors.StellarAddressInvalidError: if the provided address has a wrong format.
177178
:raises: ValueError: if the amount is not positive.
178179
:raises: KinErrors.NotValidParamError: if the amount is too precise
179-
:raises: :class:`KinErrors.AccountNotFoundError`: if the account does not exist.
180-
:raises: :class:`KinErrors.LowBalanceError`: if there is not enough KIN to send and pay transaction fee.
181-
:raises: :class:`KinErrors.NotValidParamError`: if the memo is longer than MEMO_CAP characters
180+
:raises: KinErrors.AccountNotFoundError if the account does not exist.
181+
:raises: KinErrors.LowBalanceError if there is not enough KIN to send and pay transaction fee.
182+
:raises: KinErrors.NotValidParamError if the memo is longer than MEMO_CAP characters
182183
:raises: KinErrors.NotValidParamError: if the fee is not valid
183184
"""
184185
builder = self.build_send_kin(address, amount, fee, memo_text)
@@ -202,7 +203,7 @@ def build_create_account(self, address, starting_balance, fee, memo_text=None):
202203
:param int fee: fee to be deducted for the tx
203204
204205
:return: a transaction builder object
205-
:rtype: :class: `Kin.Builder`
206+
:rtype: kin.Builder
206207
207208
:raises: KinErrors.StellarAddressInvalidError: if the supplied address has a wrong format.
208209
"""
@@ -230,7 +231,7 @@ def build_send_kin(self, address, amount, fee, memo_text=None):
230231
:param int fee: fee to be deducted for the tx
231232
232233
:return: a transaction builder
233-
:rtype: Kin.Builder
234+
:rtype: kin.Builder
234235
235236
:raises: KinErrors.StellarAddressInvalidError: if the provided address has a wrong format.
236237
:raises: ValueError: if the amount is not positive.
@@ -277,10 +278,10 @@ def monitor_payments(self, callback_fn):
277278
NOTE: the function starts a background thread.
278279
279280
:param callback_fn: the function to call on each received payment as `callback_fn(address, tx_data, monitor)`.
280-
:type: callable[str,:class:`kin.TransactionData`,:class:`kin.SingleMonitor`]
281+
:type: callable[str,kin.transactions.SimplifiedTransaction,kin.monitors.SingleMonitor]
281282
282283
:return: a monitor instance
283-
:rtype: :class:`kin.SingleMonitor`
284+
:rtype: kin.monitors.SingleMonitor
284285
"""
285286
return self._client.monitor_account_payments(self.keypair.public_address, callback_fn)
286287

kin/blockchain/builder.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, network_name, horizon, fee, secret):
1616
"""
1717
Create a new transaction builder
1818
:param str network_name: The name of the network
19-
:param Kin.Horizon horizon: The horizon instance to use
19+
:param kin.Horizon horizon: The horizon instance to use
2020
:param int fee: Fee for the transaction
2121
:param str secret: The seed to be used
2222
"""
@@ -60,7 +60,7 @@ def next(self):
6060
def set_channel(self, channel_seed):
6161
"""
6262
Set a channel to be used for this transaction
63-
:param channel_seed: Seed to use as the channel
63+
:param str channel_seed: Seed to use as the channel
6464
"""
6565
self.keypair = Keypair.from_seed(channel_seed)
6666
self.address = self.keypair.address().decode()

kin/blockchain/channel_manager.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def get_status(self, verbose=False):
6464
"""
6565
Return the current status of the channel manager
6666
:param bool verbose: Include all channel seeds and their statuses in the response
67-
:return: dict
67+
:return: The status of the channel manager
68+
:rtype dict
6869
"""
6970
free_channels = len(self.channel_pool.get_free_channels())
7071
status = {

kin/blockchain/environment.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ def __init__(self, name, horizon_endpoint_uri, network_passphrase, friendbot_url
1919
:param str network_passphrase: The passphrase/network_id of the environment.
2020
:param str friendbot_url: a url to a friendbot service
2121
:return: An instance of the Environment class.
22-
:rtype: :class: `kin.Environment`
23-
24-
:raises: ValueError: is the kin_issuer is invalid
22+
:rtype: kin.Environment
2523
"""
2624
# Add the network to the kin_base network list.
2725
NETWORKS[name.upper()] = network_passphrase

kin/blockchain/errors.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class ChannelsFullError(Exception):
1212

1313

1414
HORIZON_NS_PREFIX = 'https://stellar.org/horizon-errors/'
15-
16-
'''
15+
"""
1716
Horizon error example:
1817
1918
{
@@ -37,7 +36,8 @@ class ChannelsFullError(Exception):
3736
},
3837
'type': 'https://stellar.org/horizon-errors/transaction_failed'
3938
}
40-
'''
39+
40+
"""
4141

4242

4343
class HorizonError(HTTPProblemDetails, Exception):

kin/blockchain/keypair.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Keypair:
1515
def __init__(self, seed=None):
1616
"""
1717
# Create an instance of Keypair.
18-
:param seed: (Optional) The secret seed of an account
18+
:param str seed: (Optional) The secret seed of an account
1919
"""
2020
self.secret_seed = seed or self.generate_seed()
2121
if not is_valid_secret_key(self.secret_seed):
@@ -29,10 +29,10 @@ def __init__(self, seed=None):
2929

3030
def sign(self, data):
3131
"""
32-
Sign any data using the keypair private key
32+
Sign any data using the keypair's private key
3333
:param bytes data: any data to sign
3434
:return: a decorated signature
35-
:rtype :class: DecoratedSignature
35+
:rtype kin_base.stellarxdr.StellarXDR_type.DecoratedSignature
3636
"""
3737
signature = self._signing_key.sign(data)
3838
return DecoratedSignature(self._hint, signature)
@@ -41,8 +41,9 @@ def sign(self, data):
4141
def address_from_seed(seed):
4242
"""
4343
Get a public address from a secret seed.
44-
:param seed: The secret seed of an account.
44+
:param str seed: The secret seed of an account.
4545
:return: A public address.
46+
:rtype str
4647
"""
4748
return BaseKeypair.from_seed(seed).address().decode()
4849

@@ -51,16 +52,18 @@ def generate_seed():
5152
"""
5253
Generate a random secret seed.
5354
:return: A secret seed.
55+
:rtype str
5456
"""
5557
return BaseKeypair.random().seed().decode()
5658

5759
@staticmethod
5860
def generate_hd_seed(base_seed, salt):
5961
"""
6062
Generate a highly deterministic seed from a base seed + salt
61-
:param base_seed: The base seed to generate a seed from
62-
:param salt: A unique string that will be used to generate the seed
63+
:param str base_seed: The base seed to generate a seed from
64+
:param str salt: A unique string that will be used to generate the seed
6365
:return: a new seed.
66+
:rtype str
6467
"""
6568
# Create a new raw seed from this hash
6669
raw_seed = sha256((base_seed + salt).encode()).digest()

kin/client.py

+19-18
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ class KinClient(object):
2525

2626
def __init__(self, environment):
2727
"""Create a new instance of the KinClient to query the Kin blockchain.
28-
:param `kin.Environment` environment: an environment for the client to point to.
28+
:param kin.Environment environment: an environment for the client to point to.
2929
3030
:return: An instance of the KinClient.
31-
:rtype: :class:`KinErrors.KinClient`
31+
:rtype: KinErrors.KinClient
3232
"""
3333

3434
self.environment = environment
@@ -41,12 +41,12 @@ def kin_account(self, seed, channel_secret_keys=None, app_id=ANON_APP_ID):
4141
"""
4242
Create a new instance of a KinAccount to perform authenticated operations on the blockchain.
4343
:param str seed: The secret seed of the account that will be used
44-
:param list of str channel_secret_keys: A list of seeds to be used as channels
44+
:param list[str] channel_secret_keys: A list of seeds to be used as channels
4545
:param str app_id: the unique id of your app
4646
:return: An instance of KinAccount
4747
:rtype: kin.KinAccount
4848
49-
:raises: :class:`KinErrors.AccountNotFoundError`: if SDK wallet or channel account is not yet created.
49+
:raises: KinErrors.AccountNotFoundError if SDK wallet or channel account is not yet created.
5050
"""
5151

5252
# Create a new kin account, using self as the KinClient to be used
@@ -101,7 +101,7 @@ def get_account_balance(self, address):
101101
:rtype: float
102102
103103
:raises: StellarAddressInvalidError: if the provided address has the wrong format.
104-
:raises: :class:`KinErrors.AccountNotFoundError`: if the account does not exist.
104+
:raises: KinErrors.AccountNotFoundError if the account does not exist.
105105
"""
106106

107107
if not is_valid_address(address):
@@ -119,7 +119,7 @@ def does_account_exists(self, address):
119119
:return: does the account exists on the blockchain
120120
:rtype boolean
121121
122-
:raises: :class:`KinErrors.StellarAddressInvalidError`: if the address is not valid.
122+
:raises: KinErrors.StellarAddressInvalidError if the address is not valid.
123123
"""
124124

125125
if not is_valid_address(address):
@@ -137,7 +137,7 @@ def get_account_data(self, address):
137137
:param str address: the public address of the account to query.
138138
139139
:return: account data
140-
:rtype: :class:`kin.AccountData`
140+
:rtype: kin.blockchain.horizon_models.AccountData
141141
142142
:raises: StellarAddressInvalidError: if the provided address has a wrong format.
143143
:raises: :class:`KinErrors.AccountNotFoundError`: if the account does not exist.
@@ -161,7 +161,7 @@ def get_transaction_data(self, tx_hash, simple=True):
161161
:param boolean simple: (optional) returns a simplified transaction object
162162
163163
:return: transaction data
164-
:rtype: :class:`kin.TransactionData` or `kin.SimplifiedTransaction`
164+
:rtype: kin.transactions.RawTransaction | kin.transactions.SimplifiedTransaction
165165
166166
:raises: ValueError: if the provided hash is invalid.
167167
:raises: :class:`KinErrors.ResourceNotFoundError`: if the transaction does not exist.
@@ -189,7 +189,7 @@ def get_account_tx_history(self, address, amount=10, descending=True, cursor=Non
189189
:param int cursor: The horizon paging token
190190
:param bool simple: Should the returned txs be simplified, if True, complicated txs will be ignored
191191
:return: A list of transactions
192-
:rtype: list
192+
:rtype: list[kin.transactions.RawTransaction | kin.transactions.SimplifiedTransaction]
193193
"""
194194

195195
if not is_valid_address(address):
@@ -264,13 +264,14 @@ def friendbot(self, address):
264264
"""
265265
Use the friendbot service to create and fund an account
266266
:param str address: The address to create and fund
267-
:return: the hash of the friendobt transaction
267+
268+
:return: the hash of the friendbot transaction
268269
:rtype str
269270
270271
:raises ValueError: if no friendbot service was provided
271272
:raises ValueError: if the address is invalid
272-
:raises :class: `KinErrors.AccountExistsError`: if the account already exists
273-
:raises :class: `KinErrors.FriendbotError`: If the friendbot request failed
273+
:raises KinErrors.AccountExistsError if the account already exists
274+
:raises KinErrors.FriendbotError If the friendbot request failed
274275
"""
275276

276277
if self.environment.friendbot_url is None:
@@ -294,14 +295,14 @@ def monitor_account_payments(self, address, callback_fn):
294295
:param str address: the address of the account to query.
295296
296297
:param callback_fn: the function to call on each received payment as `callback_fn(address, tx_data, monitor)`.
297-
:type: callable[str,:class:`kin.TransactionData`,:class:`kin.SingleMonitor`]
298+
:type: callable[str,kin.transactions.SimplifiedTransaction, kin.SingleMonitor]
298299
299300
:return: a monitor instance
300-
:rtype: :class:`kin.SingleMonitor`
301+
:rtype: kin.monitors.SingleMonitor
301302
302303
:raises: ValueError: when no address is given.
303304
:raises: ValueError: if the address is in the wrong format
304-
:raises: :class:`KinErrors.AccountNotActivatedError`: if the account given is not activated
305+
:raises: KinErrors.AccountNotActivatedError if the account given is not activated
305306
"""
306307

307308
return SingleMonitor(self, address, callback_fn)
@@ -313,14 +314,14 @@ def monitor_accounts_payments(self, addresses, callback_fn):
313314
:param str addresses: the addresses of the accounts to query.
314315
315316
:param callback_fn: the function to call on each received payment as `callback_fn(address, tx_data, monitor)`.
316-
:type: callable[str,:class:`kin.TransactionData`,:class:`kin.MultiMonitor`]
317+
:type: callable[str,kin.transactions.SimplifiedTransaction ,kin.monitors.MultiMonitor]
317318
318319
:return: a monitor instance
319-
:rtype: :class:`kin.MultiMonitor`
320+
:rtype: kin.monitors.MultiMonitor
320321
321322
:raises: ValueError: when no address is given.
322323
:raises: ValueError: if the addresses are in the wrong format
323-
:raises: :class:`KinErrors.AccountNotActivatedError`: if the accounts given are not activated
324+
:raises: KinErrors.AccountNotActivatedError if the accounts given are not activated
324325
"""
325326

326327
return MultiMonitor(self, addresses, callback_fn)

kin/monitors.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ class SingleMonitor:
1616
def __init__(self, kin_client, address, callback_fn):
1717
"""
1818
Monitors a single account for kin payments
19-
:param kin_client: a kin client directed to the correct network
20-
:param address: address to watch
21-
:param callback_fn: function to callback when the payment is found
19+
:param kin.KinClient kin_client: a kin client directed to the correct network
20+
:param str address: address to watch
21+
:param callback_fn: the function to call on each received payment as `callback_fn(address, tx_data, monitor)`.
22+
:type: callable[str,kin.transactions.SimplifiedTransaction ,kin.monitors.MultiMonitor]
2223
"""
2324
self.kin_client = kin_client
2425
self.callback_fn = callback_fn
@@ -57,7 +58,7 @@ def __init__(self, kin_client, address, callback_fn):
5758
def event_processor(self, stop_event):
5859
"""
5960
Method to filter through SSE events and find kin payments for an account
60-
:param stop_event: an event that can be used to stop this method
61+
:param threading.Event stop_event: an event that can be used to stop this method
6162
"""
6263
import json
6364
try:
@@ -108,9 +109,10 @@ class MultiMonitor:
108109
def __init__(self, kin_client, addresses, callback_fn):
109110
"""
110111
Monitors multiple accounts for kin payments
111-
:param kin_client: a kin client directed to the correct network
112-
:param addresses: addresses to watch
113-
:param callback_fn: function to callback when the payment is found
112+
:param kin.KinClient kin_client: a kin client directed to the correct network
113+
:param str addresses: addresses to watch
114+
:param callback_fn: the function to call on each received payment as `callback_fn(address, tx_data, monitor)`.
115+
:type: callable[str,kin.transactions.SimplifiedTransaction ,kin.monitors.MultiMonitor]
114116
"""
115117
self.kin_client = kin_client
116118
self.callback_fn = callback_fn
@@ -148,7 +150,7 @@ def __init__(self, kin_client, addresses, callback_fn):
148150
def event_processor(self, stop_event):
149151
"""
150152
Method to filter through SSE events and find kin payments for an account
151-
:param stop_event: an event that can be used to stop this method
153+
:param threading.Event stop_event: an event that can be used to stop this method
152154
"""
153155
import json
154156
try:

0 commit comments

Comments
 (0)