Merge pull request #92 from orionprotocol/OP-3440.referral

Referral schema / request updates
This commit is contained in:
Dmitry
2023-04-19 10:24:10 +03:00
committed by GitHub
7 changed files with 7906 additions and 378 deletions

8168
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.18.17",
"version": "0.18.18",
"description": "Orion Protocol SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",

View File

@@ -8,6 +8,8 @@ import {
rewardsClaimedSchema,
linkSchema,
ratingSchema,
claimInfoSchema,
aggregatedHistorySchema,
} from './schemas/index.js';
type CreateLinkPayloadType = {
@@ -48,6 +50,10 @@ class ReferralSystem {
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.getClamInfo = this.getClamInfo.bind(this);
this.getAggregatedHistory = this.getAggregatedHistory.bind(this);
}
getLink = (refererAddress: string) =>
@@ -154,11 +160,39 @@ class ReferralSystem {
errorSchema
);
getRating = () =>
getRating = (refererAddress: string) =>
fetchWithValidation(
`${this.apiUrl}/referer/ve/rating-table-leaderboard`,
ratingSchema,
{},
{
headers: {
'referer-address': refererAddress,
},
},
errorSchema
);
getClamInfo = (refererAddress: string) =>
fetchWithValidation(
`${this.apiUrl}/referer/view/claim-info-with-stats`,
claimInfoSchema,
{
headers: {
'referer-address': refererAddress,
},
},
errorSchema
);
getAggregatedHistory = (refererAddress: string) =>
fetchWithValidation(
`${this.apiUrl}/referer/view/aggregated-history`,
aggregatedHistorySchema,
{
headers: {
'referer-address': refererAddress,
},
},
errorSchema
);
}

View File

@@ -0,0 +1,20 @@
import { z } from 'zod';
const aggregatedHistorySchema = z.array(z.object({
history_type: z.object({
RewardDistribution: z.string()
}),
chain_type: z.string(),
chain_comp: z.string(),
date_unix: z.number(),
date_time_local: z.string(),
date_time_utc: z.string(),
amount_orn: z.string(),
amount_orn_fmt: z.number(),
amount_usd: z.string(),
amount_usd_fmt: z.number(),
orn_price: z.string(),
orn_price_fmt: z.number()
}))
export default aggregatedHistorySchema;

View File

@@ -0,0 +1,31 @@
import { z } from 'zod';
const claimInfoSchema = z.object({
global: z.object({
total_non_accrued: z.number(),
total_non_accrued_orn: z.number(),
total_non_accrued_usd: z.number()
}),
chain_to_reward_info: z.record(
z.string(),
z.object({
total_accrued: z.number(),
total_accrued_orn: z.number(),
total_accrued_usd: z.number(),
total_non_accrued: z.number(),
total_non_accrued_orn: z.number(),
total_non_accrued_usd: z.number(),
total_earned: z.number()
})
),
mini_stats: z.object({
earned_on_referrals_orn: z.number(),
earned_on_referrals_usd: z.number(),
orn_usd: z.number(),
registered_via_link_count: z.number(),
earned_in_a_week_orn: z.number(),
earned_in_a_week_usd: z.number()
}),
});
export default claimInfoSchema;

View File

@@ -6,3 +6,5 @@ export { default as rewardsMappingSchema } from './rewardsMappingSchema.js';
export { default as rewardsClaimedSchema } from './rewardsClaimedSchema.js';
export { default as globalAnalyticsSchema } from './globalAnalyticsSchema.js';
export { default as ratingSchema } from './ratingSchema.js';
export { default as claimInfoSchema } from './claimInfoSchema.js';
export { default as aggregatedHistorySchema } from './aggregatedHistorySchema.js';

View File

@@ -2,12 +2,23 @@ import { z } from 'zod';
const ratingSchema = z.object({
info: z.object({
weekly_boost_budget: z.string(),
weekly_boost_budget_fmt: z.number(),
time_left_for_the_reward: z.number(),
time_left_for_the_reward_local: z.string(),
time_left_for_the_reward_utc: z.string(),
personal_info: z.any(),
weekly_boost_budget: z.string(),
weekly_boost_budget_fmt: z.number(),
time_left_for_the_reward: z.number(),
time_left_for_the_reward_local: z.string(),
time_left_for_the_reward_utc: z.string(),
personal_info: z.object({
rank_id: z.number(),
wallet: z.string(),
staked_ve_orn: z.string(),
staked_ve_orn_fmt: z.number(),
weighted_volume: z.string(),
weighted_volume_fmt: z.number(),
total_weight: z.string(),
total_weight_fmt: z.number(),
reward: z.string(),
reward_fmt: z.number()
}).nullable(),
}),
list: z.array(z.object({
rank_id: z.number(),