예제 #1
0
def searchWallet(request):    
    # print(request.body);
    if os.path.exists (BASE_DIR+"/keystore/"+request.session.session_key+'/'+request.session['keystore']):
        try:
            data = json.loads(request.body)
            j = json.loads(data)
            password = j['keystore_password']
            wallet = KeyWallet.load(BASE_DIR+"/keystore/"+request.session.session_key+'/'+request.session['keystore'],password);
            params = { "address" : wallet.get_address()}
            print("wallet addr >> "+ wallet.get_address())        
            return JsonResponse(params)
        except Exception as e:
            return JsonResponse({"status":"fail", "msg":str(e)})

    try:
        data = json.loads(request.body)    
        # print("json.loads(value) >> "+data)
        # print(type(data))  
        j = json.loads(data)
        # print("json.loads(json) >> "+j['private_key'])
        key = bytes.fromhex(j['private_key'])
        # print("bytes json['private_key'] >> ")
        # print(key)
        wallet = KeyWallet.load(key)
        params = { "address" : wallet.get_address()}
        print("wallet addr >> "+ wallet.get_address())        
        return JsonResponse(params)
    except Exception:
        return JsonResponse({"status":"fail"})
예제 #2
0
    def test_wallet_load_by_private_key(self):
        """A wallet loads by a private key correctly."""

        # Creates a wallet.
        private_key_object = PrivateKey()
        private_key = private_key_object.private_key
        wallet1 = KeyWallet.load(private_key)

        # Checks a private key as same.
        self.assertEqual(private_key.hex(), wallet1.get_private_key())

        # Checks a wallet's address is correct.
        self.assertTrue(is_wallet_address(wallet1.get_address()))

        # Creates the other wallet.
        private_key_object2 = PrivateKey()
        private_key2 = private_key_object2.private_key
        wallet2 = KeyWallet.load(private_key2)

        # Checks a private key as same.
        self.assertEqual(private_key2.hex(), wallet2.get_private_key())

        # Checks a wallet's address is correct.
        self.assertTrue(is_wallet_address(wallet2.get_address()))

        self.assertNotEqual(private_key2, private_key)
예제 #3
0
    def setUpClass(cls):
        cls._score_root_path = '.testscore'
        cls._state_db_root_path = '.teststatedb'

        cls._icx_factor = 10**18

        cls._genesis: 'KeyWallet' = KeyWallet.create()
        cls._fee_treasury: 'KeyWallet' = KeyWallet.create()
        cls._test1: 'KeyWallet' = KeyWallet.load(
            bytes.fromhex(TEST1_PRIVATE_KEY))
        cls._wallet_array = [KeyWallet.load(v) for v in TEST_ACCOUNTS]
예제 #4
0
    def __init__(self):
        self.handlers = [
            self._set_revision,
            self._update_governance_score,
            self._set_step_cost,
        ]
        self.revision = 0
        self.gs_version = "0.0.0"

        self.key_wallet = KeyWallet.load(bytes.fromhex(TEST1_PRIVATE_KEY))
        self.preps = []
        for prep in self.PREPS:
            self.preps.append(KeyWallet.load(prep))
        uri, version = uri_parser("http://127.0.0.1:9000/api/v3")
        self.icon_service = IconService(HTTPProvider(uri, version))
 def setUp(self):
     super().setUp()
     self.contracts = {}
     self.contracts['sicx1'] = "cx20fa65cffc720db31e78fba6db5d58f58babd933"
     self.contracts['staking1'] = "cx25c39ed0d27853e44af8ab2739d6af832f35d533"
     self.contracts['staking2'] = "cx8b250e76bc919f73068571c26cadecde69e63b46"
     self.contracts['staking3'] = "cx3502e9af253098d187578ca826fe71032f116e47"
     # WARNING: ICON service emulation is not working with IISS.
     # You can stake and delegate but can't get any I-Score for reward.
     # If you want to test IISS stuff correctly, set self.icon_service and send requests to the network
     self.icon_service = IconService(HTTPProvider(self.TEST_HTTP_ENDPOINT_URI_V3))
     private2="093f12dba9dc75da81ecafc88de73ef9b311b555939aeb5a875dc6ad8feef424"
     private3="167f6ec1694ab63243efdce98f6f6bfdcef0575cefbb86ffe3826f8373f12b85"
     self._test2 = KeyWallet.load(bytes.fromhex(private2))
     self._test3 = KeyWallet.load(bytes.fromhex(private3))
