Esempio n. 1
0
def eos_issue(transfer):
    quantity = f'{transfer.amount:.4f} {ISSUE_ASSET}'

    raw = RawinputParams(
        'transfer',
        {
            'from': ISSUER_NAME,
            'memo': '',  # TODO Какое мемо ставить?
            'quantity': quantity,
            'to': transfer.eos_name
        },
        'eosio.token',
        f'{ISSUER_NAME}@active')

    eosiop_arams = EosioParams(raw.params_actions_list, ISSUER_WIF)
    r = NodeNetwork.push_transaction(eosiop_arams.trx_json)

    if 'transaction_id' not in r:
        logging.error(f'Issuing eos tokens \n {r}')
        transfer.sys_message = r
    else:
        logger.info(f'Issued {quantity} for '
                    f'{transfer.eos_name} -> {r["transaction_id"]}')

        transfer.eos_hash = r['transaction_id']
        transfer.tokens_emitted = True
Esempio n. 2
0
 def is_valid(serial_number):
     raw = RawinputParams("isvalid", {
         "serial_number": int(serial_number),
     }, "warrantease", "{}@active".format('warrantease'))
     eosiop_arams = EosioParams(raw.eos_params, keys['warrantease'])
     net = NodeNetwork.push_transaction(eosiop_arams.trx_json)
     return True if net['processed']['action_traces'][0][
         'console'] == '1' else False
Esempio n. 3
0
 def create(cls, renter, tile, seed):
     raw = RawinputParams("rentcreate", {
         "_user": renter,
         "tile": int(tile),
         "seed": int(seed),
     }, "fadmin", "{}@active".format(renter))
     eosiop_arams = EosioParams(raw.params_actions_list, keys[renter])
     net = NodeNetwork.push_transaction(eosiop_arams.trx_json)
     print(net)
Esempio n. 4
0
 def get_seed(cls, id):
     raw = RawinputParams("seedget", {
         '_user': '******',
         'id': id,
     }, "fadmin", "{}@active".format('fadmin'))
     eosiop_arams = EosioParams(raw.params_actions_list, keys['fadmin'])
     net = NodeNetwork.push_transaction(eosiop_arams.trx_json)
     return Seed.deserialize(
         net['processed']['action_traces'][0]['console'])
Esempio n. 5
0
 def get_all_seeds(cls):
     raw = RawinputParams("seedgetall", {'_user': '******'}, "fadmin",
                          "{}@active".format('fadmin'))
     eosiop_arams = EosioParams(raw.params_actions_list, keys['fadmin'])
     net = NodeNetwork.push_transaction(eosiop_arams.trx_json)
     return [
         Seed.deserialize(_) for _ in net['processed']['action_traces'][0]
         ['console'].split('+++') if _
     ]
Esempio n. 6
0
 def list(account):
     raw = RawinputParams("list", {
         "account": account,
     }, "warrantease", "{}@active".format(account))
     eosiop_arams = EosioParams(raw.eos_params, keys[account])
     net = NodeNetwork.push_transaction(eosiop_arams.trx_json)
     text = net['processed']['action_traces'][0]['console']
     items = [Warranty.deserialize(_) for _ in text.split('+++') if _]
     return items
Esempio n. 7
0
 def invalidate(manufacturer, serial_number):
     raw = RawinputParams("invalidate", {
         "manufacturer": manufacturer,
         "serial_number": int(serial_number)
     }, "warrantease", "{}@active".format(manufacturer))
     eosiop_arams = EosioParams(raw.eos_params, keys[manufacturer])
     net = NodeNetwork.push_transaction(eosiop_arams.trx_json)
     return Warranty.deserialize(
         net['processed']['action_traces'][0]['console'])
Esempio n. 8
0
 def get_by_tile(cls, tile, fetch_tile=True):
     raw = RawinputParams("rentgettile", {
         "_user": U_ADMIN,
         "tile": int(tile)
     }, "fadmin", "{}@active".format(U_ADMIN))
     eosiop_arams = EosioParams(raw.params_actions_list, keys[U_ADMIN])
     net = NodeNetwork.push_transaction(eosiop_arams.trx_json)
     print(net)
     return Rent.deserialize(
         net['processed']['action_traces'][0]['console'], fetch_tile)
