@dripfi/drip-sdk 1.1.18 → 1.1.20
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/DripApi.d.ts +24 -4
- package/dist/DripApi.js +34 -6
- package/dist/DripConfig.d.ts +1 -0
- package/dist/DripConfig.js +3 -2
- package/dist/DripSdk.d.ts +3 -1
- package/dist/DripSdk.js +3 -3
- package/dist/test.js +1 -1
- package/dist/types/LoyaltyCard.d.ts +1 -2
- package/package.json +1 -1
package/dist/DripApi.d.ts
CHANGED
@@ -31,8 +31,28 @@ export default class DripApi {
|
|
31
31
|
fetchUserRewards(walletAddress: string, token: string, headers?: Headers): Promise<UserRewards>;
|
32
32
|
fetchVaultsClaimableData(walletAddress: string, token: string, headers?: Headers): Promise<VaultClaimData>;
|
33
33
|
fetchAllLoyaltyCards(token: string, headers?: Headers): Promise<any>;
|
34
|
-
fetchOwnedLoyaltyCards(token: string, headers?: Headers): Promise<
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
fetchOwnedLoyaltyCards(token: string, headers?: Headers): Promise<{
|
35
|
+
id: any;
|
36
|
+
tier: any;
|
37
|
+
level: any;
|
38
|
+
cost: number;
|
39
|
+
boost: any;
|
40
|
+
}>;
|
41
|
+
fetchNextLoyaltyCard(token: string, headers?: Headers): Promise<{
|
42
|
+
id: any;
|
43
|
+
tier: any;
|
44
|
+
level: any;
|
45
|
+
cost: number;
|
46
|
+
boost: any;
|
47
|
+
}>;
|
48
|
+
fetchBeansBalance(token: string, headers?: Headers): Promise<{
|
49
|
+
balance: number;
|
50
|
+
}>;
|
51
|
+
upgradeLoyaltyCard(token: string, headers?: Headers): Promise<{
|
52
|
+
id: any;
|
53
|
+
tier: any;
|
54
|
+
level: any;
|
55
|
+
cost: number;
|
56
|
+
boost: any;
|
57
|
+
}>;
|
38
58
|
}
|
package/dist/DripApi.js
CHANGED
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
exports.IMPERSONATOR_HEADER = void 0;
|
13
13
|
const ethers_1 = require("ethers");
|
14
|
+
const DripConfig_1 = require("./DripConfig");
|
14
15
|
const WETH_TOKEN_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
|
15
16
|
exports.IMPERSONATOR_HEADER = 'impersonatorAddress';
|
16
17
|
const AUTHORIZATION_HEADER = 'Authorization';
|
@@ -363,7 +364,16 @@ class DripApi {
|
|
363
364
|
headers: reqHeaders,
|
364
365
|
});
|
365
366
|
const data = yield res.json();
|
366
|
-
|
367
|
+
const mappedData = data.map((element) => {
|
368
|
+
return {
|
369
|
+
id: element.id,
|
370
|
+
tier: element.tier,
|
371
|
+
level: element.level,
|
372
|
+
cost: parseFloat(ethers_1.ethers.utils.formatUnits(element.cost.toString(), DripConfig_1.DRIP_TOKEN_DECIMALS)),
|
373
|
+
boost: element.boost
|
374
|
+
};
|
375
|
+
});
|
376
|
+
return mappedData;
|
367
377
|
});
|
368
378
|
}
|
369
379
|
fetchOwnedLoyaltyCards(token, headers) {
|
@@ -374,7 +384,13 @@ class DripApi {
|
|
374
384
|
headers: reqHeaders,
|
375
385
|
});
|
376
386
|
const data = yield res.json();
|
377
|
-
return
|
387
|
+
return {
|
388
|
+
id: data.id,
|
389
|
+
tier: data.tier,
|
390
|
+
level: data.level,
|
391
|
+
cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), DripConfig_1.DRIP_TOKEN_DECIMALS)),
|
392
|
+
boost: data.boost
|
393
|
+
};
|
378
394
|
});
|
379
395
|
}
|
380
396
|
fetchNextLoyaltyCard(token, headers) {
|
@@ -385,10 +401,16 @@ class DripApi {
|
|
385
401
|
headers: reqHeaders,
|
386
402
|
});
|
387
403
|
const data = yield res.json();
|
388
|
-
return
|
404
|
+
return {
|
405
|
+
id: data.id,
|
406
|
+
tier: data.tier,
|
407
|
+
level: data.level,
|
408
|
+
cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), DripConfig_1.DRIP_TOKEN_DECIMALS)),
|
409
|
+
boost: data.boost
|
410
|
+
};
|
389
411
|
});
|
390
412
|
}
|
391
|
-
fetchBeansBalance(
|
413
|
+
fetchBeansBalance(token, headers) {
|
392
414
|
return __awaiter(this, void 0, void 0, function* () {
|
393
415
|
const reqHeaders = headers ? headers : new Headers();
|
394
416
|
reqHeaders.append(AUTHORIZATION_HEADER, token);
|
@@ -396,7 +418,7 @@ class DripApi {
|
|
396
418
|
headers: reqHeaders,
|
397
419
|
});
|
398
420
|
const data = yield res.json();
|
399
|
-
return data;
|
421
|
+
return { balance: parseFloat(ethers_1.ethers.utils.formatUnits(data.balance, DripConfig_1.DRIP_TOKEN_DECIMALS)) };
|
400
422
|
});
|
401
423
|
}
|
402
424
|
upgradeLoyaltyCard(token, headers) {
|
@@ -408,7 +430,13 @@ class DripApi {
|
|
408
430
|
headers: reqHeaders,
|
409
431
|
});
|
410
432
|
const data = yield res.json();
|
411
|
-
return
|
433
|
+
return {
|
434
|
+
id: data.id,
|
435
|
+
tier: data.tier,
|
436
|
+
level: data.level,
|
437
|
+
cost: parseFloat(ethers_1.ethers.utils.formatUnits(data.cost.toString(), DripConfig_1.DRIP_TOKEN_DECIMALS)),
|
438
|
+
boost: data.boost
|
439
|
+
};
|
412
440
|
});
|
413
441
|
}
|
414
442
|
}
|
package/dist/DripConfig.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { ContractAddresses, SDKConfig } from '@spool.fi/spool-v2-sdk';
|
2
2
|
import { Signer } from 'ethers';
|
3
3
|
export declare const NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
|
4
|
+
export declare const DRIP_TOKEN_DECIMALS = 18;
|
4
5
|
export declare class DripConfig {
|
5
6
|
internalConfig: SDKConfig;
|
6
7
|
dripRoute: string;
|
package/dist/DripConfig.js
CHANGED
@@ -9,9 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
});
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.DripConfig = exports.NULL_ADDRESS = void 0;
|
12
|
+
exports.DripConfig = exports.DRIP_TOKEN_DECIMALS = exports.NULL_ADDRESS = void 0;
|
13
13
|
const spool_v2_sdk_1 = require("@spool.fi/spool-v2-sdk");
|
14
|
-
exports.NULL_ADDRESS =
|
14
|
+
exports.NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
|
15
|
+
exports.DRIP_TOKEN_DECIMALS = 18;
|
15
16
|
class DripConfig {
|
16
17
|
constructor(subgraphUrl, priceFeedApiUrl, rewardsUrl, fastRedeemApi, contracts, dripRoute, dripTokenAddress, dripTokenRecyclerAddress) {
|
17
18
|
this.internalConfig = new spool_v2_sdk_1.SDKConfig(subgraphUrl, priceFeedApiUrl, rewardsUrl, fastRedeemApi, contracts);
|
package/dist/DripSdk.d.ts
CHANGED
@@ -40,7 +40,9 @@ export default class DripSdk {
|
|
40
40
|
withdraw(vaultAddress: string, amountToWithdraw?: string): Promise<string>;
|
41
41
|
claimWithdraws(vaultAddress: string): Promise<string>;
|
42
42
|
getVaultsClaimableData(headers?: Headers): Promise<VaultClaimData>;
|
43
|
-
getBeansBalance(
|
43
|
+
getBeansBalance(headers?: Headers): Promise<{
|
44
|
+
balance: number;
|
45
|
+
}>;
|
44
46
|
recycleTokens(amount: string): Promise<string>;
|
45
47
|
upgradeLoyaltyCard(): Promise<LoyaltyCard>;
|
46
48
|
getNextLoyaltyCard(headers?: Headers): Promise<LoyaltyCard>;
|
package/dist/DripSdk.js
CHANGED
@@ -330,13 +330,13 @@ class DripSdk {
|
|
330
330
|
return yield this.dripApi.fetchVaultsClaimableData(authData.address, authData.token, headers);
|
331
331
|
});
|
332
332
|
}
|
333
|
-
getBeansBalance(
|
333
|
+
getBeansBalance(headers) {
|
334
334
|
return __awaiter(this, void 0, void 0, function* () {
|
335
335
|
const authData = yield this.isUserAuthenticated();
|
336
336
|
if (!authData.isAuthenticated) {
|
337
337
|
throw Error(`User not authenticated: ${authData.message}`);
|
338
338
|
}
|
339
|
-
return this.dripApi.fetchBeansBalance(
|
339
|
+
return this.dripApi.fetchBeansBalance(authData.token, headers);
|
340
340
|
});
|
341
341
|
}
|
342
342
|
recycleTokens(amount) {
|
@@ -350,7 +350,7 @@ class DripSdk {
|
|
350
350
|
}
|
351
351
|
const decimals = yield this.getERC20Precission(this.dripConfig.dripTokenAddress);
|
352
352
|
const amountWithDecimals = parseFloat(parseFloat(amount).toFixed(decimals));
|
353
|
-
const recycleTx = yield this.dripTokenRecyclerContract.recycle(amountWithDecimals.toString());
|
353
|
+
const recycleTx = yield this.dripTokenRecyclerContract.recycle(ethers_1.ethers.utils.parseUnits(amountWithDecimals.toString(), decimals).toString());
|
354
354
|
const receipt = yield recycleTx.wait();
|
355
355
|
return receipt.transactionHash;
|
356
356
|
});
|
package/dist/test.js
CHANGED
@@ -17,7 +17,7 @@ const ethers_1 = require("ethers");
|
|
17
17
|
const DripConfig_1 = require("./DripConfig");
|
18
18
|
const DripSdk_1 = __importDefault(require("./DripSdk"));
|
19
19
|
// This is script to test locally the drip sdk methods
|
20
|
-
const account2 =
|
20
|
+
const account2 = '0x9E9B6899Ea314dD553A99f4F49440d2CeD2b2848'; // privKey 92eb90257aa76cc56ead18dd52dd3433689712ebe7356a70308b760bfcbdd787
|
21
21
|
// const privKey: string = '6ffc226f7b7769e27124317372c9dbb579a324e67e97bf07131bf2f59ec0f4fe';
|
22
22
|
const privKey = '92eb90257aa76cc56ead18dd52dd3433689712ebe7356a70308b760bfcbdd787';
|
23
23
|
const testConfigParams = {
|