Пример #1
0
    def __handle_message_queue():
        while len(state['msg_queue']):
            msg_opt = state['msg_queue'].pop(0)

            parsed = async_custom_client.boc.parse_message(
                params=ParamsOfParse(boc=msg_opt))
            body = parsed.parsed['body']
            dest_address = parsed.parsed['dst']
            src_address = parsed.parsed['src']
            wc, interface_id = dest_address.split(':')

            if wc == str(DEBOT_WC):
                if interface_id == INTERFACES[0]:
                    abi = Abi.Json(value=json.dumps(ECHO_ABI))
                elif interface_id == INTERFACES[1]:
                    abi = Abi.Json(value=json.dumps(TERMINAL_ABI))
                else:
                    raise ValueError('Unsupported interface')

                decoded = async_custom_client.abi.decode_message_body(
                    params=ParamsOfDecodeMessageBody(
                        abi=abi, body=body, is_internal=True))
                logging.info(f'Request: `{decoded.name}` ({decoded.value})')

                if interface_id == INTERFACES[0]:
                    method = state['echo'].methods[decoded.name]
                elif interface_id == INTERFACES[1]:
                    method = state['terminal'].methods[decoded.name]
                else:
                    raise ValueError('Unsupported interface')

                func_id, kwargs = method(decoded.value)
                logging.info(f'Response: `{func_id}` ({kwargs})')
                call_set = CallSet(function_name=hex(func_id), input=kwargs) \
                    if func_id > 0 else None
                internal = async_custom_client.abi.encode_internal_message(
                    params=ParamsOfEncodeInternalMessage(
                        value='1000000000000000',
                        abi=Abi.Json(value=debot.debot_abi),
                        address=src_address, call_set=call_set))
                async_custom_client.debot.send(
                    params=ParamsOfSend(
                        debot_handle=debot.debot_handle,
                        message=internal.message))
            else:
                debot_fetched = state['bots'].get(dest_address)
                if not debot_fetched:
                    _params = ParamsOfInit(address=dest_address)
                    debot_browser(
                        steps=[], start=False, keypair=keypair,
                        params=_params, state=state)

                debot_fetched = state['bots'][dest_address].debot_handle
                async_custom_client.debot.send(
                    params=ParamsOfSend(
                        debot_handle=debot_fetched, message=msg_opt))
Пример #2
0
 def setUp(self) -> None:
     self.keypair = KeyPair.load(
         path=os.path.join(SAMPLES_DIR, 'keys_raw.json'), is_binary=False)
     self.target_abi = Abi.from_path(
         path=os.path.join(SAMPLES_DIR, 'DebotTarget.abi.json'))
     with open(os.path.join(SAMPLES_DIR, 'DebotTarget.tvc'), 'rb') as fp:
         self.target_tvc = base64.b64encode(fp.read()).decode()
Пример #3
0
    def test_encode_internal_message_run(self):
        address = '0:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
        abi = Abi.from_path(path=os.path.join(SAMPLES_DIR, 'Hello.abi.json'))

        result = async_core_client.abi.encode_internal_message(
            params=ParamsOfEncodeInternalMessage(abi=abi,
                                                 value='1000000000',
                                                 address=address,
                                                 call_set=CallSet(
                                                     function_name='sayHello'),
                                                 bounce=True))
        self.assertEqual(address, result.address)
        self.assertEqual(
            'te6ccgEBAQEAOgAAcGIACRorPEhV5veJGis8SFXm94kaKzxIVeb3iRorPEhV5veh3NZQAAAAAAAAAAAAAAAAAABQy+0X',
            result.message)

        boc_hash = async_core_client.boc.get_boc_hash(
            params=ParamsOfGetBocHash(boc=result.message))
        self.assertEqual(result.message_id, boc_hash.hash)

        parsed = async_core_client.boc.parse_message(params=ParamsOfParse(
            boc=result.message))
        self.assertEqual('internal', parsed.parsed['msg_type_name'])
        self.assertEqual('', parsed.parsed['src'])
        self.assertEqual(address, parsed.parsed['dst'])
        self.assertEqual('0x3b9aca00', parsed.parsed['value'])
        self.assertEqual(True, parsed.parsed['bounce'])
        self.assertEqual(True, parsed.parsed['ihr_disabled'])