예제 #6
0
    def __gen_conf_file() -> list:
        result = []

        if os.path.exists(FN_CLI_CONF) is False:
            result.append(FN_CLI_CONF[2:])
            write_file('./', FN_CLI_CONF, json.dumps(tbears_cli_config, indent=4))

        if os.path.exists(FN_SERVER_CONF) is False:
            result.append(FN_SERVER_CONF[2:])
            server_config_json = make_server_config(tbears_server_config)
            write_file('./', FN_SERVER_CONF, json.dumps(server_config_json, indent=4))

        # mkdir keystore
        keystore_dir = "./keystore"
        if os.path.exists(keystore_dir) is False:
            os.mkdir(keystore_dir)

        # gen keystore files
        write_file(keystore_dir, FN_KEYSTORE_TEST1, json.dumps(keystore_test1, indent=4))

        # keystore file for main P-Rep
        main_prep_count = tbears_server_config.get(TConfigKey.PREP_MAIN_PREPS, 0)
        for i, prep in enumerate(TEST_ACCOUNTS[:main_prep_count]):
            wallet = KeyWallet.load(prep)
            wallet.store(file_path=os.path.join(keystore_dir, f"prep{i}_keystore"),
                         password=f"prep{i}_Account")

        result.append(keystore_dir + "/*")

        return result
    def __init__(self, node_conf_path: str, wallet_path: str, passwd: str):

        # Node configuration to be connected
        with open(node_conf_path, "r") as f:
            node_conf = json.load(f)

        self._my_chain_name = node_conf["chain_name"]
        self._nid = int(node_conf["nid"], 16)

        if node_conf["web_protocol"] == "ssl":
            self._icon_service = IconService(
                HTTPProvider("https://" + node_conf["address"], 3))
        else:
            self._icon_service = IconService(
                HTTPProvider("http://" + node_conf["address"], 3))
        print(
            f"--------------------------------<Connecting node>--------------------------------"
        )
        print(f" - address    : {node_conf['address']}")
        print(f" - chain_name : {self._my_chain_name}")
        print(f" - nid        : {self._nid}")
        print(
            f"---------------------------------------------------------------------------------"
        )

        # Set wallet of deployer
        self._wallet = KeyWallet.load(wallet_path, passwd)
        # print(f"pk: {self._wallet.get_private_key()}")

        # Set deployed score address
        self._score_addr = ""  # It will be set after deployment
        self._score_path = ""
        self._score_params = {}
        self._score_info = ""
예제 #8
0
파일: prep.py 프로젝트: robcxyz/preptools
def create_writer(url: str, nid: int, keystore_path: str,
                  password: str) -> PRepToolsWriter:
    icon_service = create_icon_service(url)

    owner_wallet = KeyWallet.load(keystore_path, password)

    return PRepToolsWriter(icon_service, nid, owner_wallet)
예제 #9
0
def load_keystore(keystore, passwd=None):
    try:
        if passwd is None:
            passwd = getpass.getpass()
        return KeyWallet.load(keystore.name, passwd)
    except KeyStoreException as e:
        die(e.message)
    def transfer(self, conf: dict) -> dict:
        """Transfer ICX Coin.

        :param conf: transfer command configuration.
        :return: response of transfer.
        """
        # check value type (must be int), address and keystore file
        # if valid, return user input password
        password = conf.get('password', None)
        password = self._check_transfer(conf, password)

        if password:
            try:
                wallet = KeyWallet.load(conf['keyStore'], password)
                from_ = wallet.get_address()

            except KeyStoreException as e:
                print(e.args[0])
                return None
        else:
            # make dummy wallet
            wallet = KeyWallet.create()
            from_ = conf['from']

        uri, version = uri_parser(conf['uri'])
        icon_service = IconService(HTTPProvider(uri, version))

        transaction = TransactionBuilder() \
            .from_(from_) \
            .to(conf['to']) \
            .value(int(conf['value'])) \
            .nid(convert_hex_str_to_int(conf['nid'])) \
            .timestamp(int(time() * 10 ** 6)) \
            .build()

        if 'stepLimit' not in conf:
            step_limit = icon_service.estimate_step(transaction)
        else:
            step_limit = convert_hex_str_to_int(conf['stepLimit'])

        transaction.step_limit = step_limit

        # Returns the signed transaction object having a signature
        signed_transaction = SignedTransaction(transaction, wallet)

        if not password:
            signed_transaction.signed_transaction_dict['signature'] = 'sig'

        # Sends transaction and return response
        response = send_transaction_with_logger(icon_service, signed_transaction, uri)

        if 'result' in response:
            print('Send transfer request successfully.')
            tx_hash = response['result']
            print(f"transaction hash: {tx_hash}")
        else:
            print('Got an error response')
            print(json.dumps(response, indent=4))

        return response
