Exemple #1
0
    def mockup(cls):
        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        cls.session.add(client1)

        cls.session.commit()
    def mockup(cls):
        admin1 = Admin()
        admin1.email = '*****@*****.**'
        admin1.password = '******'
        admin1.is_active = True
        cls.session.add(admin1)

        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        cls.session.add(client1)

        cls.session.commit()

        cls.client1_id = client1.id
Exemple #3
0
    def get(self, client_id: MemberId = None, inner_resource: str = None):
        if context.identity.is_in_roles('client'):
            if client_id == 'me':
                client = Client.current()

                if inner_resource == 'evidences':
                    return client.evidence

                return client

        elif context.identity.is_in_roles('admin'):

            query = Client.query
            if client_id is not None:
                client = query.filter(Client.id == client_id).one_or_none()

                if client is None:
                    raise HttpNotFound()

                if inner_resource == 'evidences':
                    return client.evidence

                return client

            return query

        raise HttpNotFound()
Exemple #4
0
    def submit(self):
        evidence = Client.current().evidence

        if evidence.mobile_phone is None or evidence.fixed_phone is None:
            raise HttpForbidden('Please verify your mobile and fixed phone first.')

        evidence.update_from_request()

        id_card = context.form.get('idCard')
        id_card_secondary = context.form.get('idCardSecondary')

        try:
            evidence.id_card = id_card
            evidence.id_card_secondary = id_card_secondary

        except AspectRatioValidationError as ex:
            raise HttpBadRequest(str(ex), reason='invalid-aspectratio')

        except DimensionValidationError as ex:
            raise HttpBadRequest(str(ex), reason='invalid-dimensions')

        except (AnalyzeError, ContentTypeValidationError) as ex:
            raise HttpBadRequest(str(ex), reason='invalid-type')

        return evidence
Exemple #5
0
    def change(self):
        current_password = context.form.get('currentPassword')
        new_password = context.form.get('newPassword')

        client = Client.current()
        client.change_password(current_password=current_password, new_password=new_password)

        context.application.__authenticator__.invalidate_member(context.identity.id)

        return client
Exemple #6
0
    def provision(self):
        client = Client.current()
        if client.has_second_factor is False:
            raise HttpBadRequest('Client haven\'t enabled 2-factor authentication')
        # TODO: Use another salt too (password or ...)
        oath = Oath(seed=settings.membership.second_factor_seed, derivate_seed_from=client.email)

        with io.BytesIO() as virtual_file:
            qrcode.make(oath.get_google_auth_uri(client.email)).save(stream=virtual_file)
            return base64.b64encode(virtual_file.getvalue()).decode()
    def mockup(cls):
        cls.mockup_id_card = join(STUFF_DIR, 'test-image-1.jpg')
        cls.mockup_id_card_secondary = join(STUFF_DIR, 'test-image-2.png')

        iran = Country(name='Iran', code='ir', phone_prefix=98)
        tehran_state = State(name='Tehran', country=iran)
        tehran_city = City(name='Tehran', state=tehran_state)

        cls.session.add(tehran_city)

        admin1 = Admin()
        admin1.email = '*****@*****.**'
        admin1.password = '******'
        admin1.is_active = True
        cls.session.add(admin1)

        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        client1.is_email_verified = True
        client1.evidence.mobile_phone = '+77777777777'
        client1.evidence.fixed_phone = '+888888888'
        cls.session.add(client1)

        cls.session.commit()

        cls.city1_id = tehran_city.id
        cls.client1_id = client1.id
Exemple #8
0
    def register(self):
        email = context.form.get('email')
        password = context.form.get('password')
        invitation_code = context.form.get('invitationCode', None)

        client = Client()

        if invitation_code is None and settings.membership.invitation_code_required is True:
            raise HttpBadRequest('Bad invitation code', 'bad-invitation-code')

        if invitation_code is not None:
            invitation = Invitation.query.filter(Invitation.code == invitation_code).with_for_update().one_or_none()
            if invitation is None or invitation.is_active is False:
                raise HttpBadRequest('Bad invitation code', 'bad-invitation-code')

            if invitation.unfilled_sits <= 0:
                raise HttpBadRequest('Fully filled invitation code', 'fully-filled-invitation-code')

            invitation.filled_sits += 1
            client.invitation_code = invitation_code

        client.email = email
        client.password = password
        client.is_active = True
        DBSession.add(client)

        return client
Exemple #9
0
    def mockup(cls):
        admin1 = Admin()
        admin1.email = '*****@*****.**'
        admin1.password = '******'
        admin1.is_active = True
        cls.session.add(admin1)

        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        cls.session.add(client1)

        testnet = Cryptocurrency(symbol='TESTNET3',
                                 name='TESTNET3',
                                 wallet_id='TESTNET3')
        rinkeby = Cryptocurrency(symbol='RINKEBY',
                                 name='RINKEBY',
                                 wallet_id='RINKEBY')
        cls.session.add(testnet)
        cls.session.add(rinkeby)

        cls.session.commit()

        class MockStexchangeClient(StexchangeClient):
            def __init__(self, headers=None):
                super().__init__("", headers)

            def asset_list(self):
                return ujson.loads(
                    '[{"name": "RINKEBY", "prec": 8}, {"name": "TESTNET3", "prec": 8}]'
                )

            def balance_query(self, *args, **kwargs):
                return ujson.loads(
                    '{"TESTNET3": {"available": "9137.8", "freeze": "0"}, "RINKEBY": {"available": "100.65", '
                    '"freeze": "10.01"}}')

        stexchange_client._set_instance(MockStexchangeClient())
