from boa_test.tests.boa_test import BoaFixtureTest
from boa.compiler import Compiler
from neo.Core.TX.Transaction import Transaction
from neo.Prompt.Commands.BuildNRun import TestBuild
from neo.EventHub import events
from neo.SmartContract.SmartContractEvent import SmartContractEvent, NotifyEvent
from neo.Settings import settings
from neo.Prompt.Utils import parse_param
from neo.Core.FunctionCode import FunctionCode
from neocore.Fixed8 import Fixed8
from boa_test.example.demo.nex.token import *

import shutil
import os
from logzero import logger

settings.USE_DEBUG_STORAGE = True
settings.DEBUG_STORAGE_PATH = './fixtures/debugstorage'


class TestContract(BoaFixtureTest):

    dispatched_events = []
    dispatched_logs = []

    @classmethod
    def tearDownClass(cls):
        super(BoaFixtureTest, cls).tearDownClass()
        try:
            if os.path.exists(settings.debug_storage_leveldb_path):

                shutil.rmtree(settings.debug_storage_leveldb_path)
            else:
                logger.error("debug storage path doesn't exist")
        except Exception as e:
            logger.error("couldn't remove debug storage %s " % e)

    @classmethod
    def setUpClass(cls):
        super(TestContract, cls).setUpClass()

        def on_notif(evt):
            print(evt)
            cls.dispatched_events.append(evt)
            print("dispatched events %s " % cls.dispatched_events)

        def on_log(evt):
            print(evt)
            cls.dispatched_logs.append(evt)
        events.on(SmartContractEvent.RUNTIME_NOTIFY, on_notif)
        events.on(SmartContractEvent.RUNTIME_LOG, on_log)

    def test_ICOTemplate_1(self):

        output = Compiler.instance().load('%s/boa_test/example/demo/ICO_Template.py' % TestContract.dirname).default
        out = output.write()
