mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-15 22:52:36 +03:00
Доработа логика генерации apiUrl для тестинг-окружения реферальной системы
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.15.27-rc.2",
|
||||
"version": "0.15.27-rc.3",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/esm/index.js",
|
||||
"module": "./lib/esm/index.js",
|
||||
|
||||
@@ -145,7 +145,7 @@ export default class OrionUnit {
|
||||
this.orionAnalytics = new OrionAnalytics(orionAnalyticsUrl);
|
||||
this.exchange = new Exchange(this);
|
||||
this.farmingManager = new FarmingManager(this);
|
||||
this.referralSystem = new ReferralSystem(`${options?.api ?? customApi}/referral-api`);
|
||||
this.referralSystem = new ReferralSystem(options?.api ?? customApi, env);
|
||||
}
|
||||
|
||||
get siblings() {
|
||||
|
||||
@@ -19,8 +19,8 @@ type SignatureType = {
|
||||
class ReferralSystem {
|
||||
private apiUrl: string;
|
||||
|
||||
constructor(apiUrl: string) {
|
||||
this.apiUrl = apiUrl;
|
||||
constructor(apiUrl: string, env: string) {
|
||||
this.apiUrl = ReferralSystem.getActualApiUrl(apiUrl, env);
|
||||
|
||||
this.getLink = this.getLink.bind(this);
|
||||
this.getSubscribersList = this.getSubscribersList.bind(this);
|
||||
@@ -29,6 +29,19 @@ class ReferralSystem {
|
||||
this.getMyReferral = this.getMyReferral.bind(this);
|
||||
}
|
||||
|
||||
// ресурсы реферальной системы в тестинг окружении имеют вид
|
||||
// testing.orionprotocol.io/referral-api вместо обычного
|
||||
// testing.orionprotocol.io/bsc-testnet/referral-api, поэтому лишняя часть вырезается
|
||||
static getActualApiUrl = (apiUrl: string, env: string) => {
|
||||
if (env !== 'testing') {
|
||||
return `${apiUrl}/referral-api`;
|
||||
}
|
||||
|
||||
const { protocol, hostname } = new URL(apiUrl);
|
||||
|
||||
return `${protocol}//${hostname}/referral-api`;
|
||||
};
|
||||
|
||||
getLink = (refererAddress: string) => fetchWithValidation(`${this.apiUrl}/referer/view/link`, linkSchema, {
|
||||
headers: {
|
||||
'referer-address': refererAddress,
|
||||
|
||||
Reference in New Issue
Block a user