Exemple #10
0
    def __verify_fixed_phone_verification(self):
        client = Client.current()

        if client.evidence.fixed_phone is not None:
            raise HttpConflict('Already verified.', 'already-verified')

        phone = context.form.get('phone')
        code = context.form.get('code')

        oath = Oath(seed=settings.fixed_phone_verification.seed, derivate_seed_from=client.email)
        if oath.verify(challenge=phone[1:], code=code)[0] is True:
            client.evidence.fixed_phone = phone
            context.application.__authenticator__.invalidate_member(client.id)
            return client

        raise HttpBadRequest()
Exemple #11
0
    def __schedule_email_verification(self):
        client = Client.current()

        if client.is_email_verified is True or client.is_evidence_verified is True:
            raise HttpConflict('Already verified.', 'already-verified')

        principal = VerificationEmailPrincipal({'id': client.id})
        # noinspection PyArgumentList
        task = VerificationEmail(
            to=client.email,
            subject='Email verification',
            body={'token': principal.dump().decode()},
        )

        DBSession.add(task)
        return
Exemple #12
0
    def __verify_email_verification(self):
        token = context.form.get('token')
        try:
            principal = VerificationEmailPrincipal.load(token)
        except itsdangerous.SignatureExpired:
            raise HttpBadRequest()

        except itsdangerous.BadData:
            raise HttpBadRequest()

        if principal.id != context.identity.id:
            raise HttpBadRequest()

        client = Client.current()
        client.is_email_verified = True
        context.application.__authenticator__.invalidate_member(client.id)

        return client
Exemple #13
0
    def __schedule_fixed_phone_verification(self):
        client = Client.current()

        if client.evidence.fixed_phone is not None:
            raise HttpConflict('Already verified.', 'already-verified')

        phone = context.form.get('phone')

        # TODO: The following error can cause security issues!
        if ClientEvidence.query.filter(ClientEvidence.fixed_phone == phone).count() > 0:
            raise HttpConflict('Already used.', 'already-used')

        oath = Oath(seed=settings.fixed_phone_verification.seed, derivate_seed_from=client.email)
        code = oath.generate(challenge=phone[1:])

        sms = VerificationSms()
        sms.to = phone
        sms.body = {'code': code, 'template': settings.fixed_phone_verification.template}

        DBSession.add(sms)
    def mockup(cls):
        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        client1.is_email_verified = True
        cls.session.add(client1)

        cls.session.commit()

        cls.client1_id = client1.id

        cls.mockup_mobile_phone = '+119954395345'
        cls.valid_mobile_verification_code = '168875'
        cls.bad_mobile_verification_code = '101010'

        cls.mockup_fixed_phone = '+112159409435'
        cls.valid_fixed_verification_code = '200666'
        cls.bad_fixed_verification_code = '101010'
Exemple #15
0
    def mockup(cls):
        admin1 = Admin()
        admin1.email = '*****@*****.**'
        admin1.password = '******'
        admin1.is_active = True

        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        client1.is_email_verified = True
        client1.is_evidence_verified = True

        cls.session.add(admin1)
        cls.session.add(client1)

        usd = Fiat(symbol='USD', name='USA Dollar')

        cls.session.add(usd)

        cls.session.commit()

        cls.client1_id = client1.id
Exemple #16
0
    def mockup(cls):
        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        client1.is_email_verified = True
        client1.is_evidence_verified = True
        cls.session.add(client1)

        irr = Fiat(
            symbol='IRR',
            name='Iran Rial',
            normalization_scale=-5,
            smallest_unit_scale=-3,
        )
        cls.session.add(irr)

        # Adding a payment gateway
        shaparak = PaymentGateway()
        shaparak.name = "shaparak"
        shaparak.fiat_symbol = "IRR"
        shaparak.cashin_min = cashin_min
        shaparak.cashin_max = cashin_max
        shaparak.cashin_static_commission = cashin_static_commission
        shaparak.cashin_commission_rate = cashin_commission_rate
        shaparak.cashin_max_commission = cashin_max_commission
        cls.session.add(shaparak)

        shetab_address_1 = BankCard()
        shetab_address_1.pan = mockup_card_address
        shetab_address_1.holder = "Test Tester"
        shetab_address_1.client = client1
        shetab_address_1.fiat_symbol = "IRR"
        shetab_address_1.is_verified = True

        cls.session.add(shetab_address_1)

        cls.session.commit()

        cls.mockup_client_1_id = client1.id
        cls.mockup_shetab_address_1_id = shetab_address_1.id
        cls.mockup_payment_gateway_name = shaparak.name

        class MockStexchangeClient(StexchangeClient):
            def __init__(self, headers=None):
                super().__init__("", headers)
                self.mock_balance = ["0", "0"]

            def asset_list(self):
                return ujson.loads('[{"name": "IRR", "prec": 2}]')

            def balance_update(self, user_id, asset, business, business_id, change, detail):
                if user_id == cls.mockup_client_1_id and business == 'cashin' and asset == 'IRR':
                    self.mock_balance[0] = '{:.8f}'.format(Decimal(self.mock_balance[0]) + Decimal(change))
                return ujson.loads(
                    '{"IRR": {"available": "' +
                    self.mock_balance[0] +
                    '", "freeze": "' +
                    self.mock_balance[1] +
                    '"}}'
                )

            def balance_query(self, *args, **kwargs):
                return ujson.loads(
                    '{"IRR": {"available": "' +
                    self.mock_balance[0] +
                    '", "freeze": "' +
                    self.mock_balance[1] +
                    '"}}'
                )

        stexchange_client._set_instance(MockStexchangeClient())
