@huma-finance/shared 0.0.59-beta.487 → 0.0.59-beta.488
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.js +1 -0
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/useAuthErrorHandling.d.ts +3 -0
- package/dist/cjs/hooks/useAuthErrorHandling.js +17 -2
- package/dist/cjs/hooks/useAuthErrorHandling.js.map +1 -1
- package/dist/cjs/hooks/useDebouncedValue.d.ts +1 -0
- package/dist/cjs/hooks/useDebouncedValue.js +16 -0
- package/dist/cjs/hooks/useDebouncedValue.js.map +1 -0
- package/dist/cjs/services/CampaignService.d.ts +91 -0
- package/dist/cjs/services/CampaignService.js +278 -0
- package/dist/cjs/services/CampaignService.js.map +1 -0
- package/dist/cjs/services/IdentityServiceV2.d.ts +55 -0
- package/dist/cjs/services/IdentityServiceV2.js +64 -0
- package/dist/cjs/services/IdentityServiceV2.js.map +1 -0
- package/dist/cjs/services/index.d.ts +2 -0
- package/dist/cjs/services/index.js +2 -0
- package/dist/cjs/services/index.js.map +1 -1
- package/dist/cjs/utils/config.d.ts +1 -0
- package/dist/cjs/utils/config.js +4 -0
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/cjs/utils/const.d.ts +1 -0
- package/dist/cjs/utils/const.js +2 -1
- package/dist/cjs/utils/const.js.map +1 -1
- package/dist/cjs/utils/credit.d.ts +1 -2
- package/dist/cjs/utils/credit.js +0 -2
- package/dist/cjs/utils/credit.js.map +1 -1
- package/dist/cjs/utils/pool.js +3 -3
- package/dist/cjs/utils/pool.js.map +1 -1
- package/dist/cjs/utils/request.js +1 -0
- package/dist/cjs/utils/request.js.map +1 -1
- package/dist/cjs/v2/metadata/alfajores.js +23 -1
- package/dist/cjs/v2/metadata/alfajores.js.map +1 -1
- package/dist/cjs/v2/metadata/baseSepolia.js +84 -57
- package/dist/cjs/v2/metadata/baseSepolia.js.map +1 -1
- package/dist/cjs/v2/metadata/humaTestnet.js +25 -24
- package/dist/cjs/v2/metadata/humaTestnet.js.map +1 -1
- package/dist/cjs/v2/utils/const.d.ts +2 -1
- package/dist/cjs/v2/utils/const.js +1 -0
- package/dist/cjs/v2/utils/const.js.map +1 -1
- package/dist/cjs/v2/utils/pool.d.ts +14 -6
- package/dist/cjs/v2/utils/pool.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useAuthErrorHandling.d.ts +3 -0
- package/dist/hooks/useAuthErrorHandling.js +17 -2
- package/dist/hooks/useAuthErrorHandling.js.map +1 -1
- package/dist/hooks/useDebouncedValue.d.ts +1 -0
- package/dist/hooks/useDebouncedValue.js +12 -0
- package/dist/hooks/useDebouncedValue.js.map +1 -0
- package/dist/services/CampaignService.d.ts +91 -0
- package/dist/services/CampaignService.js +275 -0
- package/dist/services/CampaignService.js.map +1 -0
- package/dist/services/IdentityServiceV2.d.ts +55 -0
- package/dist/services/IdentityServiceV2.js +61 -0
- package/dist/services/IdentityServiceV2.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +2 -0
- package/dist/services/index.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils/config.d.ts +1 -0
- package/dist/utils/config.js +4 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/const.d.ts +1 -0
- package/dist/utils/const.js +1 -0
- package/dist/utils/const.js.map +1 -1
- package/dist/utils/credit.d.ts +1 -2
- package/dist/utils/credit.js +0 -2
- package/dist/utils/credit.js.map +1 -1
- package/dist/utils/pool.js +3 -3
- package/dist/utils/pool.js.map +1 -1
- package/dist/utils/request.js +1 -0
- package/dist/utils/request.js.map +1 -1
- package/dist/v2/metadata/alfajores.js +23 -1
- package/dist/v2/metadata/alfajores.js.map +1 -1
- package/dist/v2/metadata/baseSepolia.js +84 -57
- package/dist/v2/metadata/baseSepolia.js.map +1 -1
- package/dist/v2/metadata/humaTestnet.js +25 -24
- package/dist/v2/metadata/humaTestnet.js.map +1 -1
- package/dist/v2/utils/const.d.ts +2 -1
- package/dist/v2/utils/const.js +1 -0
- package/dist/v2/utils/const.js.map +1 -1
- package/dist/v2/utils/pool.d.ts +14 -6
- package/dist/v2/utils/pool.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -20,4 +20,5 @@ tslib_1.__exportStar(require("./usePoolContract"), exports);
|
|
|
20
20
|
tslib_1.__exportStar(require("./useRFPoolContract"), exports);
|
|
21
21
|
tslib_1.__exportStar(require("./useRefresh"), exports);
|
|
22
22
|
tslib_1.__exportStar(require("./useGetSizes"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./useDebouncedValue"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.tsx"],"names":[],"mappings":";;;AAAA,6DAAkC;AAClC,iDAAsB;AACtB,2DAAgC;AAChC,0DAA+B;AAC/B,iEAAsC;AACtC,8DAAmC;AACnC,wDAA6B;AAC7B,gEAAqC;AACrC,yDAA8B;AAC9B,4DAAiC;AACjC,kEAAuC;AACvC,kDAAuB;AACvB,qDAA0B;AAC1B,4DAAiC;AACjC,oDAAyB;AACzB,4DAAiC;AACjC,8DAAmC;AACnC,uDAA4B;AAC5B,wDAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.tsx"],"names":[],"mappings":";;;AAAA,6DAAkC;AAClC,iDAAsB;AACtB,2DAAgC;AAChC,0DAA+B;AAC/B,iEAAsC;AACtC,8DAAmC;AACnC,wDAA6B;AAC7B,gEAAqC;AACrC,yDAA8B;AAC9B,4DAAiC;AACjC,kEAAuC;AACvC,kDAAuB;AACvB,qDAA0B;AAC1B,4DAAiC;AACjC,oDAAyB;AACzB,4DAAiC;AACjC,8DAAmC;AACnC,uDAA4B;AAC5B,wDAA6B;AAC7B,8DAAmC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
type ErrorType = 'NotSignedIn' | 'UserRejected' | 'Other';
|
|
2
3
|
export type AuthState = {
|
|
3
4
|
isWalletOwnershipVerificationRequired: boolean;
|
|
4
5
|
isWalletOwnershipVerified: boolean;
|
|
6
|
+
errorType?: ErrorType;
|
|
5
7
|
error: unknown;
|
|
6
8
|
setError: React.Dispatch<React.SetStateAction<unknown>>;
|
|
7
9
|
};
|
|
8
10
|
export declare const useAuthErrorHandling: (isDev: boolean) => AuthState;
|
|
11
|
+
export {};
|
|
@@ -39,25 +39,40 @@ const useAuthErrorHandling = (isDev) => {
|
|
|
39
39
|
const handleVerificationCompletion = () => {
|
|
40
40
|
setIsVerified(true);
|
|
41
41
|
};
|
|
42
|
+
const [errorType, setErrorType] = (0, react_1.useState)();
|
|
42
43
|
(0, react_1.useEffect)(() => {
|
|
43
44
|
var _a, _b, _c, _d;
|
|
44
45
|
if (!account || !chainId || !error || !provider) {
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
const isUnauthorizedError = axios_1.default.isAxiosError(error) &&
|
|
48
49
|
((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === axios_1.HttpStatusCode.Unauthorized &&
|
|
49
50
|
[
|
|
50
51
|
'IdTokenNotFoundException',
|
|
51
52
|
'InvalidIdTokenException',
|
|
52
53
|
'WalletMismatchException',
|
|
53
|
-
].includes((_d = (_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.detail) === null || _d === void 0 ? void 0 : _d.type)
|
|
54
|
+
].includes((_d = (_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.detail) === null || _d === void 0 ? void 0 : _d.type);
|
|
55
|
+
const isWalletNotCreatedError = error === 'WalletNotCreatedException';
|
|
56
|
+
const isWalletNotSignInError = error === 'WalletNotSignInException';
|
|
57
|
+
if (isUnauthorizedError ||
|
|
58
|
+
isWalletNotCreatedError ||
|
|
59
|
+
isWalletNotSignInError) {
|
|
60
|
+
setErrorType('NotSignedIn');
|
|
54
61
|
setIsVerificationRequired(true);
|
|
55
62
|
verifyOwnership(account, chainId, isDev, provider, handleVerificationCompletion).catch((e) => setError(e));
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
}
|
|
65
|
+
else if ([4001, 'ACTION_REJECTED'].includes(error.code)) {
|
|
66
|
+
setErrorType('UserRejected');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
setErrorType('Other');
|
|
56
70
|
}
|
|
57
71
|
}, [chainId, isDev, error, throwError, account, provider]);
|
|
58
72
|
return {
|
|
59
73
|
isWalletOwnershipVerificationRequired: isVerificationRequired,
|
|
60
74
|
isWalletOwnershipVerified: isVerified,
|
|
75
|
+
errorType,
|
|
61
76
|
error,
|
|
62
77
|
setError,
|
|
63
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthErrorHandling.js","sourceRoot":"","sources":["../../../src/hooks/useAuthErrorHandling.ts"],"names":[],"mappings":";;;;AAAA,iCAA2C;AAC3C,uDAA6C;AAC7C,+BAAkC;AAClC,2CAA+C;AAE/C,mDAA+C;AAC/C,0CAAyC;
|
|
1
|
+
{"version":3,"file":"useAuthErrorHandling.js","sourceRoot":"","sources":["../../../src/hooks/useAuthErrorHandling.ts"],"names":[],"mappings":";;;;AAAA,iCAA2C;AAC3C,uDAA6C;AAC7C,+BAAkC;AAClC,2CAA+C;AAE/C,mDAA+C;AAC/C,0CAAyC;AAIzC,MAAM,iBAAiB,GAAG,CACxB,OAAe,EACf,OAAe,EACf,KAAa,EACb,SAAiB,EACjB,EAAE;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAA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AAE;YAClE,YAAY,CAAC,cAAc,CAAC,CAAA;SAC7B;aAAM;YACL,YAAY,CAAC,OAAO,CAAC,CAAA;SACtB;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAA;IAE1D,OAAO;QACL,qCAAqC,EAAE,sBAAsB;QAC7D,yBAAyB,EAAE,UAAU;QACrC,SAAS;QACT,KAAK;QACL,QAAQ;KACT,CAAA;AACH,CAAC,CAAA;AA1DY,QAAA,oBAAoB,wBA0DhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useDebouncedValue: (value?: number | string, delay?: number) => string | number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDebouncedValue = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useDebouncedValue = (value = '', delay = 500) => {
|
|
6
|
+
const [debouncedValue, setDebouncedValue] = (0, react_1.useState)(value);
|
|
7
|
+
(0, react_1.useEffect)(() => {
|
|
8
|
+
const timer = setTimeout(() => {
|
|
9
|
+
setDebouncedValue(value);
|
|
10
|
+
}, delay);
|
|
11
|
+
return () => clearTimeout(timer);
|
|
12
|
+
}, [value, delay]);
|
|
13
|
+
return debouncedValue;
|
|
14
|
+
};
|
|
15
|
+
exports.useDebouncedValue = useDebouncedValue;
|
|
16
|
+
//# sourceMappingURL=useDebouncedValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebouncedValue.js","sourceRoot":"","sources":["../../../src/hooks/useDebouncedValue.ts"],"names":[],"mappings":";;;AAAA,iCAA2C;AAEpC,MAAM,iBAAiB,GAAG,CAC/B,QAAyB,EAAE,EAC3B,KAAK,GAAG,GAAG,EACM,EAAE;IACnB,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IAE3D,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,iBAAiB,CAAC,KAAK,CAAC,CAAA;QAC1B,CAAC,EAAE,KAAK,CAAC,CAAA;QAET,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IAElB,OAAO,cAAc,CAAA;AACvB,CAAC,CAAA;AAfY,QAAA,iBAAiB,qBAe7B"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ChainEnum } from '../utils/chain';
|
|
2
|
+
import { PoolInfoV2 } from '../v2/utils/pool';
|
|
3
|
+
export type CampaignSeason = {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
estimatedTotalPoints: number;
|
|
7
|
+
};
|
|
8
|
+
export type CampaignPartner = {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
multiplier: number;
|
|
12
|
+
};
|
|
13
|
+
export type Campaign = {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
chainId: string;
|
|
17
|
+
juniorMultiplier: number;
|
|
18
|
+
seniorMultiplier: number;
|
|
19
|
+
lockupPeriodMonths: number;
|
|
20
|
+
poolAddress: string;
|
|
21
|
+
campaignGroupId: string;
|
|
22
|
+
poolInfo: PoolInfoV2;
|
|
23
|
+
partner?: CampaignPartner | null;
|
|
24
|
+
multiplierRange?: string;
|
|
25
|
+
};
|
|
26
|
+
export type CampaignGroup = {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
campaigns: Campaign[];
|
|
30
|
+
partners: CampaignPartner[];
|
|
31
|
+
};
|
|
32
|
+
type Wallet = {
|
|
33
|
+
id: string;
|
|
34
|
+
address: string;
|
|
35
|
+
referralCode: string;
|
|
36
|
+
referrer: {
|
|
37
|
+
id: string;
|
|
38
|
+
address: string;
|
|
39
|
+
};
|
|
40
|
+
createdAt: string;
|
|
41
|
+
};
|
|
42
|
+
type WalletPoint = {
|
|
43
|
+
id: string;
|
|
44
|
+
rank: number;
|
|
45
|
+
wallet: Wallet;
|
|
46
|
+
totalPoints: number;
|
|
47
|
+
numberOfReferred: number;
|
|
48
|
+
};
|
|
49
|
+
type WalletRank = {
|
|
50
|
+
totalCount: number;
|
|
51
|
+
walletPoints: WalletPoint[];
|
|
52
|
+
};
|
|
53
|
+
type CampaignPoints = {
|
|
54
|
+
campaignId: string;
|
|
55
|
+
juniorTranchePoints: number;
|
|
56
|
+
seniorTranchePoints: number;
|
|
57
|
+
lockupPeriodMonths: number;
|
|
58
|
+
};
|
|
59
|
+
declare function checkWalletOwnership(wallet: string, isDev: boolean): Promise<boolean | undefined>;
|
|
60
|
+
declare function getWalletInfo(wallet: string, isDev: boolean): Promise<{
|
|
61
|
+
wallet: Wallet;
|
|
62
|
+
walletPoint: WalletPoint;
|
|
63
|
+
} | undefined>;
|
|
64
|
+
declare function getWalletRankList(first: number, skip: number, isDev: boolean): Promise<WalletRank | undefined>;
|
|
65
|
+
declare function getRecentJoins(isDev: boolean): Promise<Wallet[] | undefined>;
|
|
66
|
+
declare function getActiveSeasonAndCampaignGroups(isDev: boolean): Promise<{
|
|
67
|
+
activeSeason?: CampaignSeason;
|
|
68
|
+
campaignGroups?: CampaignGroup[];
|
|
69
|
+
}>;
|
|
70
|
+
declare function getEstimatedPoints(campaignGroupId: string, principal: string, isDev: boolean): Promise<CampaignPoints[]>;
|
|
71
|
+
declare function createNewWallet(account: string, referralCode: string | null | undefined, isDev: boolean): Promise<{
|
|
72
|
+
wallet: string;
|
|
73
|
+
} | undefined>;
|
|
74
|
+
declare function updateWalletPoints(chainId: ChainEnum, account: string, hash: string, isDev: boolean): Promise<{
|
|
75
|
+
pointsAccumulated?: number;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* An object that contains functions to interact with Huma's campaign service.
|
|
79
|
+
* @namespace SubgraphService
|
|
80
|
+
*/
|
|
81
|
+
export declare const CampaignService: {
|
|
82
|
+
checkWalletOwnership: typeof checkWalletOwnership;
|
|
83
|
+
getWalletInfo: typeof getWalletInfo;
|
|
84
|
+
getWalletRankList: typeof getWalletRankList;
|
|
85
|
+
getRecentJoins: typeof getRecentJoins;
|
|
86
|
+
getActiveSeasonAndCampaignGroups: typeof getActiveSeasonAndCampaignGroups;
|
|
87
|
+
getEstimatedPoints: typeof getEstimatedPoints;
|
|
88
|
+
createNewWallet: typeof createNewWallet;
|
|
89
|
+
updateWalletPoints: typeof updateWalletPoints;
|
|
90
|
+
};
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CampaignService = void 0;
|
|
4
|
+
const graphql_request_1 = require("graphql-request");
|
|
5
|
+
const config_1 = require("../utils/config");
|
|
6
|
+
const request_1 = require("../utils/request");
|
|
7
|
+
function checkWalletOwnership(wallet, isDev) {
|
|
8
|
+
const url = config_1.configUtil.getCampaignAPIUrl(isDev);
|
|
9
|
+
const query = (0, graphql_request_1.gql) `
|
|
10
|
+
query {
|
|
11
|
+
walletOwnership(address: "${wallet}")
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
15
|
+
.then((res) => {
|
|
16
|
+
var _a;
|
|
17
|
+
if (res.errors) {
|
|
18
|
+
console.error(res.errors);
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return (_a = res.data) === null || _a === void 0 ? void 0 : _a.walletOwnership;
|
|
22
|
+
})
|
|
23
|
+
.catch((err) => {
|
|
24
|
+
console.error(err);
|
|
25
|
+
return undefined;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function getWalletInfo(wallet, isDev) {
|
|
29
|
+
const url = config_1.configUtil.getCampaignAPIUrl(isDev);
|
|
30
|
+
const query = (0, graphql_request_1.gql) `
|
|
31
|
+
query {
|
|
32
|
+
wallet(address:"${wallet}") {
|
|
33
|
+
id
|
|
34
|
+
address
|
|
35
|
+
referralCode
|
|
36
|
+
}
|
|
37
|
+
walletPoint(address:"${wallet}") {
|
|
38
|
+
rank
|
|
39
|
+
numberOfReferred
|
|
40
|
+
totalPoints
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
45
|
+
.then((res) => {
|
|
46
|
+
if (res.errors) {
|
|
47
|
+
console.error(res.errors);
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
return res.data;
|
|
51
|
+
})
|
|
52
|
+
.catch((err) => {
|
|
53
|
+
console.error(err);
|
|
54
|
+
return undefined;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function getWalletRankList(first, skip, isDev) {
|
|
58
|
+
const url = config_1.configUtil.getCampaignAPIUrl(isDev);
|
|
59
|
+
const query = (0, graphql_request_1.gql) `
|
|
60
|
+
query {
|
|
61
|
+
walletPoints(first: ${first}, skip: ${skip}){
|
|
62
|
+
totalCount
|
|
63
|
+
walletPoints {
|
|
64
|
+
id
|
|
65
|
+
rank
|
|
66
|
+
wallet {
|
|
67
|
+
id
|
|
68
|
+
address
|
|
69
|
+
}
|
|
70
|
+
totalPoints
|
|
71
|
+
numberOfReferred
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
77
|
+
.then((res) => {
|
|
78
|
+
var _a;
|
|
79
|
+
if (res.errors) {
|
|
80
|
+
console.error(res.errors);
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
return (_a = res.data) === null || _a === void 0 ? void 0 : _a.walletPoints;
|
|
84
|
+
})
|
|
85
|
+
.catch((err) => {
|
|
86
|
+
console.error(err);
|
|
87
|
+
return undefined;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function getRecentJoins(isDev) {
|
|
91
|
+
const url = config_1.configUtil.getCampaignAPIUrl(isDev);
|
|
92
|
+
const query = (0, graphql_request_1.gql) `
|
|
93
|
+
query {
|
|
94
|
+
wallets(first: 5, skip: 0, orderBy: "createdAt", orderDirection: "desc") {
|
|
95
|
+
wallets {
|
|
96
|
+
id
|
|
97
|
+
address
|
|
98
|
+
referrer {
|
|
99
|
+
id
|
|
100
|
+
address
|
|
101
|
+
}
|
|
102
|
+
createdAt
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
return ((0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
|
+
.then((res) => {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
if (res.errors) {
|
|
112
|
+
console.error(res.errors);
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
return (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.wallets) === null || _b === void 0 ? void 0 : _b.wallets;
|
|
116
|
+
})
|
|
117
|
+
.catch((err) => {
|
|
118
|
+
console.error(err);
|
|
119
|
+
return undefined;
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
function getActiveSeasonAndCampaignGroups(isDev) {
|
|
123
|
+
const url = config_1.configUtil.getCampaignAPIUrl(isDev);
|
|
124
|
+
const query = (0, graphql_request_1.gql) `
|
|
125
|
+
query {
|
|
126
|
+
activeSeason {
|
|
127
|
+
id
|
|
128
|
+
estimatedTotalPoints
|
|
129
|
+
name
|
|
130
|
+
}
|
|
131
|
+
campaignGroups {
|
|
132
|
+
id
|
|
133
|
+
name
|
|
134
|
+
campaigns {
|
|
135
|
+
id
|
|
136
|
+
name
|
|
137
|
+
chainId
|
|
138
|
+
juniorMultiplier
|
|
139
|
+
lockupPeriodMonths
|
|
140
|
+
seniorMultiplier
|
|
141
|
+
poolAddress
|
|
142
|
+
}
|
|
143
|
+
partners {
|
|
144
|
+
id
|
|
145
|
+
name
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
`;
|
|
150
|
+
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
151
|
+
.then((res) => {
|
|
152
|
+
var _a;
|
|
153
|
+
if (res.errors) {
|
|
154
|
+
console.error(res.errors);
|
|
155
|
+
return {};
|
|
156
|
+
}
|
|
157
|
+
return (_a = res.data) !== null && _a !== void 0 ? _a : {};
|
|
158
|
+
})
|
|
159
|
+
.catch((err) => {
|
|
160
|
+
console.error(err);
|
|
161
|
+
return {};
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function getEstimatedPoints(campaignGroupId, principal, isDev) {
|
|
165
|
+
const url = config_1.configUtil.getCampaignAPIUrl(isDev);
|
|
166
|
+
const query = (0, graphql_request_1.gql) `
|
|
167
|
+
query {
|
|
168
|
+
calculateEstimatedPoints(input: {campaignGroupId:"${campaignGroupId}", principal:"${principal}"}){
|
|
169
|
+
campaignPointsEstimations {
|
|
170
|
+
campaignId
|
|
171
|
+
juniorTranchePoints
|
|
172
|
+
seniorTranchePoints
|
|
173
|
+
lockupPeriodMonths
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
`;
|
|
178
|
+
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
179
|
+
.then((res) => {
|
|
180
|
+
var _a, _b, _c;
|
|
181
|
+
if (res.errors) {
|
|
182
|
+
console.error(res.errors);
|
|
183
|
+
return [];
|
|
184
|
+
}
|
|
185
|
+
return (_c = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.calculateEstimatedPoints) === null || _b === void 0 ? void 0 : _b.campaignPointsEstimations) !== null && _c !== void 0 ? _c : [];
|
|
186
|
+
})
|
|
187
|
+
.catch((err) => {
|
|
188
|
+
console.error(err);
|
|
189
|
+
return [];
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function createNewWallet(account, referralCode, isDev) {
|
|
193
|
+
const url = config_1.configUtil.getCampaignAPIUrl(isDev);
|
|
194
|
+
const query = (0, graphql_request_1.gql) `
|
|
195
|
+
mutation {
|
|
196
|
+
createWallet(
|
|
197
|
+
input: {
|
|
198
|
+
walletAddress: "${account}"
|
|
199
|
+
referralCode: "${referralCode}"
|
|
200
|
+
}
|
|
201
|
+
) {
|
|
202
|
+
... on CreateWalletResult {
|
|
203
|
+
wallet {
|
|
204
|
+
address
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
... on WalletExistsError {
|
|
208
|
+
message
|
|
209
|
+
}
|
|
210
|
+
... on UnauthorizedError {
|
|
211
|
+
message
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
`;
|
|
216
|
+
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
217
|
+
.then((res) => {
|
|
218
|
+
var _a;
|
|
219
|
+
if (res.errors) {
|
|
220
|
+
console.error(res.errors);
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
return (_a = res.data) === null || _a === void 0 ? void 0 : _a.createWallet;
|
|
224
|
+
})
|
|
225
|
+
.catch((err) => {
|
|
226
|
+
console.error(err);
|
|
227
|
+
return undefined;
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function updateWalletPoints(chainId, account, hash, isDev) {
|
|
231
|
+
const url = config_1.configUtil.getCampaignAPIUrl(isDev);
|
|
232
|
+
const query = (0, graphql_request_1.gql) `
|
|
233
|
+
mutation {
|
|
234
|
+
updateWalletPoints(
|
|
235
|
+
input: {
|
|
236
|
+
chainId: ${chainId},
|
|
237
|
+
walletAddress: "${account}",
|
|
238
|
+
transactionHash: "${hash}"
|
|
239
|
+
}
|
|
240
|
+
) {
|
|
241
|
+
... on UpdateWalletPointsResult {
|
|
242
|
+
pointsAccumulated
|
|
243
|
+
}
|
|
244
|
+
... on UnauthorizedError {
|
|
245
|
+
message
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
`;
|
|
250
|
+
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
251
|
+
.then((res) => {
|
|
252
|
+
var _a, _b;
|
|
253
|
+
if (res.errors) {
|
|
254
|
+
console.error(res.errors);
|
|
255
|
+
return {};
|
|
256
|
+
}
|
|
257
|
+
return (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.updateWalletPoints) !== null && _b !== void 0 ? _b : {};
|
|
258
|
+
})
|
|
259
|
+
.catch((err) => {
|
|
260
|
+
console.error(err);
|
|
261
|
+
return {};
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* An object that contains functions to interact with Huma's campaign service.
|
|
266
|
+
* @namespace SubgraphService
|
|
267
|
+
*/
|
|
268
|
+
exports.CampaignService = {
|
|
269
|
+
checkWalletOwnership,
|
|
270
|
+
getWalletInfo,
|
|
271
|
+
getWalletRankList,
|
|
272
|
+
getRecentJoins,
|
|
273
|
+
getActiveSeasonAndCampaignGroups,
|
|
274
|
+
getEstimatedPoints,
|
|
275
|
+
createNewWallet,
|
|
276
|
+
updateWalletPoints,
|
|
277
|
+
};
|
|
278
|
+
//# sourceMappingURL=CampaignService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CampaignService.js","sourceRoot":"","sources":["../../../src/services/CampaignService.ts"],"names":[],"mappings":";;;AAAA,qDAAqC;AAGrC,4CAA4C;AAC5C,8CAA8C;AAmE9C,SAAS,oBAAoB,CAC3B,MAAc,EACd,KAAc;IAEd,MAAM,GAAG,GAAG,mBAAU,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;IAE/C,MAAM,KAAK,GAAG,IAAA,qBAAG,EAAA;;kCAEe,MAAM;;GAErC,CAAA;IAED,OAAO,IAAA,qBAAW,EAKf,GA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IAAA,qBAAW,EAKf,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;SAC/B,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;;QACZ,IAAI,GAAG,CAAC,MAAM,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACzB,OAAO,EAAE,CAAA;SACV;QACD,OAAO,MAAA,MAAA,GAAG,CAAC,IAAI,0CAAE,kBAAkB,mCAAI,EAAE,CAAA;IAC3C,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAClB,OAAO,EAAE,CAAA;IACX,CAAC,CAAC,CAAA;AACN,CAAC;AAED;;;GAGG;AACU,QAAA,eAAe,GAAG;IAC7B,oBAAoB;IACpB,aAAa;IACb,iBAAiB;IACjB,cAAc;IACd,gCAAgC;IAChC,kBAAkB;IAClB,eAAe;IACf,kBAAkB;CACnB,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing the identity status V2.
|
|
3
|
+
* @typedef {Enum} IdentityVerificationStatusV2
|
|
4
|
+
*/
|
|
5
|
+
export declare enum IdentityVerificationStatusV2 {
|
|
6
|
+
NOT_STARTED = "not_started",
|
|
7
|
+
CREATED = "created",
|
|
8
|
+
PENDING = "pending",
|
|
9
|
+
EXPIRED = "expired",
|
|
10
|
+
APPROVED = "approved",
|
|
11
|
+
DECLINED = "declined",
|
|
12
|
+
NEEDS_REVIEW = "needs_review"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Object representing the response to the identity verification status request.
|
|
16
|
+
* @typedef {Object} VerificationStatusResultV2
|
|
17
|
+
* @property {string} walletAddress the wallet address to get the verification status.
|
|
18
|
+
* @property {IdentityVerificationStatusV2} status The wallet's identity verification status.
|
|
19
|
+
* @property {string} personaInquiryId The persona inquiry id.
|
|
20
|
+
*/
|
|
21
|
+
export type VerificationStatusResultV2 = {
|
|
22
|
+
walletAddress: string;
|
|
23
|
+
status: IdentityVerificationStatusV2;
|
|
24
|
+
personaInquiryId: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Object representing the response to the identity verification status request.
|
|
28
|
+
* @typedef {Object} StartVerificationResultV2
|
|
29
|
+
* @property {string} walletAddress the wallet address to get the verification status.
|
|
30
|
+
* @property {IdentityVerificationStatusV2} status The wallet's identity verification status.
|
|
31
|
+
* @property {string} personaInquiryId The persona inquiry id.
|
|
32
|
+
*/
|
|
33
|
+
export type StartVerificationResultV2 = {
|
|
34
|
+
walletAddress: string;
|
|
35
|
+
status: IdentityVerificationStatusV2;
|
|
36
|
+
personaInquiryId: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Object representing the response to the identity verification resume request.
|
|
40
|
+
* @typedef {Object} StartVerificationResultV2
|
|
41
|
+
* @property {string} walletAddress The wallet address to resume the verification.
|
|
42
|
+
* @property {string} sessionToken The session token.
|
|
43
|
+
* @property {IdentityVerificationStatusV2} status The wallet's identity verification status.
|
|
44
|
+
*/
|
|
45
|
+
export type ResumeVerificationResultV2 = {
|
|
46
|
+
walletAddress: string;
|
|
47
|
+
sessionToken: string;
|
|
48
|
+
status: IdentityVerificationStatusV2;
|
|
49
|
+
};
|
|
50
|
+
export declare const IdentityServiceV2: {
|
|
51
|
+
getVerificationStatusV2: (walletAddress: string, chainId: number, isDev?: boolean) => Promise<VerificationStatusResultV2>;
|
|
52
|
+
startVerification: (walletAddress: string, chainId: number, isDev?: boolean) => Promise<VerificationStatusResultV2>;
|
|
53
|
+
resumeVerification: (walletAddress: string, chainId: number, isDev?: boolean) => Promise<ResumeVerificationResultV2>;
|
|
54
|
+
approveLender: (walletAddress: string, chainId: number, contractAddress: string, isDev?: boolean) => Promise<void>;
|
|
55
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdentityServiceV2 = exports.IdentityVerificationStatusV2 = void 0;
|
|
4
|
+
const config_1 = require("../utils/config");
|
|
5
|
+
const request_1 = require("../utils/request");
|
|
6
|
+
/**
|
|
7
|
+
* Enum representing the identity status V2.
|
|
8
|
+
* @typedef {Enum} IdentityVerificationStatusV2
|
|
9
|
+
*/
|
|
10
|
+
var IdentityVerificationStatusV2;
|
|
11
|
+
(function (IdentityVerificationStatusV2) {
|
|
12
|
+
IdentityVerificationStatusV2["NOT_STARTED"] = "not_started";
|
|
13
|
+
IdentityVerificationStatusV2["CREATED"] = "created";
|
|
14
|
+
IdentityVerificationStatusV2["PENDING"] = "pending";
|
|
15
|
+
IdentityVerificationStatusV2["EXPIRED"] = "expired";
|
|
16
|
+
IdentityVerificationStatusV2["APPROVED"] = "approved";
|
|
17
|
+
IdentityVerificationStatusV2["DECLINED"] = "declined";
|
|
18
|
+
IdentityVerificationStatusV2["NEEDS_REVIEW"] = "needs_review";
|
|
19
|
+
})(IdentityVerificationStatusV2 = exports.IdentityVerificationStatusV2 || (exports.IdentityVerificationStatusV2 = {}));
|
|
20
|
+
/**
|
|
21
|
+
* Get wallet's identity verification status.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} walletAddress The wallet address.
|
|
24
|
+
* @param {string} pool The pool address.
|
|
25
|
+
* @param {number} chainId Chain ID.
|
|
26
|
+
* @param {boolean} isDev Is dev environment or not.
|
|
27
|
+
* @returns {Promise<VerificationStatusResultV2>} Promise that returns the verification status result.
|
|
28
|
+
*/
|
|
29
|
+
const getVerificationStatusV2 = async (walletAddress, chainId, isDev = false) => (0, request_1.requestGet)(`${config_1.configUtil.getIdentityAPIUrl(chainId, isDev)}/wallets/${walletAddress}/verification-status?&chainId=${chainId}`);
|
|
30
|
+
/**
|
|
31
|
+
* Start wallet's verification process.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} walletAddress The wallet address.
|
|
34
|
+
* @param {number} chainId Chain ID.
|
|
35
|
+
* @param {boolean} isDev Is dev environment or not.
|
|
36
|
+
* @returns {Promise<VerificationStatusResultV2>} Promise that returns the start verification result.
|
|
37
|
+
*/
|
|
38
|
+
const startVerification = async (walletAddress, chainId, isDev = false) => (0, request_1.requestPost)(`${config_1.configUtil.getIdentityAPIUrl(chainId, isDev)}/wallets/${walletAddress}/start-verification?chainId=${chainId}`);
|
|
39
|
+
/**
|
|
40
|
+
* Resume wallet's verification process.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} walletAddress The wallet address.
|
|
43
|
+
* @param {number} chainId Chain ID.
|
|
44
|
+
* @param {boolean} isDev Is dev environment or not.
|
|
45
|
+
* @returns {Promise<ResumeVerificationResultV2>} Promise that returns the start verification result.
|
|
46
|
+
*/
|
|
47
|
+
const resumeVerification = async (walletAddress, chainId, isDev = false) => (0, request_1.requestPost)(`${config_1.configUtil.getIdentityAPIUrl(chainId, isDev)}/wallets/${walletAddress}/resume-verification?chainId=${chainId}`);
|
|
48
|
+
/**
|
|
49
|
+
* Approve wallet as lender.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} walletAddress The wallet address.
|
|
52
|
+
* @param {number} chainId Chain ID.
|
|
53
|
+
* @param {string} contractAddress The tranche vault contract address.
|
|
54
|
+
* @param {boolean} isDev Is dev environment or not.
|
|
55
|
+
* @returns {Promise<void>} Promise that returns void.
|
|
56
|
+
*/
|
|
57
|
+
const approveLender = async (walletAddress, chainId, contractAddress, isDev = false) => (0, request_1.requestPost)(`${config_1.configUtil.getIdentityAPIUrl(chainId, isDev)}/wallets/${walletAddress}/approve-lender?chainId=${chainId}&contractAddress=${contractAddress}`);
|
|
58
|
+
exports.IdentityServiceV2 = {
|
|
59
|
+
getVerificationStatusV2,
|
|
60
|
+
startVerification,
|
|
61
|
+
resumeVerification,
|
|
62
|
+
approveLender,
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=IdentityServiceV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityServiceV2.js","sourceRoot":"","sources":["../../../src/services/IdentityServiceV2.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,8CAA0D;AAE1D;;;GAGG;AACH,IAAY,4BAQX;AARD,WAAY,4BAA4B;IACtC,2DAA2B,CAAA;IAC3B,mDAAmB,CAAA;IACnB,mDAAmB,CAAA;IACnB,mDAAmB,CAAA;IACnB,qDAAqB,CAAA;IACrB,qDAAqB,CAAA;IACrB,6DAA6B,CAAA;AAC/B,CAAC,EARW,4BAA4B,GAA5B,oCAA4B,KAA5B,oCAA4B,QAQvC;AAeD;;;;;;;;GAQG;AACH,MAAM,uBAAuB,GAAG,KAAK,EACnC,aAAqB,EACrB,OAAe,EACf,KAAK,GAAG,KAAK,EACwB,EAAE,CACvC,IAAA,oBAAU,EACR,GAAG,mBAAU,CAAC,iBAAiB,CAC7B,OAAO,EACP,KAAK,CACN,YAAY,aAAa,iCAAiC,OAAO,EAAE,CACrE,CAAA;AAeH;;;;;;;GAOG;AACH,MAAM,iBAAiB,GAAG,KAAK,EAC7B,aAAqB,EACrB,OAAe,EACf,KAAK,GAAG,KAAK,EACwB,EAAE,CACvC,IAAA,qBAAW,EACT,GAAG,mBAAU,CAAC,iBAAiB,CAC7B,OAAO,EACP,KAAK,CACN,YAAY,aAAa,+BAA+B,OAAO,EAAE,CACnE,CAAA;AAeH;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,KAAK,EAC9B,aAAqB,EACrB,OAAe,EACf,KAAK,GAAG,KAAK,EACwB,EAAE,CACvC,IAAA,qBAAW,EACT,GAAG,mBAAU,CAAC,iBAAiB,CAC7B,OAAO,EACP,KAAK,CACN,YAAY,aAAa,gCAAgC,OAAO,EAAE,CACpE,CAAA;AAEH;;;;;;;;GAQG;AACH,MAAM,aAAa,GAAG,KAAK,EACzB,aAAqB,EACrB,OAAe,EACf,eAAuB,EACvB,KAAK,GAAG,KAAK,EACE,EAAE,CACjB,IAAA,qBAAW,EACT,GAAG,mBAAU,CAAC,iBAAiB,CAC7B,OAAO,EACP,KAAK,CACN,YAAY,aAAa,2BAA2B,OAAO,oBAAoB,eAAe,EAAE,CAClG,CAAA;AAEU,QAAA,iBAAiB,GAAG;IAC/B,uBAAuB;IACvB,iBAAiB;IACjB,kBAAkB;IAClB,aAAa;CACd,CAAA"}
|
|
@@ -4,5 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./EAService"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./RNService"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./IdentityService"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./IdentityServiceV2"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./AuthService"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./CampaignService"), exports);
|
|
8
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,sDAA2B;AAC3B,sDAA2B;AAC3B,4DAAiC;AACjC,wDAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,sDAA2B;AAC3B,sDAA2B;AAC3B,4DAAiC;AACjC,8DAAmC;AACnC,wDAA6B;AAC7B,4DAAiC"}
|
|
@@ -5,5 +5,6 @@ export declare const configUtil: {
|
|
|
5
5
|
getIdentityAPIUrl: (chainId: number, isDev?: boolean) => string;
|
|
6
6
|
getAuthServiceUrl: (chainId: number, isDev?: boolean) => string;
|
|
7
7
|
getKYCProviderBaseUrl: (provider: 'Securitize', chainId: number) => string;
|
|
8
|
+
getCampaignAPIUrl: (isDev: boolean) => string;
|
|
8
9
|
DEFAULT_CHAIN_ID: number;
|
|
9
10
|
};
|
package/dist/cjs/utils/config.js
CHANGED
|
@@ -33,6 +33,9 @@ const getKYCProviderBaseUrl = (provider, chainId) => {
|
|
|
33
33
|
throw new Error(`Unknown KYC provider: ${provider}`);
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
+
const getCampaignAPIUrl = (isDev) =>
|
|
37
|
+
// @TODO Should remove the testnet path because no need to separate testnet and mainet for campaign
|
|
38
|
+
`https://${isDev ? 'dev.testnet.' : ''}campaign-points.huma.finance/graphql`;
|
|
36
39
|
// @todo: ReferenceError: Cannot access 'ChainEnum' before initialization
|
|
37
40
|
const DEFAULT_CHAIN_ID = 137;
|
|
38
41
|
exports.configUtil = {
|
|
@@ -42,6 +45,7 @@ exports.configUtil = {
|
|
|
42
45
|
getIdentityAPIUrl,
|
|
43
46
|
getAuthServiceUrl,
|
|
44
47
|
getKYCProviderBaseUrl,
|
|
48
|
+
getCampaignAPIUrl,
|
|
45
49
|
DEFAULT_CHAIN_ID,
|
|
46
50
|
};
|
|
47
51
|
//# sourceMappingURL=config.js.map
|