Пример #4
0
    def __init_debot3(self, keypair: KeyPair) -> str:
        signer = Signer.Keys(keys=keypair)
        debot_abi = Abi.from_path(
            path=os.path.join(SAMPLES_DIR, 'Debot3.abi.json'))
        with open(os.path.join(SAMPLES_DIR, 'Debot3.tvc'), 'rb') as fp:
            debot_tvc = base64.b64encode(fp.read()).decode()

        call_set = CallSet(function_name='constructor')
        deploy_set = DeploySet(tvc=debot_tvc)
        encode_params = ParamsOfEncodeMessage(
            abi=debot_abi, signer=signer, deploy_set=deploy_set,
            call_set=call_set)
        message = async_custom_client.abi.encode_message(params=encode_params)

        # Check if debot contract does not exists
        debot_address = self.__check_address(address=message.address)
        if not debot_address:
            process_params = ParamsOfProcessMessage(
                message_encode_params=encode_params, send_events=False)
            debot = async_custom_client.processing.process_message(
                params=process_params)
            debot_address = debot.transaction['account_addr']

            # Set ABI
            call_set = CallSet(
                function_name='setABI',
                input={'dabi': debot_abi.value.encode().hex()})
            async_custom_client.processing.process_message(
                params=ParamsOfProcessMessage(
                    message_encode_params=ParamsOfEncodeMessage(
                        abi=debot_abi, signer=signer, address=debot_address,
                        call_set=call_set),
                    send_events=False))

        return debot_address
Пример #5
0
 def get_testnet_grams(self,address: str):
     giver_abi = Abi.from_json_path(
         path=os.path.join(self.SAMPLES_DIR, 'Giver.abi.json'))
     call_set = CallSet(
         function_name='grant',
         inputs={'addr': address})
     self.async_core_client.processing.process_message(
         abi=giver_abi, signer=Signer(), address='0:653b9a6452c7a982c6dc92b2da9eba832ade1c467699ebb3b43dca6d77b780dd',
         call_set=call_set, send_events=False)
Пример #6
0
def send_grams(address: str):
    giver_abi = Abi.from_json_path(
        path=os.path.join(SAMPLES_DIR, 'Giver.abi.json'))
    call_set = CallSet(function_name='grant', inputs={'addr': address})
    async_core_client.processing.process_message(abi=giver_abi,
                                                 signer=Signer(),
                                                 address=GIVER_ADDRESS,
                                                 call_set=call_set,
                                                 send_events=False)
Пример #7
0
 def send_data(self,function_name,inputs,outputs):
     with open(".contract.abi.json") as f:
         data = json.loads(f.read())
     sender = {}
     for i in inputs:
         for x in data["functions"]:
             if x["name"] == function_name:
                 for t in x["inputs"]:
                     if t["name"] == i[0]:
                         if "int" in t["type"]:
                             sender[i[0]] = int(i[1].text())
                         else:
                             sender[i[0]] = i[1].text()
     #m = QMessageBox.about(self, "Running...", "Please wait for a while. Dont press any button")
     print(self.addr,Abi.from_json_path(
         path='.contract.abi.json'),function_name,sender,Signer(self.main_key))
     response = self.wrapper.run_contract(self.addr,Abi.from_json_path(
         path='.contract.abi.json'),function_name,sender,signer=Signer(self.main_key))
     QMessageBox.about(self, "Running...", str(response))