예제 #11
0
    def __init__(self, node_conf_path: str, wallet_path: str, passwd: str):

        # Node configuration to be connected
        with open(node_conf_path, "r") as f:
            node_conf = json.load(f)

        self._my_chain_name = node_conf["chain_name"]
        self._nid = int(node_conf["nid"], 16)

        self.web_protocol = node_conf["web_protocol"]

        if self.web_protocol == "ssl":
            self._icon_service = IconService(
                HTTPProvider("https://" + node_conf["address"], 3))
            self._ws_block = f"wss://{node_conf['address']}/api/ws/{node_conf['channel']}"
        elif self.web_protocol == "http":
            self._icon_service = IconService(
                HTTPProvider("http://" + node_conf["address"], 3))
            self._ws_block = f"ws://{node_conf['address']}/api/node/{node_conf['channel']}"
        else:
            print("[error] Not supported web_protocol")
            sys.exit()

        # Set wallet of actor
        self._wallet = KeyWallet.load(wallet_path, passwd)

        self._score_info = node_conf["scores"]
예제 #12
0
def generate_tx(file, password, icx_value, to_addr, nid, api_url, is_send,
                timestamp):
    step_limit = 1000000
    value = int(icx_value * 10**18)
    wallet = KeyWallet.load(file, password)
    owner_from_addr = wallet.get_address()
    transaction = TransactionBuilder() \
        .from_(owner_from_addr) \
        .to(to_addr) \
        .step_limit(step_limit) \
        .nid(int(nid)) \
        .nonce(100) \
        .value(value) \
        .timestamp(timestamp)\
        .build()
    signed_params = SignedTransaction(transaction, wallet)
    signed_payload = {
        'jsonrpc': '2.0',
        'method': "icx_sendTransaction",
        'id': 1234,
        "params": signed_params.signed_transaction_dict
    }
    kvPrint("[before] signed_payload",
            json.dumps(signed_payload, indent=4, sort_keys=True))
    kvPrint("[before] calculate the tx_hash",
            f"0x{generate_message(signed_params.signed_transaction_dict)}")

    if is_send:
        print("===== send tx =====")
        provider = HTTPProvider(f"{api_url}/api/v3")
        icon_service = IconService(provider)
        tx_hash = icon_service.send_transaction(signed_params)
        kvPrint(f"[after]  sendTX() txResult", tx_hash)

    return signed_payload
    def keyinfo(self, conf: dict):
        """Show a keystore information with the the specified path and password.

        :param conf: keyinfo command configuration
        """
        password = conf.get('password', None)
        password = self._check_keyinfo(password)

        try:
            wallet = KeyWallet.load(conf['path'], password)

            key_info = {
                "address": wallet.get_address(),
                "publicKey": convert_bytes_to_hex_str(wallet.public_key)
            }

            if conf['privateKey']:
                key_info['privateKey'] = add_0x_prefix(wallet.get_private_key())

            print(json.dumps(key_info, indent=4))

            return key_info

        except KeyStoreException as e:
            print(e.args[0])
예제 #14
0
파일: views.py 프로젝트: NeneWang/iconexapp
def add_token_test(request):
    # Withouth all the mapping fusiness. This just min  ts the token and show it up

    #Connect to Federico wallet Method

    node_uri = "https://bicon.net.solidwallet.io/api/v3"
    network_id = 3
    hello_world_address = "cx2a96ae73368ee622f29ea6df5a9e621059326feb"
    keystore_path = "./walletFEDEKEYSTORE.119Z--hx8bad34f951350f2805af083b50562529241c5baf"
    keystore_pw = "Darkarior448!"

    wallet = KeyWallet.load(keystore_path, keystore_pw)
    tester_addr = wallet.get_address()
    icon_service = IconService(HTTPProvider(node_uri))

    #Checking the wallet data

    print("address: ", wallet.get_address())  # Returns an address
    print("private key: ", wallet.get_private_key())  # Returns a private key

    tester_addr = wallet.get_address()
    icon_service = IconService(HTTPProvider(node_uri))
    service_adress = "cx312f84fa11a0d315ea4331c5e601d3c4897575f8"
    # TODO Here put the receiver address from the current logged in data
    receiver_address = tester_addr

    # Way to large
    # tokenId = uuid.uuid1().int

    tokenId_start = int(str(uuid.uuid1().int)[:5])
    tokenId = tokenId_start + int(round(time.time() * 1000))

    firebase_id = request.session['local_id']
    champType = 1

    addChampionToDB(firebase_id, tokenId, champType)

    params = {
        '_to': receiver_address,
        '_tokenId': tokenId,
    }

    transaction = CallTransactionBuilder().from_(tester_addr)\
                        .to(service_adress)\
                        .method("mint")\
                        .nid(3)\
                        .nonce(100)\
                        .params(params)\
                        .step_limit(1000000)\
                        .build()

    # Returns the signed transaction object having a signature
    signed_transaction = SignedTransaction(transaction, wallet)

    # Sends the transaction
    tx_hash = icon_service.send_transaction(signed_transaction)
    print(tx_hash)

    context = {'newChampionName': "example"}
    return render(request, join('core', 'champion_added.html'), context)
