mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
Merge pull request #133 from orionprotocol/feat/fetch-referral-contract-addresses
feat: fetch referral contract addresses
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.19.25",
|
||||
"version": "0.19.26-rc2",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/index.cjs",
|
||||
"module": "./lib/index.js",
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
aggregatedHistorySchema,
|
||||
} from './schemas/index.js';
|
||||
import {SupportedChainId} from "../../types.js";
|
||||
import contractsAddressesSchema from './schemas/contractsAddressesSchema.js';
|
||||
|
||||
type CreateLinkPayloadType = {
|
||||
referer: string
|
||||
@@ -53,7 +54,8 @@ class ReferralSystem {
|
||||
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.getContractsAddresses = this.getContractsAddresses.bind(this);
|
||||
this.getClaimInfo = this.getClaimInfo.bind(this);
|
||||
this.getAggregatedHistory = this.getAggregatedHistory.bind(this);
|
||||
}
|
||||
|
||||
@@ -169,7 +171,15 @@ class ReferralSystem {
|
||||
errorSchema
|
||||
);
|
||||
|
||||
getClamInfo = (refererAddress: string) =>
|
||||
getContractsAddresses = () =>
|
||||
fetchWithValidation(
|
||||
`${this.apiUrl}/referer/view/contracts`,
|
||||
contractsAddressesSchema,
|
||||
undefined,
|
||||
errorSchema
|
||||
);
|
||||
|
||||
getClaimInfo = (refererAddress: string) =>
|
||||
fetchWithValidation(
|
||||
`${this.apiUrl}/referer/view/claim-info-with-stats?&suppress_error=1`,
|
||||
claimInfoSchema,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { z } from 'zod';
|
||||
import { SupportedChainId } from '../../../types.js';
|
||||
import { isAddress } from 'ethers/lib/utils.js';
|
||||
|
||||
const contractsAddressesSchema = z.record(
|
||||
z.nativeEnum(SupportedChainId),
|
||||
z.string().refine(isAddress)
|
||||
);
|
||||
|
||||
export default contractsAddressesSchema;
|
||||
@@ -8,3 +8,4 @@ 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';
|
||||
export { default as contractsAddressesSchema } from './contractsAddressesSchema.js';
|
||||
|
||||
Reference in New Issue
Block a user