Exemple #17
0
    def mockup(cls):
        admin1 = Admin()
        admin1.email = '*****@*****.**'
        admin1.password = '******'
        admin1.is_active = True
        cls.session.add(admin1)

        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        client1.is_email_verified = True
        client1.is_evidence_verified = True
        cls.session.add(client1)

        client2 = Client()
        client2.email = '*****@*****.**'
        client2.password = '******'
        client2.is_active = True
        client2.is_email_verified = True
        client2.is_evidence_verified = True
        cls.session.add(client2)

        irr = Fiat(
            symbol='IRR',
            name='Iran Rial',
        )
        cls.session.add(irr)

        # Adding a payment gateway
        shaparak = PaymentGateway()
        shaparak.name = "shaparak"
        shaparak.fiat_symbol = "IRR"
        shaparak.cashout_min = cashout_min
        shaparak.cashout_max = cashout_max
        shaparak.cashout_static_commission = cashout_static_commission
        shaparak.cashout_commission_rate = cashout_commission_rate
        shaparak.cashout_max_commission = cashout_max_commission
        cls.session.add(shaparak)

        # Mine, verified:
        sheba_address_1 = BankAccount()
        sheba_address_1.iban = 'IR123456789123456789123456'
        sheba_address_1.owner = "Client One"
        sheba_address_1.client = client1
        sheba_address_1.fiat_symbol = "IRR"
        sheba_address_1.is_verified = True

        # Mine, unverified:
        sheba_address_2 = BankAccount()
        sheba_address_2.iban = 'IR837498056254698443242343'
        sheba_address_2.owner = "Client One"
        sheba_address_2.client = client1
        sheba_address_2.fiat_symbol = "IRR"
        sheba_address_2.is_verified = False

        # Other's, verified:
        sheba_address_3 = BankAccount()
        sheba_address_3.iban = 'IR837498056254698443242343'
        sheba_address_3.owner = "Client Two"
        sheba_address_3.client = client2
        sheba_address_3.fiat_symbol = "IRR"
        sheba_address_3.is_verified = True

        for address in [sheba_address_1, sheba_address_2, sheba_address_3]:
            cls.session.add(address)

        cls.session.commit()

        cls.mockup_client_1_id = client1.id

        cls.mockup_sheba_address_verified_id = sheba_address_1.id
        cls.mockup_sheba_address_unverified_id = sheba_address_2.id
        cls.mockup_sheba_address_others_id = sheba_address_3.id
        cls.mockup_payment_gateway_name = shaparak.name

        class MockStexchangeClient(StexchangeClient):
            def __init__(self, headers=None):
                super().__init__("", headers)
                self.mock_balance = ["3001", "0"]

            def asset_list(self):
                return ujson.loads('[{"name": "IRR", "prec": 2}]')

            def balance_update(self, user_id, asset, business, business_id, change, detail):
                if user_id == cls.mockup_client_1_id and business in ['cashout', 'cashback'] and asset == 'IRR':
                    self.mock_balance[0] = '{:.8f}'.format(Decimal(change) + Decimal(self.mock_balance[0]))
                return ujson.loads(
                    '{"IRR": {"available": "' +
                    self.mock_balance[0] +
                    '", "freeze": "' +
                    self.mock_balance[1] +
                    '"}}'
                )

            def balance_query(self, *args, **kwargs):
                return ujson.loads(
                    '{"IRR": {"available": "' +
                    self.mock_balance[0] +
                    '", "freeze": "' +
                    self.mock_balance[1] +
                    '"}}'
                )

        stexchange_client._set_instance(MockStexchangeClient())
