@mezo-org/passport 0.4.0-dev.5 → 0.4.0-dev.7
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/auth.d.ts +36 -59
- package/dist/src/api/auth.d.ts.map +1 -1
- package/dist/src/api/auth.js +21 -49
- package/dist/src/api/auth.js.map +1 -1
- package/dist/src/api/client.d.ts +24 -0
- package/dist/src/api/client.d.ts.map +1 -0
- package/dist/src/api/client.js +54 -0
- package/dist/src/api/client.js.map +1 -0
- package/dist/src/api/fetch-error.d.ts +5 -0
- package/dist/src/api/fetch-error.d.ts.map +1 -0
- package/dist/src/api/fetch-error.js +8 -0
- package/dist/src/api/fetch-error.js.map +1 -0
- package/dist/src/api/index.d.ts +3 -0
- package/dist/src/api/index.d.ts.map +1 -0
- package/dist/src/api/index.js +3 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/api/portal.d.ts +32 -0
- package/dist/src/api/portal.d.ts.map +1 -0
- package/dist/src/api/portal.js +23 -0
- package/dist/src/api/portal.js.map +1 -0
- package/dist/src/assets/DefaultAvatar.d.ts +5 -0
- package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
- package/dist/src/assets/DefaultAvatar.js +21 -0
- package/dist/src/assets/DefaultAvatar.js.map +1 -0
- 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 +58 -0
- package/dist/src/components/Dropdown/AccountAddress.js.map +1 -0
- package/dist/src/components/Dropdown/AccountAssets.d.ts +14 -0
- package/dist/src/components/Dropdown/AccountAssets.d.ts.map +1 -0
- package/dist/src/components/Dropdown/AccountAssets.js +44 -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 +18 -0
- package/dist/src/components/Dropdown/AccountBalance.js.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +7 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js +30 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Content.d.ts +9 -0
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Content.js +69 -0
- package/dist/src/components/Dropdown/Content.js.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts +20 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.js +45 -0
- package/dist/src/components/Dropdown/Dropdown.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 +44 -0
- package/dist/src/components/Dropdown/WelcomeBlock.js.map +1 -0
- package/dist/src/components/Dropdown/index.d.ts +3 -0
- package/dist/src/components/Dropdown/index.d.ts.map +1 -0
- package/dist/src/components/Dropdown/index.js +2 -0
- package/dist/src/components/Dropdown/index.js.map +1 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +2 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/hooks/constants.d.ts +1 -0
- package/dist/src/hooks/constants.d.ts.map +1 -1
- package/dist/src/hooks/constants.js +1 -0
- package/dist/src/hooks/constants.js.map +1 -1
- package/dist/src/hooks/index.d.ts +0 -1
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +0 -1
- package/dist/src/hooks/index.js.map +1 -1
- 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/useAuthApiClient.d.ts +1 -1
- package/dist/src/hooks/useAuthApiClient.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +12 -102
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js +23 -11
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
- package/dist/src/hooks/useCreateAccount.d.ts +23 -173
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +7 -4
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useCreateSession.d.ts +12 -101
- package/dist/src/hooks/useCreateSession.d.ts.map +1 -1
- package/dist/src/hooks/useCreateSession.js +10 -8
- package/dist/src/hooks/useCreateSession.js.map +1 -1
- package/dist/src/hooks/useDropdownData.d.ts +44 -0
- package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
- package/dist/src/hooks/useDropdownData.js +73 -0
- package/dist/src/hooks/useDropdownData.js.map +1 -0
- package/dist/src/hooks/useGetAccountByAddress.d.ts +2 -2
- package/dist/src/hooks/useGetAccountByAddress.d.ts.map +1 -1
- package/dist/src/hooks/useGetAccountByMezoId.d.ts +2 -2
- package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts +16 -2
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +25 -3
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useGetSession.d.ts +1 -1
- package/dist/src/hooks/useGetSession.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts +15 -175
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +7 -4
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/usePortalApiClient.d.ts +2 -0
- package/dist/src/hooks/usePortalApiClient.d.ts.map +1 -0
- package/dist/src/hooks/usePortalApiClient.js +6 -0
- package/dist/src/hooks/usePortalApiClient.js.map +1 -0
- package/dist/src/hooks/useSignInWithDiscord.d.ts +12 -100
- package/dist/src/hooks/useSignInWithDiscord.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithDiscord.js +6 -3
- package/dist/src/hooks/useSignInWithDiscord.js.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.d.ts +12 -100
- package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.js +2 -2
- package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
- package/dist/src/hooks/useSignOut.d.ts +12 -28
- package/dist/src/hooks/useSignOut.d.ts.map +1 -1
- package/dist/src/hooks/useSignOut.js +7 -4
- package/dist/src/hooks/useSignOut.js.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.d.ts +12 -100
- package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.js +2 -2
- package/dist/src/hooks/useSignUpWithWallet.js.map +1 -1
- package/dist/src/hooks/useUpdateMezoId.d.ts +30 -136
- package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useUpdateMezoId.js +7 -4
- package/dist/src/hooks/useUpdateMezoId.js.map +1 -1
- package/dist/src/hooks/useWalletAccount.d.ts +12 -0
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -0
- package/dist/src/hooks/useWalletAccount.js +25 -0
- package/dist/src/hooks/useWalletAccount.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/provider.d.ts +10 -13
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +11 -20
- package/dist/src/provider.js.map +1 -1
- package/dist/src/utils/address.d.ts +15 -0
- package/dist/src/utils/address.d.ts.map +1 -0
- package/dist/src/utils/address.js +35 -0
- package/dist/src/utils/address.js.map +1 -0
- package/dist/src/utils/address.test.d.ts +2 -0
- package/dist/src/utils/address.test.d.ts.map +1 -0
- package/dist/src/utils/address.test.js +37 -0
- package/dist/src/utils/address.test.js.map +1 -0
- package/dist/src/utils/cryptoAssets.d.ts +28 -0
- package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.js +73 -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 +49 -0
- package/dist/src/utils/cryptoAssets.test.js.map +1 -0
- package/dist/src/utils/currency.d.ts +14 -0
- package/dist/src/utils/currency.d.ts.map +1 -0
- package/dist/src/utils/currency.js +27 -0
- package/dist/src/utils/currency.js.map +1 -0
- package/dist/src/utils/currency.test.d.ts +2 -0
- package/dist/src/utils/currency.test.d.ts.map +1 -0
- package/dist/src/utils/currency.test.js +34 -0
- package/dist/src/utils/currency.test.js.map +1 -0
- package/dist/src/utils/numbers.d.ts +43 -0
- package/dist/src/utils/numbers.d.ts.map +1 -0
- package/dist/src/utils/numbers.js +81 -0
- package/dist/src/utils/numbers.js.map +1 -0
- package/dist/src/utils/numbers.test.d.ts +2 -0
- package/dist/src/utils/numbers.test.d.ts.map +1 -0
- package/dist/src/utils/numbers.test.js +68 -0
- package/dist/src/utils/numbers.test.js.map +1 -0
- package/package.json +8 -2
- package/src/api/auth.ts +72 -129
- package/src/api/client.ts +78 -0
- package/src/api/fetch-error.ts +8 -0
- package/src/api/index.ts +2 -0
- package/src/api/portal.ts +56 -0
- package/src/assets/DefaultAvatar.tsx +74 -0
- package/src/components/Dropdown/AccountAddress.tsx +111 -0
- package/src/components/Dropdown/AccountAssets.tsx +110 -0
- package/src/components/Dropdown/AccountBalance.tsx +38 -0
- package/src/components/Dropdown/ConnectedTrigger.tsx +56 -0
- package/src/components/Dropdown/Content.tsx +148 -0
- package/src/components/Dropdown/DisconnectedTrigger.tsx +35 -0
- package/src/components/Dropdown/Dropdown.tsx +88 -0
- package/src/components/Dropdown/README.md +49 -0
- package/src/components/Dropdown/WelcomeBlock.tsx +92 -0
- package/src/components/Dropdown/index.ts +2 -0
- package/src/components/index.ts +1 -0
- package/src/hooks/constants.ts +1 -0
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useAssetsUSDConversion.ts +31 -0
- package/src/hooks/useAuthenticateWithWallet.ts +38 -14
- package/src/hooks/useCreateAccount.ts +19 -5
- package/src/hooks/useCreateSession.ts +22 -9
- package/src/hooks/useDropdownData.ts +130 -0
- package/src/hooks/useGetAccountByAddress.ts +2 -2
- package/src/hooks/useGetAccountByMezoId.ts +2 -2
- package/src/hooks/useGetCurrentAccount.ts +46 -6
- package/src/hooks/useGetSession.ts +1 -1
- package/src/hooks/useLinkAccount.ts +18 -5
- package/src/hooks/usePortalApiClient.ts +6 -0
- package/src/hooks/useSignInWithDiscord.ts +14 -5
- package/src/hooks/useSignInWithWallet.ts +9 -2
- package/src/hooks/useSignOut.ts +18 -4
- package/src/hooks/useSignUpWithWallet.ts +9 -2
- package/src/hooks/useUpdateMezoId.ts +19 -4
- package/src/hooks/useWalletAccount.ts +41 -0
- package/src/index.ts +1 -0
- package/src/provider.ts +30 -37
- package/src/utils/address.test.ts +44 -0
- package/src/utils/address.ts +43 -0
- package/src/utils/cryptoAssets.test.ts +59 -0
- package/src/utils/cryptoAssets.ts +93 -0
- package/src/utils/currency.test.ts +38 -0
- package/src/utils/currency.ts +32 -0
- package/src/utils/numbers.test.ts +89 -0
- package/src/utils/numbers.ts +110 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { MutationOptions, DefaultError } from "@tanstack/react-query";
|
|
2
|
+
import type { UpdateMezoIdResponse } from "../api";
|
|
3
|
+
export declare function useUpdateMezoId(mutationOptions?: Omit<MutationOptions<UpdateMezoIdResponse, DefaultError, string>, "mutationFn" | "mutationKey">): {
|
|
2
4
|
data: undefined;
|
|
3
5
|
variables: undefined;
|
|
4
6
|
error: null;
|
|
@@ -13,40 +15,16 @@ export declare function useUpdateMezoId(useMutationOptions?: {}): {
|
|
|
13
15
|
failureReason: Error | null;
|
|
14
16
|
isPaused: boolean;
|
|
15
17
|
submittedAt: number;
|
|
16
|
-
updateMezoId: import("@tanstack/react-query").UseMutateFunction<
|
|
18
|
+
updateMezoId: import("@tanstack/react-query").UseMutateFunction<{
|
|
17
19
|
mezoId: string;
|
|
18
20
|
hasModifiedMezoId: boolean;
|
|
19
|
-
linkedAccounts: import("../api
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
app_metadata: {
|
|
23
|
-
provider: "wallet" | "discord" | "email";
|
|
24
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
25
|
-
};
|
|
26
|
-
user_metadata: {
|
|
27
|
-
mezoId?: string | undefined;
|
|
28
|
-
btcAddress: string;
|
|
29
|
-
evmAddress: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
}> | null, Error, string, unknown>;
|
|
33
|
-
updateMezoIdAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Partial<{
|
|
21
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
22
|
+
}, Error, string, unknown>;
|
|
23
|
+
updateMezoIdAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
34
24
|
mezoId: string;
|
|
35
25
|
hasModifiedMezoId: boolean;
|
|
36
|
-
linkedAccounts: import("../api
|
|
37
|
-
|
|
38
|
-
id: string;
|
|
39
|
-
app_metadata: {
|
|
40
|
-
provider: "wallet" | "discord" | "email";
|
|
41
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
42
|
-
};
|
|
43
|
-
user_metadata: {
|
|
44
|
-
mezoId?: string | undefined;
|
|
45
|
-
btcAddress: string;
|
|
46
|
-
evmAddress: string;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
}> | null, Error, string, unknown>;
|
|
26
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
27
|
+
}, Error, string, unknown>;
|
|
50
28
|
} | {
|
|
51
29
|
data: undefined;
|
|
52
30
|
variables: string;
|
|
@@ -62,40 +40,16 @@ export declare function useUpdateMezoId(useMutationOptions?: {}): {
|
|
|
62
40
|
failureReason: Error | null;
|
|
63
41
|
isPaused: boolean;
|
|
64
42
|
submittedAt: number;
|
|
65
|
-
updateMezoId: import("@tanstack/react-query").UseMutateFunction<
|
|
43
|
+
updateMezoId: import("@tanstack/react-query").UseMutateFunction<{
|
|
66
44
|
mezoId: string;
|
|
67
45
|
hasModifiedMezoId: boolean;
|
|
68
|
-
linkedAccounts: import("../api
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
app_metadata: {
|
|
72
|
-
provider: "wallet" | "discord" | "email";
|
|
73
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
74
|
-
};
|
|
75
|
-
user_metadata: {
|
|
76
|
-
mezoId?: string | undefined;
|
|
77
|
-
btcAddress: string;
|
|
78
|
-
evmAddress: string;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
}> | null, Error, string, unknown>;
|
|
82
|
-
updateMezoIdAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Partial<{
|
|
46
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
47
|
+
}, Error, string, unknown>;
|
|
48
|
+
updateMezoIdAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
83
49
|
mezoId: string;
|
|
84
50
|
hasModifiedMezoId: boolean;
|
|
85
|
-
linkedAccounts: import("../api
|
|
86
|
-
|
|
87
|
-
id: string;
|
|
88
|
-
app_metadata: {
|
|
89
|
-
provider: "wallet" | "discord" | "email";
|
|
90
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
91
|
-
};
|
|
92
|
-
user_metadata: {
|
|
93
|
-
mezoId?: string | undefined;
|
|
94
|
-
btcAddress: string;
|
|
95
|
-
evmAddress: string;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
}> | null, Error, string, unknown>;
|
|
51
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
52
|
+
}, Error, string, unknown>;
|
|
99
53
|
} | {
|
|
100
54
|
data: undefined;
|
|
101
55
|
error: Error;
|
|
@@ -111,58 +65,22 @@ export declare function useUpdateMezoId(useMutationOptions?: {}): {
|
|
|
111
65
|
failureReason: Error | null;
|
|
112
66
|
isPaused: boolean;
|
|
113
67
|
submittedAt: number;
|
|
114
|
-
updateMezoId: import("@tanstack/react-query").UseMutateFunction<
|
|
68
|
+
updateMezoId: import("@tanstack/react-query").UseMutateFunction<{
|
|
115
69
|
mezoId: string;
|
|
116
70
|
hasModifiedMezoId: boolean;
|
|
117
|
-
linkedAccounts: import("../api
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
app_metadata: {
|
|
121
|
-
provider: "wallet" | "discord" | "email";
|
|
122
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
123
|
-
};
|
|
124
|
-
user_metadata: {
|
|
125
|
-
mezoId?: string | undefined;
|
|
126
|
-
btcAddress: string;
|
|
127
|
-
evmAddress: string;
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
}> | null, Error, string, unknown>;
|
|
131
|
-
updateMezoIdAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Partial<{
|
|
71
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
72
|
+
}, Error, string, unknown>;
|
|
73
|
+
updateMezoIdAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
132
74
|
mezoId: string;
|
|
133
75
|
hasModifiedMezoId: boolean;
|
|
134
|
-
linkedAccounts: import("../api
|
|
135
|
-
|
|
136
|
-
id: string;
|
|
137
|
-
app_metadata: {
|
|
138
|
-
provider: "wallet" | "discord" | "email";
|
|
139
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
140
|
-
};
|
|
141
|
-
user_metadata: {
|
|
142
|
-
mezoId?: string | undefined;
|
|
143
|
-
btcAddress: string;
|
|
144
|
-
evmAddress: string;
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
}> | null, Error, string, unknown>;
|
|
76
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
77
|
+
}, Error, string, unknown>;
|
|
148
78
|
} | {
|
|
149
|
-
data:
|
|
79
|
+
data: {
|
|
150
80
|
mezoId: string;
|
|
151
81
|
hasModifiedMezoId: boolean;
|
|
152
|
-
linkedAccounts: import("../api
|
|
153
|
-
|
|
154
|
-
id: string;
|
|
155
|
-
app_metadata: {
|
|
156
|
-
provider: "wallet" | "discord" | "email";
|
|
157
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
158
|
-
};
|
|
159
|
-
user_metadata: {
|
|
160
|
-
mezoId?: string | undefined;
|
|
161
|
-
btcAddress: string;
|
|
162
|
-
evmAddress: string;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
}> | null;
|
|
82
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
83
|
+
};
|
|
166
84
|
error: null;
|
|
167
85
|
variables: string;
|
|
168
86
|
isError: false;
|
|
@@ -176,39 +94,15 @@ export declare function useUpdateMezoId(useMutationOptions?: {}): {
|
|
|
176
94
|
failureReason: Error | null;
|
|
177
95
|
isPaused: boolean;
|
|
178
96
|
submittedAt: number;
|
|
179
|
-
updateMezoId: import("@tanstack/react-query").UseMutateFunction<
|
|
97
|
+
updateMezoId: import("@tanstack/react-query").UseMutateFunction<{
|
|
180
98
|
mezoId: string;
|
|
181
99
|
hasModifiedMezoId: boolean;
|
|
182
|
-
linkedAccounts: import("../api
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
app_metadata: {
|
|
186
|
-
provider: "wallet" | "discord" | "email";
|
|
187
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
188
|
-
};
|
|
189
|
-
user_metadata: {
|
|
190
|
-
mezoId?: string | undefined;
|
|
191
|
-
btcAddress: string;
|
|
192
|
-
evmAddress: string;
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
}> | null, Error, string, unknown>;
|
|
196
|
-
updateMezoIdAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Partial<{
|
|
100
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
101
|
+
}, Error, string, unknown>;
|
|
102
|
+
updateMezoIdAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
197
103
|
mezoId: string;
|
|
198
104
|
hasModifiedMezoId: boolean;
|
|
199
|
-
linkedAccounts: import("../api
|
|
200
|
-
|
|
201
|
-
id: string;
|
|
202
|
-
app_metadata: {
|
|
203
|
-
provider: "wallet" | "discord" | "email";
|
|
204
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
205
|
-
};
|
|
206
|
-
user_metadata: {
|
|
207
|
-
mezoId?: string | undefined;
|
|
208
|
-
btcAddress: string;
|
|
209
|
-
evmAddress: string;
|
|
210
|
-
};
|
|
211
|
-
};
|
|
212
|
-
}> | null, Error, string, unknown>;
|
|
105
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
106
|
+
}, Error, string, unknown>;
|
|
213
107
|
};
|
|
214
108
|
//# sourceMappingURL=useUpdateMezoId.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUpdateMezoId.d.ts","sourceRoot":"","sources":["../../../src/hooks/useUpdateMezoId.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUpdateMezoId.d.ts","sourceRoot":"","sources":["../../../src/hooks/useUpdateMezoId.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,YAAY,EACb,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAElD,wBAAgB,eAAe,CAC7B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,oBAAoB,EAAE,YAAY,EAAE,MAAM,CAAC,EAC3D,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBP"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { useQueryClient, useMutation } from "@tanstack/react-query";
|
|
1
|
+
import { useQueryClient, useMutation, } from "@tanstack/react-query";
|
|
2
2
|
import { useAuthApiClient } from "./useAuthApiClient";
|
|
3
3
|
import { QUERY_KEYS } from "./constants";
|
|
4
|
-
export function useUpdateMezoId(
|
|
4
|
+
export function useUpdateMezoId(mutationOptions = {}) {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
6
|
const authApiClient = useAuthApiClient();
|
|
7
|
+
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
|
|
7
8
|
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
8
9
|
mutationFn: (newMezoId) => authApiClient.updateMezoId(newMezoId),
|
|
9
|
-
onSuccess: () => {
|
|
10
|
+
onSuccess: (data, variables, context) => {
|
|
10
11
|
queryClient.resetQueries({ queryKey: [QUERY_KEYS.ACCOUNT] });
|
|
12
|
+
if (customOnSuccess)
|
|
13
|
+
customOnSuccess(data, variables, context);
|
|
11
14
|
},
|
|
12
|
-
...
|
|
15
|
+
...restMutationOptions,
|
|
13
16
|
});
|
|
14
17
|
return { updateMezoId: mutate, updateMezoIdAsync: mutateAsync, ...rest };
|
|
15
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUpdateMezoId.js","sourceRoot":"","sources":["../../../src/hooks/useUpdateMezoId.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useUpdateMezoId.js","sourceRoot":"","sources":["../../../src/hooks/useUpdateMezoId.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,MAAM,UAAU,eAAe,CAC7B,kBAGI,EAAE;IAEN,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IAExC,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,mBAAmB,EAAE,GAAG,eAAe,CAAA;IAE9E,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,CAAC;QACnD,UAAU,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC,SAAS,CAAC;QACxE,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;YACtC,WAAW,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAE5D,IAAI,eAAe;gBAAE,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;QACD,GAAG,mBAAmB;KACvB,CAAC,CAAA;IAEF,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAA;AAC1E,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
import { Connector } from "wagmi";
|
|
3
|
+
type UseWalletAccountReturn = {
|
|
4
|
+
address?: string | Address;
|
|
5
|
+
isConnected: boolean;
|
|
6
|
+
networkFamily: "bitcoin" | "evm";
|
|
7
|
+
connector?: Connector;
|
|
8
|
+
chainId?: number;
|
|
9
|
+
};
|
|
10
|
+
export default function useWalletAccount(): UseWalletAccountReturn;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=useWalletAccount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWalletAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useWalletAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAc,MAAM,OAAO,CAAA;AAE7C,KAAK,sBAAsB,GAAG;IAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC1B,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,SAAS,GAAG,KAAK,CAAA;IAChC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,IAAI,sBAAsB,CA2BjE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useBitcoinAccount } from "@mezo-org/orangekit";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { useAccount } from "wagmi";
|
|
4
|
+
export default function useWalletAccount() {
|
|
5
|
+
const { address: evmAddress, connector, chainId } = useAccount();
|
|
6
|
+
const { btcAddress } = useBitcoinAccount();
|
|
7
|
+
const [isConnected, setIsConnected] = useState(false);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!connector) {
|
|
10
|
+
setIsConnected(false);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const isBitcoinFlow = connector.type === "orangekit";
|
|
14
|
+
setIsConnected(isBitcoinFlow ? !!btcAddress : !!evmAddress);
|
|
15
|
+
}, [btcAddress, connector, evmAddress]);
|
|
16
|
+
const networkFamily = useMemo(() => (btcAddress ? "bitcoin" : "evm"), [btcAddress]);
|
|
17
|
+
return {
|
|
18
|
+
address: btcAddress || evmAddress,
|
|
19
|
+
isConnected,
|
|
20
|
+
networkFamily,
|
|
21
|
+
connector,
|
|
22
|
+
chainId,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=useWalletAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWalletAccount.js","sourceRoot":"","sources":["../../../src/hooks/useWalletAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEpD,OAAO,EAAa,UAAU,EAAE,MAAM,OAAO,CAAA;AAU7C,MAAM,CAAC,OAAO,UAAU,gBAAgB;IACtC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAAA;IAChE,MAAM,EAAE,UAAU,EAAE,GAAG,iBAAiB,EAAE,CAAA;IAC1C,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAErD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,cAAc,CAAC,KAAK,CAAC,CAAA;YACrB,OAAM;QACR,CAAC;QAED,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,KAAK,WAAW,CAAA;QACpD,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;IAC7D,CAAC,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,CAAA;IAEvC,MAAM,aAAa,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EACtC,CAAC,UAAU,CAAC,CACb,CAAA;IAED,OAAO;QACL,OAAO,EAAE,UAAU,IAAI,UAAU;QACjC,WAAW;QACX,aAAa;QACb,SAAS;QACT,OAAO;KACC,CAAA;AACZ,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
|
package/dist/src/index.js
CHANGED
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
|
package/dist/src/provider.d.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import { API_ENDPOINTS_BY_ENV, AuthApiClient } from "./api/auth";
|
|
1
|
+
import { AuthApiClient, PortalApiClient } from "./api";
|
|
3
2
|
export interface PassportContextValue {
|
|
4
3
|
authApiClient: AuthApiClient;
|
|
4
|
+
portalApiClient: PortalApiClient;
|
|
5
|
+
environment?: Environment;
|
|
5
6
|
}
|
|
6
7
|
export declare const PassportContext: import("react").Context<PassportContextValue | undefined>;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
environment?: keyof typeof API_ENDPOINTS_BY_ENV;
|
|
10
|
-
apiUrl?: string;
|
|
11
|
-
} & ({
|
|
12
|
-
environment: keyof typeof API_ENDPOINTS_BY_ENV;
|
|
13
|
-
} | {
|
|
14
|
-
apiUrl: string;
|
|
15
|
-
});
|
|
8
|
+
type Environment = "mainnet" | "testnet";
|
|
9
|
+
type PassportProviderProps = {
|
|
16
10
|
children: React.ReactNode;
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
environment?: Environment;
|
|
12
|
+
authApiUrl?: string;
|
|
13
|
+
portalApiUrl?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function PassportProvider({ environment, authApiUrl, portalApiUrl, children, }: PassportProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<PassportContextValue | undefined>>;
|
|
19
16
|
export {};
|
|
20
17
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAEtD,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,aAAa,CAAA;IAC5B,eAAe,EAAE,eAAe,CAAA;IAChC,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B;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;IAEzB,WAAW,CAAC,EAAE,WAAW,CAAA;IAEzB,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,WAAW,EACX,UAAU,EACV,YAAY,EACZ,QAAQ,GACT,EAAE,qBAAqB,6GAmBvB"}
|
package/dist/src/provider.js
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
import { createContext, createElement
|
|
2
|
-
import {
|
|
1
|
+
import { createContext, createElement } from "react";
|
|
2
|
+
import { AuthApiClient, PortalApiClient } from "./api";
|
|
3
3
|
export const PassportContext = createContext(undefined);
|
|
4
|
-
export function PassportProvider({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
throw new Error("Neither apiUrl or environment are specified in Passport Provider");
|
|
9
|
-
}
|
|
10
|
-
if (apiUrl)
|
|
11
|
-
return apiUrl;
|
|
12
|
-
if (!(environment in API_ENDPOINTS_BY_ENV)) {
|
|
13
|
-
throw new Error("Wrong environment passed to PassportProvider.");
|
|
14
|
-
}
|
|
15
|
-
return API_ENDPOINTS_BY_ENV[environment];
|
|
16
|
-
}, [environment, apiUrl]);
|
|
4
|
+
export function PassportProvider({ environment, authApiUrl, portalApiUrl, children, }) {
|
|
5
|
+
if (environment !== "mainnet" && environment !== "testnet") {
|
|
6
|
+
throw new Error("Wrong environment passed to PassportProvider.");
|
|
7
|
+
}
|
|
17
8
|
return createElement(PassportContext.Provider, {
|
|
18
|
-
value:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
value: {
|
|
10
|
+
authApiClient: new AuthApiClient(environment ?? "mainnet", authApiUrl),
|
|
11
|
+
portalApiClient: new PortalApiClient(environment ?? "mainnet", portalApiUrl),
|
|
12
|
+
environment,
|
|
13
|
+
},
|
|
23
14
|
}, children);
|
|
24
15
|
}
|
|
25
16
|
//# sourceMappingURL=provider.js.map
|
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,
|
|
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;AAQtD,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAC1C,SAAS,CACV,CAAA;AAcD,MAAM,UAAU,gBAAgB,CAAC,EAC/B,WAAW,EACX,UAAU,EACV,YAAY,EACZ,QAAQ,GACc;IACtB,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC3D,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,WAAW;SACZ;KACF,EACD,QAAQ,CACT,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trims the address to the first 5 and last 5 characters.
|
|
3
|
+
* @param address The address to trim.
|
|
4
|
+
* @returns The trimmed address.
|
|
5
|
+
*/
|
|
6
|
+
export declare function trimAddress(address: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Get the URL of the block explorer page for an address.
|
|
9
|
+
* @param address - The address to link to.
|
|
10
|
+
* @param chainType - The chain type of the address.
|
|
11
|
+
* @param isTestnet - Whether the address is on testnet.
|
|
12
|
+
* @returns The URL of the block explorer page for the address.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getAddressExplorerUrl(address: string, chainType: "bitcoin" | "evm", isTestnet: boolean): string;
|
|
15
|
+
//# sourceMappingURL=address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/utils/address.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMnD;AAYD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,SAAS,GAAG,KAAK,EAC5B,SAAS,EAAE,OAAO,UASnB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trims the address to the first 5 and last 5 characters.
|
|
3
|
+
* @param address The address to trim.
|
|
4
|
+
* @returns The trimmed address.
|
|
5
|
+
*/
|
|
6
|
+
export function trimAddress(address) {
|
|
7
|
+
if (address.length < 11)
|
|
8
|
+
return address;
|
|
9
|
+
const trimmedAddress = `${address.slice(0, 5)}...${address.slice(-5)}`;
|
|
10
|
+
return trimmedAddress;
|
|
11
|
+
}
|
|
12
|
+
const MAINNET_EXPLORER_URLS = {
|
|
13
|
+
bitcoin: "https://mempool.space",
|
|
14
|
+
evm: "https://etherscan.io",
|
|
15
|
+
};
|
|
16
|
+
const TESTNET_EXPLORER_URLS = {
|
|
17
|
+
bitcoin: "https://mempool.space/testnet",
|
|
18
|
+
evm: "https://sepolia.etherscan.io",
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Get the URL of the block explorer page for an address.
|
|
22
|
+
* @param address - The address to link to.
|
|
23
|
+
* @param chainType - The chain type of the address.
|
|
24
|
+
* @param isTestnet - Whether the address is on testnet.
|
|
25
|
+
* @returns The URL of the block explorer page for the address.
|
|
26
|
+
*/
|
|
27
|
+
export function getAddressExplorerUrl(address, chainType, isTestnet) {
|
|
28
|
+
const EXPLORER_URLS = isTestnet
|
|
29
|
+
? TESTNET_EXPLORER_URLS
|
|
30
|
+
: MAINNET_EXPLORER_URLS;
|
|
31
|
+
const baseUrl = EXPLORER_URLS[chainType];
|
|
32
|
+
const endpoint = `address/${address}`;
|
|
33
|
+
return `${baseUrl}/${endpoint}`;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../../src/utils/address.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE;QAAE,OAAO,OAAO,CAAA;IAEvC,MAAM,cAAc,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAEtE,OAAO,cAAc,CAAA;AACvB,CAAC;AAED,MAAM,qBAAqB,GAAsC;IAC/D,OAAO,EAAE,uBAAuB;IAChC,GAAG,EAAE,sBAAsB;CAC5B,CAAA;AAED,MAAM,qBAAqB,GAAsC;IAC/D,OAAO,EAAE,+BAA+B;IACxC,GAAG,EAAE,8BAA8B;CACpC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAe,EACf,SAA4B,EAC5B,SAAkB;IAElB,MAAM,aAAa,GAAG,SAAS;QAC7B,CAAC,CAAC,qBAAqB;QACvB,CAAC,CAAC,qBAAqB,CAAA;IACzB,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAA;IACxC,MAAM,QAAQ,GAAG,WAAW,OAAO,EAAE,CAAA;IAErC,OAAO,GAAG,OAAO,IAAI,QAAQ,EAAE,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.test.d.ts","sourceRoot":"","sources":["../../../src/utils/address.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getAddressExplorerUrl, trimAddress } from "./address";
|
|
2
|
+
describe("trimAddress", () => {
|
|
3
|
+
it("returns full address if length is less than 11", () => {
|
|
4
|
+
expect(trimAddress("0x12345")).toBe("0x12345");
|
|
5
|
+
});
|
|
6
|
+
it("returns trimmed address if length is 11 or more", () => {
|
|
7
|
+
const input = "0x123456789abcdef";
|
|
8
|
+
const expected = "0x123...bcdef";
|
|
9
|
+
expect(trimAddress(input)).toBe(expected);
|
|
10
|
+
});
|
|
11
|
+
it("returns lowercase result", () => {
|
|
12
|
+
const input = "0xABCDEF1234567890";
|
|
13
|
+
const expected = "0xabc...67890";
|
|
14
|
+
expect(trimAddress(input)).toBe(expected);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
describe("getAddressExplorerUrl", () => {
|
|
18
|
+
const btcAddress = "bc1qxyz123";
|
|
19
|
+
const evmAddress = "0x1234567890abcdef";
|
|
20
|
+
it("returns correct mainnet Bitcoin explorer URL", () => {
|
|
21
|
+
const url = getAddressExplorerUrl(btcAddress, "bitcoin", false);
|
|
22
|
+
expect(url).toBe(`https://mempool.space/address/${btcAddress}`);
|
|
23
|
+
});
|
|
24
|
+
it("returns correct testnet Bitcoin explorer URL", () => {
|
|
25
|
+
const url = getAddressExplorerUrl(btcAddress, "bitcoin", true);
|
|
26
|
+
expect(url).toBe(`https://mempool.space/testnet/address/${btcAddress}`);
|
|
27
|
+
});
|
|
28
|
+
it("returns correct mainnet EVM explorer URL", () => {
|
|
29
|
+
const url = getAddressExplorerUrl(evmAddress, "evm", false);
|
|
30
|
+
expect(url).toBe(`https://etherscan.io/address/${evmAddress}`);
|
|
31
|
+
});
|
|
32
|
+
it("returns correct testnet EVM explorer URL", () => {
|
|
33
|
+
const url = getAddressExplorerUrl(evmAddress, "evm", true);
|
|
34
|
+
expect(url).toBe(`https://sepolia.etherscan.io/address/${evmAddress}`);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=address.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.test.js","sourceRoot":"","sources":["../../../src/utils/address.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE9D,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,KAAK,GAAG,mBAAmB,CAAA;QACjC,MAAM,QAAQ,GAAG,eAAe,CAAA;QAChC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QAClC,MAAM,KAAK,GAAG,oBAAoB,CAAA;QAClC,MAAM,QAAQ,GAAG,eAAe,CAAA;QAChC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,MAAM,UAAU,GAAG,YAAY,CAAA;IAC/B,MAAM,UAAU,GAAG,oBAAoB,CAAA;IAEvC,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,GAAG,GAAG,qBAAqB,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;QAC/D,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,iCAAiC,UAAU,EAAE,CAAC,CAAA;IACjE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,GAAG,GAAG,qBAAqB,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;QAC9D,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,yCAAyC,UAAU,EAAE,CAAC,CAAA;IACzE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,GAAG,GAAG,qBAAqB,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;QAC3D,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,gCAAgC,UAAU,EAAE,CAAC,CAAA;IAChE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,GAAG,GAAG,qBAAqB,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;QAC1D,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,wCAAwC,UAAU,EAAE,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IconProps } from "@mezo-org/mezo-clay";
|
|
2
|
+
import { FC } from "react";
|
|
3
|
+
export type CryptoAssetKey = "btc" | "eth" | "tbtc" | "wbtc" | "mbtc" | "musd";
|
|
4
|
+
export type CryptoAsset = {
|
|
5
|
+
name: string;
|
|
6
|
+
symbol: string;
|
|
7
|
+
icon: FC<IconProps>;
|
|
8
|
+
decimals: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Gets details of given crypto asset
|
|
12
|
+
* @param key The key of crypto asset
|
|
13
|
+
* @returns The crypto asset details
|
|
14
|
+
*/
|
|
15
|
+
export declare function getCryptoAsset(key: CryptoAssetKey): CryptoAsset;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if given crypto asset is Bitcoin-like
|
|
18
|
+
* @param key The key of crypto asset
|
|
19
|
+
* @returns True if crypto asset is Bitcoin-like
|
|
20
|
+
*/
|
|
21
|
+
export declare function isBitcoinLikeCryptoAsset(key: CryptoAssetKey): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if given crypto asset is USD-like
|
|
24
|
+
* @param key The key of crypto asset
|
|
25
|
+
* @returns True if crypto asset is USD-like
|
|
26
|
+
*/
|
|
27
|
+
export declare function isUsdLikeCryptoAsset(key: CryptoAssetKey): boolean;
|
|
28
|
+
//# sourceMappingURL=cryptoAssets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptoAssets.d.ts","sourceRoot":"","sources":["../../../src/utils/cryptoAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAGV,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAiB,EAAE,EAAE,MAAM,OAAO,CAAA;AAEzC,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAmDD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,eAEjD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,cAAc,WAE3D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,cAAc,WAEvD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BitcoinCircle, EthCircle, MUsdCircle, TBtcCircle, } from "@mezo-org/mezo-clay";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
const CRYPTO_ASSETS = {
|
|
4
|
+
btc: {
|
|
5
|
+
name: "Bitcoin",
|
|
6
|
+
symbol: "BTC",
|
|
7
|
+
icon: BitcoinCircle,
|
|
8
|
+
decimals: 8,
|
|
9
|
+
},
|
|
10
|
+
eth: {
|
|
11
|
+
name: "Ethereum",
|
|
12
|
+
symbol: "ETH",
|
|
13
|
+
icon: EthCircle,
|
|
14
|
+
decimals: 18,
|
|
15
|
+
},
|
|
16
|
+
tbtc: {
|
|
17
|
+
name: "Threshold Bitcoin",
|
|
18
|
+
symbol: "tBTC",
|
|
19
|
+
icon: TBtcCircle,
|
|
20
|
+
decimals: 18,
|
|
21
|
+
},
|
|
22
|
+
wbtc: {
|
|
23
|
+
name: "Wrapped Bitcoin",
|
|
24
|
+
symbol: "wBTC",
|
|
25
|
+
icon: (props) => createElement(BitcoinCircle, {
|
|
26
|
+
...props,
|
|
27
|
+
symbolColor: "#FF8A00",
|
|
28
|
+
color: "#000000",
|
|
29
|
+
}),
|
|
30
|
+
decimals: 8,
|
|
31
|
+
},
|
|
32
|
+
mbtc: {
|
|
33
|
+
name: "Matsnet Bitcoin",
|
|
34
|
+
symbol: "BTC",
|
|
35
|
+
icon: (props) => createElement(BitcoinCircle, {
|
|
36
|
+
...props,
|
|
37
|
+
symbolColor: "#000000",
|
|
38
|
+
color: "#FFC907",
|
|
39
|
+
}),
|
|
40
|
+
decimals: 18,
|
|
41
|
+
},
|
|
42
|
+
musd: {
|
|
43
|
+
name: "Mezo USD",
|
|
44
|
+
symbol: "MUSD",
|
|
45
|
+
icon: MUsdCircle,
|
|
46
|
+
decimals: 18,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Gets details of given crypto asset
|
|
51
|
+
* @param key The key of crypto asset
|
|
52
|
+
* @returns The crypto asset details
|
|
53
|
+
*/
|
|
54
|
+
export function getCryptoAsset(key) {
|
|
55
|
+
return CRYPTO_ASSETS[key];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Checks if given crypto asset is Bitcoin-like
|
|
59
|
+
* @param key The key of crypto asset
|
|
60
|
+
* @returns True if crypto asset is Bitcoin-like
|
|
61
|
+
*/
|
|
62
|
+
export function isBitcoinLikeCryptoAsset(key) {
|
|
63
|
+
return ["btc", "tbtc", "wbtc", "mbtc"].includes(key);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Checks if given crypto asset is USD-like
|
|
67
|
+
* @param key The key of crypto asset
|
|
68
|
+
* @returns True if crypto asset is USD-like
|
|
69
|
+
*/
|
|
70
|
+
export function isUsdLikeCryptoAsset(key) {
|
|
71
|
+
return ["musd"].includes(key);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=cryptoAssets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptoAssets.js","sourceRoot":"","sources":["../../../src/utils/cryptoAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,SAAS,EAET,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAM,MAAM,OAAO,CAAA;AAWzC,MAAM,aAAa,GAAwC;IACzD,GAAG,EAAE;QACH,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,CAAC;KACZ;IACD,GAAG,EAAE;QACH,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,mBAAmB;QACzB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACd,aAAa,CAAC,aAAa,EAAE;YAC3B,GAAG,KAAK;YACR,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,SAAS;SACjB,CAAC;QACJ,QAAQ,EAAE,CAAC;KACZ;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACd,aAAa,CAAC,aAAa,EAAE;YAC3B,GAAG,KAAK;YACR,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,SAAS;SACjB,CAAC;QACJ,QAAQ,EAAE,EAAE;KACb;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,EAAE;KACb;CACF,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAmB;IAChD,OAAO,aAAa,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAmB;IAC1D,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAmB;IACtD,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAC/B,CAAC"}
|