def deploy_contract(web3, sol_path, address): from solc import compile_standard file_name = get_file_name(sol_path) clz_name = file_name.replace('.sol', '') sol_content = read_file_content(sol_path) # 編譯 compiled_sol = compile_standard({ 'language': 'Solidity', 'sources': { file_name: { 'content': sol_content } }, 'settings': { 'outputSelection': { "*": { "*": ["metadata", "evm.bytecode", "evm.bytecode.sourceMap"] } } } }) bytecode = compiled_sol['contracts'][file_name][clz_name]['evm'][ 'bytecode']['object'] abi = json.loads(compiled_sol['contracts'][file_name][clz_name] ['metadata'])['output']['abi'] # # pre_contract = web3.eth.contract(abi=abi, bytecode=bytecode) # # # 設定部署的帳號 # pri_key = '413AE44638D2CECC9B5137EC4A9657083C2DF0BBDD1E1105574A3F8EB75F0C81' # account = web3.eth.account.privateKeyToAccount(pri_key) # # # 傳遞建構式參數 # transaction = pre_contract.constructor(10000, 'WToken3', 'WToken3').buildTransaction( # { # 'gasPrice': web3.toWei('10', 'gwei'), # 'from': account.address, # 'nonce': web3.eth.getTransactionCount(account.address) # } # ) # # signed_txn = web3.eth.account.signTransaction(transaction, private_key=pri_key) # data = web3.eth.sendRawTransaction(signed_txn.rawTransaction) # # print(data) # print(data.hex()) contract = web3.eth.contract( address= '890e85693d7060d7277bb51facb2d2b69311198e3d5157db59cfc0f8e210c426', abi=abi) functions = Web3Client.get_functions(contract) print(functions) pass
def init(): global PROJECTS_ROOT_DIR, USERS_ROOT_DIR config_json = json.loads( file_utils.read_file_content(path.join(ROOT_PATH, "config.json"))) # initialize storage settings PROJECTS_ROOT_DIR = config_json[ConfigKeys.projects_root_dir] storage_facade.PROJECTS_ROOT_DIR = PROJECTS_ROOT_DIR USERS_ROOT_DIR = config_json[ConfigKeys.users_root_dir] storage_facade.USERS_ROOT_DIR = USERS_ROOT_DIR
def test_copy_nels_to_sbi(nels_id): feed_utils.heading("copy use case nels to sbi. nels_id: %s" % nels_id) credentail = ssh_utils.get_ssh_credentials(nels_id) if not credentail: feed_utils.failed("fetching key") return False feed_utils.ok("ssh key fetched") (host, username, key_file) = credentail test_file = "dummy5.txt" src_dir = "Personal" src_file = "%s/%s" % (src_dir, test_file) dest_dir = '' if not ssh_utils.write_dummy_file(key_file, username, host, src_file, "5k"): # 5M feed_utils.failed("write test file") return False feed_utils.ok("write test file") dataset_id = "c16ff090-605d-4228-a8c9-3713a9a40e45" dataset_name = "regtest1feb" subtype = "Intensities" subtype_id = 1124874 job_id = job.add_sbi_job(job.SBI_PULL, nels_id, [test_file], [], host, username, file_utils.read_file_content(key_file), dataset_id, dataset_name, subtype, subtype_id, src_dir, "") if job_id == -1: feed_utils.failed("job submission") return False feed_utils.ok("job submission. job-id: %s" % job_id) job.wait_for_job(job_id) # validate file (to do) # clean up if not job.delete_job(job_id): feed_utils.failed("job delete") return False feed_utils.ok("job delete") # clean up on NeLS side [exit_code, output, error] = run_utils.launch_remote_with_key(key_file, username, host, "rm -rf %s " % (src_file)) if exit_code != 0: feed_utils.error(error) return False feed_utils.ok("clean up") return True
def init(): config_json = json.loads( file_utils.read_file_content(path.join(ROOT_PATH, "config.json"))) # initialize master api settings nels_master_api.API_URL = config_json[ConfigKeys.master_api_url] nels_master_api.CLIENT_KEY = config_json[ConfigKeys.master_api_client_key] nels_master_api.CLIENT_SECRET = config_json[ ConfigKeys.master_api_client_secret] #initialize storage settings storage_facade.PROJECTS_ROOT_DIR = config_json[ ConfigKeys.projects_root_dir] storage_facade.USERS_ROOT_DIR = config_json[ConfigKeys.users_root_dir]
def configure(): global PORT, ENCRYPTION_KEY, PORTAL_URL, CLIENT_CREDENTIAL_CLIENTS, IMPLICIT_CLIENTS config_pth = path.join(ROOT_DIR, "config.json") if not path.exists(config_pth): run_utils.exit_fail("missing configuration file") config_json = json.loads(file_utils.read_file_content(config_pth)) feed_utils.info(config_json) PORT = int(config_json[ConfigKeys.port]) ENCRYPTION_KEY = config_json[ConfigKeys.encrytion_key] PORTAL_URL = config_json[ConfigKeys.portal_url] CLIENT_CREDENTIAL_CLIENTS = config_json[ ConfigKeys.oauth2_client_credentail_clients] IMPLICIT_CLIENTS = config_json[ConfigKeys.oauth2_implicit_clients]
def init(): global API_URL, API_KEY, API_SECRET, STORAGE_URL, STORAGE_KEY, STORAGE_SECRET, SBI_URL, SBI_KEY, SBI_SECRET config_json = json.loads( file_utils.read_file_content(path.join(ROOT_PATH, "config.json"))) API_URL = config_json[ConfigKeys.API_URL] API_KEY = config_json[ConfigKeys.API_KEY] API_SECRET = config_json[ConfigKeys.API_SECRET] STORAGE_URL = config_json[ConfigKeys.STORAGE_URL] STORAGE_KEY = config_json[ConfigKeys.STORAGE_KEY] STORAGE_SECRET = config_json[ConfigKeys.STORAGE_SECRET] SBI_URL = config_json[ConfigKeys.SBI_URL] SBI_KEY = config_json[ConfigKeys.SBI_KEY] SBI_SECRET = config_json[ConfigKeys.SBI_SECRET] feed_utils.NOTIFY_TO = [config_json[ConfigKeys.NOTIFY_TO]] if ',' not in config_json[ConfigKeys.NOTIFY_TO] else \ config_json[ConfigKeys.NOTIFY_TO].split(',')