def updateAuth(account, permission, parent, controller): accounts = [{ 'weight': 1, 'permission': { 'actor': controller, 'permission': 'active' } }] if account in remcode_permission_accounts and permission == 'active': accounts.append({ "permission": { "actor": account, "permission": "rem.code" }, "weight": 1 }) run(remcli + 'push action rem updateauth' + jsonArg({ 'account': account, 'permission': permission, 'parent': parent, 'auth': { 'threshold': 1, 'keys': [], 'waits': [], 'accounts': accounts, } }) + '-p ' + account + '@' + permission)
def start_wallet(): run('rm -rf ' + os.path.abspath(wallet_dir)) run('mkdir -p ' + os.path.abspath(wallet_dir)) background(remvault + ' --unlock-timeout %d --http-server-address 127.0.0.1:6666 --wallet-dir %s'\ % (unlockTimeout, os.path.abspath(wallet_dir))) sleep(.4) run(remcli + 'wallet create --to-console')
def init_supply_to_rem_acc(): timestamp = datetime.today().strftime("%Y-%m-%dT%H:%M:%S") epoch = datetime.utcfromtimestamp(0) block_datetime_utc = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc).timestamp() epoch_datetime_utc = datetime.utcfromtimestamp(0).replace(tzinfo=timezone.utc).timestamp() seconds_since_epoch = str(int(block_datetime_utc - epoch_datetime_utc)) txid = '0x0000000000000000000000000000000000000000000000000000000000000000' return_address = '0x0000000000000000000000000000000000000000' chain_id = get_chain_id() return_chainid = 'eth' rampayer = 'rem' receiver = 'rem' digest_to_sign = f'{receiver}*{txid}*{chain_id}*{intToRemCurrency(initial_supply)}*\ {return_address}*{return_chainid}*{seconds_since_epoch}'.encode() headers = { 'accept': "application/json", 'content-type': "application/json" } response = requests.post(sign_digest_url, headers=headers, data=json.dumps([hashlib.sha256(digest_to_sign).hexdigest(), swap_pubkey])) sig = response.json() run(remcli + f' push action rem.swap init \'["{rampayer}",\ "{txid}", "{swap_pubkey}",\ "{intToRemCurrency(initial_supply)}", "{return_address}", "{return_chainid}", "{timestamp}"]\'\ -p rem@active') run(remcli + f' push action rem.swap finish \'["{rampayer}", "{receiver}",\ "{txid}",\ "{swap_pubkey}", "{intToRemCurrency(initial_supply)}", "{return_address}", "{return_chainid}",\ "{timestamp}", "{sig}"]\'\ -p rem@active')
def start_node(nodeIndex, accounts): account = accounts[0] dir = nodes_dir + ('%02d-' % nodeIndex) + account['name'] + '/' run('rm -rf ' + dir) run('mkdir -p ' + dir) otherOpts = ''.join( list( map(lambda i: ' --p2p-peer-address localhost:' + str(9000 + i), range(nodeIndex)))) if not nodeIndex: otherOpts += (' --plugin eosio::history_plugin' ' --plugin eosio::history_api_plugin') swap_and_oracle_opts = (' --plugin eosio::eth_swap_plugin' ' --plugin eosio::rem_oracle_plugin') if cryptocompare_apikey: swap_and_oracle_opts += (' --cryptocompare-apikey ' + cryptocompare_apikey) if eth_https_provider: swap_and_oracle_opts += (' --eth-https-provider ' + eth_https_provider) cmd = (remnode + ' --max-irreversible-block-age -1' ' --contracts-console' ' --genesis-json ' + os.path.abspath(genesis) + ' --blocks-dir ' + os.path.abspath(dir) + '/blocks' ' --config-dir ' + os.path.abspath(dir) + ' --data-dir ' + os.path.abspath(dir) + ' --chain-state-db-size-mb 1024' ' --max-transaction-time 200' ' --http-server-address 127.0.0.1:' + str(8888 + nodeIndex) + ' --p2p-listen-endpoint 127.0.0.1:' + str(9000 + nodeIndex) + ' --max-clients ' + str(maxClients) + ' --p2p-max-nodes-per-host ' + str(maxClients) + ' --enable-stale-production' ' --access-control-allow-origin=\'*\'' ' --plugin eosio::http_plugin' ' --plugin eosio::chain_api_plugin' ' --plugin eosio::producer_api_plugin' ' --plugin eosio::producer_plugin') for account in accounts: swap_and_oracle_opts += (' --oracle-authority ' + account['name'] + '@active' + ' --oracle-signing-key ' + account['pvt'] + ' --swap-signing-key ' + account['pvt'] + ' --swap-authority ' + account['name'] + '@active') cmd += (' --producer-name ' + account['name'] + ' --private-key \'["' + account['pub'] + '","' + account['pvt'] + '"]\'') cmd += (swap_and_oracle_opts + otherOpts) with open(dir + 'stderr', mode='w') as f: f.write(cmd + '\n\n') background(cmd + ' 2>>' + dir + 'stderr') sleep(2) run(f'curl -X POST http://127.0.0.1:{8888+nodeIndex}/v1/producer/schedule_protocol_feature_activations -d \'{{"protocol_features_to_activate": ["0ec7e080177b2c02b278d5088611686b49d739925a92d9bfcacd7fc6b74053bd"]}}\'' )
def resign(account, controller): updateAuth(account, 'owner', '', controller) updateAuth(account, 'active', 'owner', controller) sleep(1) run(remcli + 'get account ' + account)
def vote_producers(): for prod in producers['producers']: run(remcli + f' system voteproducer prods {prod["name"]} {prod["name"]} \ -p {prod["name"]}@active')
def reg_producers(): for prod in producers['producers']: run(remcli + f' system regproducer {prod["name"]} {prod["pub"]} "" \ -p {prod["name"]}@active')
def stake_tokens(): run(remcli + f' system delegatebw swapbot swapbot \ "{intToRemCurrency(swapbot_stake)}" -p swapbot@active')
def transfer_tokens_to_accounts(): for account_name, public_key, stake, liquid in tech_accounts: run(remcli + f' transfer rem {account_name} "{intToRemCurrency(liquid)}" ""') run(remcli + f' transfer rem swapbot "{intToRemCurrency(swapbot_stake)}" ""')
def import_producer_keys(): for prod in producers['producers']: run(remcli + 'wallet import --private-key ' + prod['pvt'])
def create_producer_accounts(): for prod in producers['producers']: run(remcli + f' system newaccount rem {prod["name"]} {prod["pub"]} {prod["pub"]} \ --stake "{intToRemCurrency(prod["funds"])}" --transfer -p rem@active')
def issue_supply_to_rem_acc(): run(remcli + f' push action rem.token issue \'["rem.swap",\ "{intToRemCurrency(initial_supply)}", "initial supply"]\' -p rem.swap -p rem ') run(remcli + f' push action rem.token transfer \'["rem.swap", "rem",\ "{intToRemCurrency(initial_supply)}", "initial supply"]\' -p rem.swap -p rem ')
def create_tech_accounts(): for account_name, public_key, stake, liquid in tech_accounts: run(remcli + f' system newaccount rem {account_name} {public_key} {public_key} \ --stake "{intToRemCurrency(stake)}" --transfer -p rem@active')
def import_private_keys(): run(remcli + 'wallet import --private-key ' + private_key)
def kill_all(): run('killall remvault remnode || true') sleep(1.5)