@dripfi/drip-sdk 1.2.12 → 1.2.14
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 +2 -0
- package/dist/DripApi.js +19 -0
- package/dist/DripConfig.js +1 -1
- package/dist/DripSdk.d.ts +1 -1
- package/dist/DripSdk.js +3 -6
- package/dist/types/AuthenticationStatus.d.ts +14 -3
- package/dist/types/AuthenticationStatus.js +16 -0
- package/package.json +1 -1
package/dist/DripApi.d.ts
CHANGED
@@ -11,6 +11,7 @@ import { LoyaltyCard } from './types/LoyaltyCard';
|
|
11
11
|
import { BeansBalance } from './types/BeansBalance';
|
12
12
|
import { PerqToBeansSwapInfo } from './types/PerqToBeansSwapInfo';
|
13
13
|
import BeanEntry from './types/BeanEntry';
|
14
|
+
import { AuthenticationStatus } from './types/AuthenticationStatus';
|
14
15
|
export declare const IMPERSONATOR_HEADER = "impersonatorAddress";
|
15
16
|
export default class DripApi {
|
16
17
|
route: string;
|
@@ -62,4 +63,5 @@ export default class DripApi {
|
|
62
63
|
getLoyaltyCardBoost(rewardId: string, token: string, headers?: Headers): Promise<number>;
|
63
64
|
getSwapPerqForBeansInfo(): Promise<PerqToBeansSwapInfo>;
|
64
65
|
fetchBeansHistory(walletAddress: string, token: string, headers?: Headers): Promise<BeanEntry[]>;
|
66
|
+
checkTokenStatus(token: string): Promise<AuthenticationStatus>;
|
65
67
|
}
|
package/dist/DripApi.js
CHANGED
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.IMPERSONATOR_HEADER = void 0;
|
13
13
|
const ethers_1 = require("ethers");
|
14
14
|
const DripConfig_1 = require("./DripConfig");
|
15
|
+
const AuthenticationStatus_1 = require("./types/AuthenticationStatus");
|
15
16
|
const WETH_TOKEN_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
|
16
17
|
exports.IMPERSONATOR_HEADER = 'impersonatorAddress';
|
17
18
|
const AUTHORIZATION_HEADER = 'Authorization';
|
@@ -524,5 +525,23 @@ class DripApi {
|
|
524
525
|
}
|
525
526
|
});
|
526
527
|
}
|
528
|
+
checkTokenStatus(token) {
|
529
|
+
return __awaiter(this, void 0, void 0, function* () {
|
530
|
+
try {
|
531
|
+
const reqHeaders = new Headers();
|
532
|
+
reqHeaders.append(AUTHORIZATION_HEADER, token);
|
533
|
+
const res = yield fetch(`${this.route}/api-be/auth/validateToken`, {
|
534
|
+
method: 'GET',
|
535
|
+
headers: reqHeaders,
|
536
|
+
});
|
537
|
+
const data = yield res.json();
|
538
|
+
return res.ok ? new AuthenticationStatus_1.ValidStatus(data.address) : new AuthenticationStatus_1.ErrorStatus(data.error);
|
539
|
+
}
|
540
|
+
catch (error) {
|
541
|
+
console.log(error);
|
542
|
+
return new AuthenticationStatus_1.ErrorStatus(error === null || error === void 0 ? void 0 : error.message);
|
543
|
+
}
|
544
|
+
});
|
545
|
+
}
|
527
546
|
}
|
528
547
|
exports.default = DripApi;
|
package/dist/DripConfig.js
CHANGED
@@ -23,7 +23,7 @@ const RECYCLER_ADDRESS_SEPOLIA = '0x07F2264E199D62afe07E8288eC9D36d155fc3f24';
|
|
23
23
|
const SWAP_AND_RECYCLER_ADDRESS_SEPOLIA = '0xA4ed357FF233731860Ec8D0446FD95756d564014';
|
24
24
|
const VESTING_ADDRESS_SEPOLIA = '0x1d3B9E32a7139718f94BE32c797682fFf2D1bE60';
|
25
25
|
const DRIP_TOKEN_ADDRESS_SEPOLIA = '0x707B4Cc05645713d8Ea04FBC7192A0f2c1503d6E';
|
26
|
-
const DEV_BACKEND_ROUTE = 'https://dev.
|
26
|
+
const DEV_BACKEND_ROUTE = 'https://dev.dripfi.io';
|
27
27
|
const SUBGRAPH_URL_MAINNET = 'https://subgraph.satsuma-prod.com/49eb322da234/solidant/spool-v2/api';
|
28
28
|
const RECYCLER_ADDRESS_MAINNET = '0x2FdcdB17799557Dce6f26921f12B7FA1DbcD79FA';
|
29
29
|
const SWAP_AND_RECYCLER_ADDRESS_MAINNET = '0x15ED53964E6a5EcbEBAb80A0Fc68c2297b0eaA8D';
|
package/dist/DripSdk.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { BigNumber, Signer } from 'ethers';
|
2
|
-
import { AuthenticationStatus } from './types/AuthenticationStatus';
|
3
2
|
import { UserRewards } from './types/UserRewards';
|
4
3
|
import { VaultStats } from './types/VaultStats';
|
5
4
|
import { UserBalance } from './types/UserBalance';
|
@@ -13,6 +12,7 @@ import { BeansBalance } from './types/BeansBalance';
|
|
13
12
|
import { PerqToBeansSwapInfo } from './types/PerqToBeansSwapInfo';
|
14
13
|
import BeanEntry from './types/BeanEntry';
|
15
14
|
import { VestingInfo } from './types/VestingInfo';
|
15
|
+
import { AuthenticationStatus } from './types/AuthenticationStatus';
|
16
16
|
export default class DripSdk {
|
17
17
|
private dripApi;
|
18
18
|
private dripTokenContract;
|
package/dist/DripSdk.js
CHANGED
@@ -23,6 +23,7 @@ const DripTokenRecyclerContract_1 = __importDefault(require("./contracts/DripTok
|
|
23
23
|
const DripSwapAndRecyclerContract_1 = __importDefault(require("./contracts/DripSwapAndRecyclerContract"));
|
24
24
|
const PerqVestingContract_1 = __importDefault(require("./contracts/PerqVestingContract"));
|
25
25
|
const utils_1 = require("ethers/lib/utils");
|
26
|
+
const AuthenticationStatus_1 = require("./types/AuthenticationStatus");
|
26
27
|
class DripSdk {
|
27
28
|
constructor(chain, signer, dripRoute) {
|
28
29
|
this.signer = signer;
|
@@ -70,10 +71,7 @@ class DripSdk {
|
|
70
71
|
const userAddress = yield this.signer.getAddress();
|
71
72
|
const cookieName = `auth_${userAddress.toLowerCase()}`;
|
72
73
|
const authToken = js_cookie_1.default.get(cookieName);
|
73
|
-
|
74
|
-
return { isAuthenticated: false, message: 'Auth token not found' };
|
75
|
-
}
|
76
|
-
return { isAuthenticated: true, address: userAddress.toLowerCase(), token: authToken };
|
74
|
+
return !authToken ? new AuthenticationStatus_1.ErrorStatus('Auth token not found') : yield this.dripApi.checkTokenStatus(authToken);
|
77
75
|
});
|
78
76
|
}
|
79
77
|
authenticate() {
|
@@ -532,8 +530,7 @@ class DripSdk {
|
|
532
530
|
if (!this.signer) {
|
533
531
|
throw Error('No signer provided');
|
534
532
|
}
|
535
|
-
|
536
|
-
const decimals = tokenAddress === '0x4200000000000000000000000000000000000006' ? 18 : yield this.getERC20Precission(tokenAddress);
|
533
|
+
const decimals = yield this.getERC20Precission(tokenAddress);
|
537
534
|
const erc20Instance = spool_v2_sdk_1.ERC20__factory.connect(tokenAddress, this.signer);
|
538
535
|
const approveTx = yield erc20Instance.transfer(receiver, ethers_1.ethers.utils.parseUnits(amount, decimals));
|
539
536
|
const receipt = yield approveTx.wait();
|
@@ -1,6 +1,17 @@
|
|
1
|
-
export
|
1
|
+
export interface AuthenticationStatus {
|
2
|
+
message: string;
|
2
3
|
isAuthenticated: boolean;
|
3
4
|
address?: string;
|
4
5
|
token?: string;
|
5
|
-
|
6
|
-
|
6
|
+
}
|
7
|
+
export declare class ValidStatus implements AuthenticationStatus {
|
8
|
+
message: string;
|
9
|
+
isAuthenticated: boolean;
|
10
|
+
address: string;
|
11
|
+
constructor(address: string);
|
12
|
+
}
|
13
|
+
export declare class ErrorStatus implements AuthenticationStatus {
|
14
|
+
message: string;
|
15
|
+
isAuthenticated: boolean;
|
16
|
+
constructor(message: string);
|
17
|
+
}
|
@@ -1,2 +1,18 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ErrorStatus = exports.ValidStatus = void 0;
|
4
|
+
class ValidStatus {
|
5
|
+
constructor(address) {
|
6
|
+
this.message = 'Valid Token';
|
7
|
+
this.isAuthenticated = true;
|
8
|
+
this.address = address;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
exports.ValidStatus = ValidStatus;
|
12
|
+
class ErrorStatus {
|
13
|
+
constructor(message) {
|
14
|
+
this.isAuthenticated = false;
|
15
|
+
this.message = message;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
exports.ErrorStatus = ErrorStatus;
|