Пример #8
0
def send_grams(address: str):
    giver_abi = Abi.from_path(path=os.path.join(SAMPLES_DIR, 'Giver.abi.json'))
    call_set = CallSet(function_name='grant', input={'dest': address})
    encode_params = ParamsOfEncodeMessage(abi=giver_abi,
                                          signer=Signer.NoSigner(),
                                          address=GIVER_ADDRESS,
                                          call_set=call_set)
    process_params = ParamsOfProcessMessage(
        message_encode_params=encode_params, send_events=False)
    async_custom_client.processing.process_message(params=process_params)
Пример #9
0
    def __init_debot5(self, count: int) -> Tuple[List[str], str]:
        debot_abi = Abi.from_path(
            path=os.path.join(SAMPLES_DIR, 'Debot5.abi.json'))
        with open(os.path.join(SAMPLES_DIR, 'Debot5.tvc'), 'rb') as fp:
            debot_tvc = base64.b64encode(fp.read()).decode()

        result = async_custom_client.boc.get_code_from_tvc(
            params=ParamsOfGetCodeFromTvc(tvc=debot_tvc))
        result = async_custom_client.boc.get_boc_hash(
            params=ParamsOfGetBocHash(boc=result.code))
        contract_hash = result.hash

        call_set = CallSet(
            function_name='constructor',
            input={'codeHash': f'0x{contract_hash}'})
        deploy_set = DeploySet(tvc=debot_tvc)
        deploy_params = ParamsOfEncodeMessage(
            abi=debot_abi, deploy_set=deploy_set, call_set=call_set,
            signer=Signer.NoSigner())

        addresses = []
        for i in range(count):
            # Set signer for deploy params
            keypair = async_custom_client.crypto.generate_random_sign_keys()
            deploy_params.signer = Signer.Keys(keys=keypair)

            # Calculate address
            message = async_custom_client.abi.encode_message(
                params=deploy_params)
            self.__check_address(address=message.address)

            # Deploy address
            process_params = ParamsOfProcessMessage(
                message_encode_params=deploy_params, send_events=False)
            result = async_custom_client.processing.process_message(
                params=process_params)
            debot_address = result.transaction['account_addr']
            addresses.append(debot_address)
            if i > 0:
                continue

            # Set ABI
            call_set = CallSet(
                function_name='setABI',
                input={'dabi': debot_abi.value.encode().hex()})
            async_custom_client.processing.process_message(
                params=ParamsOfProcessMessage(
                    message_encode_params=ParamsOfEncodeMessage(
                        abi=debot_abi, signer=deploy_params.signer,
                        address=debot_address, call_set=call_set),
                    send_events=False))

        return addresses, contract_hash
Пример #10
0
    def send_grams(self,address: str,value:id,signer, bounce: bool,workchaind_id):
        wallet_abi = Abi.from_json_path(
            path=os.path.join(self.SAMPLES_DIR, 'wallet.abi.json'))
        call_set = CallSet(
            function_name='sendTransaction',
            inputs={'dest': address, 'value': value, 'bounce': bounce})

        message_source = MessageSource.from_encoding_params(
            abi=wallet_abi, signer=signer, address=self.get_address(signer,wallet_abi,self.open_tvc('abi/wallet.tvc'),workchaind_id=workchaind_id),
            call_set=call_set)
        self.async_core_client.processing.process_message(
            message=message_source, send_events=False)
Пример #11
0
 def setUp(self) -> None:
     # Events contract params
     self.events_abi = Abi.from_path(
         path=os.path.join(SAMPLES_DIR, 'Events.abi.json'))
     self.keypair = KeyPair(
         public=
         '4c7c408ff1ddebb8d6405ee979c716a14fdd6cc08124107a61d3c25597099499',
         secret=
         'cc8929d635719612a9478b9cd17675a39cfad52d8959e8a177389b8c0b9122a7')
     with open(os.path.join(SAMPLES_DIR, 'Events.tvc'), 'rb') as fp:
         self.events_tvc = base64.b64encode(fp.read()).decode()
     self.events_time = 1599458364291
     self.events_expire = 1599458404