Esempio n. 9
0
    def get_by_username(cls, username):
        raw = RawinputParams("rentgetuser", {"_user": username}, "fadmin",
                             "{}@active".format(username))
        eosiop_arams = EosioParams(raw.params_actions_list, keys[username])
        net = NodeNetwork.push_transaction(eosiop_arams.trx_json)

        return [
            Rent.deserialize(_) for _ in net['processed']['action_traces'][0]
            ['console'].split('+++') if _
        ]
Esempio n. 10
0
 def change_nick(account, serial_number, nickname):
     raw = RawinputParams(
         "changenick", {
             "account": account,
             "serial_number": int(serial_number),
             "nickname": nickname
         }, "warrantease", "{}@active".format(account))
     eosiop_arams = EosioParams(raw.eos_params, keys[account])
     net = NodeNetwork.push_transaction(eosiop_arams.trx_json)
     return Warranty.deserialize(
         net['processed']['action_traces'][0]['console'])
Esempio n. 11
0
 def transfer(old_account, new_account, serial_number):
     raw = RawinputParams(
         "transfer", {
             "old_account": old_account,
             "new_account": new_account,
             "serial_number": int(serial_number)
         }, "warrantease", "{}@active".format(old_account))
     eosiop_arams = EosioParams(raw.eos_params, keys[old_account])
     net = NodeNetwork.push_transaction(eosiop_arams.trx_json)
     return Warranty.deserialize(
         net['processed']['action_traces'][0]['console'])
def eos_transfer(order):
    """
    serialize, sign, and broadcast an order dictionary with nine keys
    """
    # FIXME log this event
    timestamp()
    line_number()
    print("\nORDER\n\n", {k: v for k, v in order.items() if k != "private"}, "\n")
    nodes = eosio_nodes()
    while 1:
        nodes.append(nodes.pop(0))
        node = nodes[0]
        # configure the url and port
        eosio_config.url = node
        eosio_config.port = ""
        print("\nADDRESS\n\n", node, "\n")
        # assemble the transfer operation dictionary
        operation = {
            "from": order["public"],
            "memo": "",
            # eos must have 4 decimal places formatted as string with space and "EOS"
            "quantity": precisely(order["quantity"], 4) + " EOS",
            "to": order["to"],
        }
        print("\nOPERATION\n\n", operation, "\n")
        # serialize the transfer operation
        raw = RawinputParams(
            "transfer",  # the operation type
            operation,  # the parameters
            "eosio.token",  # the contract; for our purposes always "eosio.token"
            order["public"] + "@active",  # the permitted party (or @owner)
        )
        print("\nSERIALIZE\n\n", raw.params_actions_list, "\n")
        # sign the transfer operation
        params = EosioParams(raw.params_actions_list, order["private"])
        print("\nSIGN\n\n", params.trx_json, "\n")
        # broadcast the transfer to the network
        try:
            ret = NodeNetwork.push_transaction(params.trx_json)
            print("\nBROADCAST\n\n", ret)
            if "processed" not in ret.keys():
                raise ValueError("NOT PROCESSED")
            print(it("red", "EOS TRANSFERRED"))
            break
        except Exception as error:
            print(error)
            print(it("red", "BROADCAST FAILED"), node, "attempting new api...")
            continue
    return ret
    def send(self, account_from_name, account_to_name, amount, symbol) -> str:
        """
        Send transaction.
        """
        raw_input_params = RawinputParams(
            'transfer', {
                'from': account_from_name,
                'memo': 'Remme Protocol transaction.',
                'quantity': f'{amount}.0000 {symbol}',
                'to': account_to_name,
            }, 'eosio.token', f'{account_from_name}@active')

        eosio_params = EosioParams(raw_input_params.params_actions_list,
                                   MASTER_WALLET_PRIVATE_KEY)

        transaction = NodeNetwork.push_transaction(eosio_params.trx_json)
        return transaction.get('transaction_id')