Exemple #18
0
    def mockup(cls):
        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        cls.session.add(client1)

        testnet = Cryptocurrency(symbol='TESTNET3',
                                 name='TESTNET3',
                                 wallet_id='TESTNET3')
        rinkeby = Cryptocurrency(symbol='RINKEBY',
                                 name='RINKEBY',
                                 wallet_id='RINKEBY')
        rinkeby_testnet = Market(
            name="TESTNET3_RINKEBY",
            base_currency=rinkeby,
            quote_currency=testnet,
            buy_amount_min=10,
            buy_amount_max=10000,
            sell_amount_min=0,
            sell_amount_max=0,
            taker_commission_rate="0.4",
            maker_commission_rate="0.1",
        )
        cls.session.add(rinkeby_testnet)

        cls.session.commit()

        cls.mock_client1 = client1

        class MockStexchangeClient(StexchangeClient):
            def __init__(self, headers=None):
                super().__init__("", headers)

            def market_last(self, market):
                return '2.00000000'

            def market_list(self):
                return ujson.loads(
                    '[{"name": "TESTNET3_RINKEBY", "stock": "rinkeby", "stock_prec": 8, "money": "testnet3", '
                    '"fee_prec": 4, "min_amount": "0.00001", "money_prec": 8}] '
                )

            def market_summary(self, market):
                return ujson.loads(
                    '[{"name": "TESTNET3_RINKEBY", "bid_amount": "0", "bid_count": 0, "ask_count": 0, '
                    '"ask_amount":"0"}] ')

            def market_status(self, market, period):
                return ujson.loads(
                    '{"low": "2", "period": 86400, "deal": "1622", "high": "88", "last": "2", "open": "88", "close": '
                    '"2", "volume": "37"} ')

            def market_status_today(self, market):
                return ujson.loads(
                    '{"open": "88", "deal": "1622", "high": "88", "last": "2", "low": "2", "volume": "37"}'
                )

            def market_kline(self, market, start, end, interval):
                return ujson.loads(
                    '[[1547337600, "88", "2", "88", "2", "37", "1622", "TESTNET3RINKEBY"]]'
                )

            def market_deals(self, market, limit, last_id):
                if market == 'TESTNET3_RINKEBY' and limit == 10 and last_id < 18:
                    return ujson.loads(
                        '[{"id": 27, "time": 1547419172.446089, "price": "2", "amount": "3", "type": "sell"},{"id": 26,'
                        '"time": 1547419117.217958, "price": "2", "amount": "3", "type": "sell"}, {"id": 25, '
                        '"time": 1547419093.255915, "price": "2", "amount": "3", "type": "sell"}, {"id": 24, '
                        '"time": 1547419090.164703, "price": "2", "amount": "3", "type": "sell"}, {"id": 23, '
                        '"time": 1547419079.117212, "price": "2", "amount": "3", "type": "sell"}, {"id": 22, '
                        '"time": 1547419050.312692, "price": "2", "amount": "1", "type": "sell"}, {"id": 21, '
                        '"time": 1547419045.695404, "price": "2", "amount": "1", "type": "sell"}, {"id": 20, '
                        '"time": 1547419044.574597, "price": "2", "amount": "1", "type": "sell"}, {"id": 19, '
                        '"time": 1547419043.018591, "price": "2", "amount": "1", "type": "sell"}, {"id": 18, '
                        '"time": 1547419014.44956, "price": "88", "amount": "1", "type": "sell"}]'
                    )
                raise StexchangeUnknownException()

            def market_user_deals(self, user_id, market, offset, limit):
                if user_id == cls.mock_client1.id and market == 'TESTNET3_RINKEBY' and offset == 0 and limit == 10:
                    return ujson.loads(
                        '{"offset": 0, "limit": 10, "records": [{"time": 1547419172.446089, "id": 27, "side": 2, '
                        '"price": "2", "user": 1, "fee": "0.3", "role": 1, "amount": "3", "deal": "6", '
                        '"deal_order_id": 61}, {"time": 1547419172.446089, "id": 27, "side": 1, "price": "2", '
                        '"user": 1, "fee": "0.6", "role": 2, "amount": "3", "deal": "6", "deal_order_id": 60}, '
                        '{"time": 1547419117.217958, "id": 26, "side": 2, "price": "2", "user": 1, "fee": "0.3", '
                        '"role": 1, "amount": "3", "deal": "6", "deal_order_id": 59}, {"time": 1547419117.217958, '
                        '"id": 26, "side": 1, "price": "2", "user": 1, "fee": "0.6", "role": 2, "amount": "3", '
                        '"deal": "6", "deal_order_id": 58}, {"time": 1547419093.255915, "id": 25, "side": 2, '
                        '"price": "2", "user": 1, "fee": "0.3", "role": 1, "amount": "3", "deal": "6", '
                        '"deal_order_id": 57}, {"time": 1547419093.255915, "id": 25, "side": 1, "price": "2", '
                        '"user": 1, "fee": "0.6", "role": 2, "amount": "3", "deal": "6", "deal_order_id": 56}, '
                        '{"time": 1547419090.164703, "id": 24, "side": 2, "price": "2", "user": 1, "fee": "0.3", '
                        '"role": 1, "amount": "3", "deal": "6", "deal_order_id": 55}, {"time": 1547419090.164703, '
                        '"id": 24, "side": 1, "price": "2", "user": 1, "fee": "0.6", "role": 2, "amount": "3", '
                        '"deal": "6", "deal_order_id": 54}, {"time": 1547419079.117212, "id": 23, "side": 2, '
                        '"price": "2", "user": 1, "fee": "0.3", "role": 1, "amount": "3", "deal": "6", '
                        '"deal_order_id": 53}, {"time": 1547419079.117212, "id": 23, "side": 1, "price": "2", '
                        '"user": 1, "fee": "0.6", "role": 2, "amount": "3", "deal": "6", "deal_order_id": 52}]} '
                    )
                raise StexchangeUnknownException()

            def order_book(self, market, side, offset, limit):
                return ujson.loads(
                    """{"offset": 0, "orders": [], "limit": 10, "total": 0}""")

            def order_depth(self, market, limit, interval):
                if market == 'TESTNET3_RINKEBY' and interval == 0:
                    return ujson.loads(
                        """{"asks": [], "bids": [["2", "97"]]}""")
                raise StexchangeUnknownException()

        stexchange_client._set_instance(MockStexchangeClient())
Exemple #19
0
 def disable(self):
     Client.current().has_second_factor = False
     return {'message': 'done'}
Exemple #20
0
 def enable(self):
     Client.current().has_second_factor = True
     return {'message': 'done'}