Пример #12
0
    def compile_contract(self):
        if not ".tmp_contract_deployer" in os.listdir():
            os.mkdir(".tmp_contract_deployer")
        f = open(f'.tmp_contract_deployer/.contract.sol','w')
        f.write(self.plainTextEdit.toPlainText())
        f.close()

        home_dir = os.system("solc .tmp_contract_deployer/.contract.sol")
        os.system("tvm_linker compile .contract.code --abi-json .contract.abi.json --lib stdlib_sol.tvm -o .contract.tvc")
        with open(".contract.abi.json","r") as f:
            abi = f.read()
        addr = self.wrapper.get_address(Signer(self.main_key),Abi.from_json_path(
            path='.contract.abi.json'),self.wrapper.open_tvc(".contract.tvc"))
        self.address.setText(QCoreApplication.translate("MainWindow", f"Address of contract: {addr}", None))
        self.addr = addr
        self.update_balance()
        with open(".contract.abi.json") as f:
            data = json.loads(f.read())

        self.create_function(data)
Пример #13
0
    def test_encode_internal_message_deploy(self):
        abi = Abi.from_path(path=os.path.join(SAMPLES_DIR, 'Hello.abi.json'))
        with open(os.path.join(SAMPLES_DIR, 'Hello.tvc'), 'rb') as fp:
            tvc = base64.b64encode(fp.read()).decode()

        result = async_core_client.abi.encode_internal_message(
            params=ParamsOfEncodeInternalMessage(
                abi=abi,
                value='0',
                deploy_set=DeploySet(tvc=tvc),
                call_set=CallSet(function_name='constructor')))
        self.assertEqual(
            'te6ccgECHAEABG0AAmliADYO5IoxskLmUfURre2fOB04OmP32VjPwA/lDM/Cpvh8AAAAAAAAAAAAAAAAAAIxotV8/gYBAQHAAgIDzyAFAwEB3gQAA9AgAEHYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQCJv8A9KQgIsABkvSg4YrtU1gw9KEJBwEK9KQg9KEIAAACASAMCgHo/38h0wABjiaBAgDXGCD5AQFw7UTQ9AWAQPQO8orXC/8B7Ucib3XtVwMB+RDyqN7tRNAg10nCAY4W9ATTP9MA7UcBb3EBb3YBb3MBb3LtV44Y9AXtRwFvcnBvc3BvdsiAIM9AydBvce1X4tM/Ae1HbxMhuSALAGCfMCD4I4ED6KiCCBt3QKC53pntRyFvUyDtVzCUgDTy8OIw0x8B+CO88rnTHwHxQAECASAYDQIBIBEOAQm6i1Xz+A8B+u1Hb2FujjvtRNAg10nCAY4W9ATTP9MA7UcBb3EBb3YBb3MBb3LtV44Y9AXtRwFvcnBvc3BvdsiAIM9AydBvce1X4t7tR28WkvIzl+1HcW9W7VfiAPgA0fgjtR/tRyBvETAByMsfydBvUe1X7UdvEsj0AO1HbxPPCz/tR28WEAAczwsA7UdvEc8Wye1UcGoCAWoVEgEJtAAa1sATAfztR29hbo477UTQINdJwgGOFvQE0z/TAO1HAW9xAW92AW9zAW9y7VeOGPQF7UcBb3Jwb3Nwb3bIgCDPQMnQb3HtV+Le7UdvZSBukjBw3nDtR28SgED0DvKK1wv/uvLgZPgA+kDRIMjJ+wSBA+hwgQCAyHHPCwEizwoAcc9A+CgUAI7PFiTPFiP6AnHPQHD6AnD6AoBAz0D4I88LH3LPQCDJIvsAXwUw7UdvEsj0AO1HbxPPCz/tR28WzwsA7UdvEc8Wye1UcGrbMAEJtGX2i8AWAfjtR29hbo477UTQINdJwgGOFvQE0z/TAO1HAW9xAW92AW9zAW9y7VeOGPQF7UcBb3Jwb3Nwb3bIgCDPQMnQb3HtV+Le0e1HbxHXCx/IghBQy+0XghCAAAAAsc8LHyHPCx/Ic88LAfgozxZyz0D4Jc8LP4Ahz0AgzzUizzG8FwB4lnHPQCHPF5Vxz0EhzeIgyXH7AFshwP+OHu1HbxLI9ADtR28Tzws/7UdvFs8LAO1HbxHPFsntVN5xatswAgEgGxkBCbtzEuRYGgD47UdvYW6OO+1E0CDXScIBjhb0BNM/0wDtRwFvcQFvdgFvcwFvcu1Xjhj0Be1HAW9ycG9zcG92yIAgz0DJ0G9x7Vfi3vgA0fgjtR/tRyBvETAByMsfydBvUe1X7UdvEsj0AO1HbxPPCz/tR28WzwsA7UdvEc8Wye1UcGrbMADK3XAh10kgwSCOKyDAAI4cI9Bz1yHXCwAgwAGW2zBfB9swltswXwfbMOME2ZbbMF8G2zDjBNngItMfNCB0uyCOFTAgghD/////uiCZMCCCEP////6639+W2zBfB9sw4CMh8UABXwc=',
            result.message)

        boc_hash = async_core_client.boc.get_boc_hash(
            params=ParamsOfGetBocHash(boc=result.message))
        self.assertEqual(result.message_id, boc_hash.hash)

        parsed = async_core_client.boc.parse_message(params=ParamsOfParse(
            boc=result.message))
        code = async_core_client.boc.get_code_from_tvc(
            params=ParamsOfGetCodeFromTvc(tvc=tvc))
        self.assertEqual(code.code, parsed.parsed['code'])
