DEL: LocalTrader (HodlHodl) starts with Globabl offers by default (closes #2465)

This commit is contained in:
Overtorment 2021-01-26 19:32:00 +00:00
parent 2448a15cac
commit ecea668b98
30 changed files with 24 additions and 93 deletions

24
FAQ.md Normal file
View file

@ -0,0 +1,24 @@
# FAQ
## Too much nodejs dependencies! Who audits all of that?
We do. Really, when we bump deps we glance over the diff, and all versions are
pinned. Also we use paid audit solution https://snyk.io which is specifically
designed to keep an eye on deps.
And yes we have too many of them, and PRs cutting deps are welcome
(see https://github.com/BlueWallet/BlueWallet/blob/master/CONTRIBUTING.md)
Also really risky dependencies (like, from not-reputable/anonymous maintainers)
we fork and use under our organization, and when we update them from upstream (rarely)
we do review the code
## Does BlueWallet downloads the Bitcoin Headers? I see no place you call blockchain.block.headers so I'm wondering how do you guys deal with the headers, how can you make sure you follow the correct chain in order to make sure you're spending a confirmed UTXO?
The idea is that by default BW doesnt use public electrum servers, only
ones hosted by bluewallet, so they are kinda trusted. And end-user has an
option to change electrum server to something he provides, so he knows what
is he doing and trusts his own electrum server.
We would definitely need proper SPV verification if we used random
electrum server every time from a pool of public servers.

View file

@ -76,39 +76,6 @@ export class HodlHodlApi {
return (this._countries = json.countries);
}
async getMyCountryCode() {
const _api = new Frisbee({ baseURI: 'https://ifconfig.co/' });
const _api2 = new Frisbee({ baseURI: 'https://geolocation-db.com/' });
let response;
let allowedTries = 6;
while (allowedTries > 0) {
// this API fails a lot, so lets retry several times
response = await _api.get('/country-iso', { headers: { 'Access-Control-Allow-Origin': '*' } });
let body = response.body;
if (typeof body === 'string') body = body.replace('\n', '');
if (!body || body.length !== 2) {
// trying api2
const response = await _api2.get('/json/', { headers: { 'Access-Control-Allow-Origin': '*' } });
body = response.body;
let json;
try {
json = JSON.parse(body);
} catch (_) {}
if (json && json.country_code) return (this._myCountryCode = json.country_code);
// failed, retry
allowedTries--;
await (async () => new Promise(resolve => setTimeout(resolve, 3000)))(); // sleep
} else {
return (this._myCountryCode = body);
}
}
throw new Error('API failure after several tries: ' + JSON.stringify(response));
}
async getPaymentMethods(country) {
const response = await this._api.get('/api/v1/payment_methods?filters[country]=' + country, this._getHeaders());

View file

@ -53,7 +53,6 @@
"filter_any": "أي عقد",
"filter_buying": "الشراء",
"filter_country_global": "العروض الشاملة",
"filter_country_near": "بالقرب مني",
"filter_currency": "العملة",
"filter_detail": "التفاصيل",
"filter_filters": "المرشحات",

View file

@ -55,7 +55,6 @@
"filter_any": "Всички",
"filter_buying": "Купуване",
"filter_country_global": "Всички оферти",
"filter_country_near": "Наблизо",
"filter_currency": "Валута",
"filter_detail": "Детайли",
"filter_filters": "Филтри",

View file

@ -58,7 +58,6 @@
"cont_title": "Els meus contractes",
"filter_buying": "Comprant",
"filter_country_global": "Ofertes globals",
"filter_country_near": "A prop meu",
"filter_currency": "Moneda",
"filter_detail": "Detalls",
"filter_filters": "Filtres",

View file

@ -61,7 +61,6 @@
"filter_any": "Žádné",
"filter_buying": "Nákup",
"filter_country_global": "Globální nabídky",
"filter_country_near": "Blízko mne",
"filter_currency": "Měna",
"filter_detail": "Detail",
"filter_filters": "Filtry",

View file

@ -61,7 +61,6 @@
"filter_any": "Jegliche",
"filter_buying": "Kaufen",
"filter_country_global": "Weltweite Angebote",
"filter_country_near": "In meiner Nähe",
"filter_currency": "Währung",
"filter_detail": "Details",
"filter_filters": "Filter",

View file

@ -61,7 +61,6 @@
"filter_any": "Any",
"filter_buying": "Buying",
"filter_country_global": "Global Offers",
"filter_country_near": "Near Me",
"filter_currency": "Currency",
"filter_detail": "Detail",
"filter_filters": "Filters",

View file

@ -61,7 +61,6 @@
"filter_any": "Cualquiera",
"filter_buying": "Comprando",
"filter_country_global": "Ofertas globales",
"filter_country_near": "Cerca de mí",
"filter_currency": "Divisa",
"filter_detail": "Detalle",
"filter_filters": "Filtros",

View file

@ -55,7 +55,6 @@
"filter_any": "Algo",
"filter_buying": "Comprando",
"filter_country_global": "Ofertas Globales",
"filter_country_near": "Cerca de mí",
"filter_currency": "Moneda",
"filter_detail": "Detalle",
"filter_filters": "Filtros",

View file

@ -61,7 +61,6 @@
"filter_any": "همه",
"filter_buying": "خرید",
"filter_country_global": "پیشنهادهای جهانی",
"filter_country_near": "نزدیک من",
"filter_currency": "واحد پول",
"filter_detail": "جزئیات",
"filter_filters": "فیلترها",

View file

@ -61,7 +61,6 @@
"filter_any": "Mikä tahansa",
"filter_buying": "Ostaminen",
"filter_country_global": "Maailmanlaajuiset tarjoukset",
"filter_country_near": "Lähellä minua",
"filter_currency": "Valuutta",
"filter_detail": "Tiedot",
"filter_filters": "Suodattimet",

View file

@ -61,7 +61,6 @@
"filter_any": "Tous",
"filter_buying": "Acheteur",
"filter_country_global": "Offres internationales",
"filter_country_near": "Près de moi",
"filter_currency": "Devise",
"filter_detail": "Détails",
"filter_filters": "Filtres",

View file

@ -70,7 +70,6 @@
"filter_any": "הכל",
"filter_buying": "קנייה",
"filter_country_global": "הצעות גלובליות",
"filter_country_near": "לידי",
"filter_currency": "מטבע",
"filter_detail": "פרטים",
"filter_filters": "מסננים",

View file

@ -67,7 +67,6 @@
"filter_any": "Bármennyi",
"filter_buying": "Vásárlás",
"filter_country_global": "Ajánlatok világszerte",
"filter_country_near": "Közelemben",
"filter_currency": "Pénznem",
"filter_detail": "Részletek",
"filter_filters": "Szűrők",

View file

@ -53,7 +53,6 @@
"filter_any": "Apapun",
"filter_buying": "Membeli",
"filter_country_global": "Penawaran global",
"filter_country_near": "Dekat saya",
"filter_currency": "Mata uang",
"filter_detail": "Perincian",
"filter_filters": "Menyaring",

View file

@ -34,7 +34,6 @@
"cont_how": "Come pagare",
"cont_st_completed": "Fatto!",
"cont_title": "I miei contratti",
"filter_country_near": "Vicino a me",
"filter_currency": "Valuta",
"filter_detail": "Dettaglio",
"filter_filters": "Filtri",

View file

@ -68,7 +68,6 @@
"filter_any": "すべて",
"filter_buying": "買う",
"filter_country_global": "グローバル・オファー",
"filter_country_near": "近くで探す",
"filter_currency": "通貨",
"filter_detail": "詳細",
"filter_filters": "フィルター",

View file

@ -61,7 +61,6 @@
"filter_any": "ieder",
"filter_buying": "Kopen",
"filter_country_global": "Wereldwijd aanbod",
"filter_country_near": "Dicht bij mij",
"filter_currency": "Valuta",
"filter_detail": "Detail",
"filter_filters": "Filters",

View file

@ -61,7 +61,6 @@
"filter_any": "Każdy",
"filter_buying": "Kupno",
"filter_country_global": "Oferty globalne",
"filter_country_near": "Blisko mnie",
"filter_currency": "Waluta",
"filter_detail": "Szczegóły",
"filter_filters": "Filtry",

View file

@ -61,7 +61,6 @@
"filter_any": "Qualquer",
"filter_buying": "Compra",
"filter_country_global": "Ofertas globais",
"filter_country_near": "Perto de mim",
"filter_currency": "Moeda",
"filter_detail": "Detalhe",
"filter_filters": "Filtrar",

View file

@ -53,7 +53,6 @@
"filter_any": "Qualquer",
"filter_buying": "Compra",
"filter_country_global": "Ofertas globais",
"filter_country_near": "Perto de mim",
"filter_currency": "Moeda",
"filter_detail": "Detalhe",
"filter_filters": "Filtrar",

View file

@ -61,7 +61,6 @@
"filter_any": "Все",
"filter_buying": "Покупаю",
"filter_country_global": "Глобальные",
"filter_country_near": "Рядом со мной",
"filter_currency": "Валюта",
"filter_detail": "Все",
"filter_filters": "Фильтры",

View file

@ -36,7 +36,6 @@
"cont_paid_q": "Naozaj chcete označiť tento kontrakt ako zaplatený?",
"cont_st_completed": "Hotovo!",
"cont_title": "Moje kontrakty",
"filter_country_near": "Blízko mňa",
"filter_currency": "Mena",
"filter_detail": "Detail",
"filter_filters": "Filtre",

View file

@ -61,7 +61,6 @@
"filter_any": "Vse",
"filter_buying": "Kupujem",
"filter_country_global": "Globalne ponudbe",
"filter_country_near": "Blizu mene",
"filter_currency": "Valuta",
"filter_detail": "Podrobno",
"filter_filters": "Filtriraj",

View file

@ -49,7 +49,6 @@
"cont_st_completed": "Klart!",
"cont_st_paid_enought": "Bitcoin hålls som säkerhet! Betala säljaren\nvia överenskommen betalmetod.",
"cont_title": "Mina kontrakt",
"filter_country_near": "Nära mig",
"filter_currency": "Valuta",
"filter_detail": "Detaljer",
"filter_filters": "Filtrera",

View file

@ -51,7 +51,6 @@
"filter_any": "ใดๆ",
"filter_buying": "กำลังซื้อ",
"filter_country_global": "Global offers",
"filter_country_near": "ใก้ลท่าน",
"filter_currency": "สกุลเงิน",
"filter_detail": "รายละเอียด",
"filter_filters": "ตัวกรอง",

View file

@ -39,7 +39,6 @@
"cont_title": "我的合約",
"filter_any": "任何",
"filter_buying": "購買",
"filter_country_near": "靠近我",
"filter_currency": "貨幣",
"filter_detail": "細節",
"filter_iambuying": "我正在買比特幣",

View file

@ -62,7 +62,6 @@ export default class HodlHodl extends Component {
currencies: [], // list of hodlhodl supported currencies. filled later via api
methods: [], // list of hodlhodl payment methods. filled later via api
country: HodlHodlApi.FILTERS_COUNTRY_VALUE_GLOBAL, // country currently selected by user to display orders on screen. this is country code
myCountryCode: HodlHodlApi.FILTERS_COUNTRY_VALUE_GLOBAL, // current user's country. filled later, via geoip api
};
}
@ -123,33 +122,6 @@ export default class HodlHodl extends Component {
});
}
async fetchMyCountry() {
return new Promise(resolve => {
Geolocation.getCurrentPosition(
async _position => {
const myCountryCode = await this.state.HodlApi.getMyCountryCode();
if (myCountryCode === 'US') {
alert('This service is currently not available in your country.');
this.props.navigation.goBack();
} else {
this.setState(
{
myCountryCode,
country: myCountryCode, // we start with orders from current country
},
resolve(),
);
}
},
_error =>
resolve(
this.setState({ myCountryCode: HodlHodlApi.FILTERS_COUNTRY_VALUE_GLOBAL, cuntry: HodlHodlApi.FILTERS_COUNTRY_VALUE_GLOBAL }),
),
{ enableHighAccuracy: false, timeout: 20000, maximumAge: 1000 },
);
});
}
/**
* fetches all countries from API and sets them to state
*
@ -213,7 +185,6 @@ export default class HodlHodl extends Component {
});
try {
await this.fetchMyCountry();
await this.fetchOffers();
} catch (Error) {
alert(Error.message);
@ -345,8 +316,6 @@ export default class HodlHodl extends Component {
}
getNativeCountryName() {
if (this.state.country === this.state.myCountryCode && this.state.country !== HodlHodlApi.FILTERS_COUNTRY_VALUE_GLOBAL)
return loc.hodl.filter_country_near;
for (const c of this.state.countries) {
if (c.code === this.state.country) return c.native_name;
}

View file

@ -106,9 +106,6 @@ describe.skip('HodlHodl API', function () {
assert.ok(countries[0].native_name);
assert.ok(countries[0].currency_code);
assert.ok(countries[0].currency_name);
const countryCode = await Hodl.getMyCountryCode();
assert.strictEqual(countryCode.length, 2);
});
it('can get offers', async () => {