Exemple #21
0
    def mockup(cls):
        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        client1.is_evidence_verified = True
        cls.session.add(client1)

        usd = Fiat(symbol='USD',
                   name='USA Dollar',
                   smallest_unit_scale=-1,
                   normalization_scale=0)
        btc = Cryptocurrency(symbol='BTC',
                             name='Bitcoin',
                             wallet_id='BTC',
                             smallest_unit_scale=-4,
                             normalization_scale=0)
        btc_usd = Market(
            name="BTC_USD",
            base_currency=btc,
            quote_currency=usd,
            buy_amount_min=10,
            buy_amount_max=10000,
            sell_amount_min=0,
            sell_amount_max=0,
            taker_commission_rate="0.4",
            maker_commission_rate="0.1",
        )
        cls.session.add(btc_usd)

        cls.session.commit()

        cls.market1_name = btc_usd.name
        cls.mockup_client_1_id = client1.id

        class MockStexchangeClient(StexchangeClient):
            def __init__(self, headers=None):
                super().__init__("", headers)
                self.mock_balance_btc = ['0', '0']
                self.mock_balance_usd = ['15500', '0']

            def asset_list(self):
                return ujson.loads(
                    '[{"name": "BTC", "prec": 8}, {"name": "USD", "prec": 2}]')

            def market_last(self, market):
                if market == 'BTC_USD':
                    return '1000.00000000'

            def balance_update(self, user_id, asset, business, business_id,
                               change, detail):
                if user_id == cls.mockup_client_1_id and business in [
                        'deposit', 'withdraw'
                ]:
                    (self.mock_balance_btc if asset == 'BTC' else
                     self.mock_balance_usd)[0] += int(change)
                    return ujson.loads('{"btc": {"available": "' +
                                       self.mock_balance_btc[0] +
                                       '", "freeze": "' +
                                       self.mock_balance_btc[1] +
                                       '"}, {usd": {"available": "' +
                                       self.mock_balance_usd[0] +
                                       '", "freeze": "' +
                                       self.mock_balance_usd[1] + '"}}')
                else:
                    raise StexchangeUnknownException("Error updateing balance")

            def balance_query(self, *args, **kwargs):
                return ujson.loads('{"btc": {"available": "' +
                                   self.mock_balance_btc[0] +
                                   '", "freeze": "' +
                                   self.mock_balance_btc[1] +
                                   '"}, {usd": {"available": "' +
                                   self.mock_balance_usd[0] +
                                   '", "freeze": "' +
                                   self.mock_balance_usd[1] + '"}}')

            def order_put_limit(self, user_id, market, side, amount, price,
                                taker_fee_rate, maker_fee_rate, source):
                if Decimal(amount) == Decimal('120'):
                    raise BalanceNotEnoughException(0)

                return ujson.loads(
                    """{"price": "2", "id": 62, "side": 2, "market": "BTC_USD", "taker_fee": "0.1",
                "type": 1, "deal_fee": "0", "deal_stock": "0", "maker_fee": "0.1", "source": "abc", "user": 1,
                "left": "100", "ctime": 1547419213.026914, "mtime": 1547419213.026914, "amount": "100", "deal_money":
                "0"} """)

            def order_put_market(self, user_id, market, side, amount,
                                 taker_fee_rate, source):
                if Decimal(amount) == Decimal('120'):
                    raise BalanceNotEnoughException(0)
                return ujson.loads(
                    """{"price": "0", "id": 63, "side": 1, "market": "BTC_USD", "taker_fee":
                "0.1", "type": 2, "deal_fee": "0.6", "deal_stock": "3", "maker_fee": "0", "source": "cbd", "user": 1,
                "left": "0e-8", "ctime": 1547419213.029479, "mtime": 1547419213.029483, "amount": "3", "deal_money":
                "6"}""")

            def order_pending(self, user_id, market, offset, limit):
                return ujson.loads(
                    """{"limit": 10, "offset": 0, "total": 1, "records": [{"price": "2", "id": 62,
                "side": 2, "market": "BTC_USD", "taker_fee": "0.1", "type": 1, "deal_fee": "0.3",
                "deal_stock": "3", "maker_fee": "0.1", "source": "abc", "user": 1, "left": "97",
                "ctime": 1547419213.026914, "mtime": 1547419213.029483, "amount": "100", "deal_money": "6"}]}"""
                )

            def order_pending_detail(self, market, order_id):
                return ujson.loads(
                    """{"price": "2", "id": 62, "side": 2, "market": "BTC_USD", "taker_fee":
                "0.1", "type": 1, "deal_fee": "0.3", "deal_stock": "3", "maker_fee": "0.1", "source": "abc",
                "user": 1, "left": "97", "ctime": 1547419213.026914, "mtime": 1547419213.029483, "amount": "100",
                "deal_money": "6"}""")

            def order_finished(self, user_id, market, start_time, end_time,
                               offset, limit, side):
                if market == 'BTC_USD' and user_id == cls.mockup_client_1_id and offset < 18:
                    return ujson.loads(
                        """{"offset": 0, "limit": 20, "records": [{"id": 61, "source": "cbd", "side":
                    1, "type": 2, "deal_money": "6", "ctime": 1547419172.446086, "ftime": 1547419172.446089,
                    "user": 1, "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1",
                    "maker_fee": "0", "deal_stock": "3", "deal_fee": "0.6"}, {"id": 59, "source": "cbd", "side": 1,
                    "type": 2, "deal_money": "6", "ctime": 1547419117.217955, "ftime": 1547419117.217958, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "3", "deal_fee": "0.6"}, {"id": 57, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "6", "ctime": 1547419093.255911, "ftime": 1547419093.255915, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "3", "deal_fee": "0.6"}, {"id": 55, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "6", "ctime": 1547419090.1647, "ftime": 1547419090.164703, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "3", "deal_fee": "0.6"}, {"id": 53, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "6", "ctime": 1547419079.117208, "ftime": 1547419079.117212, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "3", "deal_fee": "0.6"}, {"id": 51, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "2", "ctime": 1547419050.312686, "ftime": 1547419050.312692, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "1", "deal_fee": "0.2"}, {"id": 49, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "2", "ctime": 1547419045.695398, "ftime": 1547419045.695404, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "1", "deal_fee": "0.2"}, {"id": 47, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "2", "ctime": 1547419044.574593, "ftime": 1547419044.574597, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "1", "deal_fee": "0.2"}, {"id": 45, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "2", "ctime": 1547419043.018587, "ftime": 1547419043.018591, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "1", "deal_fee": "0.2"}, {"id": 43, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "88", "ctime": 1547419014.449556, "ftime": 1547419014.44956, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "1", "deal_fee": "8.8"}, {"id": 41, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "88", "ctime": 1547419005.914382, "ftime": 1547419005.914387, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "1", "deal_fee": "8.8"}, {"id": 39, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "88", "ctime": 1547418994.681865, "ftime": 1547418994.681873, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "1", "deal_fee": "8.8"}, {"id": 37, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "88", "ctime": 1547418971.478641, "ftime": 1547418971.478644, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "1", "deal_fee": "8.8"}, {"id": 35, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "176", "ctime": 1547418955.745287, "ftime": 1547418955.745518, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "2", "deal_fee": "17.6"}, {"id": 33, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "264", "ctime": 1547418943.696649, "ftime": 1547418943.697126, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "3", "deal_fee": "26.4"}, {"id": 31, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "264", "ctime": 1547418864.639109, "ftime": 1547418864.639465, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "3", "deal_fee": "26.4"}, {"id": 29, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "264", "ctime": 1547418683.910061, "ftime": 1547418683.910436, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "3", "deal_fee": "26.4"}, {"id": 27, "source": "cbd", "side": 1, "type": 2,
                    "deal_money": "264", "ctime": 1547418339.31098, "ftime": 1547418339.311348, "user": 1,
                    "market": "BTC_USD", "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0",
                    "deal_stock": "3", "deal_fee": "26.4"}]}""")
                raise StexchangeUnknownException()

            def order_finished_detail(self, order_id):
                if order_id == 57:
                    return ujson.loads(
                        """{"id": 57, "source": "cbd", "side": 1, "type": 2, "deal_money": "6",
                    "ctime": 1547419093.255911, "ftime": 1547419093.255915, "user": 1, "market": "BTC_USD",
                    "price": "0", "amount": "3", "taker_fee": "0.1", "maker_fee": "0", "deal_stock": "3", "deal_fee":
                    "0.6"}""")
                raise StexchangeUnknownException()

            def order_deals(self, order_id, offset, limit):
                if order_id == 1 and offset == 0:
                    return ujson.loads(
                        """{"offset": 0, "limit": 10, "records": []}""")
                raise StexchangeUnknownException()

            def order_cancel(self, user_id, market, order_id):
                if user_id == cls.mockup_client_1_id and market == 'BTC_USD' and order_id == 1:
                    return ujson.loads(
                        """{"price": "2", "id": 62, "side": 2, "market": "BTC_USD",
                    "taker_fee": "0.1", "type": 1, "deal_fee": "0.3", "deal_stock": "3", "maker_fee": "0.1",
                    "source": "abc", "user": 1, "left": "97", "ctime": 1547419213.026914, "mtime": 1547419213.029483,
                    "amount": "100", "deal_money": "6"}""")
                raise StexchangeUnknownException()

        stexchange_client._set_instance(MockStexchangeClient())