Пример #14
0
    def test_suspend_resume(self):
        # Data for contract deployment
        keypair = async_custom_client.crypto.generate_random_sign_keys()
        abi = Abi.from_path(path=os.path.join(SAMPLES_DIR, 'Hello.abi.json'))
        with open(os.path.join(SAMPLES_DIR, 'Hello.tvc'), 'rb') as fp:
            tvc = base64.b64encode(fp.read()).decode()
        signer = Signer.Keys(keys=keypair)
        deploy_set = DeploySet(tvc=tvc)
        call_set = CallSet(function_name='constructor')

        # Prepare deployment params
        encode_params = ParamsOfEncodeMessage(
            abi=abi, signer=signer, deploy_set=deploy_set, call_set=call_set)
        encode = async_custom_client.abi.encode_message(params=encode_params)

        # Subscribe for address deploy transaction status
        transactions = []

        def __callback(response_data, response_type, *args):
            if response_type == SubscriptionResponseType.OK:
                result = ResultOfSubscription(**response_data)
                transactions.append(result.result)
                self.assertEqual(encode.address, result.result['account_addr'])
            if response_type == SubscriptionResponseType.ERROR:
                logging.info(ClientError(**response_data).__str__())

        subscribe_params = ParamsOfSubscribeCollection(
            collection='transactions', result='id account_addr',
            filter={'account_addr': {'eq': encode.address}, 'status_name': {'eq': 'Finalized'}})
        subscribe = async_custom_client.net.subscribe_collection(
            params=subscribe_params, callback=__callback)

        # Send grams to new account to create first transaction
        send_grams(address=encode.address)
        # Give some time for subscription to receive all data
        time.sleep(2)

        # Suspend subscription
        async_custom_client.net.suspend()
        time.sleep(2)  # Wait a bit for suspend

        # Deploy to create second transaction.
        # Use another client, because of error: Fetch first block failed:
        # Can not use network module since it is suspended
        second_config = ClientConfig()
        second_config.network.server_address = CUSTOM_BASE_URL
        second_client = TonClient(config=second_config)

        process_params = ParamsOfProcessMessage(
            message_encode_params=encode_params, send_events=False)
        second_client.processing.process_message(params=process_params)
        second_client.destroy_context()

        # Check that second transaction is not received when
        # subscription suspended
        self.assertEqual(1, len(transactions))

        # Resume subscription
        async_custom_client.net.resume()
        time.sleep(2)  # Wait a bit for resume

        # Run contract function to create third transaction
        call_set = CallSet(function_name='touch')
        encode_params = ParamsOfEncodeMessage(
            abi=abi, signer=signer, address=encode.address, call_set=call_set)
        process_params = ParamsOfProcessMessage(
            message_encode_params=encode_params, send_events=False)
        async_custom_client.processing.process_message(params=process_params)

        # Give some time for subscription to receive all data
        time.sleep(2)

        # Check that third transaction is now received after resume
        self.assertEqual(2, len(transactions))
        self.assertNotEqual(transactions[0]['id'], transactions[1]['id'])

        # Unsubscribe
        async_custom_client.net.unsubscribe(params=subscribe)
