Skip to content

Commit

Permalink
Remove unused schemas and update package version
Browse files Browse the repository at this point in the history
Deleted distinctAnalyticsSchema, globalAnalyticsSchema, miniStatsSchema and ratingSchema files. The corresponding imports and usages in the ReferralSystem service were removed. Also upgraded package version to 0.2.7-rc6.
  • Loading branch information
TheJuze committed Feb 22, 2024
1 parent b1be0ad commit 71b9698
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 199 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package",
"name": "@electra.finance/sdk",
"version": "0.2.7-rc5",
"version": "0.2.7-rc6",
"description": "Electra finance SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",
Expand Down
118 changes: 8 additions & 110 deletions src/services/ReferralSystem/index.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,21 @@
import { fetchWithValidation } from 'simple-typed-fetch';
import {
errorSchema,
miniStatsSchema,
rewardsMappingSchema,
distinctAnalyticsSchema,
globalAnalyticsSchema,
rewardsClaimedSchema,
linkSchema,
ratingSchema,
claimInfoSchema,
aggregatedHistorySchema,
leaderboardSchema,
accountDetailsSchema,
accountReferralsSchema,
} from './schemas/index.js';
import type { SupportedChainId } from '../../types.js';
import contractsAddressesSchema from './schemas/contractsAddressesSchema.js';

export type { AccountDetails, AccountReferrals, Leaderboard } from './schemas';

type CreateLinkPayloadType = {
referer: string
link_option: number
};

type ClaimRewardsPayload = {
reward_recipient: string
chain_id: number
};

type SubscribePayloadType = {
ref_target: string
referral: string
};

type SignatureType = {
signature: string
};

type AddressType = {
address: string
}
Expand All @@ -52,73 +30,14 @@ class ReferralSystem {
constructor(apiUrl: string) {
this.apiUrl = apiUrl;

this.getLink = this.getLink.bind(this);
this.getDistinctAnalytics = this.getDistinctAnalytics.bind(this);
this.createReferralLink = this.createReferralLink.bind(this);
this.subscribeToReferral = this.subscribeToReferral.bind(this);
this.getMyReferral = this.getMyReferral.bind(this);
this.getGlobalAnalytics = this.getGlobalAnalytics.bind(this);
this.getMiniStats = this.getMiniStats.bind(this);
this.getRewardsMapping = this.getRewardsMapping.bind(this);
this.claimRewards = this.claimRewards.bind(this);
this.getRating = this.getRating.bind(this);
this.getRating = this.getRating.bind(this);
this.getContractsAddresses = this.getContractsAddresses.bind(this);
this.getClaimInfo = this.getClaimInfo.bind(this);
this.getAggregatedHistory = this.getAggregatedHistory.bind(this);
this.getLeaderboard = this.getLeaderboard.bind(this);
this.getAccountDetails = this.getAccountDetails.bind(this);
this.getAccountReferrals = this.getAccountReferrals.bind(this);
}

getLink = (refererAddress: string) =>
fetchWithValidation(`${this.apiUrl}/referer/view/link`, linkSchema, {
headers: {
'referer-address': refererAddress,
},
});

getMyReferral = (myWalletAddress: string) =>
fetchWithValidation(`${this.apiUrl}/referral/view/link`, linkSchema, {
headers: {
referral: myWalletAddress,
},
});

getDistinctAnalytics = (refererAddress: string) =>
fetchWithValidation(
`${this.apiUrl}/referer/view/distinct-analytics`,
distinctAnalyticsSchema,
{
headers: {
'referer-address': refererAddress,
},
},
errorSchema
);

getGlobalAnalytics = () =>
fetchWithValidation(
`${this.apiUrl}/referer/view/global-analytics`,
globalAnalyticsSchema
);

/**
* @param refererAddress Address without 0x prefix
*/
getMiniStats = (refererAddress: string) =>
fetchWithValidation(
`${this.apiUrl}/referer/view/mini-latest-stats`,
miniStatsSchema,
{
headers: {
'referer-address': refererAddress,
},
},
errorSchema
);

getRewardsMapping = (
/* getRewardsMapping = (
referralAddress: string,
page = 1,
positionsPerPage = 10
Expand All @@ -131,9 +50,9 @@ class ReferralSystem {
referral: referralAddress,
},
}
);
); */

claimRewards = (payload: ClaimRewardsPayload, signature: SignatureType) =>
/* claimRewards = (payload: ClaimRewardsPayload, signature: SignatureType) =>
fetchWithValidation(
`${this.apiUrl}/referer/governance/claim-rewards`,
rewardsClaimedSchema,
Expand All @@ -144,18 +63,7 @@ class ReferralSystem {
method: 'POST',
body: JSON.stringify({ payload, signature }),
}
);

createReferralLink = (
payload: CreateLinkPayloadType
) =>
fetchWithValidation(`${this.apiUrl}/referer/create2`, linkSchema, {
headers: {
'Content-type': 'application/json',
},
method: 'POST',
body: JSON.stringify(payload),
});
); */

subscribeToReferral = (
payload: SubscribePayloadType
Expand All @@ -173,25 +81,15 @@ class ReferralSystem {
errorSchema
);

getRating = (refererAddress: string | undefined, chainId: SupportedChainId) =>
fetchWithValidation(
`${this.apiUrl}/referer/ve/rating-table-leaderboard?chain_id=${chainId}`,
ratingSchema,
{
headers: refererAddress !== undefined ? { 'referer-address': refererAddress } : {},
},
errorSchema
);

getContractsAddresses = () =>
/* getContractsAddresses = () =>
fetchWithValidation(
`${this.apiUrl}/referer/view/contracts`,
contractsAddressesSchema,
undefined,
errorSchema
);
); */

getClaimInfo = (refererAddress: string) =>
/* getClaimInfo = (refererAddress: string) =>
fetchWithValidation(
`${this.apiUrl}/referer/view/claim-info-with-stats?&suppress_error=1`,
claimInfoSchema,
Expand All @@ -201,7 +99,7 @@ class ReferralSystem {
},
},
errorSchema
);
); */

getAggregatedHistory = (
refererAddress: string,
Expand Down
22 changes: 0 additions & 22 deletions src/services/ReferralSystem/schemas/distinctAnalyticsSchema.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/services/ReferralSystem/schemas/globalAnalyticsSchema.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/services/ReferralSystem/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
export { default as linkSchema } from './linkSchema';
export { default as distinctAnalyticsSchema } from './distinctAnalyticsSchema';
export { default as errorSchema } from './errorSchema';
export { default as miniStatsSchema } from './miniStatsSchema';
export { default as rewardsMappingSchema } from './rewardsMappingSchema';
export { default as rewardsClaimedSchema } from './rewardsClaimedSchema';
export { default as globalAnalyticsSchema } from './globalAnalyticsSchema';
export { default as ratingSchema } from './ratingSchema';
export { default as claimInfoSchema } from './claimInfoSchema';
export { default as aggregatedHistorySchema } from './aggregatedHistorySchema';
export { default as contractsAddressesSchema } from './contractsAddressesSchema';
Expand Down
12 changes: 0 additions & 12 deletions src/services/ReferralSystem/schemas/miniStatsSchema.ts

This file was deleted.

37 changes: 0 additions & 37 deletions src/services/ReferralSystem/schemas/ratingSchema.ts

This file was deleted.

0 comments on commit 71b9698

Please sign in to comment.