コード例 #1
0
def create_new_sifaddr(credentials: SifchaincliCredentials, keyname):
    keyring_passphrase = credentials.keyring_passphrase
    yes_subcmd = f"yes {keyring_passphrase} |" if keyring_passphrase else ""
    keyring_backend_subcmd = f"--keyring-backend {credentials.keyring_backend}" if credentials.keyring_backend else ""
    # Note that keys-add prints to stderr
    cmd = f"{yes_subcmd} sifnodecli keys add {keyname} --home {credentials.sifnodecli_homedir} {keyring_backend_subcmd} -o json 2>&1"
    return get_shell_output_json(cmd)
コード例 #2
0
def swap_pool(transfer_request: EthereumToSifchainTransferRequest, sent_symbol,
              received_symbol, credentials: SifchaincliCredentials):
    logging.debug(f"swap_pool")
    yes_entry = f"yes {credentials.keyring_passphrase} | " if credentials.keyring_passphrase else ""
    keyring_backend_entry = f"--keyring-backend {credentials.keyring_backend}" if credentials.keyring_backend else ""
    chain_id_entry = f"--chain-id {transfer_request.chain_id}" if transfer_request.chain_id else ""
    node = f"--node {transfer_request.sifnodecli_node}" if transfer_request.sifnodecli_node else ""
    sifchain_fees_entry = f"--fees {transfer_request.sifchain_fees}" if transfer_request.sifchain_fees else ""
    cmd = " ".join([
        yes_entry, "sifnodecli tx clp swap",
        f"--from {transfer_request.sifchain_address}",
        f"--sentSymbol {sent_symbol}", f"--receivedSymbol {received_symbol}",
        f"--sentAmount {transfer_request.amount}",
        f"--minReceivingAmount {int(transfer_request.amount * 0.99)}",
        keyring_backend_entry, chain_id_entry, node, sifchain_fees_entry,
        f"--home {credentials.sifnodecli_homedir} ", "-y -o json"
    ])
    json_str = get_shell_output_json(cmd)
    assert (json_str.get("code", 0) == 0)
    txn = get_transaction_result(json_str["txhash"],
                                 transfer_request.sifnodecli_node,
                                 transfer_request.chain_id)
    tx = txn["tx"]
    logging.debug(f"resulting tx: {tx}")
    return txn
コード例 #3
0
def query_created_claim(claimType):
    cmd = " ".join([
        "sifnoded q dispensation claims-by-type", f"{claimType}",
        "--chain-id localnet", f"-o json"
    ])
    json_str = get_shell_output_json(cmd)
    return json_str
コード例 #4
0
def add_pool_liquidity(transfer_request: EthereumToSifchainTransferRequest,
                       credentials: SifchaincliCredentials):
    logging.debug(f"add_pool_liquidity")
    yes_entry = f"yes {credentials.keyring_passphrase} | " if credentials.keyring_passphrase else ""
    keyring_backend_entry = f"--keyring-backend {credentials.keyring_backend}" if credentials.keyring_backend else ""
    chain_id_entry = f"--chain-id {transfer_request.chain_id}" if transfer_request.chain_id else ""
    node = f"--node {transfer_request.sifnodecli_node}" if transfer_request.sifnodecli_node else ""
    sifchain_fees_entry = f"--fees {transfer_request.sifchain_fees}" if transfer_request.sifchain_fees else ""
    cmd = " ".join([
        yes_entry, "sifnodecli tx clp add-liquidity",
        f"--from {transfer_request.sifchain_address}",
        f"--symbol {transfer_request.sifchain_symbol}",
        f"--nativeAmount {transfer_request.amount}",
        f"--externalAmount {transfer_request.amount}", keyring_backend_entry,
        chain_id_entry, node, sifchain_fees_entry,
        f"--home {credentials.sifnodecli_homedir} ", "-y -o json"
    ])
    json_str = get_shell_output_json(cmd)
    assert (json_str.get("code", 0) == 0)
    txn = get_transaction_result(json_str["txhash"],
                                 transfer_request.sifnodecli_node,
                                 transfer_request.chain_id)
    tx = txn["tx"]
    logging.debug(f"resulting tx: {tx}")
    return txn
コード例 #5
0
def create_new_sifaddr(credentials: SifchaincliCredentials, keyname):
    """returns something like {"name":"9cbf3bd4-f15c-4128-bae6-a534fc8d6877","type":"local","address":"sif19u4xtckuvy2zk9r2l4063g93s3r8qc4vw0a20t","pubkey":"sifpub1addwnpepqw88ns6dmy3xwjqh4mkvuda6ezn056nxy8ldrtpkrfuvuamexv9hxyzhxm7","mnemonic":"surprise fire cupboard orange scatter boat cruel ability oven gap accident purity delay"}"""
    keyring_passphrase = credentials.keyring_passphrase
    yes_subcmd = f"yes {keyring_passphrase} |" if keyring_passphrase else ""
    keyring_backend_subcmd = f"--keyring-backend {credentials.keyring_backend}" if credentials.keyring_backend else ""
    # Note that keys-add prints to stderr
    cmd = f"{yes_subcmd} {sifnoded_binary} keys add {keyname} --home {credentials.sifnoded_homedir} {keyring_backend_subcmd} --output json 2>&1"
    return get_shell_output_json(cmd)
コード例 #6
0
def broadcast_async_txn(file_path):
    cmd = " ".join([
        "sifnoded tx broadcast", f"{file_path}", f"--broadcast-mode async",
        f"--yes"
    ])
    json_str = get_shell_output_json(cmd)
    txn = json_str["txhash"]
    return txn