Пример #15
0
 def setUp(self) -> None:
     self.events_abi = Abi.from_json_path(
         path=os.path.join(SAMPLES_DIR, 'Events.abi.json'))
     with open(os.path.join(SAMPLES_DIR, 'Events.tvc'), 'rb') as fp:
         self.events_tvc = base64.b64encode(fp.read()).decode()
     self.deploy_set = DeploySet(tvc=self.events_tvc)
Пример #16
0
 def deploy_wallet(self,signer):
     return self.deploy_contract(abi=Abi.from_json_path(
         path=os.path.join(self.SAMPLES_DIR, 'wallet.abi.json')),tvc=self.open_tvc('abi/wallet.tvc'),signer=signer)
Пример #17
0
    def __init_debot_pair(self, keypair: KeyPair) -> Tuple[str, str]:
        signer = Signer.Keys(keys=keypair)
        debot_a_abi = Abi.from_path(
            path=os.path.join(SAMPLES_DIR, 'DebotPairA.abi.json'))
        with open(os.path.join(SAMPLES_DIR, 'DebotPairA.tvc'), 'rb') as fp:
            debot_a_tvc = base64.b64encode(fp.read()).decode()

        debot_b_abi = Abi.from_path(
            path=os.path.join(SAMPLES_DIR, 'DebotPairB.abi.json'))
        with open(os.path.join(SAMPLES_DIR, 'DebotPairB.tvc'), 'rb') as fp:
            debot_b_tvc = base64.b64encode(fp.read()).decode()

        # Deploy debot B
        call_set = CallSet(function_name='constructor')
        deploy_set = DeploySet(tvc=debot_b_tvc)
        encode_params = ParamsOfEncodeMessage(
            abi=debot_b_abi, signer=signer, deploy_set=deploy_set,
            call_set=call_set)
        message = async_custom_client.abi.encode_message(params=encode_params)
        b_address = message.address

        self.__check_address(address=b_address)
        process_params = ParamsOfProcessMessage(
            message_encode_params=encode_params, send_events=False)
        debot_b = async_custom_client.processing.process_message(
            params=process_params)
        b_address = debot_b.transaction['account_addr']

        # Set ABI
        call_set = CallSet(
            function_name='setAbi',
            input={'debotAbi': debot_b_abi.value.encode().hex()})
        async_custom_client.processing.process_message(
            params=ParamsOfProcessMessage(
                message_encode_params=ParamsOfEncodeMessage(
                    abi=debot_b_abi, signer=signer, address=b_address,
                    call_set=call_set),
                send_events=False))

        # Deploy debot A
        call_set = CallSet(
            function_name='constructor', input={
                'targetAddr': b_address
            })
        deploy_set = DeploySet(tvc=debot_a_tvc)
        encode_params = ParamsOfEncodeMessage(
            abi=debot_a_abi, signer=signer, deploy_set=deploy_set,
            call_set=call_set)
        message = async_custom_client.abi.encode_message(params=encode_params)
        a_address = message.address

        self.__check_address(address=a_address)
        process_params = ParamsOfProcessMessage(
            message_encode_params=encode_params, send_events=False)
        debot_a = async_custom_client.processing.process_message(
            params=process_params)
        a_address = debot_a.transaction['account_addr']

        # Set ABI
        call_set = CallSet(
            function_name='setAbi',
            input={'debotAbi': debot_a_abi.value.encode().hex()})
        async_custom_client.processing.process_message(
            params=ParamsOfProcessMessage(
                message_encode_params=ParamsOfEncodeMessage(
                    abi=debot_a_abi, signer=signer, address=a_address,
                    call_set=call_set),
                send_events=False))

        return a_address, b_address