예제 #15
0
 def setUpClass(self):
     self._currentDirPath = path.abspath(path.dirname(__file__))
     self._walletOfTest1 = KeyWallet.load(
         f'{self._currentDirPath}/.keystore/{TEST_KEYSTORE_TEST1}',
         'test1_Account')
     self._walletOfUc = KeyWallet.load(
         f'{self._currentDirPath}/.keystore/{TEST_KEYSTORE_UC}',
         TEST_KEYSTORE_PW)
     self._walletOfProvider = KeyWallet.load(
         f'{self._currentDirPath}/.keystore/{TEST_KEYSTORE_PROVIDER}',
         TEST_KEYSTORE_PW)
     self._walletOfCustomer = KeyWallet.load(
         f'{self._currentDirPath}/.keystore/{TEST_KEYSTORE_CUSTOMER}',
         TEST_KEYSTORE_PW)
     self._iconService = IconService(
         HTTPProvider(TEST_HTTP_ENDPOINT_URI_V3))
예제 #16
0
def create_writer(keystore_path, password):
    icon_service = IconService()
    wallet = KeyWallet.load(keystore_path, password)

    writer = PRepToolsWriter(icon_service, 3, wallet)
    writer.set_on_send_request(lambda x: True)

    return writer
예제 #17
0
def login():
    print(request.args.get('privateKey'))
    # init wallet
    private_key = request.args.get('privateKey')
    wallet = KeyWallet.load(bytes.fromhex(private_key))
    IconServiceContainer.wallet = wallet

    return jsonify({"result": True})
예제 #18
0
def load_keystore(keystore_path, passwd=None):
    try:
        if passwd is None:
            print("Keystore:", keystore_path)
            passwd = getpass.getpass()
        return KeyWallet.load(keystore_path, passwd)
    except KeyStoreException as e:
        die(e.message)
예제 #19
0
def walletPrivateKey(request):
    try:
        file_path= BASE_DIR+"/keystore/"+request.session.session_key+'/'+request.session['wallet_name']
        wallet = KeyWallet.load(file_path, request.session['wallet_password'])
        wallet_json = { "address" : wallet.get_address(),
                        "private_key" : wallet.get_private_key()}
        return JsonResponse(wallet_json)
    except Exception:
        return JsonResponse({"ERROR": 404})
예제 #20
0
def get_keywallet():
    config = open("config.json").read()
    try:
        config_in_json = json.loads(config)
    except json.JSONDecodeError as err:
        print(f'Error loading JSON: {err.msg}')

    key_wallet = KeyWallet.load(config_in_json["KeyWallet"]["File"], config_in_json["KeyWallet"]["Password"])
    return key_wallet
    def test_wallet_load_from_keystore_file(self):
        """A wallet loads from a keystore file correctly."""

        # Loads a wallet.
        wallet = KeyWallet.load(self.TEST_KEYSTORE_FILE_DIR,
                                self.TEST_KEYSTORE_FILE_PASSWORD)

        # Checks a wallet's address is correct.
        self.assertEqual(wallet.get_address(),
                         "hxfd7e4560ba363f5aabd32caac7317feeee70ea57")
 def setUp(self):
     super().setUp()
     self.mock_score = Address.from_string(f"cx{'abcd' * 10}")
     self.dividends = self.get_score_instance(Dividends, self.test_account1)
     self.wallet_array = [KeyWallet.load(v) for v in TEST_ACCOUNTS]
     account_info = {
         Address.from_string(wallet.get_address()): 10**21
         for wallet in self.wallet_array
     }
     self.initialize_accounts(account_info)
예제 #23
0
def get_wallet(args: dict) -> KeyWallet:
    key_path = args.get('key')
    password = args.get('password')
    if password is None:
        getpass.getpass('Enter password : '******'invalid keystore file or wrong password')
        sys.exit(1)
