def claim_genesis(): cleos = eospy.cleos.Cleos(url=URI) arguments = {"claimer": BP_ACCOUNT} payload = { "account": "eosio", "name": "claimgenesis", "authorization": [{ "actor": BP_ACCOUNT, "permission": PERMISSION, }], } data = cleos.abi_json_to_bin(payload['account'], payload['name'], arguments) payload['data'] = data['binargs'] trx = {"actions": [payload]} trx['expiration'] = str( (dt.datetime.utcnow() + dt.timedelta(seconds=60)).replace(tzinfo=pytz.UTC)) try: resp = cleos.push_transaction(trx, KEY, broadcast=True) logger.info(resp) except Exception as e: logger.error(e)
def main(): try: telos_genesis = pandas.read_csv( SNAPSHOT_FILE, dtype=str, names=['eth_address', 'eos_account', 'eos_key', 'balance']) except Exception as e: logger.critical('Error loading snapshot at {}: {}'.format( SNAPSHOT_FILE, e)) exit(1) logging.info('Creating accounts') created_accounts = 0 num_accounts = len(telos_genesis.index) #Set chain params to max performance logger.info('Setting chain params to max performance') global_params = get_chain_params() max_block_cpu_usage = global_params['max_block_cpu_usage'] max_transaction_cpu_usage = global_params['max_transaction_cpu_usage'] global_params['max_block_cpu_usage'] = 100000000 global_params['max_transaction_cpu_usage'] = 99999899 try: set_chain_params(global_params) except Exception as e: logger.critical('Error setting chain params: {}'.format(e)) quit() #Create accounts for i in chunker(telos_genesis, BATCH_SIZE): actions = [] for _, row in i.iterrows(): actions.extend( get_account_creation_actions(row['eos_account'], row['balance'], row['eos_key'])) #print(actions) trx = {"actions": actions} try: resp = cleos.push_transaction(trx, KEY, broadcast=True) except Exception as e: logger.critical('Error creating accounts: {}'.format(e)) quit() #logger.info(resp) created_accounts += BATCH_SIZE logger.info('Created {} accounts of {}'.format(created_accounts, num_accounts)) #Setting back chain params to original values logger.info('Setting back chain params to original values') global_params['max_block_cpu_usage'] = max_block_cpu_usage global_params['max_transaction_cpu_usage'] = max_transaction_cpu_usage try: set_chain_params(global_params) except Exception as e: logger.critical('Error setting back chain params: {}'.format(e)) quit() logger.info('Injection finished')
def set_chain_params(params): set_params_payload = {'params': params} set_params_data = cleos.abi_json_to_bin('eosio', 'setparams', set_params_payload) set_params_action = { 'account': 'eosio', 'name': 'setparams', 'authorization': [{ 'actor': 'eosio', 'permission': 'active' }], 'data': set_params_data['binargs'] } trx = {"actions": [set_params_action]} return cleos.push_transaction(trx, KEY, broadcast=True)
def push_tick(tick, key): data = cleos.abi_json_to_bin('delphioracle', 'write', { "owner": OWNER, "value": tick }) trx = { "actions": [{ "account": "delphioracle", "name": "write", "authorization": [{ "actor": OWNER, "permission": "oracle" }], "data": data['binargs'] }] } return cleos.push_transaction(trx, key, broadcast=True)
def push_quotes(quotes, key): data = cleos.abi_json_to_bin('delphioracle', 'write', { "quotes": quotes, "owner": OWNER }) trx = { "actions": [{ "account": "delphioracle", "name": "write", "authorization": [{ "actor": OWNER, "permission": "delphi" }], "data": data['binargs'] }] } trx['expiration'] = str( (dt.datetime.utcnow() + dt.timedelta(seconds=60)).replace(tzinfo=pytz.UTC)) return cleos.push_transaction(trx, key, broadcast=True)