コード例 #7
0
def sign_txn(signingaddress, file):
    keyring_backend_entry = f"--keyring-backend test"
    cmd = " ".join([
        "sifnoded tx sign", f"--from {signingaddress}", f"{file}",
        keyring_backend_entry, "--chain-id localnet", f"--yes"
    ])
    json_str = get_shell_output_json(cmd)
    return json_str
コード例 #8
0
def get_pools(sifnodecli_node):
    node = f"--node {sifnodecli_node}" if sifnodecli_node else ""
    command_line = f"sifnodecli q clp pools {node} -o json"
    # returns error when empty
    try:
        json_str = get_shell_output_json(command_line)
        return json_str
    except Exception as e:
        logging.debug(f"get_pools is empty.")
コード例 #9
0
def balance_check(address, currency):
    logging.debug(f"check_balance")
    cmd = " ".join([
        "sifnoded query bank balances", f"{address}", f"--denom {currency}",
        f"-o json"
    ])
    json_str = get_shell_output_json(cmd)
    balance = json_str['amount']
    return balance
コード例 #10
0
def send_sample_rowan(from_address, to_address, amount, keyring_backend,
                      chain_id, offline):
    logging.debug(f"transfer_rowan")
    sifchain_fees_entry = f"--fees 150000rowan"
    keyring_backend_entry = f"--keyring-backend {keyring_backend}"
    cmd = " ".join([
        "sifnoded tx bank send", f"{from_address}", f"{to_address}",
        f"{amount}", keyring_backend_entry, sifchain_fees_entry,
        f"--chain-id {chain_id}", f"--yes"
    ])
    json_str = get_shell_output_json(cmd)
    assert (json_str.get("code", 0) == 0)
    return json_str
コード例 #11
0
def create_claim(sifchain_address, claimType, keyring_backend, chain_id):
    logging.debug(f"create_claim")
    keyring_backend_entry = f"--keyring-backend {keyring_backend}"
    sifchain_gas_entry = f"--gas auto --gas-adjustment=1.5"
    sifchain_fees_entry = f"--fees 100000rowan"
    cmd = " ".join([
        "sifnoded tx dispensation claim", f"{claimType}",
        f"--from {sifchain_address}", sifchain_fees_entry, sifchain_gas_entry,
        f"--chain-id {chain_id}", keyring_backend_entry, f"--yes -o json"
    ])
    json_str = get_shell_output_json(cmd)
    assert (json_str.get("code", 0) == 0)
    txn = json_str["txhash"]
    return txn
コード例 #12
0
def create_online_singlekey_txn(claimType, signing_address, chain_id):
    logging.debug(f"create_online_dispensation")
    sifchain_gas_entry = f"--gas auto"
    sifchain_fees_entry = f"--fees 50000rowan"
    keyring_backend_entry = f"--keyring-backend test"
    output = 'output.json'
    cmd = " ".join([
        "sifnoded tx dispensation create", f"{claimType}", output,
        sifchain_gas_entry, sifchain_fees_entry, f"--from {signing_address}",
        f"--chain-id {chain_id}", keyring_backend_entry, f"--yes -o json"
    ])
    json_str = get_shell_output_json(cmd)
    assert (json_str.get("code", 0) == 0)
    txn = json_str["txhash"]
    return txn
コード例 #13
0
def run_dispensation(distribution_name, claimType, runner_address, chain_id):
    logging.debug(f"RUN DISPENSATION CLI LOGGING")
    sifchain_gas_entry = f"--gas auto --gas-adjustment=1.5"
    sifchain_fees_entry = f"--fees 200000rowan"
    keyring_backend_entry = f"--keyring-backend test"
    cmd = " ".join([
        "sifnoded tx dispensation run", distribution_name, f"{claimType}",
        f"--from {runner_address}", f"--chain-id {chain_id}",
        sifchain_gas_entry, sifchain_fees_entry, keyring_backend_entry,
        f"--yes -o json"
    ])
    json_str = get_shell_output_json(cmd)
    assert (json_str.get("code", 0) == 0)
    txn = json_str["txhash"]
    return txn
コード例 #14
0
def create_offline_singlekey_txn_with_runner(claimType, runner_address,
                                             distributor_address, chain_id):
    logging.debug(f"create_unsigned_offline_dispensation_txn")
    sifchain_fees_entry = f"--fees 150000rowan"
    sifchain_gas_entry = f"--gas auto --gas-adjustment=1.5"
    keyring_backend_entry = f"--keyring-backend test"
    output = 'output.json'
    cmd = " ".join([
        "sifnoded tx dispensation create", f"{claimType}", output,
        runner_address, f"--from {distributor_address}",
        f"--chain-id {chain_id}", sifchain_fees_entry, sifchain_gas_entry,
        keyring_backend_entry, f"--generate-only", f"--yes -o json"
    ])
    json_str = get_shell_output_json(cmd)
    assert (json_str.get("code", 0) == 0)
    return json_str
コード例 #15
0
def get_faucet_balance(sifnodecli_node):
    node = f"--node {sifnodecli_node}" if sifnodecli_node else ""
    command_line = f"sifnodecli q faucet balance {node} -o json"
    result = get_shell_output_json(command_line)
    return result
コード例 #16
0
def query_block_claim(txn_hash):
    cmd = " ".join(
        ["sifnoded query tx", f"{txn_hash}", "--chain-id localnet", "-o json"])
    json_str = get_shell_output_json(cmd)
    return json_str