예제 #24
0
    def setUpClass(cls) -> None:
        super().setUpClass()

        if not cls.LOCAL_NETWORK_TEST:
            cls._wallet = KeyWallet.load("../../keystore_test3",
                                         "test3_Account")
            cls._wallet2 = KeyWallet.load("../../keystore_test2",
                                          "test2_Account")
            cls._icon_service = IconService(
                HTTPProvider("https://bicon.net.solidwallet.io/api/v3"))
            cls._score_address = str()
            cls._fake_sys_score = str()
            cls.prep_list = cls.PREP_LIST_YEOUIDO
        else:
            cls._wallet = cls._test1
            cls._wallet2 = KeyWallet.create()
            cls._icon_service = IconService(
                HTTPProvider("http://127.0.0.1:9000/api/v3"))
            cls._score_address = str()
            cls.prep_list = cls.PREP_LIST_LOCAL
예제 #25
0
    def sendtx(self, conf: dict):
        """Send transaction.

        :param conf: sendtx command configuration.
        :return: response of transfer.
        """
        with open(conf['json_file'], 'r') as jf:
            payload = json.load(jf)

        password = conf.get('password', None)
        password = self._check_sendtx(conf, password)
        params = payload['params']

        if password and conf.get('keyStore'):
            try:
                wallet = KeyWallet.load(conf['keyStore'], password)
                params['from'] = wallet.get_address()

            except KeyStoreException as e:
                print(e.args[0])
                return None
        else:
            # make dummy wallet
            wallet = KeyWallet.create()

        uri, version = uri_parser(conf['uri'])
        icon_service = IconService(HTTPProvider(uri, version))

        transaction = self.get_transaction(conf, params)
        if 'stepLimit' not in conf:
            step_limit = icon_service.estimate_step(transaction)
        else:
            step_limit = convert_hex_str_to_int(conf['stepLimit'])

        transaction.step_limit = step_limit

        signed_transaction = SignedTransaction(transaction, wallet)

        if not password:
            signed_transaction.signed_transaction_dict['signature'] = 'sig'

        # Sends transaction
        response = send_transaction_with_logger(icon_service,
                                                signed_transaction, uri)

        if 'result' in response:
            print('Send transaction request successfully.')
            tx_hash = response['result']
            print(f"transaction hash: {tx_hash}")
        else:
            print('Got an error response')
            print(json.dumps(response, indent=4))

        return response
예제 #26
0
def create_writer(url: str, nid: int, keystore_path: str, password: str, step_limit: int) -> PRepToolsWriter:
    url: str = get_url(url)
    icon_service = IconService(HTTPProvider(url))

    try:
        owner_wallet = KeyWallet.load(keystore_path, password)

    except KeyStoreException as e:
        raise InvalidKeyStoreException(f"{e}")

    return PRepToolsWriter(icon_service, nid, owner_wallet, step_limit)