#        print(output.to_s())

        tx, results, total_ops, engine = TestBuild(out, ['name', '[]'], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetString(), TOKEN_NAME)

        tx, results, total_ops, engine = TestBuild(out, ['symbol', '[]'], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetString(), TOKEN_SYMBOL)

        tx, results, total_ops, engine = TestBuild(out, ['decimals', '[]'], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), TOKEN_DECIMALS)

        tx, results, total_ops, engine = TestBuild(out, ['totalSupply', '[]'], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 0)

        tx, results, total_ops, engine = TestBuild(out, ['nonexistentmethod', '[]'], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetString(), 'unknown operation')

        # deploy with wallet 2 should fail CheckWitness
        tx, results, total_ops, engine = TestBuild(out, ['deploy', '[]'], self.GetWallet2(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

        tx, results, total_ops, engine = TestBuild(out, ['deploy', '[]'], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), True)

        # second time, it should already be deployed and return false
        tx, results, total_ops, engine = TestBuild(out, ['deploy', '[]'], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

        # now total supply should be equal to the initial owner amount
        tx, results, total_ops, engine = TestBuild(out, ['totalSupply', '[]'], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), TOKEN_INITIAL_AMOUNT)

        # now the owner should have a balance of the TOKEN_INITIAL_AMOUNT
        tx, results, total_ops, engine = TestBuild(out, ['balanceOf', parse_param([bytearray(TOKEN_OWNER)])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), TOKEN_INITIAL_AMOUNT)

    def test_ICOTemplate_2(self):

        output = Compiler.instance().load('%s/boa_test/example/demo/ICO_Template.py' % TestContract.dirname).default
        out = output.write()

        # now transfer tokens to wallet 2

        TestContract.dispatched_events = []

        test_transfer_amount = 2400000001
        tx, results, total_ops, engine = TestBuild(out, ['transfer', parse_param([bytearray(TOKEN_OWNER), self.wallet_2_script_hash.Data, test_transfer_amount])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), True)

        self.assertEqual(len(TestContract.dispatched_events), 1)
        evt = TestContract.dispatched_events[0]
        self.assertIsInstance(evt, NotifyEvent)
        self.assertEqual(evt.addr_from.Data, bytearray(TOKEN_OWNER))
        self.assertEqual(evt.addr_to, self.wallet_2_script_hash)
        self.assertEqual(evt.amount, test_transfer_amount)

        # now get balance of wallet 2
        tx, results, total_ops, engine = TestBuild(out, ['balanceOf', parse_param([self.wallet_2_script_hash.Data])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), test_transfer_amount)

        # now the owner should have less
        tx, results, total_ops, engine = TestBuild(out, ['balanceOf', parse_param([bytearray(TOKEN_OWNER)])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), TOKEN_INITIAL_AMOUNT - test_transfer_amount)

        # now this transfer should fail
        tx, results, total_ops, engine = TestBuild(out, ['transfer', parse_param([bytearray(TOKEN_OWNER), self.wallet_2_script_hash.Data, TOKEN_INITIAL_AMOUNT])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

        # this transfer should fail because it is not signed by the 'from' address
        tx, results, total_ops, engine = TestBuild(out, ['transfer', parse_param([bytearray(TOKEN_OWNER), self.wallet_2_script_hash.Data, 10000])], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

        # now this transfer should fail, this is from address with no tokens
        tx, results, total_ops, engine = TestBuild(out, ['transfer', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 1000])], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

        # get balance of bad data
        tx, results, total_ops, engine = TestBuild(out, ['balanceOf', parse_param(['abc'])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 0)

        # get balance no params
        tx, results, total_ops, engine = TestBuild(out, ['balanceOf', parse_param([])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

    def test_ICOTemplate_3_KYC(self):

        output = Compiler.instance().load('%s/boa_test/example/demo/ICO_Template.py' % TestContract.dirname).default
        out = output.write()
        print(output.to_s())
        # now transfer tokens to wallet 2

        TestContract.dispatched_events = []

        # test mint tokens without being kyc verified
        tx, results, total_ops, engine = TestBuild(out, ['mintTokens', '[]', '--attach-neo=10'], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

        # Try to register as a non owner
        tx, results, total_ops, engine = TestBuild(out, ['crowdsale_register', parse_param([self.wallet_3_script_hash.Data])], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

        # Get status of non registered address
        tx, results, total_ops, engine = TestBuild(out, ['crowdsale_status', parse_param([self.wallet_3_script_hash.Data])], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

        TestContract.dispatched_events = []

        # register an address
        tx, results, total_ops, engine = TestBuild(out, ['crowdsale_register', parse_param([self.wallet_3_script_hash.Data])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 1)

        # it should dispatch an event
        self.assertEqual(len(TestContract.dispatched_events), 1)
        evt = TestContract.dispatched_events[0]
        self.assertEqual(evt.event_payload.Value[0].Value, b'kyc_registration')

        # register 2 addresses at once
        tx, results, total_ops, engine = TestBuild(out, ['crowdsale_register', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 2)

        # now check reg status
        tx, results, total_ops, engine = TestBuild(out, ['crowdsale_status', parse_param([self.wallet_3_script_hash.Data])], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), True)

    def test_ICOTemplate_4_attachments(self):

        output = Compiler.instance().load('%s/boa_test/example/demo/ICO_Template.py' % TestContract.dirname).default
        out = output.write()

        # test mint tokens without being kyc verified
        tx, results, total_ops, engine = TestBuild(out, ['get_attachments', '[]', '--attach-neo=10'], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        attachments = results[0].GetArray()
        self.assertEqual(len(attachments), 4)

        fn = FunctionCode(out, '0705', '05')

        self.assertEqual(attachments[0].GetByteArray(), fn.ScriptHash().Data)
        self.assertEqual(attachments[1].GetByteArray(), self.wallet_3_script_hash.Data)
        self.assertEqual(attachments[2].GetBigInteger(), Fixed8.FromDecimal(10).value)
        self.assertEqual(attachments[3].GetBigInteger(), 0)

        tx, results, total_ops, engine = TestBuild(out, ['get_attachments', '[]'], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        attachments = results[0].GetArray()
        self.assertEqual(len(attachments), 4)

        self.assertEqual(attachments[1].GetByteArray(), bytearray())
        self.assertEqual(attachments[2].GetBigInteger(), 0)
        self.assertEqual(attachments[3].GetBigInteger(), 0)

        tx, results, total_ops, engine = TestBuild(out, ['get_attachments', '[]', '--attach-neo=3', '--attach-gas=3.12'], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        attachments = results[0].GetArray()
        self.assertEqual(len(attachments), 4)
        self.assertEqual(attachments[1].GetByteArray(), self.wallet_1_script_hash.Data)
        self.assertEqual(attachments[2].GetBigInteger(), Fixed8.FromDecimal(3).value)
        self.assertEqual(attachments[3].GetBigInteger(), Fixed8.FromDecimal(3.12).value)

    def test_ICOTemplate_5_mint(self):

        output = Compiler.instance().load('%s/boa_test/example/demo/ICO_Template.py' % TestContract.dirname).default
        out = output.write()

        # register an address
        tx, results, total_ops, engine = TestBuild(out, ['crowdsale_register', parse_param([self.wallet_3_script_hash.Data])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 1)

        TestContract.dispatched_events = []

        # test mint tokens, this should return true
        tx, results, total_ops, engine = TestBuild(out, ['mintTokens', '[]', '--attach-neo=10'], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), True)

        # it should dispatch an event
        self.assertEqual(len(TestContract.dispatched_events), 1)
        evt = TestContract.dispatched_events[0]
        self.assertIsInstance(evt, NotifyEvent)
        self.assertEqual(evt.amount, 10 * TOKENS_PER_NEO)
        self.assertEqual(evt.addr_to, self.wallet_3_script_hash)

        # test mint tokens again, this should be false since you can't do it twice
        tx, results, total_ops, engine = TestBuild(out, ['mintTokens', '[]', '--attach-neo=10'], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

        # now the minter should have a balance
        tx, results, total_ops, engine = TestBuild(out, ['balanceOf', parse_param([self.wallet_3_script_hash.Data])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 10 * TOKENS_PER_NEO)

        # now the total circulation should be bigger
        tx, results, total_ops, engine = TestBuild(out, ['totalSupply', '[]'], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), (10 * TOKENS_PER_NEO) + TOKEN_INITIAL_AMOUNT)

    def test_ICOTemplate_6_approval(self):

        output = Compiler.instance().load('%s/boa_test/example/demo/ICO_Template.py' % TestContract.dirname).default
        out = output.write()

        # tranfer_from, approve, allowance
        tx, results, total_ops, engine = TestBuild(out, ['allowance', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data])], self.GetWallet2(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 0)

        # try to transfer from
        tx, results, total_ops, engine = TestBuild(out, ['transferFrom', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 10000])], self.GetWallet2(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

        # try to approve from someone not yourself
        tx, results, total_ops, engine = TestBuild(out, ['approve', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 10000])], self.GetWallet2(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 0)

        # try to approve more than you have
        tx, results, total_ops, engine = TestBuild(out, ['approve', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, TOKEN_INITIAL_AMOUNT])], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 0)

        TestContract.dispatched_events = []

        # approve should work
        tx, results, total_ops, engine = TestBuild(out, ['approve', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 1234])], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), True)

        # it should dispatch an event
        self.assertEqual(len(TestContract.dispatched_events), 1)
        evt = TestContract.dispatched_events[0]
        self.assertIsInstance(evt, NotifyEvent)
        self.assertEqual(evt.notify_type, b'approve')
        self.assertEqual(evt.amount, 1234)

        # check allowance
        tx, results, total_ops, engine = TestBuild(out, ['allowance', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data])], self.GetWallet2(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 1234)

        # approve should not be additive, it should overwrite previous approvals
        tx, results, total_ops, engine = TestBuild(out, ['approve', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 133234])], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), True)

        tx, results, total_ops, engine = TestBuild(out, ['allowance', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data])], self.GetWallet2(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 133234)

        # now you can transfer from
        tx, results, total_ops, engine = TestBuild(out, ['transferFrom', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 10000])], self.GetWallet2(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), True)

        # now the recevier should have a balance
        # it is equal to 10000 plus test_transfer_amount = 2400000001

        tx, results, total_ops, engine = TestBuild(out, ['balanceOf', parse_param([self.wallet_2_script_hash.Data])], self.GetWallet1(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 10000 + 2400000001)

        # now the allowance should be less
        tx, results, total_ops, engine = TestBuild(out, ['allowance', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data])], self.GetWallet2(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 133234 - 10000)

        # try to transfer too much, even with approval
        tx, results, total_ops, engine = TestBuild(out, ['transferFrom', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 14440000])], self.GetWallet2(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

        # cant approve negative amounts
        tx, results, total_ops, engine = TestBuild(out, ['approve', parse_param([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, -1000])], self.GetWallet3(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBoolean(), False)

    def test_many_ops(self):

        output = Compiler.instance().load('%s/boa_test/example/demo/ICO_Template.py' % TestContract.dirname).default
        out = output.write()

        # tranfer_from, approve, allowance
        tx, results, total_ops, engine = TestBuild(out, ['another_op_5', bytearray()], self.GetWallet2(), '0705', '05')
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0].GetBigInteger(), 6)

