@huma-finance/shared 0.0.65 → 0.0.66-beta.812
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/services/CampaignService.d.ts +30 -48
- package/dist/cjs/services/CampaignService.js +124 -171
- package/dist/cjs/services/CampaignService.js.map +1 -1
- package/dist/cjs/services/IdentityServiceV2.d.ts +67 -10
- package/dist/cjs/services/IdentityServiceV2.js +97 -28
- package/dist/cjs/services/IdentityServiceV2.js.map +1 -1
- package/dist/cjs/solana/chain.d.ts +2 -0
- package/dist/cjs/solana/chain.js +5 -0
- package/dist/cjs/solana/chain.js.map +1 -1
- package/dist/cjs/utils/chain.d.ts +6 -1
- package/dist/cjs/utils/chain.js +13 -4
- package/dist/cjs/utils/chain.js.map +1 -1
- package/dist/cjs/utils/config.d.ts +3 -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 +7 -0
- package/dist/cjs/utils/const.js +9 -1
- package/dist/cjs/utils/const.js.map +1 -1
- package/dist/cjs/utils/number.d.ts +4 -1
- package/dist/cjs/utils/number.js +36 -2
- package/dist/cjs/utils/number.js.map +1 -1
- package/dist/cjs/utils/request.d.ts +1 -0
- package/dist/cjs/utils/request.js +18 -11
- package/dist/cjs/utils/request.js.map +1 -1
- package/dist/services/CampaignService.d.ts +30 -48
- package/dist/services/CampaignService.js +124 -171
- package/dist/services/CampaignService.js.map +1 -1
- package/dist/services/IdentityServiceV2.d.ts +67 -10
- package/dist/services/IdentityServiceV2.js +98 -29
- package/dist/services/IdentityServiceV2.js.map +1 -1
- package/dist/solana/chain.d.ts +2 -0
- package/dist/solana/chain.js +4 -0
- package/dist/solana/chain.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils/chain.d.ts +6 -1
- package/dist/utils/chain.js +11 -3
- package/dist/utils/chain.js.map +1 -1
- package/dist/utils/config.d.ts +3 -0
- package/dist/utils/config.js +4 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/const.d.ts +7 -0
- package/dist/utils/const.js +8 -0
- package/dist/utils/const.js.map +1 -1
- package/dist/utils/number.d.ts +4 -1
- package/dist/utils/number.js +32 -1
- package/dist/utils/number.js.map +1 -1
- package/dist/utils/request.d.ts +1 -0
- package/dist/utils/request.js +16 -10
- package/dist/utils/request.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SolanaChainEnum, SolanaPoolInfo } from '../solana';
|
|
2
|
-
import { ChainEnum } from '../utils/chain';
|
|
2
|
+
import { ChainEnum, NETWORK_TYPE } from '../utils/chain';
|
|
3
3
|
import { PoolInfoV2 } from '../v2/utils/pool';
|
|
4
4
|
export type CampaignSeason = {
|
|
5
5
|
id: string;
|
|
@@ -41,67 +41,49 @@ export type SolanaCampaignGroup = {
|
|
|
41
41
|
campaigns: SolanaCampaign[];
|
|
42
42
|
partners: CampaignPartner[];
|
|
43
43
|
};
|
|
44
|
-
type Wallet = {
|
|
45
|
-
id: string;
|
|
46
|
-
address: string;
|
|
47
|
-
referralCode: string;
|
|
48
|
-
referrer: {
|
|
49
|
-
id: string;
|
|
50
|
-
address: string;
|
|
51
|
-
};
|
|
52
|
-
createdAt: string;
|
|
53
|
-
};
|
|
54
|
-
type WalletPoint = {
|
|
55
|
-
id: string;
|
|
56
|
-
rank: number;
|
|
57
|
-
wallet: Wallet;
|
|
58
|
-
totalPoints: number;
|
|
59
|
-
numberOfReferred: number;
|
|
60
|
-
};
|
|
61
|
-
type WalletRank = {
|
|
62
|
-
totalCount: number;
|
|
63
|
-
walletPoints: WalletPoint[];
|
|
64
|
-
};
|
|
65
44
|
type CampaignPoints = {
|
|
66
45
|
campaignId: string;
|
|
67
46
|
juniorTranchePoints: number;
|
|
68
47
|
seniorTranchePoints: number;
|
|
69
48
|
lockupPeriodMonths: number;
|
|
70
49
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
50
|
+
export type LeaderboardItem = {
|
|
51
|
+
accountId: string;
|
|
52
|
+
accountName: string;
|
|
53
|
+
points: number;
|
|
54
|
+
ranking: number;
|
|
55
|
+
referredCount: number;
|
|
56
|
+
};
|
|
57
|
+
export type HumaAccountPoints = {
|
|
58
|
+
accountId: string;
|
|
59
|
+
totalPoints: number;
|
|
60
|
+
basePoints: number;
|
|
61
|
+
liquidityPoints: number;
|
|
62
|
+
liquidityPointsList: {
|
|
63
|
+
address: string;
|
|
64
|
+
points: number;
|
|
65
|
+
}[];
|
|
66
|
+
referralPoints: number;
|
|
67
|
+
bonusPoints: number;
|
|
68
|
+
};
|
|
69
|
+
declare function checkWalletOwnership(wallet: string, networkType: NETWORK_TYPE, isDev: boolean): Promise<boolean | undefined>;
|
|
70
|
+
declare function getLeaderboard(seasonId: string, networkType: NETWORK_TYPE, isDev: boolean): Promise<LeaderboardItem[] | undefined>;
|
|
71
|
+
declare function getHumaAccountRanking(seasonId: string, networkType: NETWORK_TYPE, isDev: boolean): Promise<LeaderboardItem | undefined>;
|
|
72
|
+
declare function getHumaAccountPoints(networkType: NETWORK_TYPE, isDev: boolean): Promise<HumaAccountPoints | undefined>;
|
|
73
|
+
declare function getEstimatedPoints(campaignGroupId: string, principal: string, networkType: NETWORK_TYPE, isDev: boolean): Promise<CampaignPoints[]>;
|
|
74
|
+
declare function updateHumaAccountPoints(walletAddress: string, transactionHash: string, chainId: ChainEnum | SolanaChainEnum, networkType: NETWORK_TYPE, isDev: boolean): Promise<{
|
|
87
75
|
pointsAccumulated?: number;
|
|
88
76
|
}>;
|
|
89
|
-
declare function checkAndCreateWallet(account: string, referralCode: string | null | undefined, isDev: boolean, pointsTestnetExperience: boolean): Promise<{
|
|
90
|
-
wallet: string;
|
|
91
|
-
} | undefined>;
|
|
92
77
|
/**
|
|
93
78
|
* An object that contains functions to interact with Huma's campaign service.
|
|
94
79
|
* @namespace CampaignService
|
|
95
80
|
*/
|
|
96
81
|
export declare const CampaignService: {
|
|
97
82
|
checkWalletOwnership: typeof checkWalletOwnership;
|
|
98
|
-
getWalletInfo: typeof getWalletInfo;
|
|
99
|
-
getWalletRankList: typeof getWalletRankList;
|
|
100
|
-
getRecentJoins: typeof getRecentJoins;
|
|
101
|
-
getActiveSeasonAndCampaignGroups: typeof getActiveSeasonAndCampaignGroups;
|
|
102
83
|
getEstimatedPoints: typeof getEstimatedPoints;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
84
|
+
getLeaderboard: typeof getLeaderboard;
|
|
85
|
+
getHumaAccountRanking: typeof getHumaAccountRanking;
|
|
86
|
+
getHumaAccountPoints: typeof getHumaAccountPoints;
|
|
87
|
+
updateHumaAccountPoints: typeof updateHumaAccountPoints;
|
|
106
88
|
};
|
|
107
89
|
export {};
|
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CampaignService = void 0;
|
|
4
4
|
const graphql_request_1 = require("graphql-request");
|
|
5
5
|
const config_1 = require("../utils/config");
|
|
6
|
+
const const_1 = require("../utils/const");
|
|
6
7
|
const request_1 = require("../utils/request");
|
|
7
|
-
function checkWalletOwnership(wallet,
|
|
8
|
-
const url = config_1.configUtil.
|
|
8
|
+
function checkWalletOwnership(wallet, networkType, isDev) {
|
|
9
|
+
const url = config_1.configUtil.getCampaignAPIUrlV2(networkType, isDev);
|
|
9
10
|
const query = (0, graphql_request_1.gql) `
|
|
10
11
|
query {
|
|
11
12
|
walletOwnership(address: "${wallet}")
|
|
@@ -13,160 +14,150 @@ function checkWalletOwnership(wallet, isDev, pointsTestnetExperience) {
|
|
|
13
14
|
`;
|
|
14
15
|
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
15
16
|
.then((res) => {
|
|
16
|
-
var _a;
|
|
17
|
+
var _a, _b, _c;
|
|
17
18
|
if (res.errors) {
|
|
18
|
-
console.
|
|
19
|
-
|
|
19
|
+
console.log(res.errors);
|
|
20
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
+
const errMessage = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.walletOwnership) === null || _b === void 0 ? void 0 : _b.errMessage;
|
|
23
|
+
if (errMessage) {
|
|
24
|
+
console.error(errMessage);
|
|
25
|
+
throw new Error(errMessage);
|
|
26
|
+
}
|
|
27
|
+
return (_c = res.data) === null || _c === void 0 ? void 0 : _c.walletOwnership;
|
|
22
28
|
})
|
|
23
29
|
.catch((err) => {
|
|
24
30
|
console.error(err);
|
|
25
|
-
|
|
31
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
26
32
|
});
|
|
27
33
|
}
|
|
28
|
-
function
|
|
29
|
-
const url = config_1.configUtil.
|
|
34
|
+
function getLeaderboard(seasonId, networkType, isDev) {
|
|
35
|
+
const url = config_1.configUtil.getCampaignAPIUrlV2(networkType, isDev);
|
|
30
36
|
const query = (0, graphql_request_1.gql) `
|
|
31
37
|
query {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
leaderboard(seasonId: "${seasonId}") {
|
|
39
|
+
... on LeaderboardResult {
|
|
40
|
+
data {
|
|
41
|
+
accountId
|
|
42
|
+
accountName
|
|
43
|
+
points
|
|
44
|
+
referredCount
|
|
45
|
+
ranking
|
|
46
|
+
}
|
|
36
47
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
numberOfReferred
|
|
40
|
-
totalPoints
|
|
48
|
+
... on PointServiceError {
|
|
49
|
+
errMessage
|
|
41
50
|
}
|
|
42
51
|
}
|
|
52
|
+
}
|
|
43
53
|
`;
|
|
44
54
|
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
45
55
|
.then((res) => {
|
|
56
|
+
var _a, _b, _c, _d, _e;
|
|
46
57
|
if (res.errors) {
|
|
47
|
-
console.
|
|
48
|
-
|
|
58
|
+
console.log(res.errors);
|
|
59
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
49
60
|
}
|
|
50
|
-
|
|
61
|
+
const errMessage = (_c = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.leaderboard) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.errMessage;
|
|
62
|
+
if (errMessage) {
|
|
63
|
+
console.error(errMessage);
|
|
64
|
+
throw new Error(errMessage);
|
|
65
|
+
}
|
|
66
|
+
return (_e = (_d = res.data) === null || _d === void 0 ? void 0 : _d.leaderboard) === null || _e === void 0 ? void 0 : _e.data;
|
|
51
67
|
})
|
|
52
68
|
.catch((err) => {
|
|
53
69
|
console.error(err);
|
|
54
|
-
|
|
70
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
55
71
|
});
|
|
56
72
|
}
|
|
57
|
-
function
|
|
58
|
-
const url = config_1.configUtil.
|
|
73
|
+
function getHumaAccountRanking(seasonId, networkType, isDev) {
|
|
74
|
+
const url = config_1.configUtil.getCampaignAPIUrlV2(networkType, isDev);
|
|
59
75
|
const query = (0, graphql_request_1.gql) `
|
|
60
76
|
query {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
id
|
|
72
|
-
address
|
|
73
|
-
}
|
|
74
|
-
totalPoints
|
|
75
|
-
numberOfReferred
|
|
76
|
-
}
|
|
77
|
+
myRankingEntry(seasonId: "${seasonId}") {
|
|
78
|
+
... on LeaderboardItem {
|
|
79
|
+
accountId
|
|
80
|
+
accountName
|
|
81
|
+
points
|
|
82
|
+
referredCount
|
|
83
|
+
ranking
|
|
84
|
+
}
|
|
85
|
+
... on PointServiceError {
|
|
86
|
+
errMessage
|
|
77
87
|
}
|
|
78
88
|
}
|
|
89
|
+
}
|
|
79
90
|
`;
|
|
80
91
|
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
81
92
|
.then((res) => {
|
|
82
|
-
var _a;
|
|
93
|
+
var _a, _b, _c;
|
|
83
94
|
if (res.errors) {
|
|
84
|
-
console.
|
|
85
|
-
|
|
95
|
+
console.log(res.errors);
|
|
96
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
97
|
+
}
|
|
98
|
+
const errMessage = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.myRankingEntry) === null || _b === void 0 ? void 0 : _b.errMessage;
|
|
99
|
+
if (errMessage) {
|
|
100
|
+
console.error(errMessage);
|
|
101
|
+
throw new Error(errMessage);
|
|
86
102
|
}
|
|
87
|
-
return (
|
|
103
|
+
return (_c = res.data) === null || _c === void 0 ? void 0 : _c.myRankingEntry;
|
|
88
104
|
})
|
|
89
105
|
.catch((err) => {
|
|
90
106
|
console.error(err);
|
|
91
|
-
|
|
107
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
92
108
|
});
|
|
93
109
|
}
|
|
94
|
-
function
|
|
95
|
-
const url = config_1.configUtil.
|
|
110
|
+
function getHumaAccountPoints(networkType, isDev) {
|
|
111
|
+
const url = config_1.configUtil.getCampaignAPIUrlV2(networkType, isDev);
|
|
96
112
|
const query = (0, graphql_request_1.gql) `
|
|
97
113
|
query {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
114
|
+
accountPoints {
|
|
115
|
+
... on AccountPointsResult {
|
|
116
|
+
accountId
|
|
117
|
+
basePoints
|
|
118
|
+
liquidityPoints
|
|
119
|
+
liquidityPointsList {
|
|
104
120
|
address
|
|
121
|
+
points
|
|
105
122
|
}
|
|
106
|
-
|
|
123
|
+
referralPoints
|
|
124
|
+
bonusPoints
|
|
107
125
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
`;
|
|
111
|
-
return ((0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
-
.then((res) => {
|
|
114
|
-
var _a, _b;
|
|
115
|
-
if (res.errors) {
|
|
116
|
-
console.error(res.errors);
|
|
117
|
-
return undefined;
|
|
118
|
-
}
|
|
119
|
-
return (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.wallets) === null || _b === void 0 ? void 0 : _b.wallets;
|
|
120
|
-
})
|
|
121
|
-
.catch((err) => {
|
|
122
|
-
console.error(err);
|
|
123
|
-
return undefined;
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
function getActiveSeasonAndCampaignGroups(isDev, pointsTestnetExperience) {
|
|
127
|
-
const url = config_1.configUtil.getCampaignAPIUrl(isDev, pointsTestnetExperience);
|
|
128
|
-
const query = (0, graphql_request_1.gql) `
|
|
129
|
-
query {
|
|
130
|
-
activeSeason {
|
|
131
|
-
id
|
|
132
|
-
estimatedTotalPoints
|
|
133
|
-
name
|
|
134
|
-
}
|
|
135
|
-
campaignGroups {
|
|
136
|
-
id
|
|
137
|
-
name
|
|
138
|
-
campaigns {
|
|
139
|
-
id
|
|
140
|
-
name
|
|
141
|
-
chainId
|
|
142
|
-
juniorMultiplier
|
|
143
|
-
lockupPeriodMonths
|
|
144
|
-
seniorMultiplier
|
|
145
|
-
poolAddress
|
|
146
|
-
}
|
|
147
|
-
partners {
|
|
148
|
-
id
|
|
149
|
-
name
|
|
126
|
+
... on PointServiceError {
|
|
127
|
+
errMessage
|
|
150
128
|
}
|
|
151
129
|
}
|
|
152
130
|
}
|
|
153
131
|
`;
|
|
154
132
|
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
155
133
|
.then((res) => {
|
|
156
|
-
var _a;
|
|
134
|
+
var _a, _b, _c;
|
|
157
135
|
if (res.errors) {
|
|
158
|
-
console.
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
136
|
+
console.log(res.errors);
|
|
137
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
138
|
+
}
|
|
139
|
+
const errMessage = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.accountPoints) === null || _b === void 0 ? void 0 : _b.errMessage;
|
|
140
|
+
if (errMessage) {
|
|
141
|
+
console.error(errMessage);
|
|
142
|
+
throw new Error(errMessage);
|
|
143
|
+
}
|
|
144
|
+
const accountPoints = (_c = res.data) === null || _c === void 0 ? void 0 : _c.accountPoints;
|
|
145
|
+
if (accountPoints) {
|
|
146
|
+
accountPoints.totalPoints =
|
|
147
|
+
accountPoints.basePoints +
|
|
148
|
+
accountPoints.liquidityPoints +
|
|
149
|
+
accountPoints.referralPoints +
|
|
150
|
+
accountPoints.bonusPoints;
|
|
151
|
+
}
|
|
152
|
+
return accountPoints;
|
|
162
153
|
})
|
|
163
154
|
.catch((err) => {
|
|
164
155
|
console.error(err);
|
|
165
|
-
|
|
156
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
166
157
|
});
|
|
167
158
|
}
|
|
168
|
-
function getEstimatedPoints(campaignGroupId, principal,
|
|
169
|
-
const url = config_1.configUtil.
|
|
159
|
+
function getEstimatedPoints(campaignGroupId, principal, networkType, isDev) {
|
|
160
|
+
const url = config_1.configUtil.getCampaignAPIUrlV2(networkType, isDev);
|
|
170
161
|
const query = (0, graphql_request_1.gql) `
|
|
171
162
|
query {
|
|
172
163
|
calculateEstimatedPoints(input: {campaignGroupId:"${campaignGroupId}", principal:"${principal}"}){
|
|
@@ -181,110 +172,72 @@ function getEstimatedPoints(campaignGroupId, principal, isDev, pointsTestnetExpe
|
|
|
181
172
|
`;
|
|
182
173
|
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
183
174
|
.then((res) => {
|
|
184
|
-
var _a, _b, _c;
|
|
175
|
+
var _a, _b, _c, _d, _e;
|
|
185
176
|
if (res.errors) {
|
|
186
177
|
console.error(res.errors);
|
|
187
|
-
|
|
178
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
188
179
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return [];
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
function createNewWallet(account, referralCode, isDev, pointsTestnetExperience) {
|
|
197
|
-
const url = config_1.configUtil.getCampaignAPIUrl(isDev, pointsTestnetExperience);
|
|
198
|
-
const query = (0, graphql_request_1.gql) `
|
|
199
|
-
mutation {
|
|
200
|
-
createWallet(
|
|
201
|
-
input: {
|
|
202
|
-
walletAddress: "${account}"
|
|
203
|
-
referralCode: "${referralCode}"
|
|
204
|
-
}
|
|
205
|
-
) {
|
|
206
|
-
... on CreateWalletResult {
|
|
207
|
-
wallet {
|
|
208
|
-
address
|
|
209
|
-
}
|
|
180
|
+
const errMessage = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.calculateEstimatedPoints) === null || _b === void 0 ? void 0 : _b.errMessage;
|
|
181
|
+
if (errMessage) {
|
|
182
|
+
console.error(errMessage);
|
|
183
|
+
throw new Error(errMessage);
|
|
210
184
|
}
|
|
211
|
-
|
|
212
|
-
message
|
|
213
|
-
}
|
|
214
|
-
... on UnauthorizedError {
|
|
215
|
-
message
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
`;
|
|
220
|
-
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
221
|
-
.then((res) => {
|
|
222
|
-
var _a;
|
|
223
|
-
if (res.errors) {
|
|
224
|
-
console.error(res.errors);
|
|
225
|
-
return undefined;
|
|
226
|
-
}
|
|
227
|
-
return (_a = res.data) === null || _a === void 0 ? void 0 : _a.createWallet;
|
|
185
|
+
return (_e = (_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.calculateEstimatedPoints) === null || _d === void 0 ? void 0 : _d.campaignPointsEstimations) !== null && _e !== void 0 ? _e : [];
|
|
228
186
|
})
|
|
229
187
|
.catch((err) => {
|
|
230
188
|
console.error(err);
|
|
231
|
-
|
|
189
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
232
190
|
});
|
|
233
191
|
}
|
|
234
|
-
function
|
|
235
|
-
const url = config_1.configUtil.
|
|
192
|
+
function updateHumaAccountPoints(walletAddress, transactionHash, chainId, networkType, isDev) {
|
|
193
|
+
const url = config_1.configUtil.getCampaignAPIUrlV2(networkType, isDev);
|
|
236
194
|
const query = (0, graphql_request_1.gql) `
|
|
237
195
|
mutation {
|
|
238
|
-
|
|
196
|
+
updateAccountPoints(
|
|
239
197
|
input: {
|
|
240
198
|
chainId: ${chainId},
|
|
241
|
-
walletAddress: "${
|
|
242
|
-
transactionHash: "${
|
|
199
|
+
walletAddress: "${walletAddress}",
|
|
200
|
+
transactionHash: "${transactionHash}"
|
|
243
201
|
}
|
|
244
202
|
) {
|
|
245
|
-
... on
|
|
203
|
+
... on UpdateAccountPointsResult {
|
|
246
204
|
pointsAccumulated
|
|
247
205
|
}
|
|
248
|
-
... on
|
|
249
|
-
|
|
206
|
+
... on PointServiceError {
|
|
207
|
+
errMessage
|
|
250
208
|
}
|
|
251
209
|
}
|
|
252
210
|
}
|
|
253
211
|
`;
|
|
254
212
|
return (0, request_1.requestPost)(url, JSON.stringify({ query }))
|
|
255
213
|
.then((res) => {
|
|
256
|
-
var _a, _b;
|
|
214
|
+
var _a, _b, _c, _d;
|
|
257
215
|
if (res.errors) {
|
|
258
|
-
console.
|
|
259
|
-
|
|
216
|
+
console.log(res.errors);
|
|
217
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
260
218
|
}
|
|
261
|
-
|
|
219
|
+
const errMessage = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.updateAccountPoints) === null || _b === void 0 ? void 0 : _b.errMessage;
|
|
220
|
+
if (errMessage) {
|
|
221
|
+
console.error(errMessage);
|
|
222
|
+
throw new Error(errMessage);
|
|
223
|
+
}
|
|
224
|
+
return (_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.updateAccountPoints) !== null && _d !== void 0 ? _d : {};
|
|
262
225
|
})
|
|
263
226
|
.catch((err) => {
|
|
264
227
|
console.error(err);
|
|
265
|
-
|
|
228
|
+
throw new Error(const_1.COMMON_ERROR_MESSAGE);
|
|
266
229
|
});
|
|
267
230
|
}
|
|
268
|
-
async function checkAndCreateWallet(account, referralCode, isDev, pointsTestnetExperience) {
|
|
269
|
-
const result = await getWalletInfo(account, isDev, pointsTestnetExperience);
|
|
270
|
-
if (!(result === null || result === void 0 ? void 0 : result.wallet)) {
|
|
271
|
-
return createNewWallet(account, referralCode, isDev, pointsTestnetExperience);
|
|
272
|
-
}
|
|
273
|
-
return undefined;
|
|
274
|
-
}
|
|
275
231
|
/**
|
|
276
232
|
* An object that contains functions to interact with Huma's campaign service.
|
|
277
233
|
* @namespace CampaignService
|
|
278
234
|
*/
|
|
279
235
|
exports.CampaignService = {
|
|
280
236
|
checkWalletOwnership,
|
|
281
|
-
getWalletInfo,
|
|
282
|
-
getWalletRankList,
|
|
283
|
-
getRecentJoins,
|
|
284
|
-
getActiveSeasonAndCampaignGroups,
|
|
285
237
|
getEstimatedPoints,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
238
|
+
getLeaderboard,
|
|
239
|
+
getHumaAccountRanking,
|
|
240
|
+
getHumaAccountPoints,
|
|
241
|
+
updateHumaAccountPoints,
|
|
289
242
|
};
|
|
290
243
|
//# sourceMappingURL=CampaignService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CampaignService.js","sourceRoot":"","sources":["../../../src/services/CampaignService.ts"],"names":[],"mappings":";;;AAAA,qDAAqC;AAIrC,4CAA4C;AAC5C,8CAA8C;
|
|
1
|
+
{"version":3,"file":"CampaignService.js","sourceRoot":"","sources":["../../../src/services/CampaignService.ts"],"names":[],"mappings":";;;AAAA,qDAAqC;AAIrC,4CAA4C;AAC5C,0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AAI,0CAAE,mBAAmB,mCAAI,EAAE,CAAA;IAC5C,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAClB,MAAM,IAAI,KAAK,CAAC,4BAAoB,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;AACN,CAAC;AAED;;;GAGG;AACU,QAAA,eAAe,GAAG;IAC7B,oBAAoB;IACpB,kBAAkB;IAClB,cAAc;IACd,qBAAqB;IACrB,oBAAoB;IACpB,uBAAuB;CACxB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NETWORK_TYPE } from '../utils/chain';
|
|
1
2
|
/**
|
|
2
3
|
* Enum representing the identity status V2.
|
|
3
4
|
* @typedef {Enum} IdentityVerificationStatusV2
|
|
@@ -55,11 +56,49 @@ export type ResumeVerificationResultV2 = {
|
|
|
55
56
|
/**
|
|
56
57
|
* Object representing the Huma account.
|
|
57
58
|
* @typedef {Object} HumaAccount
|
|
58
|
-
* @property {string}
|
|
59
|
+
* @property {string} id The account id.
|
|
60
|
+
* @property {string} name The account name.
|
|
61
|
+
* @property {Wallet[]} wallets The account wallets.
|
|
62
|
+
* @property {string} referralCode The account referral code.
|
|
63
|
+
* @property {number} numReferrals The number of referrals.
|
|
64
|
+
* @property {Referrer} referrer The account referrer.
|
|
65
|
+
* @property {string} createdAt The account created time.
|
|
59
66
|
*/
|
|
60
67
|
export type HumaAccount = {
|
|
61
|
-
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
wallets: {
|
|
71
|
+
address: string;
|
|
72
|
+
chainId: string;
|
|
73
|
+
}[];
|
|
74
|
+
referralCode: string;
|
|
75
|
+
numReferrals: number;
|
|
76
|
+
referrer: {
|
|
77
|
+
id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
};
|
|
80
|
+
createdAt: string;
|
|
62
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* Object representing the Huma account login result.
|
|
84
|
+
* @typedef {Object} HumaAccountLoginResult
|
|
85
|
+
* @property {HumaAccount} account The Huma account.
|
|
86
|
+
* @property {boolean} isNewAccount Is new account or not.
|
|
87
|
+
*/
|
|
88
|
+
export type HumaAccountLoginResult = HumaAccount & {
|
|
89
|
+
account: HumaAccount;
|
|
90
|
+
isNewAccount: boolean;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Object representing the accreditation answers.
|
|
94
|
+
* @typedef {Object} AccreditationAnswers
|
|
95
|
+
* @property {string} question1 The question 1.
|
|
96
|
+
* @property {boolean} question1Answer The question 1 answer.
|
|
97
|
+
* @property {string} question2 The question 2.
|
|
98
|
+
* @property {boolean} question2Answer The question 2 answer.
|
|
99
|
+
* @property {string} question3 The question 3.
|
|
100
|
+
* @property {boolean} question3Answer The question 3 answer.
|
|
101
|
+
*/
|
|
63
102
|
export type AccreditationAnswers = {
|
|
64
103
|
question1: string;
|
|
65
104
|
question1Answer: boolean;
|
|
@@ -68,13 +107,31 @@ export type AccreditationAnswers = {
|
|
|
68
107
|
question3: string;
|
|
69
108
|
question3Answer: boolean;
|
|
70
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* Object representing the account name validity.
|
|
112
|
+
* @typedef {Object} AccountNameValidity
|
|
113
|
+
* @property {string} name The account name.
|
|
114
|
+
* @property {string} invalidReason The invalid reason.
|
|
115
|
+
*/
|
|
116
|
+
export type AccountNameValidity = {
|
|
117
|
+
name: string;
|
|
118
|
+
invalidReason: 'already_taken' | 'inappropriate_language';
|
|
119
|
+
};
|
|
71
120
|
export declare const IdentityServiceV2: {
|
|
72
|
-
getVerificationStatusV2: (
|
|
73
|
-
accredit: (
|
|
74
|
-
startVerification: (
|
|
75
|
-
resumeVerification: (
|
|
76
|
-
consentToSubscription: (
|
|
77
|
-
approveLender: (walletAddress: string, chainId: number, contractAddress: string, isDev?: boolean, chainSpecificData?: Record<string, unknown>) => Promise<void>;
|
|
78
|
-
|
|
79
|
-
|
|
121
|
+
getVerificationStatusV2: (networkType: NETWORK_TYPE, isDev?: boolean) => Promise<VerificationStatusResultV2>;
|
|
122
|
+
accredit: (networkType: NETWORK_TYPE, answers: AccreditationAnswers, isDev?: boolean) => Promise<AccreditationResultV2>;
|
|
123
|
+
startVerification: (networkType: NETWORK_TYPE, isDev?: boolean) => Promise<VerificationStatusResultV2>;
|
|
124
|
+
resumeVerification: (networkType: NETWORK_TYPE, isDev?: boolean) => Promise<ResumeVerificationResultV2>;
|
|
125
|
+
consentToSubscription: (networkType: NETWORK_TYPE, documentHash: string, isDev?: boolean) => Promise<void>;
|
|
126
|
+
approveLender: (networkType: NETWORK_TYPE, walletAddress: string, chainId: number, contractAddress: string, isDev?: boolean, chainSpecificData?: Record<string, unknown>) => Promise<void>;
|
|
127
|
+
getHumaAccount: (networkType: NETWORK_TYPE, isDev?: boolean) => Promise<HumaAccount>;
|
|
128
|
+
humaAccountLogin: (networkType: NETWORK_TYPE, walletAddress: string, chainId: number, isDev?: boolean) => Promise<HumaAccountLoginResult>;
|
|
129
|
+
humaAccountLogout: (networkType: NETWORK_TYPE, isDev?: boolean) => Promise<void>;
|
|
130
|
+
humaAccountUpdate: (networkType: NETWORK_TYPE, humaAccount: {
|
|
131
|
+
name: string;
|
|
132
|
+
}, isDev?: boolean) => Promise<void>;
|
|
133
|
+
humaAccountAddWallet: (networkType: NETWORK_TYPE, walletAddress: string, chainId: number, isDev?: boolean) => Promise<HumaAccount>;
|
|
134
|
+
humaAccountUpdateReferral: (networkType: NETWORK_TYPE, referralCode: string, isDev?: boolean) => Promise<void>;
|
|
135
|
+
humaAccountNameValidity: (networkType: NETWORK_TYPE, name: string, isDev?: boolean) => Promise<AccountNameValidity>;
|
|
136
|
+
getRecentlyJoinedHumaAccounts: (networkType: NETWORK_TYPE, isDev?: boolean, limit?: number) => Promise<HumaAccount[]>;
|
|
80
137
|
};
|