@mezo-org/passport 0.9.0-dev.2 → 0.10.0-dev.1
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/src/api/index.d.ts +1 -0
- package/dist/src/api/index.d.ts.map +1 -1
- package/dist/src/api/index.js +1 -0
- package/dist/src/api/index.js.map +1 -1
- package/dist/src/api/portal.d.ts +1 -1
- package/dist/src/api/portal.d.ts.map +1 -1
- package/dist/src/api/rewards.d.ts +24 -0
- package/dist/src/api/rewards.d.ts.map +1 -0
- package/dist/src/api/rewards.js +20 -0
- package/dist/src/api/rewards.js.map +1 -0
- package/dist/src/hooks/index.d.ts +1 -0
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +1 -0
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts +3 -2
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +15 -3
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useRewardsApiClient.d.ts +2 -0
- package/dist/src/hooks/useRewardsApiClient.d.ts.map +1 -0
- package/dist/src/hooks/useRewardsApiClient.js +6 -0
- package/dist/src/hooks/useRewardsApiClient.js.map +1 -0
- package/dist/src/provider.d.ts +8 -2
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +4 -2
- package/dist/src/provider.js.map +1 -1
- package/package.json +6 -6
- package/src/api/index.ts +1 -0
- package/src/api/portal.ts +1 -1
- package/src/api/rewards.ts +39 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useGetCurrentAccount.ts +32 -10
- package/src/hooks/useRewardsApiClient.ts +7 -0
- package/src/provider.ts +14 -1
package/dist/src/api/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA"}
|
package/dist/src/api/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA"}
|
package/dist/src/api/portal.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../../src/api/portal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,
|
|
1
|
+
{"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../../src/api/portal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,2BAA2B;;;CAGvC,CAAA;AAED,qBAAa,eAAgB,SAAQ,SAAS;gBAE1C,WAAW,GAAE,MAAM,OAAO,2BAAuC,EACjE,MAAM,CAAC,EAAE,MAAM;IAQX,mBAAmB;IAQnB,aAAa,CAAC,OAAO,EAAE,MAAM;CAUpC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ApiClient } from "./client";
|
|
2
|
+
type MatsData = {
|
|
3
|
+
mats: number;
|
|
4
|
+
rank: number;
|
|
5
|
+
};
|
|
6
|
+
type RewardsMatsResponse = {
|
|
7
|
+
data: {
|
|
8
|
+
mats: {
|
|
9
|
+
seasonOne: MatsData;
|
|
10
|
+
seasonTwo: MatsData;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type RewardsMats = RewardsMatsResponse["data"]["mats"];
|
|
15
|
+
export declare const REWARDS_API_ENDPOINTS_BY_ENV: {
|
|
16
|
+
mainnet: string;
|
|
17
|
+
testnet: string;
|
|
18
|
+
};
|
|
19
|
+
export declare class RewardsApiClient extends ApiClient {
|
|
20
|
+
constructor(environment?: keyof typeof REWARDS_API_ENDPOINTS_BY_ENV, apiUrl?: string);
|
|
21
|
+
getRewardsMats(address: string): Promise<RewardsMats>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=rewards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewards.d.ts","sourceRoot":"","sources":["../../../src/api/rewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,KAAK,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9C,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE;QAAE,IAAI,EAAE;YAAE,SAAS,EAAE,QAAQ,CAAC;YAAC,SAAS,EAAE,QAAQ,CAAA;SAAE,CAAA;KAAE,CAAA;CAC7D,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAE7D,eAAO,MAAM,4BAA4B;;;CAGxC,CAAA;AAED,qBAAa,gBAAiB,SAAQ,SAAS;gBAE3C,WAAW,GAAE,MAAM,OAAO,4BAAwC,EAClE,MAAM,CAAC,EAAE,MAAM;IAQX,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAY5D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ApiClient } from "./client";
|
|
2
|
+
export const REWARDS_API_ENDPOINTS_BY_ENV = {
|
|
3
|
+
mainnet: "https://api.mezo.org/rewards/",
|
|
4
|
+
testnet: "https://api.test.mezo.org/rewards/",
|
|
5
|
+
};
|
|
6
|
+
export class RewardsApiClient extends ApiClient {
|
|
7
|
+
constructor(environment = "mainnet", apiUrl) {
|
|
8
|
+
super({
|
|
9
|
+
apiUrl: apiUrl ?? REWARDS_API_ENDPOINTS_BY_ENV[environment],
|
|
10
|
+
removeVersioning: true,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async getRewardsMats(address) {
|
|
14
|
+
const { data: { mats }, } = await this.handleRequest(`/accounts/${address.toLowerCase()}`, {
|
|
15
|
+
method: "GET",
|
|
16
|
+
});
|
|
17
|
+
return mats;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=rewards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewards.js","sourceRoot":"","sources":["../../../src/api/rewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAUpC,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,OAAO,EAAE,+BAA+B;IACxC,OAAO,EAAE,oCAAoC;CAC9C,CAAA;AAED,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAC7C,YACE,cAAyD,SAAS,EAClE,MAAe;QAEf,KAAK,CAAC;YACJ,MAAM,EAAE,MAAM,IAAI,4BAA4B,CAAC,WAAW,CAAC;YAC3D,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAe;QAClC,MAAM,EACJ,IAAI,EAAE,EAAE,IAAI,EAAE,GACf,GAAG,MAAM,IAAI,CAAC,aAAa,CAC1B,aAAa,OAAO,CAAC,WAAW,EAAE,EAAE,EACpC;YACE,MAAM,EAAE,KAAK;SACd,CACF,CAAA;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
|
|
@@ -13,4 +13,5 @@ export * from "./useSignUpWithWallet";
|
|
|
13
13
|
export { useTokensBalances, useInvalidateTokensBalances, useResetTokensBalances, } from "./useTokensBalances";
|
|
14
14
|
export * from "./useUpdateMezoId";
|
|
15
15
|
export * from "./useValidateMezoId";
|
|
16
|
+
export * from "./useRewardsApiClient";
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7E,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7E,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA"}
|
package/dist/src/hooks/index.js
CHANGED
|
@@ -13,4 +13,5 @@ export * from "./useSignUpWithWallet";
|
|
|
13
13
|
export { useTokensBalances, useInvalidateTokensBalances, useResetTokensBalances, } from "./useTokensBalances";
|
|
14
14
|
export * from "./useUpdateMezoId";
|
|
15
15
|
export * from "./useValidateMezoId";
|
|
16
|
+
export * from "./useRewardsApiClient";
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7E,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC7E,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UseQueryOptions } from "@tanstack/react-query";
|
|
2
2
|
import type { GetCurrentAccountResponse } from "../api";
|
|
3
3
|
type GetCurrentAccountResponseWithMats = GetCurrentAccountResponse & {
|
|
4
4
|
mats: {
|
|
5
5
|
totalMats: number;
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type UseGetCurrentAccountOptions<TSelected = GetCurrentAccountResponseWithMats> = Omit<UseQueryOptions<GetCurrentAccountResponseWithMats, Error, TSelected>, "queryKey" | "queryFn">;
|
|
9
|
+
export declare function useGetCurrentAccount(queryOptions?: UseGetCurrentAccountOptions): import("@tanstack/react-query").UseQueryResult<Partial<{
|
|
9
10
|
mezoId: string;
|
|
10
11
|
hasModifiedMezoId: boolean;
|
|
11
12
|
linkedAccounts: import("../api").LinkedAccount[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetCurrentAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useGetCurrentAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGetCurrentAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useGetCurrentAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAKjE,OAAO,KAAK,EAAE,yBAAyB,EAA2B,MAAM,QAAQ,CAAA;AAIhF,KAAK,iCAAiC,GAAG,yBAAyB,GAAG;IACnE,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF,CAAA;AAED,KAAK,2BAA2B,CAC9B,SAAS,GAAG,iCAAiC,IAC3C,IAAI,CACN,eAAe,CAAC,iCAAiC,EAAE,KAAK,EAAE,SAAS,CAAC,EACpE,UAAU,GAAG,SAAS,CACvB,CAAA;AAED,wBAAgB,oBAAoB,CAClC,YAAY,GAAE,2BAAgC;;;;;UAbxC;QACJ,SAAS,EAAE,MAAM,CAAA;KAClB;UAoEF"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
1
2
|
import { useQuery } from "@tanstack/react-query";
|
|
2
3
|
import { ONE_MINUTE_MS } from "../utils/time";
|
|
3
4
|
import { QUERY_KEYS } from "./constants";
|
|
4
5
|
import { useAuthApiClient } from "./useAuthApiClient";
|
|
5
6
|
import { usePortalApiClient } from "./usePortalApiClient";
|
|
7
|
+
import { useRewardsApiClient } from "./useRewardsApiClient";
|
|
8
|
+
import { PassportContext } from "../provider";
|
|
6
9
|
export function useGetCurrentAccount(queryOptions = {}) {
|
|
10
|
+
const passportContext = useContext(PassportContext);
|
|
7
11
|
const authApiClient = useAuthApiClient();
|
|
8
12
|
const portalApiClient = usePortalApiClient();
|
|
13
|
+
const rewardsApiClient = useRewardsApiClient();
|
|
9
14
|
return useQuery({
|
|
10
15
|
queryKey: [QUERY_KEYS.ACCOUNT, QUERY_KEYS.CURRENT],
|
|
11
16
|
queryFn: async () => {
|
|
@@ -17,9 +22,16 @@ export function useGetCurrentAccount(queryOptions = {}) {
|
|
|
17
22
|
if (!linkedWallets || linkedWallets.length === 0) {
|
|
18
23
|
throw new Error("No linked wallets found for the current account");
|
|
19
24
|
}
|
|
20
|
-
const addresses = linkedWallets.map((account) =>
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
const addresses = linkedWallets.map((account) => passportContext?.useRewardsApi
|
|
26
|
+
? account.evmAddress
|
|
27
|
+
: account.btcAddress || account.evmAddress);
|
|
28
|
+
const mats = await Promise.all(addresses.map((address) => passportContext?.useRewardsApi
|
|
29
|
+
? rewardsApiClient.getRewardsMats(address)
|
|
30
|
+
: portalApiClient.getPortalMats(address)));
|
|
31
|
+
const totalMats = mats.reduce((sumMats, currentMats) => sumMats +
|
|
32
|
+
(passportContext?.useRewardsApi
|
|
33
|
+
? currentMats.seasonTwo.mats
|
|
34
|
+
: currentMats.totalMats), 0);
|
|
23
35
|
return {
|
|
24
36
|
...currentAccount,
|
|
25
37
|
mats: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetCurrentAccount.js","sourceRoot":"","sources":["../../../src/hooks/useGetCurrentAccount.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useGetCurrentAccount.js","sourceRoot":"","sources":["../../../src/hooks/useGetCurrentAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAmB,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAe7C,MAAM,UAAU,oBAAoB,CAClC,eAA4C,EAAE;IAE9C,MAAM,eAAe,GAAG,UAAU,CAAC,eAAe,CAAC,CAAA;IAEnD,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IACxC,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAA;IAC5C,MAAM,gBAAgB,GAAG,mBAAmB,EAAE,CAAA;IAE9C,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;QAClD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,cAAc,GAAG,MAAM,aAAa,CAAC,iBAAiB,EAAE,CAAA;YAC9D,IAAI,CAAC,cAAc,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;YAC7C,CAAC;YAED,MAAM,aAAa,GAAG,cAAc,EAAE,cAAc,EAAE,MAAM,CAC1D,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,CACvC,CAAA;YACD,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACjD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;YACpE,CAAC;YAED,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAC9C,eAAe,EAAE,aAAa;gBAC5B,CAAC,CAAC,OAAO,CAAC,UAAU;gBACpB,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAC7C,CAAA;YAED,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAC5B,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACxB,eAAe,EAAE,aAAa;gBAC5B,CAAC,CAAC,gBAAgB,CAAC,cAAc,CAAC,OAAO,CAAC;gBAC1C,CAAC,CAAC,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAC3C,CACF,CAAA;YAED,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAC3B,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,CACvB,OAAO;gBACP,CAAC,eAAe,EAAE,aAAa;oBAC7B,CAAC,CAAE,WAA2B,CAAC,SAAS,CAAC,IAAI;oBAC7C,CAAC,CAAE,WAA0B,CAAC,SAAS,CAAC,EAC5C,CAAC,CACF,CAAA;YAED,OAAO;gBACL,GAAG,cAAc;gBACjB,IAAI,EAAE;oBACJ,SAAS;iBACV;aACF,CAAA;QACH,CAAC;QACD,SAAS,EAAE,aAAa;QACxB,KAAK,EAAE,CAAC;QACR,GAAG,YAAY;KAChB,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRewardsApiClient.d.ts","sourceRoot":"","sources":["../../../src/hooks/useRewardsApiClient.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,sCAIlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRewardsApiClient.js","sourceRoot":"","sources":["../../../src/hooks/useRewardsApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,MAAM,UAAU,mBAAmB;IACjC,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAEjD,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
|
package/dist/src/provider.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { AuthApiClient, PortalApiClient } from "./api";
|
|
1
|
+
import { AuthApiClient, PortalApiClient, RewardsApiClient } from "./api";
|
|
2
2
|
export interface PassportContextValue {
|
|
3
3
|
authApiClient: AuthApiClient;
|
|
4
4
|
portalApiClient: PortalApiClient;
|
|
5
|
+
rewardsApiClient: RewardsApiClient;
|
|
5
6
|
environment?: Environment;
|
|
6
7
|
accountDataRefetchInterval: number;
|
|
7
8
|
nativeBalanceRefetchInterval: number;
|
|
8
9
|
nativePriceRefetchInterval: number;
|
|
9
10
|
borrowDataRefetchInterval: number;
|
|
11
|
+
useRewardsApi: boolean;
|
|
10
12
|
}
|
|
11
13
|
export declare const PassportContext: import("react").Context<PassportContextValue | undefined>;
|
|
12
14
|
type Environment = "mainnet" | "testnet";
|
|
@@ -15,6 +17,7 @@ type PassportProviderProps = {
|
|
|
15
17
|
environment?: Environment;
|
|
16
18
|
authApiUrl?: string;
|
|
17
19
|
portalApiUrl?: string;
|
|
20
|
+
rewardsApiUrl?: string;
|
|
18
21
|
/** Time in milliseconds after which account data (like mats or mezo id) in
|
|
19
22
|
* dropdown should be re-fetched. Default is 60000 (60 secs) */
|
|
20
23
|
accountDataRefetchInterval?: number;
|
|
@@ -28,7 +31,10 @@ type PassportProviderProps = {
|
|
|
28
31
|
* re-fetched. Default is 60000 (60 secs)
|
|
29
32
|
* price. */
|
|
30
33
|
borrowDataRefetchInterval?: number;
|
|
34
|
+
/** Determines whether passport should use Rewards API
|
|
35
|
+
* to consume data */
|
|
36
|
+
useRewardsApi?: boolean;
|
|
31
37
|
};
|
|
32
|
-
export declare function PassportProvider({ environment, authApiUrl, portalApiUrl, children, accountDataRefetchInterval, nativeBalanceRefetchInterval, nativePriceRefetchInterval, borrowDataRefetchInterval, }: PassportProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<PassportContextValue | undefined>>;
|
|
38
|
+
export declare function PassportProvider({ environment, authApiUrl, portalApiUrl, rewardsApiUrl, children, useRewardsApi, accountDataRefetchInterval, nativeBalanceRefetchInterval, nativePriceRefetchInterval, borrowDataRefetchInterval, }: PassportProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<PassportContextValue | undefined>>;
|
|
33
39
|
export {};
|
|
34
40
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAGxE,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,aAAa,CAAA;IAC5B,eAAe,EAAE,eAAe,CAAA;IAChC,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,0BAA0B,EAAE,MAAM,CAAA;IAClC,4BAA4B,EAAE,MAAM,CAAA;IACpC,0BAA0B,EAAE,MAAM,CAAA;IAClC,yBAAyB,EAAE,MAAM,CAAA;IACjC,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,eAAO,MAAM,eAAe,2DAE3B,CAAA;AAED,KAAK,WAAW,GAAG,SAAS,GAAG,SAAS,CAAA;AAExC,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;mEAC+D;IAC/D,0BAA0B,CAAC,EAAE,MAAM,CAAA;IACnC;oDACgD;IAChD,4BAA4B,CAAC,EAAE,MAAM,CAAA;IACrC;iDAC6C;IAC7C,0BAA0B,CAAC,EAAE,MAAM,CAAA;IACnC;;gBAEY;IACZ,yBAAyB,CAAC,EAAE,MAAM,CAAA;IAClC;yBACqB;IACrB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,aAAa,EACb,0BAA+C,EAC/C,4BAAiD,EACjD,0BAA+C,EAC/C,yBAA8C,GAC/C,EAAE,qBAAqB,6GA4BvB"}
|
package/dist/src/provider.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createContext, createElement } from "react";
|
|
2
|
-
import { AuthApiClient, PortalApiClient } from "./api";
|
|
2
|
+
import { AuthApiClient, PortalApiClient, RewardsApiClient } from "./api";
|
|
3
3
|
import { ONE_SECOND_MS } from "./utils/time";
|
|
4
4
|
export const PassportContext = createContext(undefined);
|
|
5
|
-
export function PassportProvider({ environment, authApiUrl, portalApiUrl, children, accountDataRefetchInterval = 60 * ONE_SECOND_MS, nativeBalanceRefetchInterval = 60 * ONE_SECOND_MS, nativePriceRefetchInterval = 60 * ONE_SECOND_MS, borrowDataRefetchInterval = 60 * ONE_SECOND_MS, }) {
|
|
5
|
+
export function PassportProvider({ environment, authApiUrl, portalApiUrl, rewardsApiUrl, children, useRewardsApi, accountDataRefetchInterval = 60 * ONE_SECOND_MS, nativeBalanceRefetchInterval = 60 * ONE_SECOND_MS, nativePriceRefetchInterval = 60 * ONE_SECOND_MS, borrowDataRefetchInterval = 60 * ONE_SECOND_MS, }) {
|
|
6
6
|
if (environment && !["mainnet", "testnet"].includes(environment)) {
|
|
7
7
|
throw new Error("Wrong environment passed to PassportProvider.");
|
|
8
8
|
}
|
|
@@ -10,11 +10,13 @@ export function PassportProvider({ environment, authApiUrl, portalApiUrl, childr
|
|
|
10
10
|
value: {
|
|
11
11
|
authApiClient: new AuthApiClient(environment ?? "mainnet", authApiUrl),
|
|
12
12
|
portalApiClient: new PortalApiClient(environment ?? "mainnet", portalApiUrl),
|
|
13
|
+
rewardsApiClient: new RewardsApiClient(environment ?? "mainnet", rewardsApiUrl),
|
|
13
14
|
environment,
|
|
14
15
|
accountDataRefetchInterval,
|
|
15
16
|
nativeBalanceRefetchInterval,
|
|
16
17
|
nativePriceRefetchInterval,
|
|
17
18
|
borrowDataRefetchInterval,
|
|
19
|
+
useRewardsApi: useRewardsApi ?? false,
|
|
18
20
|
},
|
|
19
21
|
}, children);
|
|
20
22
|
}
|
package/dist/src/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAc5C,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAC1C,SAAS,CACV,CAAA;AA4BD,MAAM,UAAU,gBAAgB,CAAC,EAC/B,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,aAAa,EACb,0BAA0B,GAAG,EAAE,GAAG,aAAa,EAC/C,4BAA4B,GAAG,EAAE,GAAG,aAAa,EACjD,0BAA0B,GAAG,EAAE,GAAG,aAAa,EAC/C,yBAAyB,GAAG,EAAE,GAAG,aAAa,GACxB;IACtB,IAAI,WAAW,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;IAClE,CAAC;IAED,OAAO,aAAa,CAClB,eAAe,CAAC,QAAQ,EACxB;QACE,KAAK,EAAE;YACL,aAAa,EAAE,IAAI,aAAa,CAAC,WAAW,IAAI,SAAS,EAAE,UAAU,CAAC;YACtE,eAAe,EAAE,IAAI,eAAe,CAClC,WAAW,IAAI,SAAS,EACxB,YAAY,CACb;YACD,gBAAgB,EAAE,IAAI,gBAAgB,CACpC,WAAW,IAAI,SAAS,EACxB,aAAa,CACd;YACD,WAAW;YACX,0BAA0B;YAC1B,4BAA4B;YAC5B,0BAA0B;YAC1B,yBAAyB;YACzB,aAAa,EAAE,aAAa,IAAI,KAAK;SACtC;KACF,EACD,QAAQ,CACT,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mezo-org/passport",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0-dev.1",
|
|
4
4
|
"main": "dist/src/index.js",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"scripts": {
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
"@mezo-org/mezo-clay": "0.1.0-dev.34",
|
|
41
41
|
"@mezo-org/mezod-contracts": "^1.0.0",
|
|
42
42
|
"@mezo-org/musd-contracts": "^1.0.1",
|
|
43
|
-
"@mezo-org/orangekit": "1.0.0-beta.40-dev.
|
|
43
|
+
"@mezo-org/orangekit": "1.0.0-beta.40-dev.19",
|
|
44
44
|
"@mezo-org/sign-in-with-wallet": "1.0.0-beta.8",
|
|
45
45
|
"qrcode.react": "^4.2.0",
|
|
46
46
|
"styletron-engine-monolithic": "^1.0.0",
|
|
47
47
|
"usehooks-ts": "^3.1.1",
|
|
48
48
|
"motion": "^12.23.6",
|
|
49
|
-
"viem": "2.22.8",
|
|
50
|
-
"wagmi": "2.5.12",
|
|
51
49
|
"zustand": "^5.0.3"
|
|
52
50
|
},
|
|
53
51
|
"peerDependencies": {
|
|
54
52
|
"@rainbow-me/rainbowkit": "2.0.2",
|
|
55
53
|
"@tanstack/react-query": "^5.28.4",
|
|
56
|
-
"react": "^18.2.0"
|
|
54
|
+
"react": "^18.2.0",
|
|
55
|
+
"viem": "2.22.8",
|
|
56
|
+
"wagmi": "2.5.12"
|
|
57
57
|
}
|
|
58
|
-
}
|
|
58
|
+
}
|
package/src/api/index.ts
CHANGED
package/src/api/portal.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ApiClient } from "./client"
|
|
2
|
+
|
|
3
|
+
type MatsData = { mats: number; rank: number }
|
|
4
|
+
|
|
5
|
+
type RewardsMatsResponse = {
|
|
6
|
+
data: { mats: { seasonOne: MatsData; seasonTwo: MatsData } }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type RewardsMats = RewardsMatsResponse["data"]["mats"]
|
|
10
|
+
|
|
11
|
+
export const REWARDS_API_ENDPOINTS_BY_ENV = {
|
|
12
|
+
mainnet: "https://api.mezo.org/rewards/",
|
|
13
|
+
testnet: "https://api.test.mezo.org/rewards/",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class RewardsApiClient extends ApiClient {
|
|
17
|
+
constructor(
|
|
18
|
+
environment: keyof typeof REWARDS_API_ENDPOINTS_BY_ENV = "mainnet",
|
|
19
|
+
apiUrl?: string,
|
|
20
|
+
) {
|
|
21
|
+
super({
|
|
22
|
+
apiUrl: apiUrl ?? REWARDS_API_ENDPOINTS_BY_ENV[environment],
|
|
23
|
+
removeVersioning: true,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async getRewardsMats(address: string): Promise<RewardsMats> {
|
|
28
|
+
const {
|
|
29
|
+
data: { mats },
|
|
30
|
+
} = await this.handleRequest<RewardsMatsResponse>(
|
|
31
|
+
`/accounts/${address.toLowerCase()}`,
|
|
32
|
+
{
|
|
33
|
+
method: "GET",
|
|
34
|
+
},
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
return mats
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useContext } from "react"
|
|
2
|
+
import { useQuery, UseQueryOptions } from "@tanstack/react-query"
|
|
2
3
|
import { ONE_MINUTE_MS } from "../utils/time"
|
|
3
4
|
import { QUERY_KEYS } from "./constants"
|
|
4
5
|
import { useAuthApiClient } from "./useAuthApiClient"
|
|
5
6
|
import { usePortalApiClient } from "./usePortalApiClient"
|
|
6
|
-
import type { GetCurrentAccountResponse } from "../api"
|
|
7
|
+
import type { GetCurrentAccountResponse, PortalMats, RewardsMats } from "../api"
|
|
8
|
+
import { useRewardsApiClient } from "./useRewardsApiClient"
|
|
9
|
+
import { PassportContext } from "../provider"
|
|
7
10
|
|
|
8
11
|
type GetCurrentAccountResponseWithMats = GetCurrentAccountResponse & {
|
|
9
12
|
mats: {
|
|
@@ -11,14 +14,21 @@ type GetCurrentAccountResponseWithMats = GetCurrentAccountResponse & {
|
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
type UseGetCurrentAccountOptions<
|
|
18
|
+
TSelected = GetCurrentAccountResponseWithMats,
|
|
19
|
+
> = Omit<
|
|
20
|
+
UseQueryOptions<GetCurrentAccountResponseWithMats, Error, TSelected>,
|
|
21
|
+
"queryKey" | "queryFn"
|
|
22
|
+
>
|
|
23
|
+
|
|
14
24
|
export function useGetCurrentAccount(
|
|
15
|
-
queryOptions:
|
|
16
|
-
UseBaseQueryOptions<GetCurrentAccountResponseWithMats>,
|
|
17
|
-
"queryKey" | "queryFn"
|
|
18
|
-
> = {},
|
|
25
|
+
queryOptions: UseGetCurrentAccountOptions = {},
|
|
19
26
|
) {
|
|
27
|
+
const passportContext = useContext(PassportContext)
|
|
28
|
+
|
|
20
29
|
const authApiClient = useAuthApiClient()
|
|
21
30
|
const portalApiClient = usePortalApiClient()
|
|
31
|
+
const rewardsApiClient = useRewardsApiClient()
|
|
22
32
|
|
|
23
33
|
return useQuery({
|
|
24
34
|
queryKey: [QUERY_KEYS.ACCOUNT, QUERY_KEYS.CURRENT],
|
|
@@ -35,14 +45,26 @@ export function useGetCurrentAccount(
|
|
|
35
45
|
throw new Error("No linked wallets found for the current account")
|
|
36
46
|
}
|
|
37
47
|
|
|
38
|
-
const addresses = linkedWallets.map(
|
|
39
|
-
|
|
48
|
+
const addresses = linkedWallets.map((account) =>
|
|
49
|
+
passportContext?.useRewardsApi
|
|
50
|
+
? account.evmAddress
|
|
51
|
+
: account.btcAddress || account.evmAddress,
|
|
40
52
|
)
|
|
53
|
+
|
|
41
54
|
const mats = await Promise.all(
|
|
42
|
-
addresses.map((address) =>
|
|
55
|
+
addresses.map((address) =>
|
|
56
|
+
passportContext?.useRewardsApi
|
|
57
|
+
? rewardsApiClient.getRewardsMats(address)
|
|
58
|
+
: portalApiClient.getPortalMats(address),
|
|
59
|
+
),
|
|
43
60
|
)
|
|
61
|
+
|
|
44
62
|
const totalMats = mats.reduce(
|
|
45
|
-
(sumMats, currentMats) =>
|
|
63
|
+
(sumMats, currentMats) =>
|
|
64
|
+
sumMats +
|
|
65
|
+
(passportContext?.useRewardsApi
|
|
66
|
+
? (currentMats as RewardsMats).seasonTwo.mats
|
|
67
|
+
: (currentMats as PortalMats).totalMats),
|
|
46
68
|
0,
|
|
47
69
|
)
|
|
48
70
|
|
package/src/provider.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { createContext, createElement } from "react"
|
|
2
|
-
import { AuthApiClient, PortalApiClient } from "./api"
|
|
2
|
+
import { AuthApiClient, PortalApiClient, RewardsApiClient } from "./api"
|
|
3
3
|
import { ONE_SECOND_MS } from "./utils/time"
|
|
4
4
|
|
|
5
5
|
export interface PassportContextValue {
|
|
6
6
|
authApiClient: AuthApiClient
|
|
7
7
|
portalApiClient: PortalApiClient
|
|
8
|
+
rewardsApiClient: RewardsApiClient
|
|
8
9
|
environment?: Environment
|
|
9
10
|
accountDataRefetchInterval: number
|
|
10
11
|
nativeBalanceRefetchInterval: number
|
|
11
12
|
nativePriceRefetchInterval: number
|
|
12
13
|
borrowDataRefetchInterval: number
|
|
14
|
+
useRewardsApi: boolean
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export const PassportContext = createContext<PassportContextValue | undefined>(
|
|
@@ -23,6 +25,7 @@ type PassportProviderProps = {
|
|
|
23
25
|
environment?: Environment
|
|
24
26
|
authApiUrl?: string
|
|
25
27
|
portalApiUrl?: string
|
|
28
|
+
rewardsApiUrl?: string
|
|
26
29
|
/** Time in milliseconds after which account data (like mats or mezo id) in
|
|
27
30
|
* dropdown should be re-fetched. Default is 60000 (60 secs) */
|
|
28
31
|
accountDataRefetchInterval?: number
|
|
@@ -36,13 +39,18 @@ type PassportProviderProps = {
|
|
|
36
39
|
* re-fetched. Default is 60000 (60 secs)
|
|
37
40
|
* price. */
|
|
38
41
|
borrowDataRefetchInterval?: number
|
|
42
|
+
/** Determines whether passport should use Rewards API
|
|
43
|
+
* to consume data */
|
|
44
|
+
useRewardsApi?: boolean
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
export function PassportProvider({
|
|
42
48
|
environment,
|
|
43
49
|
authApiUrl,
|
|
44
50
|
portalApiUrl,
|
|
51
|
+
rewardsApiUrl,
|
|
45
52
|
children,
|
|
53
|
+
useRewardsApi,
|
|
46
54
|
accountDataRefetchInterval = 60 * ONE_SECOND_MS,
|
|
47
55
|
nativeBalanceRefetchInterval = 60 * ONE_SECOND_MS,
|
|
48
56
|
nativePriceRefetchInterval = 60 * ONE_SECOND_MS,
|
|
@@ -61,11 +69,16 @@ export function PassportProvider({
|
|
|
61
69
|
environment ?? "mainnet",
|
|
62
70
|
portalApiUrl,
|
|
63
71
|
),
|
|
72
|
+
rewardsApiClient: new RewardsApiClient(
|
|
73
|
+
environment ?? "mainnet",
|
|
74
|
+
rewardsApiUrl,
|
|
75
|
+
),
|
|
64
76
|
environment,
|
|
65
77
|
accountDataRefetchInterval,
|
|
66
78
|
nativeBalanceRefetchInterval,
|
|
67
79
|
nativePriceRefetchInterval,
|
|
68
80
|
borrowDataRefetchInterval,
|
|
81
|
+
useRewardsApi: useRewardsApi ?? false,
|
|
69
82
|
},
|
|
70
83
|
},
|
|
71
84
|
children,
|