@mezo-org/passport 0.10.0 → 0.12.0-dev.0
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/index.js +68 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.js +68 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/src/api/portal.d.ts +0 -6
- package/dist/src/api/portal.d.ts.map +1 -1
- package/dist/src/api/portal.js +0 -6
- package/dist/src/api/portal.js.map +1 -1
- package/dist/src/api/rewards.d.ts +1 -1
- package/dist/src/api/rewards.d.ts.map +1 -1
- package/dist/src/api/rewards.js.map +1 -1
- package/dist/src/components/Dropdown/AccountAddress.d.ts +8 -0
- package/dist/src/components/Dropdown/AccountAddress.d.ts.map +1 -0
- package/dist/src/components/Dropdown/AccountAddress.js +66 -0
- package/dist/src/components/Dropdown/AccountAddress.js.map +1 -0
- package/dist/src/components/Dropdown/AccountAssets.d.ts +13 -0
- package/dist/src/components/Dropdown/AccountAssets.d.ts.map +1 -0
- package/dist/src/components/Dropdown/AccountAssets.js +43 -0
- package/dist/src/components/Dropdown/AccountAssets.js.map +1 -0
- package/dist/src/components/Dropdown/AccountBalance.d.ts +7 -0
- package/dist/src/components/Dropdown/AccountBalance.d.ts.map +1 -0
- package/dist/src/components/Dropdown/AccountBalance.js +16 -0
- package/dist/src/components/Dropdown/AccountBalance.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts +11 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js +9 -0
- package/dist/src/components/Dropdown/Root/AccountAssetItem.js.map +1 -0
- package/dist/src/components/Dropdown/WelcomeBlock.d.ts +8 -0
- package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +1 -0
- package/dist/src/components/Dropdown/WelcomeBlock.js +43 -0
- package/dist/src/components/Dropdown/WelcomeBlock.js.map +1 -0
- package/dist/src/hooks/useAssetsUSDConversion.d.ts +8 -0
- package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +1 -0
- package/dist/src/hooks/useAssetsUSDConversion.js +21 -0
- package/dist/src/hooks/useAssetsUSDConversion.js.map +1 -0
- package/dist/src/hooks/useDropdownData.d.ts +47 -0
- package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
- package/dist/src/hooks/useDropdownData.js +97 -0
- package/dist/src/hooks/useDropdownData.js.map +1 -0
- package/dist/src/hooks/useGetCurrentAccount.d.ts +2 -4
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +25 -31
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/lib/contracts/priceOracle.d.ts +43 -0
- package/dist/src/lib/contracts/priceOracle.d.ts.map +1 -0
- package/dist/src/lib/contracts/priceOracle.js +52 -0
- package/dist/src/lib/contracts/priceOracle.js.map +1 -0
- package/dist/src/lib/contracts/troveManager.d.ts +1401 -0
- package/dist/src/lib/contracts/troveManager.d.ts.map +1 -0
- package/dist/src/lib/contracts/troveManager.js +1820 -0
- package/dist/src/lib/contracts/troveManager.js.map +1 -0
- package/dist/src/provider.d.ts +1 -5
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +1 -2
- package/dist/src/provider.js.map +1 -1
- package/dist/src/utils/cryptoAssets.d.ts +44 -0
- package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.js +129 -0
- package/dist/src/utils/cryptoAssets.js.map +1 -0
- package/dist/src/utils/cryptoAssets.test.d.ts +2 -0
- package/dist/src/utils/cryptoAssets.test.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.test.js +67 -0
- package/dist/src/utils/cryptoAssets.test.js.map +1 -0
- package/package.json +20 -22
- package/src/api/portal.ts +0 -17
- package/src/api/rewards.ts +4 -1
- package/src/hooks/useGetCurrentAccount.ts +31 -54
- package/src/provider.ts +0 -6
|
@@ -1,28 +1,13 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
1
|
import { useQuery, } from "@tanstack/react-query";
|
|
3
2
|
import { ONE_MINUTE_MS } from "../utils/time";
|
|
4
3
|
import { QUERY_KEYS } from "./constants";
|
|
5
4
|
import { useAuthApiClient } from "./useAuthApiClient";
|
|
6
|
-
import { usePortalApiClient } from "./usePortalApiClient";
|
|
7
5
|
import { useRewardsApiClient } from "./useRewardsApiClient";
|
|
8
|
-
import { PassportContext } from "../provider";
|
|
9
|
-
export const isRewardsMats = (value) => !!value &&
|
|
10
|
-
typeof value === "object" &&
|
|
11
|
-
["seasonOne", "seasonTwo"].every((seasonKey) => !!value[seasonKey] &&
|
|
12
|
-
typeof value[seasonKey] === "object" &&
|
|
13
|
-
["mats", "rank"].every((fieldKey) => typeof value[seasonKey][fieldKey] === "number"));
|
|
14
|
-
export const isPortalMats = (value) => !!value &&
|
|
15
|
-
typeof value === "object" &&
|
|
16
|
-
["totalMats", "inactiveMats", "matsActivated"].every((fieldKey) => fieldKey === "matsActivated"
|
|
17
|
-
? typeof value[fieldKey] === "boolean"
|
|
18
|
-
: typeof value[fieldKey] === "number");
|
|
19
6
|
/**
|
|
20
7
|
* Hook to fetch current account with mats
|
|
21
8
|
*/
|
|
22
9
|
export function useGetCurrentAccount(options = {}) {
|
|
23
|
-
const passportContext = useContext(PassportContext);
|
|
24
10
|
const authApiClient = useAuthApiClient();
|
|
25
|
-
const portalApiClient = usePortalApiClient();
|
|
26
11
|
const rewardsApiClient = useRewardsApiClient();
|
|
27
12
|
const queryKey = [QUERY_KEYS.ACCOUNT, QUERY_KEYS.CURRENT];
|
|
28
13
|
const query = useQuery({
|
|
@@ -36,22 +21,31 @@ export function useGetCurrentAccount(options = {}) {
|
|
|
36
21
|
if (!linkedWallets || linkedWallets.length === 0) {
|
|
37
22
|
throw new Error("No linked wallets found for the current account");
|
|
38
23
|
}
|
|
39
|
-
const addresses = linkedWallets.map((account) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
24
|
+
const addresses = linkedWallets.map((account) => account.evmAddress);
|
|
25
|
+
try {
|
|
26
|
+
/** Mats balances aggregated from all linked wallets */
|
|
27
|
+
const mats = await Promise.all(addresses.map((address) => rewardsApiClient.getRewardsMats(address)));
|
|
28
|
+
const totalMats = mats.reduce((sumMats, currentMats) => sumMats + currentMats.seasonTwo.mats, 0);
|
|
29
|
+
return {
|
|
30
|
+
...currentAccount,
|
|
31
|
+
mats,
|
|
32
|
+
totalMats,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// If account is not recognized by Rewards API, it will return 404.
|
|
37
|
+
// To prevent errors we return default values
|
|
38
|
+
return {
|
|
39
|
+
...currentAccount,
|
|
40
|
+
mats: [
|
|
41
|
+
{
|
|
42
|
+
seasonOne: { mats: 0, rank: null },
|
|
43
|
+
seasonTwo: { mats: 0, rank: null },
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
totalMats: 0,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
55
49
|
},
|
|
56
50
|
staleTime: options.staleTime ?? ONE_MINUTE_MS,
|
|
57
51
|
retry: options.retry ?? 1,
|
|
@@ -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,EAEL,QAAQ,GAGT,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,eAA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;gBAED,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAC3B,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,CAAC,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,EAC9D,CAAC,CACF,CAAA;gBAED,OAAO;oBACL,GAAG,cAAc;oBACjB,IAAI;oBACJ,SAAS;iBACV,CAAA;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,mEAAmE;gBACnE,6CAA6C;gBAC7C,OAAO;oBACL,GAAG,cAAc;oBACjB,IAAI,EAAE;wBACJ;4BACE,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE;4BAClC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE;yBACnC;qBACF;oBACD,SAAS,EAAE,CAAC;iBACb,CAAA;YACH,CAAC;QACH,CAAC;QACD,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,aAAa;QAC7C,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QACzB,GAAG,OAAO;KACX,CAAC,CAAA;IAEF,OAAO;QACL,GAAG,KAAK;QACR,QAAQ;KACT,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
address: Address;
|
|
4
|
+
abi: readonly [{
|
|
5
|
+
readonly inputs: readonly [];
|
|
6
|
+
readonly name: "decimals";
|
|
7
|
+
readonly outputs: readonly [{
|
|
8
|
+
readonly internalType: "uint8";
|
|
9
|
+
readonly name: "";
|
|
10
|
+
readonly type: "uint8";
|
|
11
|
+
}];
|
|
12
|
+
readonly stateMutability: "view";
|
|
13
|
+
readonly type: "function";
|
|
14
|
+
}, {
|
|
15
|
+
readonly inputs: readonly [];
|
|
16
|
+
readonly name: "latestRoundData";
|
|
17
|
+
readonly outputs: readonly [{
|
|
18
|
+
readonly internalType: "uint80";
|
|
19
|
+
readonly name: "roundId";
|
|
20
|
+
readonly type: "uint80";
|
|
21
|
+
}, {
|
|
22
|
+
readonly internalType: "int256";
|
|
23
|
+
readonly name: "answer";
|
|
24
|
+
readonly type: "int256";
|
|
25
|
+
}, {
|
|
26
|
+
readonly internalType: "uint256";
|
|
27
|
+
readonly name: "startedAt";
|
|
28
|
+
readonly type: "uint256";
|
|
29
|
+
}, {
|
|
30
|
+
readonly internalType: "uint256";
|
|
31
|
+
readonly name: "updatedAt";
|
|
32
|
+
readonly type: "uint256";
|
|
33
|
+
}, {
|
|
34
|
+
readonly internalType: "uint80";
|
|
35
|
+
readonly name: "answeredInRound";
|
|
36
|
+
readonly type: "uint80";
|
|
37
|
+
}];
|
|
38
|
+
readonly stateMutability: "view";
|
|
39
|
+
readonly type: "function";
|
|
40
|
+
}];
|
|
41
|
+
};
|
|
42
|
+
export default _default;
|
|
43
|
+
//# sourceMappingURL=priceOracle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priceOracle.d.ts","sourceRoot":"","sources":["../../../../src/lib/contracts/priceOracle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;;aAG6B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AADlE,wBAkDC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
address: "0x7b7c000000000000000000000000000000000015",
|
|
3
|
+
abi: [
|
|
4
|
+
{
|
|
5
|
+
inputs: [],
|
|
6
|
+
name: "decimals",
|
|
7
|
+
outputs: [
|
|
8
|
+
{
|
|
9
|
+
internalType: "uint8",
|
|
10
|
+
name: "",
|
|
11
|
+
type: "uint8",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
stateMutability: "view",
|
|
15
|
+
type: "function",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
inputs: [],
|
|
19
|
+
name: "latestRoundData",
|
|
20
|
+
outputs: [
|
|
21
|
+
{
|
|
22
|
+
internalType: "uint80",
|
|
23
|
+
name: "roundId",
|
|
24
|
+
type: "uint80",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
internalType: "int256",
|
|
28
|
+
name: "answer",
|
|
29
|
+
type: "int256",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
internalType: "uint256",
|
|
33
|
+
name: "startedAt",
|
|
34
|
+
type: "uint256",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
internalType: "uint256",
|
|
38
|
+
name: "updatedAt",
|
|
39
|
+
type: "uint256",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
internalType: "uint80",
|
|
43
|
+
name: "answeredInRound",
|
|
44
|
+
type: "uint80",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
stateMutability: "view",
|
|
48
|
+
type: "function",
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=priceOracle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priceOracle.js","sourceRoot":"","sources":["../../../../src/lib/contracts/priceOracle.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,OAAO,EAAE,4CAAuD;IAChE,GAAG,EAAE;QACH;YACE,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE;gBACP;oBACE,YAAY,EAAE,OAAO;oBACrB,IAAI,EAAE,EAAE;oBACR,IAAI,EAAE,OAAO;iBACd;aACF;YACD,eAAe,EAAE,MAAM;YACvB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,iBAAiB;YACvB,OAAO,EAAE;gBACP;oBACE,YAAY,EAAE,QAAQ;oBACtB,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,QAAQ;iBACf;gBACD;oBACE,YAAY,EAAE,QAAQ;oBACtB,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,QAAQ;iBACf;gBACD;oBACE,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,SAAS;iBAChB;gBACD;oBACE,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,SAAS;iBAChB;gBACD;oBACE,YAAY,EAAE,QAAQ;oBACtB,IAAI,EAAE,iBAAiB;oBACvB,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,eAAe,EAAE,MAAM;YACvB,IAAI,EAAE,UAAU;SACjB;KACO;CACX,CAAA"}
|