def autoDeploy(self): self.Wallet.Rebuild() function_code = LoadContract([neo_fund_avm, '0710', '05', 'True']) self.contract_script = generate_deploy_script( function_code.Script, 'NeoFund', str(int(time.time())), 'Nick', '*****@*****.**', 'auto deploy', True, ord(function_code.ReturnType), function_code.ParameterList) if self.contract_script is not None: self.neo_fund_sc = function_code.ToJson()['hash'] # self.neo_fund_sc_addr = ImportContractAddr(self.Wallet, [self.neo_fund_sc, test_pub_addr]).Address print('SC Hash: ', self.neo_fund_sc) # print('SC Addr: ', self.neo_fund_sc_addr) return self.contract_script
def echo_post(request): if walletinfo.Wallet is None: wallethandler() #print("Wallet %s " % json.dumps(walletinfo.Wallet.ToJson(), indent=4) #print("Wallet %s " % json.dumps(walletinfo.Wallet.ToJson(), indent=4)) #return json.dumps(walletinfo.Wallet.ToJson(), indent=4) body = json.loads(request.content.read().decode('utf-8')) print('2 ----2 -> Incomming Body %s' % body) returnvalue = 'Issue in creating wallet.Please try manual approach' failed_data = { "status": "failed", "reason": "Contract Not Deployed due to issues such as **smart_contract_location: not ending with .py and/or .avm .smart_contract_location link might not be raw url.Click raw button on your github file to get the correct url**. Issue might also be caused by insufficient balance in the wallet.Please try manual approach or chat with @sharedmocha#8871 on discord." } hash_json_failed = failed_data if (body['is_the_file__smartcontract_or_avm'] == "sc"): print("SMART CONTRACT ------- IN") sc_location = body['smart_contract_location'] r = requests.get(sc_location, allow_redirects=True) localtime = str(time.time()) # this removes the decimals temp_filename = localtime + sc_location filename = re.sub('[^ a-zA-Z0-9]', '', temp_filename) path = '/home/ubuntu/' + filename scname = path + '.py' avmname = '/' + path + '.avm' try: open(scname, 'wb').write(r.content) sc_args = [] sc_args.append(scname) BuildAndRun(sc_args, walletinfo.Wallet) except Exception as e: print('Exception creating file: %s' % e) return 'Issue Downloading and Saving your smart contract.Please try manual approach' else: sc_location = body['smart_contract_location'] r = requests.get(sc_location, allow_redirects=True) localtime = str(time.time()) # this removes the decimals temp_filename = localtime + sc_location filename = re.sub('[^ a-zA-Z0-9]', '', temp_filename) path = '/home/ubuntu/' + filename scname = path + '.py' avmname = '/' + path + '.avm' try: open(avmname, 'wb').write(r.content) except Exception as e: print('Exception creating file: %s' % e) return 'Issue Downloading and Saving your smart contract avm file.Please try manual approach' # Deploy samrt contract .... try: if (body['password'] != "nosforall"): return { "status": "failed", "reason": "Incorrect Password Provided." } args = [] args.append("contract") args.append(avmname) args.append(body['input_type']) args.append(body['output_type']) args.append(body['does_smart_contract_needsstorage']) args.append(body['does_smart_contract_needsdynamicinvoke']) args, from_addr = get_from_addr(args) function_code = LoadContract(args[1:]) failed_data = { "status": "failed", "reason": "Contract Not Deployed due to issues (or) Insufficient Balance.Please try manual approach." } function_code_json = function_code.ToJson() sc_hash = function_code_json['hash'] success_data = { "status": "success", "hash": sc_hash, "details": "Wait for few minutes before you try invoke on your smart contract." } hash_json_success = success_data userinputs_args = [] userinputs_args.append(body['smart_contract_name']) userinputs_args.append(body['smart_contract_version']) userinputs_args.append(body['smart_contract_author']) userinputs_args.append(body['smart_contract_creator_email']) userinputs_args.append(body['smart_contract_description']) if function_code: contract_script = GatherContractDetails(function_code, userinputs_args) if contract_script is not None: tx, fee, results, num_ops = test_invoke(contract_script, walletinfo.Wallet, [], from_addr=from_addr) if tx is not None and results is not None: print( "\n-------------------------------------------------------------------------------------------------------------------------------------" ) print("Test deploy invoke successful") print("Total operations executed: %s " % num_ops) print("Results:") print([item.GetInterface() for item in results]) print("Deploy Invoke TX GAS cost: %s " % (tx.Gas.value / Fixed8.D)) print("Deploy Invoke TX Fee: %s " % (fee.value / Fixed8.D)) print( "-------------------------------------------------------------------------------------------------------------------------------------\n" ) result = InvokeContract(walletinfo.Wallet, tx, Fixed8.Zero(), from_addr=from_addr) if result: return hash_json_success else: #return hash_json_failed return hash_json_failed #return result else: print("Test invoke failed") print("TX is %s, results are %s" % (tx, results)) return hash_json_failed except Exception as e: # print("Pubkey %s" % key.PublicKey.encode_point(True)) print('Exception creating wallet: %s' % e) walletinfo.Wallet = None return hash_json_failed # Open and Replace Wallet # Echo it # test return {'post-body': returnvalue}