smart contract 3

in #smart6 years ago

{
"contractName": "contract",
"contractAction": "deploy",
"contractPayload": {
"name": "epic_smart_contract",
"code": "Y29uc3QgTUFYX1NVUFBMWSA9IDgwMDAwMDAwMDAgLy84YmlsbGlvbgpjb25zdCBIQUxGX1JBVEUgPSAwLjEgLy8gMTAlCmNvbnN0IFNUQVJUX1ZPTCA9IDEwMCAvLyAxMDAKY29uc3QgU1RBUlRfVk9MX09XTiA9IDY2LjY3IC8vIAovLyB0b2tlbnMgY29udHJhY3QKYWN0aW9ucy5jcmVhdGVTU0MgPSAocGF5bG9hZCkgPT4gewogICAgaWYgKGFwaS5zZW5kZXIgIT09IGFwaS5vd25lcikgcmV0dXJuOwogICAgLy8gaW5pdGlhbGl6ZSBzb21lIHN0dWZmcyBoZXJlCiAgICAvLyBhd2FpdCBhcGkuZGIuY3JlYXRlVGFibGUoJ3RyYW5zYWN0aW9ucycsIFsnYmV0QW1vdW50JywgJ3RyYW5zSWQnLCAncGxheWVyJywgJ3Rva2VuSXNzdWUnXSk7CiAgICBlbWl0KCdjcmVhdGVTU0MnLCAiRXBpY2RpY2UgU21hcnQgQ29udHJhY3QgSW5pdGlhbGl6YXRpb24iKQogICAgY29uc29sZS5sb2coJ0VwaWNkaWNlIFNtYXJ0IENvbnRyYWN0IEluaXRpYWxpemF0aW9uJykKfQoKYWN0aW9ucy5pc3N1ZVRva2VuID0gYXN5bmMgKHBheWxvYWQpID0+IHsKICAgIGF3YWl0IGlzc3VlRXBpY1Rva2VuKHBheWxvYWQpOwp9CgphY3Rpb25zLnRyYW5zZmVyID0gYXN5bmMgKHBheWxvYWQpID0+IHsKICAgIGF3YWl0IHRyYW5zZmVyVlR3byhwYXlsb2FkKTsKfQoKYWN0aW9ucy50cmFuc2Zlck93bmVyc2hpcCA9IGFzeW5jIChwYXlsb2FkKSA9PiB7CiAgICBjb25zdCB7CiAgICAgICAgc3ltYm9sLAogICAgICAgIHRvLAogICAgICAgIGlzU2lnbmVkV2l0aEFjdGl2ZUtleQogICAgfSA9IHBheWxvYWQ7CgogICAgaWYgKGFwaS5hc3NlcnQoaXNTaWduZWRXaXRoQWN0aXZlS2V5ID09PSB0cnVlLCAneW91IG11c3QgdXNlIGEgY3VzdG9tX2pzb24gc2lnbmVkIHdpdGggeW91ciBhY3RpdmUga2V5JykgJiYKICAgICAgICBhcGkuYXNzZXJ0KHN5bWJvbCAmJiB0eXBlb2Ygc3ltYm9sID09PSAnc3RyaW5nJyAmJgogICAgICAgICAgICB0byAmJiB0eXBlb2YgdG8gPT09ICdzdHJpbmcnLCAnaW52YWxpZCBwYXJhbXMnKSkgewogICAgICAgIC8vIGNoZWNrIGlmIHRoZSB0b2tlbiBleGlzdHMKICAgICAgICBsZXQgdG9rZW4gPSBhd2FpdCBhcGkuZGIuZmluZE9uZSgndG9rZW5zJywgewogICAgICAgICAgICBzeW1ib2wKICAgICAgICB9KTsKCiAgICAgICAgaWYgKHRva2VuKSB7CiAgICAgICAgICAgIGlmIChhcGkuYXNzZXJ0KHRva2VuLmlzc3VlciA9PT0gYXBpLnNlbmRlciwgJ211c3QgYmUgdGhlIGlzc3VlcicpKSB7CiAgICAgICAgICAgICAgICBjb25zdCBmaW5hbFRvID0gdG8udHJpbSgpOwogICAgICAgICAgICAgICAgLy8gYSB2YWxpZCBzdGVlbSBhY2NvdW50IGlzIGJldHdlZW4gMyBhbmQgMTYgY2hhcmFjdGVycyBpbiBsZW5ndGgKICAgICAgICAgICAgICAgIGlmIChhcGkuYXNzZXJ0KGZpbmFsVG8ubGVuZ3RoID49IDMgJiYgZmluYWxUby5sZW5ndGggPD0gMTYsICdpbnZhbGlkIHRvJykpIHsKICAgICAgICAgICAgICAgICAgICB0b2tlbi5pc3N1ZXIgPSBmaW5hbFRvCiAgICAgICAgICAgICAgICAgICAgYXdhaXQgYXBpLmRiLnVwZGF0ZSgndG9rZW5zJywgdG9rZW4pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9CgphY3Rpb25zLnVwZGF0ZU1ldGFkYXRhID0gYXN5bmMgKHBheWxvYWQpID0+IHsKICAgIGNvbnN0IHsKICAgICAgICBtZXRhZGF0YSwKICAgICAgICBzeW1ib2wKICAgIH0gPSBwYXlsb2FkOwogICAgaWYgKGFwaS5hc3NlcnQoc3ltYm9sICYmIHR5cGVvZiBzeW1ib2wgPT09ICdzdHJpbmcnICYmCiAgICAgICAgbWV0YWRhdGEgJiYgdHlwZW9mIG1ldGFkYXRhID09PSAnb2JqZWN0JywgJ2ludmFsaWQgcGFyYW1zJykpIHsKICAgICAgICAvLyBjaGVjayBpZiB0aGUgdG9rZW4gZXhpc3RzCiAgICAgICAgbGV0IHRva2VuID0gYXdhaXQgYXBpLmRiLmZpbmRPbmUoJ3Rva2VucycsIHsKICAgICAgICAgICAgc3ltYm9sCiAgICAgICAgfSk7CgogICAgICAgIGlmICh0b2tlbikgewogICAgICAgICAgICBpZiAoYXBpLmFzc2VydCh0b2tlbi5pc3N1ZXIgPT09IGFwaS5zZW5kZXIsICdtdXN0IGJlIHRoZSBpc3N1ZXInKSkgewogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBmaW5hbE1ldGFkYXRhID0gSlNPTi5zdHJpbmdpZnkobWV0YWRhdGEpOwogICAgICAgICAgICAgICAgICAgIGlmIChhcGkuYXNzZXJ0KGZpbmFsTWV0YWRhdGEubGVuZ3RoIDw9IDEwMDAsICdpbnZhbGlkIG1ldGFkYXRhOiBtYXggbGVuZ3RoIG9mIDEwMDAnKSkgewogICAgICAgICAgICAgICAgICAgICAgICB0b2tlbi5tZXRhZGF0YSA9IGZpbmFsTWV0YWRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IGFwaS5kYi51cGRhdGUoJ3Rva2VucycsIHRva2VuKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgLy8gZXJy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IHVybDsKICAgICAgICAgICAgICAgICAgICAgICAgdG9rZW4ubWV0YWRhdGEgPSBKU09OLnN0cmluZ2lmeShtZXRhZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IGFwaS5kYi51cGRhdGUoJ3Rva2VucycsIHRva2VuKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgLy8gZXJyb3Igd2hlbiBwYXJzaW5nIHRoZSBtZXRhZGF0YQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9Cgpjb25zdCBpc3N1ZUN1c3RvbUVwaWNUb2tlbiA9IGFzeW5jIChwYXlsb2FkKSA9PiB7CiAgICBjb25zdCB7CiAgICAgICAgdG8sCiAgICAgICAgc3ltYm9sLAogICAgICAgIHF1YW50aXR5LAogICAgICAgIGlzU2lnbmVkV2l0aEFjdGl2ZUtleQogICAgfSA9IHBheWxvYWQ7CgogICAgY29uc3QgaG91c2VBY2NvdW50ID0gJ2xlZ29iYXRtYXgnCiAgICBpZiAoYXBpLmFzc2VydChpc1NpZ25lZFdpdGhBY3RpdmVLZXkgPT09IHRydWUsICd5b3UgbXVzdCB1c2UgYSBjdXN0b21fanNvbiBzaWduZWQgd2l0aCB5b3VyIGFjdGl2ZSBrZXknKSAmJgogICAgICAgIGFwaS5hc3NlcnQodG8gJiYgdHlwZW9mIHRvID09PSAnc3RyaW5nJyAmJgogICAgICAgICAgICBzeW1ib2wgJiYgdHlwZW9mIHN5bWJvbCA9PT0gJ3N0cmluZycgJiYKICAgICAgICAgICAgcXVhbnRpdHkgJiYgdHlwZW9mIHF1YW50aXR5ID09PSAnc3RyaW5nJyAmJiAhYXBpLkJpZ051bWJlcihxdWFudGl0eSkuaXNOYU4oKSwgJ2ludmFsaWQgcGFyYW1zJykpIHsKICAgICAgICBjb25zdCBmaW5hbFRvID0gdG8udHJpbSgpOwogICAgIC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mFsVG8ubGVuZ3RoIDw9IDE2LCAnaW52YWxpZCB0bycpKSB7CiAgICAgICAgICAgICAgICAvLyB3ZSBtYWRlIGFsbCB0aGUgcmVxdWlyZWQgdmVyaWZpY2F0aW9uLCBsZXQncyBub3cgaXNzdWUgdGhlIHRva2VucwoKICAgICAgICAgICAgICAgIHZhciBhbW91bnRUb2tlblRvUGxheWVyID0gY2FsY3VsYXRlT3duVG9rZW5EaXN0cmlidXRpb24odG9rZW4pCiAgICAgICAgICAgICAgICB2YXIgYW1vdW50VG9rZW5Ub093bmVyID0gY2FsY3VsYXRlT3duVG9rZW5EaXN0cmlidXRpb24odG9rZW4pCiAgICAgICAgICAgICAgICB2YXIgdG90YWxUb2tlbiA9IGFtb3VudFRva2VuVG9QbGF5ZXIgKyBhbW91bnRUb2tlblRvT3duZXIKCiAgICAgICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYWRkQmFsYW5jZVZUd28odG9rZW4uaXNzdWVyLCB0b2tlbiwgYW1vdW50VG9rZW4sICdiYWxhbmNlcycpOwogICAgICAgICAgICAgICAgbGV0IHJlczIgPSBhd2FpdCBhZGRCYWxhbmNlVlR3byh0b2tlbi5pc3N1ZXIsIHRva2VuLCBhbW91bnRUb2tlbiwgJ2JhbGFuY2VzJyk7CgogICAgICAgICAgICAgICAgaWYgKHJlcyA9PT0gdHJ1ZSAmJiByZXMyID09PSB0cnVlICYmIGZpbmFsVG8gIT09IHRva2VuLmlzc3VlcikgewogICAgICAgICAgICAgICAgICAgIGlmIChhd2FpdCBzdWJCYWxhbmNlVlR3byh0b2tlbi5pc3N1ZXIsIHRva2VuLCB0b3RhbFRva2VuLCAnYmFsYW5jZXMnKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXMgPSBhd2FpdCBhZGRCYWxhbmNlVlR3byhmaW5hbFRvLCB0b2tlbiwgYW1vdW50VG9rZW5Ub1BsYXllciwgJ2JhbGFuY2VzJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlczIgPSBhd2FpdCBhZGRCYWxhbmNlVlR3byhob3VzZUFjY291bnQsIHRva2VuLCBhbW91bnRUb2tlblRvT3duZXIsICdiYWxhbmNlcycpOwoKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlcyA9PT0gZmFsc2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IGFkZEJhbGFuY2VWVHdvKHRva2VuLmlzc3VlciwgdG9rZW4sIGFtb3VudFRva2VuVG9QbGF5ZXIsICdiYWxhbmNlcycpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXMyID09PSBmYWxzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgYWRkQmFsYW5jZVZUd28odG9rZW4uaXNzdWVyLCB0b2tlbiwgYW1vdW50VG9rZW5Ub093bmVyLCAnYmFsYW5jZXMnKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvLyBsZXQgcmVhbFRva2VuUXVhbnRpdHkgPSAKCiAgICAgICAgICAgICAgICBpZiAocmVzID09PSB0cnVlKSB7CiAgICAgICAgICAgICAgICAgICAgdG9rZW4uc3VwcGx5ID0gY2FsY3VsYXRlQmFsYW5jZVZUd28odG9rZW4uc3VwcGx5LCB0b3RhbFRva2VuLCB0b2tlbi5wcmVjaXNpb24sIHRydWUpOwoKICAgICAgICAgICAgICAgICAgICBpZiAodG8gIT09ICdudWxsJykgewogICAgICAgICAgICAgICAgICAgICAgICB0b2tlbi5jaXJjdWxhdGluZ1N1cHBseSA9IGNhbGN1bGF0ZUJhbGFuY2VWVHdvKHRva2VuLmNpcmN1bGF0aW5nU3VwcGx5LCB0b3RhbFRva2VuLCB0b2tlbi5wcmVjaXNpb24sIHRydWUpOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgYXdhaXQgYXBpLmRiLnVwZGF0ZSgndG9rZW5zJywgdG9rZW4pOwoKCiAgICAgICAgICAgICAgICAgICAgYXBpLmVtaXQoJ2lzc3VlQ3VzdG9tRXBpY1Rva2VuJywgewogICAgICAgICAgICAgICAgICAgICAgICBmcm9tOiAndG9rZW5zJywKICAgICAgICAgICAgICAgICAgICAgICAgdG86IGZpbmFsVG8sCiAgICAgICAgICAgICAgICAgICAgICAgIHN5bWJvbCwKICAgICAgICAgICAgICAgICAgICAgICAgYW1vdW50VG9rZW5Ub1BsYXllcgogICAgICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygiKioqKiogaXNzdWVDdXN0b21FcGljVG9rZW4gdG8gIiArIHRvICsgIiB0b2tlbiAiICsgYW1vdW50VG9rZW5Ub1BsYXllcikKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQoKY29uc3QgaXNzdWVHZW5lcmFsRXBpY1Rva2VuID0gYXN5bmMgKHBheWxvYWQpID0+IHsKICAgIGNvbnN0IHsKICAgICAgICB0bywKICAgICAgICBzeW1ib2wsCiAgICAgICAgcXVhbnRpdHksCiAgICAgICAgaXNTaWduZWRXaXRoQWN0aXZlS2V5CiAgICB9ID0gcGF5bG9hZDsKCiAgICBpZiAoYXBpLmFzc2VydChpc1NpZ25lZFdpdGhBY3RpdmVLZXkgPT09IHRydWUsICd5b3UgbXVzdCB1c2UgYSBjdXN0b21fanNvbiBzaWduZWQgd2l0aCB5b3VyIGFjdGl2ZSBrZXknKSAmJgogICAgICAgIGFwaS5hc3NlcnQodG8gJiYgdHlwZW9mIHRvID09PSAnc3RyaW5nJyAmJgogICAgICAgICAgICBzeW1ib2wgJiYgdHlwZW9mIHN5bWJvbCA9PT0gJ3N0cmluZycgJiYKICAgICAgICAgICAgcXVhbnRpdHkgJiYgdHlwZW9mIHF1YW50aXR5ID09PSAnc3RyaW5nJyAmJiAhYXBpLkJpZ051bWJlc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ZCAxNiBjaGFyYWN0ZXJzIGluIGxlbmd0aAogICAgICAgICAgICBpZiAoYXBpLmFzc2VydChmaW5hbFRvLmxlbmd0aCA+PSAzICYmIGZpbmFsVG8ubGVuZ3RoIDw9IDE2LCAnaW52YWxpZCB0bycpKSB7CiAgICAgICAgICAgICAgICAvLyB3ZSBtYWRlIGFsbCB0aGUgcmVxdWlyZWQgdmVyaWZpY2F0aW9uLCBsZXQncyBub3cgaXNzdWUgdGhlIHRva2VucwoKICAgICAgICAgICAgICAgIGxldCByZXMgPSBhd2FpdCBhZGRCYWxhbmNlVlR3byh0b2tlbi5pc3N1ZXIsIHRva2VuLCBxdWFudGl0eSwgJ2JhbGFuY2VzJyk7CgogICAgICAgICAgICAgICAgaWYgKHJlcyA9PT0gdHJ1ZSAmJiBmaW5hbFRvICE9PSB0b2tlbi5pc3N1ZXIpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoYXdhaXQgc3ViQmFsYW5jZVZUd28odG9rZW4uaXNzdWVyLCB0b2tlbiwgcXVhbnRpdHksICdiYWxhbmNlcycpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlcyA9IGF3YWl0IGFkZEJhbGFuY2VWVHdvKGZpbmFsVG8sIHRva2VuLCBxdWFudGl0eSwgJ2JhbGFuY2VzJyk7CgogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzID09PSBmYWxzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgYWRkQmFsYW5jZVZUd28odG9rZW4uaXNzdWVyLCB0b2tlbiwgcXVhbnRpdHksICdiYWxhbmNlcycpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHJlcyA9PT0gdHJ1ZSkgewogICAgICAgICAgICAgICAgICAgIHRva2VuLnN1cHBseSA9IGNhbGN1bGF0ZUJhbGFuY2VWVHdvKHRva2VuLnN1cHBseSwgcXVhbnRpdHksIHRva2VuLnByZWNpc2lvbiwgdHJ1ZSk7CgogICAgICAgICAgICAgICAgICAgIGlmICh0byAhPT0gJ251bGwnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRva2VuLmNpcmN1bGF0aW5nU3VwcGx5ID0gY2FsY3VsYXRlQmFsYW5jZVZUd28odG9rZW4uY2lyY3VsYXRpbmdTdXBwbHksIHF1YW50aXR5LCB0b2tlbi5wcmVjaXNpb24sIHRydWUpOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgYXdhaXQgYXBpLmRiLnVwZGF0ZSgndG9rZW5zJywgdG9rZW4pOwoKICAgICAgICAgICAgICAgICAgICBhcGkuZW1pdCgnaXNzdWVHZW5lcmFsRXBpY1Rva2VuJywgewogICAgICAgICAgICAgICAgICAgICAgICBmcm9tOiAndG9rZW5zJywKICAgICAgICAgICAgICAgICAgICAgICAgdG86IGZpbmFsVG8sCiAgICAgICAgICAgICAgICAgICAgICAgIHN5bWJvbCwKICAgICAgICAgICAgICAgICAgICAgICAgcXVhbnRpdHkKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQoKY29uc3QgdHJhbnNmZXJWVHdvID0gYXN5bmMgKHBheWxvYWQpID0+IHsKICAgIGNvbnN0IHsKICAgICAgICB0bywKICAgICAgICBzeW1ib2wsCiAgICAgICAgcXVhbnRpdHksCiAgICAgICAgaXNTaWduZWRXaXRoQWN0aXZlS2V5CiAgICB9ID0gcGF5bG9hZDsKCiAgICBpZiAoYXBpLmFzc2VydChpc1NpZ25lZFdpdGhBY3RpdmVLZXkgPT09IHRydWUsICd5b3UgbXVzdCB1c2UgYSBjdXN0b21fanNvbiBzaWduZWQgd2l0aCB5b3VyIGFjdGl2ZSBrZXknKSAmJgogICAgICAgIGFwaS5hc3NlcnQodG8gJiYgdHlwZW9mIHRvID09PSAnc3RyaW5nJyAmJgogICAg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JiYKICAgICAgICAgICAgICAgICAgICBhcGkuYXNzZXJ0KGFwaS5CaWdOdW1iZXIocXVhbnRpdHkpLmd0KDApLCAnbXVzdCB0cmFuc2ZlciBwb3NpdGl2ZSBxdWFudGl0eScpKSB7CgogICAgICAgICAgICAgICAgICAgIGlmIChhd2FpdCBzdWJCYWxhbmNlVlR3byhhcGkuc2VuZGVyLCB0b2tlbiwgcXVhbnRpdHksICdiYWxhbmNlcycpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlcyA9IGF3YWl0IGFkZEJhbGFuY2VWVHdvKGZpbmFsVG8sIHRva2VuLCBxdWFudGl0eSwgJ2JhbGFuY2VzJyk7CgogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzID09PSBmYWxzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgYWRkQmFsYW5jZVZUd28oYXBpLnNlbmRlciwgdG9rZW4sIHF1YW50aXR5LCAnYmFsYW5jZXMnKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaW5hbFRvID09PSAnbnVsbCcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRva2VuLmNpcmN1bGF0aW5nU3VwcGx5ID0gY2FsY3VsYXRlQmFsYW5jZVZUd28odG9rZW4uY2lyY3VsYXRpbmdTdXBwbHksIHF1YW50aXR5LCB0b2tlbi5wcmVjaXNpb24sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IGFwaS5kYi51cGRhdGUoJ3Rva2VucycsIHRva2VuKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgICAgICAgICAgYXBpLmVtaXQoJ3RyYW5zZmVyJywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbTogYXBpLnNlbmRlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvOiBmaW5hbFRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ltYm9sLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVhbnRpdHkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgcmV0dXJuIGZhbHNlOwp9CgoKY29uc3Qgc3ViQmFsYW5jZVZUd28gPSBhc3luYyAoYWNjb3VudCwgdG9rZW4sIHF1YW50aXR5LCB0YWJsZSkgPT4gewogICAgbGV0IGJhbGFuY2UgPSBhd2FpdCBhcGkuZGIuZmluZE9uZSh0YWJsZSwgewogICAgICAgIGFjY291bnQsCiAgICAgICAgJ3N5bWJvbCc6IHRva2VuLnN5bWJvbAogICAgfSk7CiAgICBpZiAoYXBpLmFzc2VydChiYWxhbmNlICE9PSBudWxsLCAnYmFsYW5jZSBkb2VzIG5vdCBleGlzdCcpICYmCiAgICAgICAgYXBpLmFzc2VydChhcGkuQmlnTnVtYmVyKGJhbGFuY2UuYmFsYW5jZSkuZ3RlKHF1YW50aXR5KSwgJ292ZXJkcmF3biBiYWxhbmNlJykpIHsKICAgICAgICBjb25zdCBvcmlnaW5hbEJhbGFuY2UgPSBiYWxhbmNlLmJhbGFuY2U7CgogICAgICAgIGJhbGFuY2UuYmFsYW5jZSA9IGNhbGN1bGF0ZUJhbGFuY2VWVHdvKGJhbGFuY2UuYmFsYW5jZSwgcXVhbnRpdHksIHRva2VuLnByZWNpc2lvbiwgZmFsc2UpOwogICAgICAgIGlmIChhcGkuYXNzZXJ0KGFwaS5CaWdOdW1iZXIoYmFsYW5jZS5iYWxhbmNlKS5sdChvcmlnaW5hbEJhbGFuY2UpLCAnY2Fubm90IHN1YnRyYWN0JykpIHsKICAgICAgICAgICAgYX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