<commit_before>(function () {
    "use strict";

    angular.module('blocktrail.wallet')
        .factory('simplexService', function (CONFIG, walletsManagerService, launchService, randomBytesJS, settingsService) {
            return new SimplexService(CONFIG, walletsManagerService, launchService, randomBytesJS, settingsService)
        });

    function SimplexService(CONFIG, walletsManagerService, launchService, randomBytesJS, settingsService) {
        var self = this;

        self._CONFIG = CONFIG;
        self._walletsManagerService = walletsManagerService;
        self._launchService = launchService;
        self._randomBytesJS = randomBytesJS;
        self._settingsService = settingsService;
    }

    SimplexService.prototype.generateUUID = function() {
        var id = this._randomBytesJS(32).toString('hex');
        return id.slice(0, 8) + '-' + id.slice(8, 12) + '-' + id.slice(12, 16) + '-' + id.slice(16, 20)  + '-' + id.slice(20, 32);
    };

    SimplexService.prototype.buyPrices = function(qty, fiat, fiatType, fiatFirst) {
        var self = this;

        var activeWallet = self._walletsManagerService.getActiveWallet();
        var sdk = activeWallet.getSdkWallet().sdk;

        // Default to USD
        if (!fiatType) {
            fiatType = 'USD'
        }

        var postData = {
            qty: qty,
            fiat: fiat,
            fiat_type: fiatType,
            fiat_first: fiatFirst,
            coin_type: activeWallet.getReadOnlyWalletData().networkType.replace('t', ''), // replace testnet
            platform: 'mobile'
        };

        return sdk.simplexBuyPrices(postData)
            .then(function(response) {
                // Check if result is for the correct coin
                var coinType = activeWallet.getReadOnlyWalletData().networkType.replace('BCC', 'BCH').replace('t', '') // replace testnet
                if (response.supported_digital_currencies) {
                    if (response.supported_digital_currencies.indexOf(coinType) == -1) {
                        throw new Exception('trying to buy different blockchain coin from wallet');
                    }
                }

                response.qty = response.digital_money.amount;
                response.total = response.fiat_money.total_amount;
                response.fees = response.fiat_money.total_amount - response.fiat_money.base_amount;

                return response;
            });
    };

    SimplexService.prototype.issuePaymentRequest = function (simplexData) {
        var self = this;

        var activeWallet = self._walletsManagerService.getActiveWallet();
        var sdk = activeWallet.getSdkWallet().sdk;

        var postData = {
            qty: simplexData.digital_money.amount,
            fiat: simplexData.fiat_money.total_amount,
            fiat_type: simplexData.fiat_money.currency,
            coin_type: activeWallet.getReadOnlyWalletData().networkType.replace('t', ''), // replace testnet
            address: simplexData.address,
            quote_id: simplexData.quote_id,
            order_id: simplexData.order_id,
            payment_id: simplexData.payment_id,
            platform: 'mobile'
        };

        return sdk.simplexPaymentRequest(postData)
    };

    SimplexService.prototype.initRedirect = function (simplexData) {
        var self = this;

        var activeWallet = self._walletsManagerService.getActiveWallet();
        var networkType = activeWallet.getReadOnlyWalletData().networkType;

        return self._launchService.getAccountInfo().then(function (accountInfo) {
            var data = {
                address: simplexData.address,
                identifier: simplexData.identifier,
                qty: simplexData.digital_money.amount,
                fiat: simplexData.fiat_money.total_amount,
                fiat_type: simplexData.fiat_money.currency,
                coin_type: activeWallet.getReadOnlyWalletData().networkType.replace('t', ''), // replace testnet
                quote_id: simplexData.quote_id,
                payment_id: simplexData.payment_id,
                api_key: accountInfo.api_key,
                platform: 'mobile'
            };

            var queryString = Object.keys(data)
                .map(function (k) {
                    return encodeURIComponent(k) + '=' + encodeURIComponent(data[k])
                })
                .join('&');

            // TODO: This can be network agnostic, as BUY BTC is only for BTC anyways
            window.open('http://' + self._CONFIG.API_HOST + '/v1/' + networkType + '/mywallet/simplex/payment/forward?' + queryString, '_system')
        });
    };
})();<commit_msg>post orderid for address labeling<commit_after>(function () {
    "use strict";

    angular.module('blocktrail.wallet')
        .factory('simplexService', function (CONFIG, walletsManagerService, launchService, randomBytesJS, settingsService) {
            return new SimplexService(CONFIG, walletsManagerService, launchService, randomBytesJS, settingsService)
        });

    function SimplexService(CONFIG, walletsManagerService, launchService, randomBytesJS, settingsService) {
        var self = this;

        self._CONFIG = CONFIG;
        self._walletsManagerService = walletsManagerService;
        self._launchService = launchService;
        self._randomBytesJS = randomBytesJS;
        self._settingsService = settingsService;
    }

    SimplexService.prototype.generateUUID = function() {
        var id = this._randomBytesJS(32).toString('hex');
        return id.slice(0, 8) + '-' + id.slice(8, 12) + '-' + id.slice(12, 16) + '-' + id.slice(16, 20)  + '-' + id.slice(20, 32);
    };

    SimplexService.prototype.buyPrices = function(qty, fiat, fiatType, fiatFirst) {
        var self = this;

        var activeWallet = self._walletsManagerService.getActiveWallet();
        var sdk = activeWallet.getSdkWallet().sdk;

        // Default to USD
        if (!fiatType) {
            fiatType = 'USD'
        }

        var postData = {
            qty: qty,
            fiat: fiat,
            fiat_type: fiatType,
            fiat_first: fiatFirst,
            coin_type: activeWallet.getReadOnlyWalletData().networkType.replace('t', ''), // replace testnet
            platform: 'mobile'
        };

        return sdk.simplexBuyPrices(postData)
            .then(function(response) {
                // Check if result is for the correct coin
                var coinType = activeWallet.getReadOnlyWalletData().networkType.replace('BCC', 'BCH').replace('t', '') // replace testnet
                if (response.supported_digital_currencies) {
                    if (response.supported_digital_currencies.indexOf(coinType) == -1) {
                        throw new Exception('trying to buy different blockchain coin from wallet');
                    }
                }

                response.qty = response.digital_money.amount;
                response.total = response.fiat_money.total_amount;
                response.fees = response.fiat_money.total_amount - response.fiat_money.base_amount;

                return response;
            });
    };

    SimplexService.prototype.issuePaymentRequest = function (simplexData) {
        var self = this;

        var activeWallet = self._walletsManagerService.getActiveWallet();
        var sdk = activeWallet.getSdkWallet().sdk;

        var postData = {
            qty: simplexData.digital_money.amount,
            fiat: simplexData.fiat_money.total_amount,
            fiat_type: simplexData.fiat_money.currency,
            coin_type: activeWallet.getReadOnlyWalletData().networkType.replace('t', ''), // replace testnet
            address: simplexData.address,
            quote_id: simplexData.quote_id,
            order_id: simplexData.order_id,
            payment_id: simplexData.payment_id,
            platform: 'mobile'
        };

        return sdk.simplexPaymentRequest(postData)
    };

    SimplexService.prototype.initRedirect = function (simplexData) {
        var self = this;

        var activeWallet = self._walletsManagerService.getActiveWallet();
        var networkType = activeWallet.getReadOnlyWalletData().networkType;

        return self._launchService.getAccountInfo().then(function (accountInfo) {
            var data = {
                address: simplexData.address,
                identifier: simplexData.identifier,
                qty: simplexData.digital_money.amount,
                fiat: simplexData.fiat_money.total_amount,
                fiat_type: simplexData.fiat_money.currency,
                coin_type: activeWallet.getReadOnlyWalletData().networkType.replace('t', ''), // replace testnet
                quote_id: simplexData.quote_id,
                payment_id: simplexData.payment_id,
                order_id: simplexData.order_id,
                api_key: accountInfo.api_key,
                platform: 'mobile'
            };

            var queryString = Object.keys(data)
                .map(function (k) {
                    return encodeURIComponent(k) + '=' + encodeURIComponent(data[k])
                })
                .join('&');

            window.open('http://' + self._CONFIG.API_HOST + '/v1/' + networkType + '/mywallet/simplex/payment/forward?' + queryString, '_system')
        });
    };
})();
{'fraction_non_alphanumeric': 0.10413985413985415, 'fraction_numerical': 0.0045045045045045045, 'mean_word_length': 2.1771720613287906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5695945', 'n_tokens_mistral': 2633, 'n_tokens_neox': 2501, 'n_words': 464}