Esempio n. 14
0
	def create_account(self, account_name, active_key, owner_key=None):

		validate_public_key(active_key)
		if owner_key is None:
			owner_key = active_key
		else:
			validate_public_key(owner_key)

		validate_account_name(account_name)
		if account_exists(account_name):
			raise Exception(f"Account {account_name} already exists in the network")
		
		raw = self.get_account_creation_raw_params(account_name, active_key, owner_key)
		eosio_params = EosioParams(raw.params_actions_list, self.private_key)
		net_response = NodeNetwork.push_transaction(eosio_params.trx_json)
		if "transaction_id" not in net_response:
			raise Exception("Account creation trasaction was not successful")
		return net_response["transaction_id"]
Esempio n. 15
0
 def statuses(self):
     print(self.id)
     raw = RawinputParams("rentgets", {
         "_user": U_ADMIN,
         "rent": int(self.id),
     }, "fadmin", "{}@active".format(U_ADMIN))
     eosiop_arams = EosioParams(raw.params_actions_list, keys[U_ADMIN])
     net = NodeNetwork.push_transaction(eosiop_arams.trx_json)
     _statuses = [
         _.split("|||") for _ in net['processed']['action_traces'][0]
         ['console'].split('+++') if _
     ]
     _statuses = [{
         'id': int(_[0]),
         'status': _[2],
         'timestamp': int(_[3])
     } for _ in _statuses]
     return _statuses
Esempio n. 16
0
 def create(account,
            manufacturer,
            serial_number,
            length_of_warranty,
            coverage='',
            region='',
            contact_details='',
            remarks=''):
     raw = RawinputParams(
         "create", {
             "username": account,
             "manufacturer": manufacturer,
             "serial_number": int(serial_number),
             "length_of_warranty": int(length_of_warranty),
             "coverage": coverage,
             "region": region,
             "contact_details": contact_details,
             "remarks": remarks
         }, "warrantease", "{}@active".format(manufacturer))
     eosiop_arams = EosioParams(raw.eos_params, keys[manufacturer])
     net = NodeNetwork.push_transaction(eosiop_arams.trx_json)
     return Warranty.deserialize(
         net['processed']['action_traces'][0]['console'])
Esempio n. 17
0
def account_exists(account_name):
    return 'account_name' in NodeNetwork.get_account(
        {'account_name': account_name})
Esempio n. 18
0
 def get_bin(self, json_data):
     return NodeNetwork.json_to_abi(json_data=json_data)["binargs"]
Esempio n. 19
0
 def get_bin(self, json_data):
     ret = NodeNetwork.json_to_abi(json_data=json_data)
     if 'binargs' not in ret:
         raise Exception(str(ret))
     return ret["binargs"]
Esempio n. 20
0
 def get_info_block(self):
     self.info_block = NodeNetwork.get_info_block()
Esempio n. 21
0
 def get_bin(self, json_data):
     bin_ = NodeNetwork.json_to_abi(json_data=json_data)
     return bin_['binargs']
Esempio n. 22
0
from pyeos_client.NodeosConnect import RequestHandlerAPI
from pyeos_client.EOSChainApi import ChainAPI
from eosiopy.eosioparams import EosioParams
from eosiopy.nodenetwork import NodeNetwork
from eosiopy.rawinputparams import RawinputParams
from eosiopy import eosio_config

eosio_config.url="http://mainnet.genereos.io"
eosio_config.port=80
#https://api.pennstation.eosnewyork.io:7101
#connection  = RequestHandlerAPI(base_url='http://mainnet.genereos.io', headers={"Accept": "application/json"})
#chainapi = ChainAPI(connection)
#print(chainapi.get_info().json())

FROM="walletfromid"
TO="wallettoid"
PRIVATE_KEY="5Kh .... "
raw = RawinputParams("transfer", {
"from": FROM,
"memo": "remember to visit eoswin to play game and win the jack pot with referral id FROM",
"quantity": "0.00001 EOS",
"to": TO
}, FROM, "FROM@active")

eosiop_arams=EosioParams(raw.params_actions_list,PRIVATE_KEY)

print(eosiop_arams)

net=NodeNetwork.push_transaction(eosiop_arams.trx_json)

print(net)