def get_contract(path): if path is None: files = glob('*.tz') assert len(files) == 1 contract = ContractInterface.from_file(abspath(files[0])) elif exists(path): contract = ContractInterface.from_file(path) else: network, address = path.split(':') contract = pytezos.using(shell=network).contract(address) return contract
def get_contract(path): if path is None: files = glob('*.tz') if len(files) != 1: raise Exception('No contracts found in working directory, specify --path implicitly') contract = ContractInterface.from_file(abspath(files[0])) elif exists(path): contract = ContractInterface.from_file(path) else: network, address = path.split(':') contract = pytezos.using(shell=network).contract(address) return contract
def __init__(self, client: PyTezosClient): self.client = client root_dir = Path(__file__).parent.parent / "michelson" self.minter_contract = ContractInterface.from_file(root_dir / "minter.tz") self.quorum_contract = ContractInterface.from_file(root_dir / "quorum.tz") self.fa2_contract = ContractInterface.from_file(root_dir / "multi_asset.tz") self.nft_contract = ContractInterface.from_file(root_dir / "nft.tz") self.governance_contract = ContractInterface.from_file( root_dir / "governance_token.tz")
def test_increment_decrement(self): counter = ContractInterface.from_file(join(dirname(__file__), 'contracts', 'macro_counter.tz')) res = counter.increaseCounterBy(5).interpret(storage=0) self.assertEqual(res.storage, 5) res = counter.decreaseCounterBy(5).interpret(storage=0) self.assertEqual(res.storage, -5)
def get_contract(path): path = get_local_contract_path(path) if path: contract = ContractInterface.from_file(path) else: network, address = path.split(':') contract = pytezos.using(shell=network).contract(address) return contract
def test_none_vs_unit(self): ci = ContractInterface.from_file(join(dirname(__file__), 'contracts', 'none_vs_unit.tz')) res = ci.callAnotherContract().interpret(storage=None) self.assertEqual(0, len(res.operations)) res = ci.callAnotherContract('KT1VG2WtYdSWz5E7chTeAdDPZNy2MpP8pTfL').interpret(storage=None) self.assertEqual(1, len(res.operations)) res = ci.doNothing().interpret(storage=None) self.assertEqual(Unit, res.storage)
def test_mint(self): token_v3 = ContractInterface.from_file(join(dirname(__file__), 'contracts', 'token.tz')) alice = "tz1ibMpWS6n6MJn73nQHtK5f4ogyYC1z9T9z" res = token_v3 \ .mint(mintOwner=alice, mintValue=3) \ .interpret( storage={ "admin": alice, "balances": {}, "paused": False, "shareType": "APPLE", "totalSupply": 0 }, source=alice) self.assertEqual(3, res.storage['balances'][alice])
def test_concat(self): concat = ContractInterface.from_file( join(dirname(__file__), 'contracts', 'default_entrypoint.tz')) res = concat.default('bar').interpret(storage='foo') self.assertEqual('foobar', res.storage)
def test_increment(self): counter = ContractInterface.from_file( join(dirname(__file__), 'contracts', 'counter.tz')) res = counter.default('deadbeef').interpret(storage=[{}, 0]) self.assertEqual(1, res.storage[1]) self.assertIn(bytes.fromhex('deadbeef'), res.storage[0])
def test_docstring(self): ci = ContractInterface.from_file( join(dirname(__file__), 'contracts', 'macro_counter.tz')) print(ci.increaseCounterBy) self.assertFalse(is_interactive())
def setUpClass(cls): cls.mac = ContractInterface.from_file(join(dirname(__file__), 'contracts', 'mac.tz')) cls.maxDiff = None
if args.shell: pytezos = pytezos.using(shell=args.shell) print("Connecting to edo2net via: " + args.shell) cust_json = args.cust merch_json = args.merch # Set customer and merch pytezos interfaces cust_py = pytezos.using(key=cust_json) cust_addr = read_json_file(cust_json)['pkh'] merch_py = pytezos.using(key=merch_json) merch_addr = read_json_file(merch_json)['pkh'] # load cust_close json from libzkchannels cust_close_json = read_json_file('sample_cust_close.json') # load zchannel contracts main_code = ContractInterface.from_file('zkchannel_contract.tz') # Activate cust and merch testnet accounts try: print("Activating cust account") cust_py.activate_account().fill().sign().inject() except: print("Cust account already activated") try: print("Revealing cust pubkey") out = cust_py.reveal().autofill().sign().inject() except: pass cust_pubkey = cust_py.key.public_key()
# Bootstrap1 (cust) sk # edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh # Bootstrap2 (merch) sk # edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo from pytezos import pytezos from pytezos import Contract from pytezos import ContractInterface pssig_code = ContractInterface.from_file('mock_pssig3.tz') out = pytezos.using( shell='http://localhost:18731', key='edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh').origination( script=pssig_code.script()).autofill(branch_offset=1).sign().inject() input( "Bake to confirm origination of pssig contract, then hit enter continue.") opg = pytezos.using( shell='http://localhost:18731', key='edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh' ).shell.blocks[-5:].find_operation(out['hash']) pssig_id = opg['contents'][0]['metadata']['operation_result'][ 'originated_contracts'][0] main_code = ContractInterface.from_file('zkchannel_mock_ps3.tz') main_storage = {
def test_top_field_annot(self): ci = ContractInterface.from_file(join(dirname(__file__), 'contracts', 'top_field_annot.tz')) print(ci.buyTicket)
def setUpClass(cls): cls.nft = ContractInterface.from_file(join(dirname(__file__), 'contracts', 'nft.tz'))
def test_compare_enum(self): contract = ContractInterface.from_file( join(dirname(__file__), 'contracts', 'compare_enum.tz')) contract.call().interpret()
def __init__(self, client: PyTezosClient): self.client = client root_dir = Path(__file__).parent.parent / "michelson" self.staking_contract = ContractInterface.from_file(root_dir / "staking.tz") self.reserve_contract = ContractInterface.from_file(root_dir / "reserve.tz")