Exemple #22
0
app.configure()
# app.initialize_models()

with DatabaseManager() as m:
    m.drop_database()
    m.create_database()

engine = create_engine()
session = session_factory(bind=engine, expire_on_commit=True)
setup_schema(session)
session.commit()
session.close()

session0 = session_factory(bind=engine, expire_on_commit=True)

client1 = Client()
client1.email = '*****@*****.**'
client1.password = '******'
client1.is_active = True
session0.add(client1)

fund1 = Fund(currency=Cryptocurrency(name='a', code='b'), client=client1)

fund2 = Fund(currency=Cryptocurrency(name='c', code='d'), client=client1)

session0.add(fund1)
session0.add(fund2)
session0.commit()

print(fund1)
print(fund2)
    def mockup(cls):
        cls.mockup_attachment1 = join(STUFF_DIR, 'test-image-1.jpg')
        cls.mockup_attachment2 = join(STUFF_DIR, 'test-image-2.png')

        admin1 = Admin()
        admin1.email = '*****@*****.**'
        admin1.password = '******'
        admin1.is_active = True
        cls.session.add(admin1)

        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        cls.session.add(client1)

        client2 = Client()
        client2.email = '*****@*****.**'
        client2.password = '******'
        client2.is_active = True
        client2.is_email_verified = True
        cls.session.add(client2)

        department1 = TicketDepartment(title='department-1')
        department2 = TicketDepartment(title='department-2')
        cls.session.add(department1)
        cls.session.add(department2)

        cls.session.commit()

        cls.mockup_department1_id = department1.id
        cls.mockup_admin1_id = admin1.id
        cls.mockup_client1_id = client1.id
        cls.mockup_client2_id = client2.id
