@dripfi/drip-sdk 1.4.22 → 1.4.24
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/README.md +25 -8
- package/dist/PerqApi.d.ts +5 -1
- package/dist/PerqApi.js +37 -0
- package/dist/subpackages/LoyaltyCardsPackage.d.ts +4 -1
- package/dist/subpackages/LoyaltyCardsPackage.js +14 -0
- package/dist/types/ClaimSpecialEditionLoyaltyCardPayload.d.ts +4 -0
- package/dist/types/ClaimSpecialEditionLoyaltyCardPayload.js +2 -0
- package/dist/types/MyPerqData.d.ts +1 -0
- package/dist/types/SpecialEditionLoyaltyCard.d.ts +9 -0
- package/dist/types/SpecialEditionLoyaltyCard.js +2 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -80,14 +80,17 @@ Access Lite vault methods through `sdk.lite`:
|
|
80
80
|
|
81
81
|
Access loyalty card methods through `sdk.loyaltyCards`:
|
82
82
|
|
83
|
-
| Method
|
84
|
-
|
|
85
|
-
| `getBeansBalance(): Promise<BeansBalance>`
|
86
|
-
| `getBeansHistory(): Promise<BeanEntry[]>`
|
87
|
-
| `getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>`
|
88
|
-
| `upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>`
|
89
|
-
| `
|
90
|
-
| `
|
83
|
+
| Method | Description |
|
84
|
+
| ----------------------------------------------------------------------------- | ------------------------------------------------- |
|
85
|
+
| `getBeansBalance(): Promise<BeansBalance>` | Gets user's beans balance. |
|
86
|
+
| `getBeansHistory(): Promise<BeanEntry[]>` | Gets user's beans history. |
|
87
|
+
| `getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>` | Gets swap info for Perq to beans. |
|
88
|
+
| `upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>` | Upgrades loyalty card. |
|
89
|
+
| `claimSpecialEditionCard(cardId: string): Promise<SpecialEditionLoyaltyCard>` | Claims special edition loyalty card. |
|
90
|
+
| `getOwnedLoyaltyCard(): Promise<LoyaltyCard>` | Gets user's owned loyalty card. |
|
91
|
+
| `getOwnedSpecialEditionCards(): Promise<SpecialEditionLoyaltyCard[]>` | Gets user's owned special edition loyalty cards. |
|
92
|
+
| `getAllLoyaltyCards(): Promise<LoyaltyCard[]>` | Gets all available loyalty cards. |
|
93
|
+
| `getAllSpecialEditionCards(): Promise<SpecialEditionLoyaltyCard[]>` | Gets all available special edition loyalty cards. |
|
91
94
|
|
92
95
|
### Vesting
|
93
96
|
|
@@ -395,6 +398,7 @@ type MyPerqData = VaultData & MyPerqBalance {
|
|
395
398
|
ethPrice: number;
|
396
399
|
btcPrice: number;
|
397
400
|
distributionType: VaultType;
|
401
|
+
projectTvl: number;
|
398
402
|
};
|
399
403
|
|
400
404
|
type NFTBoost = {
|
@@ -470,6 +474,15 @@ type QLFastRedeem = {
|
|
470
474
|
svtWithdrawn: string;
|
471
475
|
};
|
472
476
|
|
477
|
+
type SpecialEditionLoyaltyCard = {
|
478
|
+
id: string;
|
479
|
+
name: string;
|
480
|
+
boost: number;
|
481
|
+
projects: string[];
|
482
|
+
startDate: Date;
|
483
|
+
endDate: Date;
|
484
|
+
};
|
485
|
+
|
473
486
|
type Strategy = {
|
474
487
|
address: string;
|
475
488
|
lastDoHardWorkTime: number | null;
|
@@ -494,6 +507,10 @@ type UpgradeLoyaltyCardPayload = {
|
|
494
507
|
index: number;
|
495
508
|
};
|
496
509
|
|
510
|
+
type ClaimSpecialEditionLoyaltyCardPayload = {
|
511
|
+
cardId: string;
|
512
|
+
};
|
513
|
+
|
497
514
|
type UserRewards = {
|
498
515
|
// vaultAddress => pointsName => rewardsAmount
|
499
516
|
[vaultAddress: string]: { [rewardPointsName: string]: number };
|
package/dist/PerqApi.d.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import { BigNumber } from 'ethers';
|
2
|
-
import { SwapInfo, UserRewards, VaultStats, MyPerqData, LoyaltyCard, BeansBalance, PerqToBeansSwapInfo, BeanEntry, NonceEnrichedSignedPayload, NonceEnrichedPayload, UpgradeLoyaltyCardPayload, ReducedProjectData, DetailedProjectData, Earnings, LinkedPodWallets, SuiWalletPayload, NearWalletPayload } from './types';
|
2
|
+
import { SwapInfo, UserRewards, VaultStats, MyPerqData, LoyaltyCard, BeansBalance, PerqToBeansSwapInfo, BeanEntry, NonceEnrichedSignedPayload, NonceEnrichedPayload, UpgradeLoyaltyCardPayload, ReducedProjectData, DetailedProjectData, Earnings, LinkedPodWallets, SuiWalletPayload, NearWalletPayload, SpecialEditionLoyaltyCard } from './types';
|
3
3
|
import VaultData from './types/VaultData';
|
4
4
|
import PerqSdk from './PerqSdk';
|
5
5
|
import MigrationOption from './types/MigrationOption';
|
6
6
|
import ProjectHistoricalTvl from './types/ProjectHistoricalTvl';
|
7
|
+
import ClaimSpecialEditionLoyaltyCardPayload from './types/ClaimSpecialEditionLoyaltyCardPayload';
|
7
8
|
export default class PerqApi {
|
8
9
|
private perqSdk;
|
9
10
|
constructor(perqSdk: PerqSdk);
|
@@ -22,9 +23,12 @@ export default class PerqApi {
|
|
22
23
|
fetchAssetPerSvtAtBlock(vaultAddress: string, blocknumber: number): Promise<BigNumber>;
|
23
24
|
fetchUserRewards(walletAddress: string): Promise<UserRewards>;
|
24
25
|
fetchAllLoyaltyCards(): Promise<LoyaltyCard[]>;
|
26
|
+
fetchAllSpecialEditionLoyaltyCards(): Promise<SpecialEditionLoyaltyCard[]>;
|
25
27
|
fetchOwnedLoyaltyCard(walletAddress: string): Promise<LoyaltyCard>;
|
28
|
+
fetchOwnedSpecialEditionLoyaltyCards(walletAddress: string): Promise<SpecialEditionLoyaltyCard[]>;
|
26
29
|
fetchBeansBalance(walletAddress: string): Promise<BeansBalance>;
|
27
30
|
upgradeLoyaltyCard(signedPayload: NonceEnrichedSignedPayload<UpgradeLoyaltyCardPayload>): Promise<LoyaltyCard>;
|
31
|
+
claimSpecialEditionCard(signedPayload: NonceEnrichedSignedPayload<ClaimSpecialEditionLoyaltyCardPayload>): Promise<SpecialEditionLoyaltyCard>;
|
28
32
|
fetchMyPerqData(userAddress: string): Promise<MyPerqData[]>;
|
29
33
|
getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
|
30
34
|
fetchBeansHistory(walletAddress: string): Promise<BeanEntry[]>;
|
package/dist/PerqApi.js
CHANGED
@@ -181,6 +181,16 @@ class PerqApi {
|
|
181
181
|
throw Error(`${await res.text()}`);
|
182
182
|
}
|
183
183
|
}
|
184
|
+
async fetchAllSpecialEditionLoyaltyCards() {
|
185
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/specialEditions/all`);
|
186
|
+
if (res.ok) {
|
187
|
+
const data = await res.json();
|
188
|
+
return data;
|
189
|
+
}
|
190
|
+
else {
|
191
|
+
throw Error(`${await res.text()}`);
|
192
|
+
}
|
193
|
+
}
|
184
194
|
async fetchOwnedLoyaltyCard(walletAddress) {
|
185
195
|
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/loyaltyCards/owned`);
|
186
196
|
if (res.status === 204) {
|
@@ -200,6 +210,16 @@ class PerqApi {
|
|
200
210
|
throw Error(`${await res.text()}`);
|
201
211
|
}
|
202
212
|
}
|
213
|
+
async fetchOwnedSpecialEditionLoyaltyCards(walletAddress) {
|
214
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/specialEditions/owned`);
|
215
|
+
if (res.ok) {
|
216
|
+
const data = await res.json();
|
217
|
+
return data;
|
218
|
+
}
|
219
|
+
else {
|
220
|
+
throw Error(`${await res.text()}`);
|
221
|
+
}
|
222
|
+
}
|
203
223
|
async fetchBeansBalance(walletAddress) {
|
204
224
|
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${walletAddress}/beans/balance`);
|
205
225
|
if (res.ok) {
|
@@ -237,6 +257,23 @@ class PerqApi {
|
|
237
257
|
throw Error(`${await res.text()}`);
|
238
258
|
}
|
239
259
|
}
|
260
|
+
async claimSpecialEditionCard(signedPayload) {
|
261
|
+
const { signerAddress } = signedPayload;
|
262
|
+
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${signerAddress}/specialEditions/claim`, {
|
263
|
+
method: 'POST',
|
264
|
+
headers: {
|
265
|
+
'Content-Type': 'application/json',
|
266
|
+
},
|
267
|
+
body: JSON.stringify(signedPayload),
|
268
|
+
});
|
269
|
+
if (res.ok) {
|
270
|
+
const data = await res.json();
|
271
|
+
return data;
|
272
|
+
}
|
273
|
+
else {
|
274
|
+
throw Error(`${await res.text()}`);
|
275
|
+
}
|
276
|
+
}
|
240
277
|
async fetchMyPerqData(userAddress) {
|
241
278
|
const res = await fetch(`${this.perqSdk.perqConfig.route}/api-be/api/user/${userAddress}/myperq`);
|
242
279
|
if (res.ok) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BeansBalance, BeanEntry, PerqToBeansSwapInfo, LoyaltyCard } from '../types';
|
1
|
+
import { BeansBalance, BeanEntry, PerqToBeansSwapInfo, LoyaltyCard, SpecialEditionLoyaltyCard } from '../types';
|
2
2
|
import PerqSdk from '../PerqSdk';
|
3
3
|
export default class LoyaltyPackage {
|
4
4
|
private perqSdk;
|
@@ -9,4 +9,7 @@ export default class LoyaltyPackage {
|
|
9
9
|
upgradeLoyaltyCard(index: number): Promise<LoyaltyCard>;
|
10
10
|
getOwnedLoyaltyCard(): Promise<LoyaltyCard>;
|
11
11
|
getAllLoyaltyCards(): Promise<LoyaltyCard[]>;
|
12
|
+
claimSpecialEditionCard(cardId: string): Promise<SpecialEditionLoyaltyCard>;
|
13
|
+
getOwnedSpecialEditionCards(): Promise<SpecialEditionLoyaltyCard[]>;
|
14
|
+
getAllSpecialEditionCards(): Promise<SpecialEditionLoyaltyCard[]>;
|
12
15
|
}
|
@@ -30,5 +30,19 @@ class LoyaltyPackage {
|
|
30
30
|
async getAllLoyaltyCards() {
|
31
31
|
return this.perqSdk.perqApi.fetchAllLoyaltyCards();
|
32
32
|
}
|
33
|
+
async claimSpecialEditionCard(cardId) {
|
34
|
+
const payload = {
|
35
|
+
cardId,
|
36
|
+
};
|
37
|
+
const signedPayload = await this.perqSdk.signHandler.signPayload(payload);
|
38
|
+
return this.perqSdk.perqApi.claimSpecialEditionCard(signedPayload);
|
39
|
+
}
|
40
|
+
async getOwnedSpecialEditionCards() {
|
41
|
+
const signerAddress = await this.perqSdk.signer.getAddress();
|
42
|
+
return this.perqSdk.perqApi.fetchOwnedSpecialEditionLoyaltyCards(signerAddress);
|
43
|
+
}
|
44
|
+
async getAllSpecialEditionCards() {
|
45
|
+
return this.perqSdk.perqApi.fetchAllSpecialEditionLoyaltyCards();
|
46
|
+
}
|
33
47
|
}
|
34
48
|
exports.default = LoyaltyPackage;
|
package/dist/types/index.d.ts
CHANGED
@@ -15,6 +15,7 @@ import PerqToBeansSwapInfo from './PerqToBeansSwapInfo';
|
|
15
15
|
import QLFastRedeem from './QLFastRedeem';
|
16
16
|
import { BasePayload, NonceEnrichedPayload, NonceEnrichedSignedPayload } from './SignedPayload';
|
17
17
|
import { ReducedProjectData } from './ReducedProjectData';
|
18
|
+
import SpecialEditionLoyaltyCard from './SpecialEditionLoyaltyCard';
|
18
19
|
import Strategy from './Strategy';
|
19
20
|
import StretchGoal from './StretchGoal';
|
20
21
|
import SwapInfo from './SwapInfo';
|
@@ -29,4 +30,4 @@ import YelayVersion from './YelayVersion';
|
|
29
30
|
import Earnings from './Earnings';
|
30
31
|
import LinkedPodWallets from './LinkedPodWallets';
|
31
32
|
import MigrationOption from './MigrationOption';
|
32
|
-
export { Asset, BasePayload, BeanEntry, BeansBalance, DeployedProject, DeployedVault, DepositToken, DetailedProjectData, ELoyaltyCardTier, NearWalletPayload, SuiWalletPayload, LinkedPodWallets, LoyaltyCard, MigrationOption, MyPerqData, NFTBoost, NonceEnrichedPayload, NonceEnrichedSignedPayload, PerqConfig, PerqToBeansSwapInfo, ProjectBacker, QLFastRedeem, ReducedProjectData, RewardType, Strategy, StretchGoal, SwapInfo, UpgradeLoyaltyCardPayload, UserRewards, VaultData, VaultReward, VaultStats, VaultType, VestingInfo, YelayVersion, Earnings, };
|
33
|
+
export { Asset, BasePayload, BeanEntry, BeansBalance, DeployedProject, DeployedVault, DepositToken, DetailedProjectData, ELoyaltyCardTier, NearWalletPayload, SuiWalletPayload, LinkedPodWallets, LoyaltyCard, MigrationOption, MyPerqData, NFTBoost, NonceEnrichedPayload, NonceEnrichedSignedPayload, PerqConfig, PerqToBeansSwapInfo, ProjectBacker, QLFastRedeem, ReducedProjectData, RewardType, SpecialEditionLoyaltyCard, Strategy, StretchGoal, SwapInfo, UpgradeLoyaltyCardPayload, UserRewards, VaultData, VaultReward, VaultStats, VaultType, VestingInfo, YelayVersion, Earnings, };
|