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)
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)
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))
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)
def setUp(self) -> None: # Events contract params self.events_abi = Abi.from_json_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
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)
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)
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))
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)