This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
cli.js.map
1 lines (1 loc) · 10.4 KB
/
cli.js.map
1
{"version": 3, "mappings": "AAAA,QAAA,IAAA;AACA,QAAA,OAAA,EAAA,OAAA,EAAA,IAAA;AACA,QAAA,MAAA;;AAGA,QAAA,QAAA,EAAA,QAAA,EAAA,OAAA;AACA,QAAA,kBAAA;AACA,QAAA,eAAA;AACA,QAAA,iBAAA,EAAA,wBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;IACIA,MAAM,CACF,aADE,EACa,UADb,EAEF,YAFE,EAEY,SAFZ,EAGF,YAHE,EAGY,SAHZ,EAIF,SAJE,EAIS,MAJT,EAKF,SALE,EAKS,SALT;IAON,OAAO;AARX;AAWA;;IACI,IAAG,CAAAC,IAAA,IAAA,CAAQ,IAAR,CAAH;QACIC,QAAQC,IAAA,CAAK,MAAL;mBACR,CAAO,CAAID,KAAJE,OAAA,IAAA,CAAc,CAAd,CAAP,MAAA;QACAC,WAAWC,QAAAC,UAAA,CAAmBC,OAAA,CAAQN,KAAA,CAAM,CAAN,CAAR,CAAnB;IAHf;QAKK,IAAAO,GAAA,CAAIC,GAAA,yCAAI,CAAJ,EAAkC,CAAC,SAAD,EAAY,YAAZ,EAA0B,SAA1B,EAAqC,aAArC,CAAlC,CAAJ,CAAA;;;YACD,CAAAC,OAAA,EAASC,OAAT,IAAmBX,IAAAY,MAAA,CAAW,GAAX;YACnBC,MAAMC,OAAAC,MAAA,WAAoBL,QAApB;YACNM,SAASH,GAAAI,MAAAC,UAAA,CAAoBP,OAApB,CAAAQ,OAAA;YACTf,WAAWC,QAAAe,eAAA,CAAwBJ,MAAA,CAAO,MAAP,CAAxB;QAJV;YAODZ,WAAWC,QAAAC,UAAA,CAAmBN,IAAnB;QAPV;IALL;IAcA,OAAOI;AAfX;AAkBA,gBAAA;IAEI,uBAA+B,IAA/B;QAIJ;QAAA;QAAA;QAAA;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4BACI8C,SAJzC;gBAKT9B,MAAA,CAAOoC,MAAP;YATJ;QAnBJ;8BAUOzB;gBACHX,MAAA,CAAOY,CAAP;gBACAC,IAAA,CAAK,EAAA,CAAC,CAAD,CAAL;;;;QAZJ;IAnBJ;AA5DJ;AA8GA;IACI,OAAO,IAAAyB,IAAAC,KAAA,CAAUC,UAAV;AADX;AAIA,IAAG,CAAAC,QAAA,IAAA,CAAY,UAAZ,CAAH;IACIC,IAAA;AADJ", "sources": ["cli.py"], "names": ["net", "path", "files", "glob", "files.length", "contract", "Contract", "Contract.from_file", "abspath", "any", "map", "network", "address", "path.split", "ptz", "pytezos", "pytezos.using", "script", "ptz.shell", "ptz.shell.contracts", "ptz.shell.contracts[address].script", "Contract.from_micheline", "get_contract", "action", "generate_docstring", "contract.storage", "contract.storage.schema", "pprint", "contract.storage[\"default\"]", "contract.parameter", "contract.parameter.schema", "ptz.balance", "opg", "ptz.activate_account", "ptz.activate_account().autofill", "ptz.activate_account().autofill().sign", "opg.json_payload", "opg.inject", "RpcError", "e", "exit", "ptz.reveal", "ptz.reveal().autofill", "ptz.reveal().autofill().sign", "key", "storage", "contract.storage.encode", "ptz.origination", "contract.script", "ptz.origination({\"script\": contract.script({\"storage\": storage})}).autofill", "ptz.origination({\"script\": contract.script({\"storage\": storage})}).autofill().sign", "dry_run", "opg.preapply", "originated_contracts", "OperationResult", "OperationResult.originated_contracts", "originated_contracts.length", "bcd_link", "make_bcd_link", "github_repo_slug", "deployment", "create_deployment", "github_oauth_token", "status", "create_deployment_status", "fire", "fire.Fire", "PyTezosCli", "__name__", "main"], "sourcesContent": ["from glob import glob\nfrom os.path import abspath, dirname, join\nfrom pprint import pprint\nimport fire\n\nfrom pytezos import pytezos, Contract, RpcError\nfrom pytezos.michelson.docstring import generate_docstring\nfrom pytezos.operation.result import OperationResult\nfrom pytezos.tools.github import create_deployment, create_deployment_status\n\nkernel_js_path = join(dirname(dirname(__file__)), 'assets', 'kernel.js')\nkernel_json = {\n \"argv\": ['pytezos', 'kernel', 'run', \"-file\", \"{connection_file}\"],\n \"display_name\": \"Michelson\",\n \"language\": \"michelson\",\n \"codemirror_mode\": \"michelson\"\n}\n\n\ndef make_bcd_link(network, address):\n net = {\n 'carthagenet': 'carthage',\n 'babylonnet': 'babylon',\n 'sandboxnet': 'sandbox',\n 'mainnet': 'main',\n 'zeronet': 'zeronet'\n }\n return f'https://better-call.dev/{net[network]}/{address}'\n\n\ndef get_contract(path):\n if path is None:\n files = glob('*.tz')\n assert len(files) == 1\n contract = Contract.from_file(abspath(files[0]))\n\n elif any(map(lambda x: path.startswith(x), ['zeronet', 'babylonnet', 'mainnet', 'carthagenet'])):\n network, address = path.split(':')\n ptz = pytezos.using(shell=network)\n script = ptz.shell.contracts[address].script()\n contract = Contract.from_micheline(script['code'])\n\n else:\n contract = Contract.from_file(path)\n\n return contract\n\n\nclass PyTezosCli:\n\n def storage(self, action, path=None):\n \"\"\"\n :param action: One of `schema`, `default`\n :param path: Path to the .tz file, or the following uri: <network>:<KT-address>\n \"\"\"\n contract = get_contract(path)\n if action == 'schema':\n print(generate_docstring(contract.storage.schema, title='storage'))\n elif action == 'default':\n pprint(contract.storage.default())\n else:\n assert False, action\n\n def parameter(self, action, path=None):\n \"\"\"\n :param action: One of `schema`\n :param path: Path to the .tz file, or the following uri: <network>:<KT-address>\n \"\"\"\n contract = get_contract(path)\n if action == 'schema':\n print(generate_docstring(contract.parameter.schema, title='parameter'))\n else:\n assert False, action\n\n def activate(self, path, network='carthagenet'):\n \"\"\"\n Activates and reveals key from the faucet file\n :param path: Path to the .json file downloaded from https://faucet.tzalpha.net/\n :param network: Default is Babylonnet\n \"\"\"\n ptz = pytezos.using(key=path, shell=network)\n print(f'Activating {ptz.key.public_key_hash()} in the {network}')\n\n if ptz.balance() == 0:\n try:\n opg = ptz.activate_account().autofill().sign()\n print(f'Injecting activation operation:')\n pprint(opg.json_payload())\n opg.inject(_async=False)\n except RpcError as e:\n pprint(e)\n exit(-1)\n else:\n print(f'Activation succeeded! Claimed balance: {ptz.balance()} \ua729')\n else:\n print('Already activated')\n\n try:\n opg = ptz.reveal().autofill().sign()\n print(f'Injecting reveal operation:')\n pprint(opg.json_payload())\n opg.inject(_async=False)\n except RpcError as e:\n pprint(e)\n exit(-1)\n else:\n print(f'Your key {ptz.key.public_key_hash()} is now active and revealed')\n\n def deploy(self, path, storage=None, network='carthagenet', key=None,\n github_repo_slug=None, github_oauth_token=None, dry_run=False):\n \"\"\"\n Deploy contract to the specified network\n :param path: Path to the .tz file\n :param storage: Storage in JSON format (not Micheline)\n :param network:\n :param key:\n :param github_repo_slug:\n :param github_oauth_token:\n :param dry_run: Set this flag if you just want to see what would happen\n \"\"\"\n ptz = pytezos.using(shell=network, key=key)\n print(f'Deploying contract using {ptz.key.public_key_hash()} in the {network}')\n\n contract = get_contract(path)\n if storage is not None:\n storage = contract.storage.encode(storage)\n\n try:\n opg = ptz.origination(script=contract.script(storage=storage)).autofill().sign()\n print(f'Injecting origination operation:')\n pprint(opg.json_payload())\n\n if dry_run:\n pprint(opg.preapply())\n exit(0)\n else:\n opg = opg.inject(_async=False)\n except RpcError as e:\n pprint(e)\n exit(-1)\n else:\n originated_contracts = OperationResult.originated_contracts(opg)\n assert len(originated_contracts) == 1\n bcd_link = make_bcd_link(network, originated_contracts[0])\n print(f'Contract was successfully deployed: {bcd_link}')\n\n if github_repo_slug:\n deployment = create_deployment(github_repo_slug, github_oauth_token,\n environment=network)\n pprint(deployment)\n status = create_deployment_status(github_repo_slug, github_oauth_token,\n deployment_id=deployment['id'],\n state='success',\n environment=network,\n environment_url=bcd_link)\n pprint(status)\n\n\ndef main():\n return fire.Fire(PyTezosCli)\n\n\nif __name__ == '__main__':\n main()\n"]}