예제 #27
0
    def read_data(self, contract_address, table_name, wallet_key, params):
        wallet = KeyWallet.load(bytes.fromhex(wallet_key))

        call_data = CallBuilder() \
          .from_(wallet.get_address()) \
          .to(contract_address) \
          .method('get' + table_name) \
          .params(params) \
          .build()

        result = self.icon_service.call(call_data)
        return result
    def setUpClass(cls):
        """
        Sets needed data like an instance of a wallet and iconsdk
        and default values used to make 4 types of transactions. (transfer, call, deploy, message)
        """
        cls.wallet = KeyWallet.load(PRIVATE_KEY_FOR_TEST)
        cls.version = VERSION_FOR_TEST
        cls.icon_service = IconService(
            HTTPProvider(BASE_DOMAIN_URL_V3_FOR_TEST, cls.version))

        # bytes of sample_token's content
        # current_dir_path = path.abspath(path.dirname(__file__))
        # score_path = path.join(current_dir_path, 'sample_token')
        # install_content_bytes = gen_deploy_data_content(score_path)
        install_content_bytes = b'PK\x03\x04\x14\x00\x00\x00\x08\x00P\x95\xf4LPJ<\xd7\'\x02\x00\x00]\x06\x00\x00V\x00\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token/sample_token.py\x8dTQk\xdb0\x10~\xf7\xaf\x10}\x89\x9d\xae%c/\xc3,c\xc9\xb2\x87A\xe8\n\xf1\x06\xa3\x14!\xdb\xe7`\xaaHFRBC\xe9\x7f\xdf\xd9\x91%%\x8d\xd3\xe9)\xd1\xf9\xbe\xfb\xbeOwW)\xb9!u!\x85\x06\xb5\xab\x0b \xf5\xa6\x91\xca\x90q\x14E\x05gZ\x93\x15\xdb4\x1c2\xf9\x04"\xfe\x89\x1f\xae\n\xa9`\xce4$i\x14\x11<\x94\xceg\xcb\xd9\xdd\xf7\x1f+2%\xa3\x9cq&\n\xd0#\x1b\xcb~e\xb3%]\xfd\xbe\xbf_\xfem\xe3F\x1a\xc6\xa9\xde6\r\xdf\x8f\x0e\x00\xdf`\x07\xc2p\xb9\x8ekQ\xc23\x94\xd3OI\x17(\xa1"\x99bBW\xa0b\r\xbc\xfa@XY*Z!\xe9\x94\xcc\xf0\'hm\xef\x8c\x0cnv\x8co!%\xb50IJ\x1aT\x119<JkQ\x1bJ-^\x99\xa7\xc4\xa9Z0\xc3\xf2V\x19\xb9\xf9J\xee\xa4\x80\xb4Kk\x0f\x12F\x0e\xc9\xadK/\xf3\xc4\x07\x11\n#\xa14\x94\xfa\x87\xa9\xc5<\xb6\xb1\xd0\x86\xb6\xaa\xe5H\xcd\xbe\x81i\xcb\xf3\x14\xac\xf7\x11\x81\x16ua<Ro\xf6y\x14\xa7S\nd\xaa\x91\x10\xb7J;\xde\x07r\x9d3\x08\xfcq2\x99 \x0c\x14\xf5\x86qw\xf9\xf9\x82\xfc\x00\xd5\xd6j\xcf\x89\xf0\xa0\x12\x19c\x112\x1e\xf7E\xa2K\x9e\xddj0qx1h\xcaC\xf7\x7f\xa3\xd7\x98\x82-\xa3\x1e\xb1j\x98xd\xc3\xb6)\x99\x81\xce\x85\xcb\xca\xec\x87I\xdf\x95\xcf\x06\x94`<V\xc0J)\xf8~\x9a\xa9-\xf8\xce\x0c\x0bzt4\xd1\x83+0[%\xcej]\xa3\xd6\xff\xaddeSY\rN\xc1{\xb5\x9ds.\xf51\x9c\ts<e\xf4\xdc\x98\xd1\xb7sF\x83Ak\t\xe4R\xf2\xd4\xbfq]\x1d\xca\x07\xfc=rB\xbe\xf4\xf9.\xc1=\xb5\xc2\x95\xa0L\\]\xbd\xf8\x84\xd7\x91\xee\x9d\xc0\xd4\x97C\xee\xebU\xf2\xa6\xa7\x9cV\x9f\xdb6\xc8\xa5\xe8\x8d\xa5\xf2\x0e\x94\x91\xc3@m\xec\xba\x879\xc6q;\xcc\x97\xf4v\xf6.&\xa7/\xd7\xf6\xc0I\x83\xf8\xde;\xb3\x15\x876\xa0\x7f\x98\x81\xb6\x0c\xb1\x82\xa1r\xb0\x16-X.\x15.\x80\x9c\x15OCCuX\xb9\xd1?PK\x03\x04\x14\x00\x00\x00\x08\x00P\x95\xf4L\x08M\x80\x83"\x00\x00\x00&\x00\x00\x00R\x00\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token/__init__.pyK+\xca\xcfU\xd0+N\xcc-\xc8I\x8d/\xc9\xcfN\xcdS\xc8\xcc-\xc8/*Q\x08\x06\x8b\x85\x80\x84\xb8\x00PK\x03\x04\x14\x00\x00\x00\x08\x00P\x95\xf4L\x05}|\x97B\x00\x00\x00\\\x00\x00\x00S\x00\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token/package.json\xab\xe6R\x00\x02\xa5\xb2\xd4\xa2\xe2\xcc\xfc<%+\x05%\x03=\x03=C%\x1d\x88xnbf^|ZfN*H\xa681\xb7 \'5\xbe$?;5\x0fEAqr~\x11XE0XE\x08X\x01W-\x00PK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00P\x95\xf4LPJ<\xd7\'\x02\x00\x00]\x06\x00\x00V\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token/sample_token.pyPK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00P\x95\xf4L\x08M\x80\x83"\x00\x00\x00&\x00\x00\x00R\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x9b\x02\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token/__init__.pyPK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00P\x95\xf4L\x05}|\x97B\x00\x00\x00\\\x00\x00\x00S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81-\x03\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token/package.jsonPK\x05\x06\x00\x00\x00\x00\x03\x00\x03\x00\x85\x01\x00\x00\xe0\x03\x00\x00\x00\x00'

        # bytes of sample_token2's content
        # score_path = path.join(current_dir_path, 'sample_token2')
        # update_content_bytes = gen_deploy_data_content(score_path)
        update_content_bytes = b'PK\x03\x04\x14\x00\x00\x00\x08\x00\'|\x14M|9?K6\x02\x00\x00\x95\x06\x00\x00W\x00\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token2/sample_token.py\x8dT]k\xdb0\x14}\xf7\xaf\x10y\x89\x9d\xae%c/\xc3,c\xc92\xd8 t\x85d\x832\x8a\x90\xed\xeb\xceT\x91\x8c\xa4\x84\x86\xd2\xff\xbekG\x96\x94\x0f\xa7\xd3\x93\xad\xab{\xee\xb9G\xe7\xaaTrM\xaa\\\n\rj[\xe5@\xaau-\x95!\xa3(\x8ar\xce\xb4&K\xb6\xae9\xac\xe4\x13\x88\xf8\x07\x1e\\\xe6R\xc1\x8ciH\xd2("\xb8(\x9dM\x17\xd3\xdb\xaf\xdf\x96dB\x86\x19\xe3L\xe4\xa0\x876\xb6\xfa\xb9\x9a.\xe8\xf2\xd7\xdd\xdd\xe2\xbe\x89\x1bi\x18\xa7zS\xd7|7\xdc\x03|\x81-\x08\xc3\xe5c\\\x89\x02\x9e\xa1\x98|H\xda@\x01%Y)&t\t*\xd6\xc0\xcbw\x84\x15\x85\xa2%\x92N\xc9\x14?Ak\xbbgd\xb0\xb3e|\x03)\xa9\x84IRRc\x17\x91\xc3\xa3\xb4\x12\x95\xa1\xd4\xe2\x15YJ\\WsfX\xd6tF\xae?\x93[) m\xd3\x9a\x85\x84\x91Cr\xe3\xd2\x8b,\xf1A\x84\xc2H\xd8\x1a\xb6\xfa\x9b\xa9\xf9,\xb6\xb1P\x86\xa6\xaa\xe5H\xcd\xae\x86I\xc3\xf3\x18\xac\xd3\x11\x81\xe6Un<R\'\xf6y\x14\xd7\xa7\x14\xc8T#!n;my\xef\xc9\xb5\xca \xf0\xfb\xf1x\x8c0\x90Wk\xc6\xdd\xe6\xc7\x0b\xed\x07\xa8\xb6V\xb3\x8e\x1a\x0f*\x91\x11\x16!\xa3QW$\xba\xa4\xd9\x8d\x06\x13\x87\x1b\xbd\xa2\xfci\xff\xd7\xfa\x11S\xd02\xea\x01\xab\x86\x89\x072l\xea\x82\x19hU\xb8\xdc\x99=\x98t\xae|6\xa0\x04\xe3\xb1\x02VH\xc1w\x93\x95\xda\x80wfX\xd0\xa3\xa3\x88\x1e\\\x81\xd9(A\xc6\xff\x89h\xdb\xa3\xb2\xecu{o\x8dc\x85\\\xeaC\xe8}s8M\xf4\xdc8\xd1\xd3y\xa2\xc1@5\x042)y\xea\xef\xb2*\xf7\xe5\x03\xfe\x1e9!\x9f\xba|\x97\xe0\xaeT\xe1\xe8+\x13\x97\x83\x17\x9f\xf0:\xd4\x9d\x12\x98\xfa\xb2\xcf}\x1d$\'\xdeq\xbd\xfa\xdc\xc6\x08\x97\xa2\xd7\x96\xca\x1bPF\xf6\x035\xb1\xab\x0e\xe6\x10\xc7\xbdU\xbe\xa4\x97\xb3S19\xbe\xb9\xc6\x03G\x06\xf1\x1e;\xf3\xfa\xf5\xbdt\xfeb\xce[\xe3\x00+\x18\x1e\x07k\xd1\x82G\xa4\xc4A\xcfX\xfe\xd47<\xfei}\xd3\xdb\x7f\x81s\xe9q\xb4Q\'<\x07\xdf\x9b3\x83(\xfa\x07PK\x03\x04\x14\x00\x00\x00\x08\x00P\x95\xf4L\x08M\x80\x83"\x00\x00\x00&\x00\x00\x00S\x00\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token2/__init__.pyK+\xca\xcfU\xd0+N\xcc-\xc8I\x8d/\xc9\xcfN\xcdS\xc8\xcc-\xc8/*Q\x08\x06\x8b\x85\x80\x84\xb8\x00PK\x03\x04\x14\x00\x00\x00\x08\x00P\x95\xf4L\xb85\xd6|B\x00\x00\x00\\\x00\x00\x00T\x00\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token2/package.json\xab\xe6R\x00\x02\xa5\xb2\xd4\xa2\xe2\xcc\xfc<%+\x05%\x03=\x03=#%\x1d\x88xnbf^|ZfN*H\xa681\xb7 \'5\xbe$?;5\x0fEAqr~\x11XE0XE\x08X\x01W-\x00PK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00\'|\x14M|9?K6\x02\x00\x00\x95\x06\x00\x00W\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token2/sample_token.pyPK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00P\x95\xf4L\x08M\x80\x83"\x00\x00\x00&\x00\x00\x00S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\xab\x02\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token2/__init__.pyPK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00P\x95\xf4L\xb85\xd6|B\x00\x00\x00\\\x00\x00\x00T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81>\x03\x00\x00Users/boyeon/PycharmProjects/IconPythonSDK/tests/api_send/sample_token2/package.jsonPK\x05\x06\x00\x00\x00\x00\x03\x00\x03\x00\x88\x01\x00\x00\xf2\x03\x00\x00\x00\x00'

        cls.setting = {
            "from": cls.wallet.get_address(),
            "to": "hx5bfdb090f43a808005ffc27c25b213145e80b7cd",
            "to_governance": "cx0000000000000000000000000000000000000001",
            "step_limit": 4_000_000_000,
            "nid": 3,
            "nonce": 3,
            # It is used to send icx(transfer) only.
            "value": 1_000_000_000_000_000_000,
            # It is used to send call only.
            "method": "transfer",
            "params_call": {
                "to": "hxab2d8215eab14bc6bdd8bfb2c8151257032ecd8b",
                "value": "0x1"
            },
            # It is used to send SCORE install(deploy).
            # If SCORE's address is as follows, it means install SCORE.
            "to_install": "cx0000000000000000000000000000000000000000",
            "content_type": "application/zip",
            # Data type of content should be bytes.
            "content_install": install_content_bytes,
            "content_update": update_content_bytes,
            # It is used to deploy only.(install)
            "params_install": {
                "init_supply": 10_000
            },
            # It is used to send message only.
            "data": "0x" + "test".encode().hex(),
            "id": "0x" + os.urandom(32).hex(),
            "timestamp": 10_000
        }