[((50, 8, 50, 62), 'neo.EventHub.events.on', 'events.on', ({(50, 18, 50, 51): 'SmartContractEvent.RUNTIME_NOTIFY', (50, 53, 50, 61): 'on_notif'}, {}), '(SmartContractEvent.RUNTIME_NOTIFY, on_notif)', False, 'from neo.EventHub import events\n'), ((51, 8, 51, 57), 'neo.EventHub.events.on', 'events.on', ({(51, 18, 51, 48): 'SmartContractEvent.RUNTIME_LOG', (51, 50, 51, 56): 'on_log'}, {}), '(SmartContractEvent.RUNTIME_LOG, on_log)', False, 'from neo.EventHub import events\n'), ((216, 13, 216, 44), 'neo.Core.FunctionCode.FunctionCode', 'FunctionCode', ({(216, 26, 216, 29): 'out', (216, 31, 216, 37): '"""0705"""', (216, 39, 216, 43): '"""05"""'}, {}), "(out, '0705', '05')", False, 'from neo.Core.FunctionCode import FunctionCode\n'), ((30, 15, 30, 66), 'os.path.exists', 'os.path.exists', ({(30, 30, 30, 65): 'settings.debug_storage_leveldb_path'}, {}), '(settings.debug_storage_leveldb_path)', False, 'import os\n'), ((32, 16, 32, 66), 'shutil.rmtree', 'shutil.rmtree', ({(32, 30, 32, 65): 'settings.debug_storage_leveldb_path'}, {}), '(settings.debug_storage_leveldb_path)', False, 'import shutil\n'), ((34, 16, 34, 64), 'logzero.logger.error', 'logger.error', ({(34, 29, 34, 63): '"""debug storage path doesn\'t exist"""'}, {}), '("debug storage path doesn\'t exist")', False, 'from logzero import logger\n'), ((36, 12, 36, 65), 'logzero.logger.error', 'logger.error', ({(36, 25, 36, 64): '("couldn\'t remove debug storage %s " % e)'}, {}), '("couldn\'t remove debug storage %s " % e)', False, 'from logzero import logger\n'), ((125, 70, 125, 115), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(125, 82, 125, 114): '[self.wallet_2_script_hash.Data]'}, {}), '([self.wallet_2_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((145, 69, 145, 152), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(145, 81, 145, 151): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 1000]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data,\n    1000])', False, 'from neo.Prompt.Utils import parse_param\n'), ((150, 70, 150, 90), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(150, 82, 150, 89): "['abc']"}, {}), "(['abc'])", False, 'from neo.Prompt.Utils import parse_param\n'), ((155, 70, 155, 85), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(155, 82, 155, 84): '[]'}, {}), '([])', False, 'from neo.Prompt.Utils import parse_param\n'), ((174, 79, 174, 124), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(174, 91, 174, 123): '[self.wallet_3_script_hash.Data]'}, {}), '([self.wallet_3_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((179, 77, 179, 122), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(179, 89, 179, 121): '[self.wallet_3_script_hash.Data]'}, {}), '([self.wallet_3_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((186, 79, 186, 124), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(186, 91, 186, 123): '[self.wallet_3_script_hash.Data]'}, {}), '([self.wallet_3_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((196, 79, 196, 156), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(196, 91, 196, 155): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((201, 77, 201, 122), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(201, 89, 201, 121): '[self.wallet_3_script_hash.Data]'}, {}), '([self.wallet_3_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((220, 57, 220, 79), 'neocore.Fixed8.Fixed8.FromDecimal', 'Fixed8.FromDecimal', ({(220, 76, 220, 78): '(10)'}, {}), '(10)', False, 'from neocore.Fixed8 import Fixed8\n'), ((237, 57, 237, 78), 'neocore.Fixed8.Fixed8.FromDecimal', 'Fixed8.FromDecimal', ({(237, 76, 237, 77): '(3)'}, {}), '(3)', False, 'from neocore.Fixed8 import Fixed8\n'), ((238, 57, 238, 81), 'neocore.Fixed8.Fixed8.FromDecimal', 'Fixed8.FromDecimal', ({(238, 76, 238, 80): '(3.12)'}, {}), '(3.12)', False, 'from neocore.Fixed8 import Fixed8\n'), ((246, 79, 246, 124), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(246, 91, 246, 123): '[self.wallet_3_script_hash.Data]'}, {}), '([self.wallet_3_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((270, 70, 270, 115), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(270, 82, 270, 114): '[self.wallet_3_script_hash.Data]'}, {}), '([self.wallet_3_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((285, 70, 285, 147), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(285, 82, 285, 146): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((290, 73, 290, 157), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(290, 85, 290, 156): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 10000]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data,\n    10000])', False, 'from neo.Prompt.Utils import parse_param\n'), ((295, 68, 295, 152), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(295, 80, 295, 151): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 10000]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data,\n    10000])', False, 'from neo.Prompt.Utils import parse_param\n'), ((300, 68, 300, 167), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(300, 80, 300, 166): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data,\n    TOKEN_INITIAL_AMOUNT]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data,\n    TOKEN_INITIAL_AMOUNT])', False, 'from neo.Prompt.Utils import parse_param\n'), ((307, 68, 307, 151), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(307, 80, 307, 150): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 1234]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data,\n    1234])', False, 'from neo.Prompt.Utils import parse_param\n'), ((319, 70, 319, 147), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(319, 82, 319, 146): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((324, 68, 324, 153), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(324, 80, 324, 152): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 133234]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data,\n    133234])', False, 'from neo.Prompt.Utils import parse_param\n'), ((328, 70, 328, 147), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(328, 82, 328, 146): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((333, 73, 333, 157), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(333, 85, 333, 156): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 10000]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data,\n    10000])', False, 'from neo.Prompt.Utils import parse_param\n'), ((340, 70, 340, 115), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(340, 82, 340, 114): '[self.wallet_2_script_hash.Data]'}, {}), '([self.wallet_2_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((345, 70, 345, 147), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(345, 82, 345, 146): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data])', False, 'from neo.Prompt.Utils import parse_param\n'), ((350, 73, 350, 160), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(350, 85, 350, 159): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, 14440000]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data,\n    14440000])', False, 'from neo.Prompt.Utils import parse_param\n'), ((355, 68, 355, 152), 'neo.Prompt.Utils.parse_param', 'parse_param', ({(355, 80, 355, 151): '[self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data, -1000]'}, {}), '([self.wallet_3_script_hash.Data, self.wallet_2_script_hash.Data,\n    -1000])', False, 'from neo.Prompt.Utils import parse_param\n'), ((55, 17, 55, 36), 'boa.compiler.Compiler.instance', 'Compiler.instance', ({}, {}), '()', False, 'from boa.compiler import Compiler\n'), ((105, 17, 105, 36), 'boa.compiler.Compiler.instance', 'Compiler.instance', ({}, {}), '()', False, 'from boa.compiler import Compiler\n'), ((161, 17, 161, 36), 'boa.compiler.Compiler.instance', 'Compiler.instance', ({}, {}), '()', False, 'from boa.compiler import Compiler\n'), ((207, 17, 207, 36), 'boa.compiler.Compiler.instance', 'Compiler.instance', ({}, {}), '()', False, 'from boa.compiler import Compiler\n'), ((242, 17, 242, 36), 'boa.compiler.Compiler.instance', 'Compiler.instance', ({}, {}), '()', False, 'from boa.compiler import Compiler\n'), ((281, 17, 281, 36), 'boa.compiler.Compiler.instance', 'Compiler.instance', ({}, {}), '()', False, 'from boa.compiler import Compiler\n'), ((361, 17, 361, 36), 'boa.compiler.Compiler.instance', 'Compiler.instance', ({}, {}), '()', False, 'from boa.compiler import Compiler\n')]