Пример #18
0
    def __init_debot4(self, keypair: KeyPair) -> Tuple[str, str]:
        signer = Signer.Keys(keys=keypair)
        debot_abi = Abi.from_path(
            path=os.path.join(SAMPLES_DIR, 'Debot4.abi.json'))
        with open(os.path.join(SAMPLES_DIR, 'Debot4.tvc'), 'rb') as fp:
            debot_tvc = base64.b64encode(fp.read()).decode()

        # Init target
        call_set = CallSet(function_name='constructor')
        deploy_set = DeploySet(tvc=self.target_tvc)
        encode_params = ParamsOfEncodeMessage(
            abi=self.target_abi, signer=signer, deploy_set=deploy_set,
            call_set=call_set)
        message = async_custom_client.abi.encode_message(params=encode_params)
        target_address = message.address
        self.__check_address(address=target_address)

        # Deploy debot
        call_set = CallSet(
            function_name='constructor', input={
                'targetAbi': self.target_abi.value.encode().hex(),
                'targetAddr': target_address
            })
        deploy_set = DeploySet(tvc=debot_tvc)
        encode_params = ParamsOfEncodeMessage(
            abi=debot_abi, signer=signer, deploy_set=deploy_set,
            call_set=call_set)
        message = async_custom_client.abi.encode_message(params=encode_params)

        # Check if debot contract does not exists
        debot_address = self.__check_address(address=message.address)
        if not debot_address:
            process_params = ParamsOfProcessMessage(
                message_encode_params=encode_params, send_events=False)
            debot = async_custom_client.processing.process_message(
                params=process_params)
            debot_address = debot.transaction['account_addr']

            # Set ABI
            call_set = CallSet(
                function_name='setAbi',
                input={'debotAbi': debot_abi.value.encode().hex()})
            async_custom_client.processing.process_message(
                params=ParamsOfProcessMessage(
                    message_encode_params=ParamsOfEncodeMessage(
                        abi=debot_abi, signer=signer, address=debot_address,
                        call_set=call_set),
                    send_events=False))

            # Set image
            call_set = CallSet(
                function_name='setImage',
                input={
                    'image': self.target_tvc,
                    'pubkey': f'0x{keypair.public}'
                })
            async_custom_client.processing.process_message(
                params=ParamsOfProcessMessage(
                    message_encode_params=ParamsOfEncodeMessage(
                        abi=debot_abi, signer=signer, address=debot_address,
                        call_set=call_set),
                    send_events=False))

        return debot_address, target_address
Пример #19
0
 def compile(self):
     m = QMessageBox.about(self,"Deploying...","Please wait for a while. Dont press any button")
     result = self.wrapper.deploy_contract(abi=Abi.from_json_path(
         path='.contract.abi.json'),tvc=self.wrapper.open_tvc('.contract.tvc'),signer=Signer(self.main_key))
     m.setText(str(result))
Пример #20
0
 def _ABI(name):
     return Abi.from_path(Path.cwd() / 'core' / 'package' / 'ton' / 'abi' / f'{name}.abi.json')