forked from harmony-community-node/harmony_one_tip_bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hmyclient.py
32 lines (24 loc) · 1.25 KB
/
hmyclient.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from pyhmy import account, cli
class HmyClient:
_hmyBinaryDir = '/home/satish/hmydir/hmy'
_networkUrl = 'https://api.s0.b.hmny.io' #'https://api.s0.t.hmny.io'
_oneAmountDenominator = 1000000000000000000
@classmethod
def regiterNewUser(self, telegram_user_id):
cli.set_binary(HmyClient._hmyBinaryDir)
return cli.single_call(f'hmy keys add {telegram_user_id}')
@classmethod
def transfer(self, from_address, to_address, amount, from_shard=0, to_shard=0):
cli.set_binary(HmyClient._hmyBinaryDir)
return cli.single_call(f'hmy transfer --node={HmyClient._networkUrl} --from {from_address} --to {to_address} --from-shard {from_shard} --to-shard {to_shard} --amount {amount}')
@classmethod
def getBalace(self, one_address):
return account.get_balance(one_address, endpoint=HmyClient._networkUrl) / HmyClient._oneAmountDenominator
@classmethod
def validateONEAdress(self, one_address):
return account.is_valid_address(one_address)
@classmethod
def getTransactionHistory(self, one_address):
transactions = account.get_transaction_history(one_address, endpoint=HmyClient._networkUrl, include_full_tx=True)
print(transactions)
return transactions