Exemple #24
0
    def mockup(cls):
        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        cls.session.add(client1)

        client2 = Client()
        client2.email = '*****@*****.**'
        client2.password = '******'
        client2.is_active = True
        client2.is_email_verified = True
        cls.session.add(client2)

        client3 = Client()
        client3.email = '*****@*****.**'
        client3.password = '******'
        client3.is_active = True
        cls.session.add(client3)

        cls.session.commit()

        cls.client1_id = client1.id
    def mockup(cls):
        client1 = Client()
        client1.email = '*****@*****.**'
        client1.password = '******'
        client1.is_active = True
        client1.is_email_verified = True
        cls.session.add(client1)

        cls.session.flush()

        btc = Cryptocurrency(
            symbol='BTC',
            name='Bitcoin',
            wallet_id='BTC',
            withdraw_min=withdraw_min,
            withdraw_max=withdraw_max,
            withdraw_static_commission=withdraw_static_commission,
            withdraw_commission_rate=withdraw_commission_rate,
            withdraw_max_commission=withdraw_max_commission,
        )
        cls.session.add(btc)

        cls.session.commit()

        cls.mockup_client_1_id = client1.id

        class MockStexchangeClient(StexchangeClient):
            def __init__(self, headers=None):
                super().__init__("", headers)
                self.mock_balance = ["2200", "0"]

            def asset_list(self):
                return ujson.loads('[{"name": "BTC", "prec": 8}]')

            def balance_update(self, user_id, asset, business, business_id,
                               change, detail):
                if Decimal(change) < Decimal(0) and Decimal(
                        self.mock_balance[0]) + Decimal(change) < Decimal(0):
                    raise BalanceNotEnoughException(1)

                if user_id == cls.mockup_client_1_id and business == 'withdraw' and asset == 'BTC':
                    self.mock_balance[0] = '{:.8f}'.format(
                        Decimal(change) + Decimal(self.mock_balance[0]))
                return ujson.loads('{"BTC": {"available": "' +
                                   self.mock_balance[0] + '", "freeze": "' +
                                   self.mock_balance[1] + '"}}')

            def balance_query(self, *args, **kwargs):
                return ujson.loads('{"BTC": {"available": "' +
                                   self.mock_balance[0] + '", "freeze": "' +
                                   self.mock_balance[1] + '"}}')

        stexchange_client._set_instance(MockStexchangeClient())

        class MockStawalletClient(StawalletClient):
            def __init__(self, headers=None):
                super().__init__("", headers)
                self.mock_balance = ["0", "0"]

            # def get_wallets(self):
            #     return [{
            #         'id': '1',
            #         'balance': '1',
            #         'secret': '1',
            #         'onchainStatus': '1',
            #     }]

            def get_invoice(self, wallet_id, invoice_id):
                if wallet_id == 'BTC' and invoice_id == 1:
                    return ujson.loads("""
                                        {
                                          "id" : 1,
                                          "wallet" : "BTC",
                                          "extra" : null,
                                          "user" : "1",
                                          "creation" : "2019-03-19T12:11:10.337+03:00",
                                          "expiration" : null,
                                          "address" : {
                                            "id" : 2,
                                            "wallet" : "BTC",
                                            "address" : "1D6CqUvHtQRXU4TZrrj5j1iofo8f4oXyLj",
                                            "active" : true
                                          }
                                        } 
                                    """)

            def get_invoices(self, wallet_id, user_id):
                if wallet_id == 'BTC' and user_id == 1:
                    return ujson.loads("""
                                    [ 
                                        {
                                          "id" : 1,
                                          "wallet" : "BTC",
                                          "extra" : null,
                                          "user" : "1",
                                          "creation" : "2019-03-19T12:11:10.337+03:00",
                                          "expiration" : null,
                                          "address" : {
                                            "id" : 2,
                                            "wallet" : "BTC",
                                            "address" : "1D6CqUvHtQRXU4TZrrj5j1iofo8f4oXyLj",
                                            "active" : true
                                          }
                                        } 
                                    ]
                                    """)

            def post_invoice(self, wallet_id, user_id, force=False):
                if wallet_id == 'BTC' and user_id == 1:
                    if mock_address_usage[
                            '1D6CqUvHtQRXU4TZrrj5j1iofo8f4oXyLj']:
                        return ujson.loads("""
                                    [ 
                                        {
                                          "id" : 2,
                                          "wallet" : "BTC",
                                          "extra" : null,
                                          "user" : "1",
                                          "creation" : "2019-03-19T12:11:10.337+03:00",
                                          "expiration" : null,
                                          "address" : {
                                            "id" : 2,
                                            "wallet" : "BTC",
                                            "address" : "1AJbsFZ64EpEfS5UAjAfcUG8pH8Jn3rn1F",
                                            "active" : true
                                          }
                                        } 
                                    ]
                                    """)
                    else:
                        raise StawalletHttpException(409, {})

            def get_deposits(self, wallet_id, user_id, page=0):
                if wallet_id == 'BTC' and user_id == 1:
                    if mock_address_usage[
                            '1D6CqUvHtQRXU4TZrrj5j1iofo8f4oXyLj']:
                        return ujson.loads("""
                                        [{
                                          "id" : 1,
                                          "invoice" : {
                                            "id" : 1,
                                            "wallet" : "BTC",
                                            "extra" : null,
                                            "user" : "1",
                                            "creation" : "2019-03-19T12:38:11.310+03:00",
                                            "expiration" : null,
                                            "address" : {
                                              "id" : 2,
                                              "wallet" : "BTC",
                                              "address" : "1D6CqUvHtQRXU4TZrrj5j1iofo8f4oXyLj",
                                              "active" : true
                                            }
                                          },
                                          "grossAmount" : 198763,
                                          "netAmount" : 198000,
                                          "proof" : {
                                            "txHash" : "5061556f857e118aae8d948496f61f645e12cf7ca2a107f8e4ae78b535e86dfb",
                                            "blockHash" : "000000000000000000188252ee9277e8f60482a91b7f3cc9a4a7fb75ded482a8",
                                            "blockHeight" : 562456,
                                            "confirmationsLeft" : 0,
                                            "confirmationsTrace" : [ ],
                                            "link" : "https://www.blockchain.com/btc/tx/5061556f857e118aae8d948496f61f645e12cf7ca2a107f8e4ae78b535e86dfb",
                                            "extra" : null,
                                            "error" : null
                                          },
                                          "status" : "ACCEPTED",
                                          "extra" : null,
                                          "confirmed" : true
                                        }]""")
                    else:
                        return ujson.loads("[]")

            def get_deposit(self, wallet_id, deposit_id):
                if wallet_id == 'BTC' and deposit_id == 1:
                    if mock_address_usage[
                            '1D6CqUvHtQRXU4TZrrj5j1iofo8f4oXyLj']:
                        return ujson.loads("""
                                        {
                                          "id" : 1,
                                          "invoice" : {
                                            "id" : 1,
                                            "wallet" : "BTC",
                                            "extra" : null,
                                            "user" : "1",
                                            "creation" : "2019-03-19T12:38:11.310+03:00",
                                            "expiration" : null,
                                            "address" : {
                                              "id" : 2,
                                              "wallet" : "BTC",
                                              "address" : "1D6CqUvHtQRXU4TZrrj5j1iofo8f4oXyLj",
                                              "active" : true
                                            }
                                          },
                                          "grossAmount" : 198763,
                                          "netAmount" : 198000,
                                          "proof" : {
                                            "txHash" : "5061556f857e118aae8d948496f61f645e12cf7ca2a107f8e4ae78b535e86dfb",
                                            "blockHash" : "000000000000000000188252ee9277e8f60482a91b7f3cc9a4a7fb75ded482a8",
                                            "blockHeight" : 562456,
                                            "confirmationsLeft" : 0,
                                            "confirmationsTrace" : [ ],
                                            "link" : "https://www.blockchain.com/btc/tx/5061556f857e118aae8d948496f61f645e12cf7ca2a107f8e4ae78b535e86dfb",
                                            "extra" : null,
                                            "error" : null
                                          },
                                          "status" : "ACCEPTED",
                                          "extra" : null,
                                          "confirmed" : true
                                        }""")

            def get_withdraws(self, wallet_id, user_id, page=0):
                if wallet_id == 'BTC' and user_id == 1:
                    return ujson.loads("""
                        [ {
                          "id" : 1,
                          "businessUid" : "abc-def-gh",
                          "wallet" : "test-btc-wallet",
                          "user" : "1",
                          "target" : "1Mwz1i3MK7AruNFwF3X84FK4qMmpooLtZG",
                          "netAmount" : 65020000,
                          "grossAmount" : 65740000,
                          "estimatedNetworkFee" : 50000,
                          "finalNetworkFee" : null,
                          "type" : "withdraw",
                          "status" : "queued",
                          "txid" : null,
                          "proof" : null,
                          "issuedAt" : "2019-03-20T12:55:46.390+03:00",
                          "paidAt" : null,
                          "trace" : null,
                          "manual" : true
                        } ]""")

            def get_withdraw(self, wallet_id, withdraw_id):
                return ujson.loads("""
                    {
                      "id" : 1,
                      "businessUid" : "abc-def-gh",
                      "wallet" : "test-btc-wallet",
                      "user" : "1",
                      "target" : "2N2sn7skY9ZcDph2ougMdKn9a7tFj9ADhNV",
                      "netAmount" : 65020000,
                      "grossAmount" : 65740000,
                      "estimatedNetworkFee" : 50000,
                      "finalNetworkFee" : null,
                      "type" : "withdraw",
                      "status" : "queued",
                      "txid" : null,
                      "proof" : null,
                      "issuedAt" : "2019-03-20T12:54:44.009+03:00",
                      "paidAt" : null,
                      "trace" : null,
                      "manual" : true
                    }""")

            def schedule_withdraw(self,
                                  wallet_id,
                                  user_id,
                                  business_uid,
                                  is_manual: bool,
                                  destination_address,
                                  amount_to_be_withdrawed,
                                  withdrawal_fee,
                                  estimated_network_fee,
                                  is_decharge=False):
                mock_business_uid_usage['abc-def-gh'] = True
                return ujson.loads("""{
                      "id" : 2,
                      "businessUid" : "abc-def-gh",
                      "wallet" : "test-btc-wallet",
                      "user" : "1",
                      "target" : "2N2sn7skY9ZcDph2ougMdKn9a7tFj9ADhNV",
                      "netAmount" : 2000,
                      "grossAmount" : 2175,
                      "estimatedNetworkFee" : 0,
                      "finalNetworkFee" : null,
                      "type" : "withdraw",
                      "status" : "queued",
                      "txid" : null,
                      "proof" : null,
                      "issuedAt" : "2019-03-20T12:52:26.948+03:00",
                      "paidAt" : null,
                      "trace" : "2019-03-20T12:52:38.228+03:00 : Issued (automatic)",
                      "manual" : true
                    }""")

            def edit_withdraw(self, wallet_id, withdraw_id, is_manual: bool):
                return ujson.loads("""
                    {
                      "id" : 2,
                      "businessUid" : "abc-def-gh",
                      "wallet" : "test-btc-wallet",
                      "user" : "1",
                      "target" : "2N2sn7skY9ZcDph2ougMdKn9a7tFj9ADhNV",
                      "netAmount" : 93511223,
                      "grossAmount" : 93583223,
                      "estimatedNetworkFee" : 485385,
                      "finalNetworkFee" : null,
                      "type" : "withdraw",
                      "status" : "waiting_manual",
                      "txid" : null,
                      "proof" : null,
                      "issuedAt" : "2019-03-20T12:52:26.948+03:00",
                      "paidAt" : null,
                      "trace" : "2019-03-20T12:52:38.228+03:00 : Issued (automatic)\n2019-03-20T12:53:28.001+03:00 : Change to manual",
                      "manual" : true
                    }""")

            def resolve_withdraw(self, wallet_id, withdraw_id,
                                 final_network_fee, transaction_hash: str):
                return ujson.loads("""
                    {
                      "id" : 2,
                      "businessUid" : "abc-def-gh",
                      "wallet" : "test-btc-wallet",
                      "user" : "1",
                      "target" : "2N2sn7skY9ZcDph2ougMdKn9a7tFj9ADhNV",
                      "netAmount" : 93511223,
                      "grossAmount" : 93583223,
                      "estimatedNetworkFee" : 485385,
                      "finalNetworkFee" : 485385,
                      "type" : "withdraw",
                      "status" : "pushed",
                      "txid" : "b6f6991d03df0e2e04dafffcd6bc418aac66049e2cd74b80f14ac86db1e3f0da",
                      "proof" : null,
                      "issuedAt" : "2019-03-20T12:52:26.948+03:00",
                      "paidAt" : "2019-03-20T12:54:08.547+03:00",
                      "trace" : "2019-03-20T12:52:38.228+03:00 : Issued (automatic)\n2019-03-20T12:53:28.001+03:00 : Change to manual\n2019-03-20T12:54:08.547+03:00 : Submit manual withdrawal info",
                      "manual" : null
                    }""")

            def quote_withdraw(self, wallet_id, user_id, business_uid,
                               destination_address, amount):
                return ujson.loads(
                    """
                {
                  "estimatedNetworkFee" : 0,
                  "hasSufficientWalletBalance" : true,
                  "estimatedSendingTime" : 0,
                  "estimatedReceivingTime" : 0,
                  "errors" : [ ],
                  "addressValid" : """ +
                    str(len(destination_address) >= 30).lower() + """,
                  "networkUp" : true,
                  "sendingManually" : false,
                  "userEligible" : true,
                  "businessUidDuplicated" : """ +
                    str(mock_business_uid_usage['abc-def-gh']).lower() + """,
                  "businessUidValid" : true,
                  "amountValid" : true
                }""")

        stawallet_client._set_instance(MockStawalletClient())