mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
Referral schema / request updates
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.18.14",
|
||||
"version": "0.18.16",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.18.14",
|
||||
"version": "0.18.16",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.21.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.18.15",
|
||||
"version": "0.18.16",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/index.cjs",
|
||||
"module": "./lib/index.js",
|
||||
|
||||
@@ -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) =>
|
||||
@@ -161,6 +167,30 @@ class ReferralSystem {
|
||||
{},
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
export * as schemas from './schemas/index.js';
|
||||
|
||||
@@ -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;
|
||||
31
src/services/ReferralSystem/schemas/claimInfoSchema.ts
Normal file
31
src/services/ReferralSystem/schemas/claimInfoSchema.ts
Normal 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;
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user