예제 #29
0
    def setUpClass(cls):
        icon_endpoint = os.environ['ICON_ENDPOINT']

        if icon_endpoint == 'testnet':
            cls.icon_service = IconService(HTTPProvider('https://bicon.net.solidwallet.io/api/v3'))
            cls.stg_score_address = 'cx8ada5f95f337ae332c97f3375e7e4f8209617143'
        else:
            cls.icon_service = IconService(HTTPProvider('http://127.0.0.1:9000/api/v3'))
            cls.stg_score_address = 'cx63eb7813408055717194f2f25aaeb3e837a3858d'

        cls.owner_wallet = KeyWallet.load('conf/test_owner.keystore', 'test123!')
        cls.user1_wallet = KeyWallet.load('conf/test_user1.keystore', 'test123!')
        cls.user2_wallet = KeyWallet.load('conf/test_user2.keystore', 'test123!')

        owner_balance = balance_of(cls.owner_wallet.get_address(), cls.owner_wallet.get_address())
        print('owner_balance = {}'.format(owner_balance))

        user1_balance = balance_of(cls.user1_wallet.get_address(), cls.user1_wallet.get_address())
        print('user1_balance = {}'.format(user1_balance))

        user2_balance = balance_of(cls.user2_wallet.get_address(), cls.user2_wallet.get_address())
        print('user2_balance = {}'.format(user2_balance))
예제 #30
0
 def __init__(self, _conf_rpc: dict) -> None:
     # Key Wallet with Password
     self.key_wallet = KeyWallet.load(_conf_rpc["KeyWallet"]["File"],
                                      _conf_rpc["KeyWallet"]["Password"])
     # Service Endpoint (URL)
     self.service_endpoint = IconService(
         HTTPProvider(_conf_rpc["Service Endpoint"]))
     # Smart Contract Address
     self.id_contract_address = _conf_rpc["ID Contract Address"]
     self.ptm_contract_address = _conf_rpc["PTM Contract Address"]
     self.pgm_contract_address = _conf_rpc["PGM Contract Address"]
     # Network ID
     self.nid = int(_conf_rpc["Network ID"])
예제 #31
0
 def setUp(self):
     self.wallet = KeyWallet.load(keystore_path, keystore_pw)
     self.tester_addr = self.wallet.get_address()
     self.icon_service = IconService(HTTPProvider(node_uri))