@mezo-org/passport 0.4.0-dev.9 → 0.5.1-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/README.md +18 -22
- package/dist/src/api/auth.d.ts +7 -3
- package/dist/src/api/auth.d.ts.map +1 -1
- package/dist/src/api/auth.js +3 -1
- package/dist/src/api/auth.js.map +1 -1
- package/dist/src/api/client.d.ts +4 -1
- package/dist/src/api/client.d.ts.map +1 -1
- package/dist/src/api/client.js +9 -2
- package/dist/src/api/client.js.map +1 -1
- package/dist/src/api/portal.d.ts +3 -9
- package/dist/src/api/portal.d.ts.map +1 -1
- package/dist/src/api/portal.js +8 -5
- package/dist/src/api/portal.js.map +1 -1
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +2 -1
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -1
- package/dist/src/components/Dropdown/ConnectedTrigger.js +29 -20
- package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -1
- package/dist/src/components/Dropdown/Content.d.ts +4 -5
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Content.js +19 -61
- package/dist/src/components/Dropdown/Content.js.map +1 -1
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -1
- package/dist/src/components/Dropdown/DisconnectedTrigger.js +2 -2
- package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.d.ts +9 -6
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/src/components/Dropdown/Dropdown.js +10 -10
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/src/components/Dropdown/ListingItem.d.ts +14 -0
- package/dist/src/components/Dropdown/ListingItem.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ListingItem.js +42 -0
- package/dist/src/components/Dropdown/ListingItem.js.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts +8 -0
- package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +1 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js +32 -0
- package/dist/src/components/Dropdown/NestedViewLayout.js.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts +4 -0
- package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Receive/Receive.js +64 -0
- package/dist/src/components/Dropdown/Receive/Receive.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js +49 -0
- package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js +35 -0
- package/dist/src/components/Dropdown/Root/AccountBalance.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js +27 -0
- package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountError.js +17 -0
- package/dist/src/components/Dropdown/Root/AccountError.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js +21 -0
- package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +43 -0
- package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts +8 -0
- package/dist/src/components/Dropdown/Root/Root.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/Root.js +45 -0
- package/dist/src/components/Dropdown/Root/Root.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +4 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js +66 -0
- package/dist/src/components/Dropdown/Root/WalletAddress.js.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +6 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js +88 -0
- package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +1 -0
- package/dist/src/components/Dropdown/SlotNumber.d.ts +19 -0
- package/dist/src/components/Dropdown/SlotNumber.d.ts.map +1 -0
- package/dist/src/components/Dropdown/SlotNumber.js +67 -0
- package/dist/src/components/Dropdown/SlotNumber.js.map +1 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +3 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +1 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js +14 -0
- package/dist/src/components/Dropdown/TestnetTopBanner.js.map +1 -0
- package/dist/src/config.d.ts +19 -5
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +58 -14
- package/dist/src/config.js.map +1 -1
- package/dist/src/constants.d.ts +11 -3
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +12 -4
- package/dist/src/constants.js.map +1 -1
- package/dist/src/hooks/index.d.ts +4 -0
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +4 -0
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useAssetsConversionRates.d.ts +18 -0
- package/dist/src/hooks/useAssetsConversionRates.d.ts.map +1 -0
- package/dist/src/hooks/useAssetsConversionRates.js +67 -0
- package/dist/src/hooks/useAssetsConversionRates.js.map +1 -0
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +13 -13
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js +9 -8
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
- package/dist/src/hooks/useBorrowData.d.ts +108 -0
- package/dist/src/hooks/useBorrowData.d.ts.map +1 -0
- package/dist/src/hooks/useBorrowData.js +201 -0
- package/dist/src/hooks/useBorrowData.js.map +1 -0
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +22 -1
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +4 -6
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts +19 -13
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +20 -1
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/useRefreshPassport.d.ts +19 -0
- package/dist/src/hooks/useRefreshPassport.d.ts.map +1 -0
- package/dist/src/hooks/useRefreshPassport.js +44 -0
- package/dist/src/hooks/useRefreshPassport.js.map +1 -0
- package/dist/src/hooks/useSignInWithWallet.d.ts +13 -13
- package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.d.ts +13 -13
- package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useTokensBalances.d.ts +75 -0
- package/dist/src/hooks/useTokensBalances.d.ts.map +1 -0
- package/dist/src/hooks/useTokensBalances.js +181 -0
- package/dist/src/hooks/useTokensBalances.js.map +1 -0
- package/dist/src/hooks/useValidateMezoId.d.ts +8 -0
- package/dist/src/hooks/useValidateMezoId.d.ts.map +1 -0
- package/dist/src/hooks/useValidateMezoId.js +24 -0
- package/dist/src/hooks/useValidateMezoId.js.map +1 -0
- package/dist/src/hooks/useWalletAccount.d.ts +2 -1
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -1
- package/dist/src/hooks/useWalletAccount.js +20 -15
- package/dist/src/hooks/useWalletAccount.js.map +1 -1
- package/dist/src/hooks/useWatchTransferEvents.d.ts +5 -0
- package/dist/src/hooks/useWatchTransferEvents.d.ts.map +1 -0
- package/dist/src/hooks/useWatchTransferEvents.js +63 -0
- package/dist/src/hooks/useWatchTransferEvents.js.map +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/contracts/index.d.ts +13 -0
- package/dist/src/lib/contracts/index.d.ts.map +1 -0
- package/dist/src/lib/contracts/index.js +66 -0
- package/dist/src/lib/contracts/index.js.map +1 -0
- 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/provider.d.ts +7 -1
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +4 -1
- package/dist/src/provider.js.map +1 -1
- package/dist/src/stores/dropdownStore.d.ts +12 -0
- package/dist/src/stores/dropdownStore.d.ts.map +1 -0
- package/dist/src/stores/dropdownStore.js +13 -0
- package/dist/src/stores/dropdownStore.js.map +1 -0
- package/dist/src/utils/address.d.ts +1 -1
- package/dist/src/utils/address.d.ts.map +1 -1
- package/dist/src/utils/address.js +2 -0
- package/dist/src/utils/address.js.map +1 -1
- package/dist/src/utils/address.test.js +8 -5
- package/dist/src/utils/address.test.js.map +1 -1
- package/dist/src/utils/assets.d.ts +145 -0
- package/dist/src/utils/assets.d.ts.map +1 -0
- package/dist/src/utils/assets.js +100 -0
- package/dist/src/utils/assets.js.map +1 -0
- package/dist/src/utils/assets.test.d.ts +2 -0
- package/dist/src/utils/assets.test.d.ts.map +1 -0
- package/dist/src/utils/assets.test.js +46 -0
- package/dist/src/utils/assets.test.js.map +1 -0
- package/dist/src/utils/currency.d.ts +13 -2
- package/dist/src/utils/currency.d.ts.map +1 -1
- package/dist/src/utils/currency.js +22 -8
- package/dist/src/utils/currency.js.map +1 -1
- package/dist/src/utils/currency.test.js +44 -1
- package/dist/src/utils/currency.test.js.map +1 -1
- package/dist/src/utils/mezoId.d.ts +7 -0
- package/dist/src/utils/mezoId.d.ts.map +1 -0
- package/dist/src/utils/mezoId.js +41 -0
- package/dist/src/utils/mezoId.js.map +1 -0
- package/dist/src/utils/number2.d.ts +106 -0
- package/dist/src/utils/number2.d.ts.map +1 -0
- package/dist/src/utils/number2.js +289 -0
- package/dist/src/utils/number2.js.map +1 -0
- package/dist/src/utils/numbers.d.ts +15 -33
- package/dist/src/utils/numbers.d.ts.map +1 -1
- package/dist/src/utils/numbers.js +26 -70
- package/dist/src/utils/numbers.js.map +1 -1
- package/dist/src/utils/numbers.test.js +46 -42
- package/dist/src/utils/numbers.test.js.map +1 -1
- package/dist/src/utils/siww.d.ts +1 -0
- package/dist/src/utils/siww.d.ts.map +1 -1
- package/dist/src/utils/siww.js +50 -12
- package/dist/src/utils/siww.js.map +1 -1
- package/dist/src/utils/wagmi.d.ts +3 -0
- package/dist/src/utils/wagmi.d.ts.map +1 -0
- package/dist/src/utils/wagmi.js +7 -0
- package/dist/src/utils/wagmi.js.map +1 -0
- package/dist/src/wallet/index.d.ts +1 -1
- package/dist/src/wallet/index.d.ts.map +1 -1
- package/dist/src/wallet/index.js +1 -1
- package/dist/src/wallet/index.js.map +1 -1
- package/package.json +11 -8
- package/src/api/auth.ts +8 -4
- package/src/api/client.ts +11 -2
- package/src/api/portal.ts +11 -14
- package/src/components/Dropdown/ConnectedTrigger.tsx +52 -32
- package/src/components/Dropdown/Content.tsx +26 -121
- package/src/components/Dropdown/DisconnectedTrigger.tsx +2 -1
- package/src/components/Dropdown/Dropdown.tsx +29 -17
- package/src/components/Dropdown/ListingItem.tsx +176 -0
- package/src/components/Dropdown/NestedViewLayout.tsx +87 -0
- package/src/components/Dropdown/README.md +10 -18
- package/src/components/Dropdown/Receive/Receive.tsx +144 -0
- package/src/components/Dropdown/Root/AccountAddressActions.tsx +99 -0
- package/src/components/Dropdown/Root/AccountBalance.tsx +75 -0
- package/src/components/Dropdown/Root/AccountBtcListing.tsx +52 -0
- package/src/components/Dropdown/Root/AccountError.tsx +34 -0
- package/src/components/Dropdown/Root/AccountMusdListing.tsx +45 -0
- package/src/components/Dropdown/Root/AccountOtherAssets.tsx +85 -0
- package/src/components/Dropdown/Root/Root.tsx +77 -0
- package/src/components/Dropdown/Root/WalletAddress.tsx +123 -0
- package/src/components/Dropdown/Root/WelcomeBlock.tsx +173 -0
- package/src/components/Dropdown/SlotNumber.tsx +131 -0
- package/src/components/Dropdown/TestnetTopBanner.tsx +32 -0
- package/src/config.ts +88 -20
- package/src/constants.ts +12 -4
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useAssetsConversionRates.ts +79 -0
- package/src/hooks/useAuthenticateWithWallet.ts +30 -14
- package/src/hooks/useBorrowData.ts +246 -0
- package/src/hooks/useCreateAccount.ts +29 -2
- package/src/hooks/useGetCurrentAccount.ts +5 -7
- package/src/hooks/useLinkAccount.ts +37 -4
- package/src/hooks/useRefreshPassport.ts +56 -0
- package/src/hooks/useSignInWithWallet.ts +2 -2
- package/src/hooks/useSignUpWithWallet.ts +2 -2
- package/src/hooks/useTokensBalances.ts +265 -0
- package/src/hooks/useValidateMezoId.ts +31 -0
- package/src/hooks/useWalletAccount.ts +32 -20
- package/src/hooks/useWatchTransferEvents.ts +74 -0
- package/src/index.ts +12 -1
- package/src/lib/contracts/index.ts +99 -0
- package/src/lib/contracts/priceOracle.ts +53 -0
- package/src/provider.ts +11 -3
- package/src/stores/dropdownStore.ts +20 -0
- package/src/utils/address.test.ts +10 -6
- package/src/utils/address.ts +5 -3
- package/src/utils/assets.test.ts +57 -0
- package/src/utils/assets.ts +103 -0
- package/src/utils/currency.test.ts +77 -1
- package/src/utils/currency.ts +35 -9
- package/src/utils/mezoId.ts +51 -0
- package/src/utils/number2.ts +419 -0
- package/src/utils/numbers.test.ts +49 -42
- package/src/utils/numbers.ts +33 -95
- package/src/utils/siww.ts +71 -16
- package/src/utils/wagmi.ts +12 -0
- package/src/wallet/index.ts +3 -2
- package/dist/src/components/Dropdown/AccountAddress.d.ts +0 -8
- package/dist/src/components/Dropdown/AccountAddress.d.ts.map +0 -1
- package/dist/src/components/Dropdown/AccountAddress.js +0 -58
- package/dist/src/components/Dropdown/AccountAddress.js.map +0 -1
- package/dist/src/components/Dropdown/AccountAssets.d.ts +0 -14
- package/dist/src/components/Dropdown/AccountAssets.d.ts.map +0 -1
- package/dist/src/components/Dropdown/AccountAssets.js +0 -44
- package/dist/src/components/Dropdown/AccountAssets.js.map +0 -1
- package/dist/src/components/Dropdown/AccountBalance.d.ts +0 -7
- package/dist/src/components/Dropdown/AccountBalance.d.ts.map +0 -1
- package/dist/src/components/Dropdown/AccountBalance.js +0 -18
- package/dist/src/components/Dropdown/AccountBalance.js.map +0 -1
- package/dist/src/components/Dropdown/WelcomeBlock.d.ts +0 -8
- package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +0 -1
- package/dist/src/components/Dropdown/WelcomeBlock.js +0 -44
- package/dist/src/components/Dropdown/WelcomeBlock.js.map +0 -1
- package/dist/src/hooks/useAssetsUSDConversion.d.ts +0 -8
- package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +0 -1
- package/dist/src/hooks/useAssetsUSDConversion.js +0 -21
- package/dist/src/hooks/useAssetsUSDConversion.js.map +0 -1
- package/dist/src/hooks/useDropdownData.d.ts +0 -44
- package/dist/src/hooks/useDropdownData.d.ts.map +0 -1
- package/dist/src/hooks/useDropdownData.js +0 -73
- package/dist/src/hooks/useDropdownData.js.map +0 -1
- package/dist/src/utils/cryptoAssets.d.ts +0 -28
- package/dist/src/utils/cryptoAssets.d.ts.map +0 -1
- package/dist/src/utils/cryptoAssets.js +0 -73
- package/dist/src/utils/cryptoAssets.js.map +0 -1
- package/dist/src/utils/cryptoAssets.test.d.ts +0 -2
- package/dist/src/utils/cryptoAssets.test.d.ts.map +0 -1
- package/dist/src/utils/cryptoAssets.test.js +0 -49
- package/dist/src/utils/cryptoAssets.test.js.map +0 -1
- package/src/components/Dropdown/AccountAddress.tsx +0 -111
- package/src/components/Dropdown/AccountAssets.tsx +0 -110
- package/src/components/Dropdown/AccountBalance.tsx +0 -38
- package/src/components/Dropdown/WelcomeBlock.tsx +0 -92
- package/src/hooks/useAssetsUSDConversion.ts +0 -31
- package/src/hooks/useDropdownData.ts +0 -130
- package/src/utils/cryptoAssets.test.ts +0 -59
- package/src/utils/cryptoAssets.ts +0 -93
package/dist/src/utils/siww.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
type NetworkFamily = "evm" | "bitcoin";
|
|
2
2
|
export declare function createSignInWithWalletMessage(address: string, nonce: string, networkFamily: NetworkFamily, chainId?: number): string;
|
|
3
|
+
export declare function verifyDomainInSignInWithWalletMessage(message: string, signature: string, nonce: string): Promise<void>;
|
|
3
4
|
export {};
|
|
4
5
|
//# sourceMappingURL=siww.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siww.d.ts","sourceRoot":"","sources":["../../../src/utils/siww.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"siww.d.ts","sourceRoot":"","sources":["../../../src/utils/siww.ts"],"names":[],"mappings":"AAQA,KAAK,aAAa,GAAG,KAAK,GAAG,SAAS,CAAA;AAEtC,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,MAAM,UAwBjB;AASD,wBAAsB,qCAAqC,CACzD,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,iBAmCd"}
|
package/dist/src/utils/siww.js
CHANGED
|
@@ -1,19 +1,57 @@
|
|
|
1
|
-
import { SignInWithWalletMessage } from "@mezo-org/sign-in-with-wallet";
|
|
1
|
+
import { SignInWithWalletErrorType, SignInWithWalletMessage, } from "@mezo-org/sign-in-with-wallet";
|
|
2
2
|
import { ONE_DAY_MS } from "./time";
|
|
3
3
|
const SESSION_EXPIRATION_DURATION_MS = 14 * ONE_DAY_MS;
|
|
4
4
|
export function createSignInWithWalletMessage(address, nonce, networkFamily, chainId) {
|
|
5
5
|
const { host: domain, origin: uri } = window.location;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
let siwwMessage;
|
|
7
|
+
try {
|
|
8
|
+
siwwMessage = new SignInWithWalletMessage({
|
|
9
|
+
domain,
|
|
10
|
+
address, // if "bitcoin" this should be btc address, not underlaying eth address
|
|
11
|
+
uri,
|
|
12
|
+
nonce,
|
|
13
|
+
issuedAt: new Date().toISOString(),
|
|
14
|
+
expirationTime: new Date(Date.now() + SESSION_EXPIRATION_DURATION_MS).toISOString(),
|
|
15
|
+
version: "1",
|
|
16
|
+
chainId: networkFamily === "evm" ? chainId : undefined,
|
|
17
|
+
networkFamily,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
throw new Error(`Failed to create sign in with wallet message: ${error}`);
|
|
22
|
+
}
|
|
23
|
+
return siwwMessage.prepareMessage();
|
|
24
|
+
}
|
|
25
|
+
class SIWWDomainError extends Error {
|
|
26
|
+
constructor(message) {
|
|
27
|
+
super(`Error when verifying domain in SIWW message: ${message}`);
|
|
28
|
+
this.name = "SIWWDomainError";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export async function verifyDomainInSignInWithWalletMessage(message, signature, nonce) {
|
|
32
|
+
const { host: domain } = window.location;
|
|
33
|
+
let siwwMessage;
|
|
34
|
+
try {
|
|
35
|
+
siwwMessage = new SignInWithWalletMessage(message);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw new SIWWDomainError("Failed to parse SIWW message");
|
|
39
|
+
}
|
|
40
|
+
if (!siwwMessage.expirationTime) {
|
|
41
|
+
throw new SIWWDomainError("SIWW messages must have an expiration time set");
|
|
42
|
+
}
|
|
43
|
+
const result = await siwwMessage.verify({
|
|
44
|
+
signature,
|
|
45
|
+
// Nonce has to match the session ID carried in the request.
|
|
10
46
|
nonce,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
47
|
+
domain,
|
|
48
|
+
// Time is used as a reference to verify the expiration time set in the
|
|
49
|
+
// message.
|
|
50
|
+
time: new Date().toISOString(),
|
|
51
|
+
}, { suppressExceptions: true });
|
|
52
|
+
if (result.error &&
|
|
53
|
+
result.error.type === SignInWithWalletErrorType.DOMAIN_MISMATCH) {
|
|
54
|
+
throw new SIWWDomainError("Domain does not match provided domain for verification.");
|
|
55
|
+
}
|
|
18
56
|
}
|
|
19
57
|
//# sourceMappingURL=siww.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siww.js","sourceRoot":"","sources":["../../../src/utils/siww.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"siww.js","sourceRoot":"","sources":["../../../src/utils/siww.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEnC,MAAM,8BAA8B,GAAG,EAAE,GAAG,UAAU,CAAA;AAItD,MAAM,UAAU,6BAA6B,CAC3C,OAAe,EACf,KAAa,EACb,aAA4B,EAC5B,OAAgB;IAEhB,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAA;IAErD,IAAI,WAAW,CAAA;IACf,IAAI,CAAC;QACH,WAAW,GAAG,IAAI,uBAAuB,CAAC;YACxC,MAAM;YACN,OAAO,EAAE,uEAAuE;YAChF,GAAG;YACH,KAAK;YACL,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YAClC,cAAc,EAAE,IAAI,IAAI,CACtB,IAAI,CAAC,GAAG,EAAE,GAAG,8BAA8B,CAC5C,CAAC,WAAW,EAAE;YACf,OAAO,EAAE,GAAG;YACZ,OAAO,EAAE,aAAa,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;YACtD,aAAa;SACd,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,iDAAiD,KAAK,EAAE,CAAC,CAAA;IAC3E,CAAC;IAED,OAAO,WAAW,CAAC,cAAc,EAAE,CAAA;AACrC,CAAC;AAED,MAAM,eAAgB,SAAQ,KAAK;IACjC,YAAY,OAAe;QACzB,KAAK,CAAC,gDAAgD,OAAO,EAAE,CAAC,CAAA;QAChE,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;IAC/B,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,OAAe,EACf,SAAiB,EACjB,KAAa;IAEb,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAA;IACxC,IAAI,WAAoC,CAAA;IACxC,IAAI,CAAC;QACH,WAAW,GAAG,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAA;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,eAAe,CAAC,8BAA8B,CAAC,CAAA;IAC3D,CAAC;IAED,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;QAChC,MAAM,IAAI,eAAe,CAAC,gDAAgD,CAAC,CAAA;IAC7E,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,MAAM,CACrC;QACE,SAAS;QACT,4DAA4D;QAC5D,KAAK;QACL,MAAM;QACN,uEAAuE;QACvE,WAAW;QACX,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KAC/B,EACD,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAC7B,CAAA;IAED,IACE,MAAM,CAAC,KAAK;QACZ,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,yBAAyB,CAAC,eAAe,EAC/D,CAAC;QACD,MAAM,IAAI,eAAe,CACvB,yDAAyD,CAC1D,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wagmi.d.ts","sourceRoot":"","sources":["../../../src/utils/wagmi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,wBAAsB,gCAAgC,CAAC,SAAS,EAAE,SAAS,+BAQ1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wagmi.js","sourceRoot":"","sources":["../../../src/utils/wagmi.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,SAAoB;IACzE,IAAI,SAAS,CAAC,IAAI,KAAK,WAAW;QAAE,OAAO,SAAS,CAAA;IAEpD,MAAM,QAAQ,GACZ,SACD,CAAC,kBAAkB,EAAE,CAAA;IAEtB,OAAO,QAAQ,CAAC,YAAY,EAAE,CAAA;AAChC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { getOKXWallet, getUnisatWallet, getXverseWallet,
|
|
1
|
+
export { BitcoinWalletConnectionError, getOKXWallet, getUnisatWallet, getXverseWallet, isUnsupportedBitcoinAddressError, isWalletNetworkDoesNotMatchProviderChainError, OrangeKitConnector, WalletNetworkDoesNotMatchProviderChainError, } from "@mezo-org/orangekit";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,YAAY,EACZ,eAAe,EACf,eAAe,EACf,gCAAgC,EAChC,6CAA6C,EAC7C,kBAAkB,EAClB,2CAA2C,GAC5C,MAAM,qBAAqB,CAAA"}
|
package/dist/src/wallet/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { getOKXWallet, getUnisatWallet, getXverseWallet,
|
|
1
|
+
export { BitcoinWalletConnectionError, getOKXWallet, getUnisatWallet, getXverseWallet, isUnsupportedBitcoinAddressError, isWalletNetworkDoesNotMatchProviderChainError, WalletNetworkDoesNotMatchProviderChainError, } from "@mezo-org/orangekit";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,YAAY,EACZ,eAAe,EACf,eAAe,EACf,gCAAgC,EAChC,6CAA6C,EAE7C,2CAA2C,GAC5C,MAAM,qBAAqB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mezo-org/passport",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1-dev.0",
|
|
4
4
|
"main": "dist/src/index.js",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"scripts": {
|
|
@@ -28,8 +28,6 @@
|
|
|
28
28
|
"@types/jest": "^29.5.12",
|
|
29
29
|
"@types/node": "^20.11.30",
|
|
30
30
|
"@types/react": "^18.2.64",
|
|
31
|
-
"@types/ungap__structured-clone": "^1.2.0",
|
|
32
|
-
"@ungap/structured-clone": "^1.3.0",
|
|
33
31
|
"eslint": "^8.57.1",
|
|
34
32
|
"jest": "^29.7.0",
|
|
35
33
|
"jest-environment-jsdom": "^29.7.0",
|
|
@@ -39,16 +37,21 @@
|
|
|
39
37
|
"typescript": "^5.4.3"
|
|
40
38
|
},
|
|
41
39
|
"dependencies": {
|
|
42
|
-
"@mezo-org/mezo-clay": "0.1.0-dev.
|
|
43
|
-
"@mezo-org/
|
|
44
|
-
"@mezo-org/
|
|
40
|
+
"@mezo-org/mezo-clay": "0.1.0-dev.30",
|
|
41
|
+
"@mezo-org/mezod-contracts": "^1.0.0",
|
|
42
|
+
"@mezo-org/musd-contracts": "^1.0.1",
|
|
43
|
+
"@mezo-org/orangekit": "1.0.0-beta.40-dev.19",
|
|
44
|
+
"@mezo-org/sign-in-with-wallet": "1.0.0-beta.8",
|
|
45
|
+
"qrcode.react": "^4.2.0",
|
|
46
|
+
"styletron-engine-monolithic": "^1.0.0",
|
|
47
|
+
"usehooks-ts": "^3.1.1",
|
|
48
|
+
"motion": "^12.23.6",
|
|
49
|
+
"zustand": "^5.0.3"
|
|
45
50
|
},
|
|
46
51
|
"peerDependencies": {
|
|
47
52
|
"@rainbow-me/rainbowkit": "2.0.2",
|
|
48
53
|
"@tanstack/react-query": "^5.28.4",
|
|
49
54
|
"react": "^18.2.0",
|
|
50
|
-
"styletron-engine-monolithic": "^1.0.0",
|
|
51
|
-
"usehooks-ts": "^3.1.1",
|
|
52
55
|
"viem": "2.22.8",
|
|
53
56
|
"wagmi": "2.5.12"
|
|
54
57
|
}
|
package/src/api/auth.ts
CHANGED
|
@@ -38,7 +38,7 @@ export type AuthenticationProviderRedirectResponse = {
|
|
|
38
38
|
redirectTo: string
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
type SignatureData = {
|
|
41
|
+
export type SignatureData = {
|
|
42
42
|
message: string
|
|
43
43
|
signature: string
|
|
44
44
|
}
|
|
@@ -62,12 +62,14 @@ export type GetAccountByMezoIdOrAddressResponse = {
|
|
|
62
62
|
linkedAccounts?: Extract<LinkedAccount, { type: "wallet" }>[]
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export type LinkAccountRequest =
|
|
65
|
+
export type LinkAccountRequest = CreateAccountRequest | { type: "discord" }
|
|
66
66
|
export type LinkAccountResponse =
|
|
67
67
|
| Account
|
|
68
68
|
| AuthenticationProviderRedirectResponse
|
|
69
69
|
|
|
70
|
-
export type CreateAccountRequest = { type: "wallet" } & SignatureData
|
|
70
|
+
export type CreateAccountRequest = { type: "wallet" } & SignatureData & {
|
|
71
|
+
bitcoinPublicKey?: string
|
|
72
|
+
}
|
|
71
73
|
export type CreateAccountResponse = Account
|
|
72
74
|
|
|
73
75
|
export type UpdateMezoIdResponse = Account
|
|
@@ -82,7 +84,9 @@ export class AuthApiClient extends ApiClient {
|
|
|
82
84
|
environment: keyof typeof AUTH_API_ENDPOINTS_BY_ENV = "mainnet",
|
|
83
85
|
apiUrl?: string,
|
|
84
86
|
) {
|
|
85
|
-
super(
|
|
87
|
+
super({
|
|
88
|
+
apiUrl: apiUrl ?? AUTH_API_ENDPOINTS_BY_ENV[environment],
|
|
89
|
+
})
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
async getSession(code?: string) {
|
package/src/api/client.ts
CHANGED
|
@@ -5,10 +5,19 @@ type RequestHandlerOptions = Omit<RequestInit, "credentials" | "body"> & {
|
|
|
5
5
|
queryParams?: Record<string, string | undefined>
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
const ENDS_WITH_VERSIONING_REGEX = /\/v\d+(?=\/|$)/
|
|
9
|
+
const TRAILING_SLASH_REGEX = /\/$/
|
|
10
|
+
|
|
8
11
|
export abstract class ApiClient {
|
|
9
12
|
private apiUrl: string
|
|
10
13
|
|
|
11
|
-
constructor(apiUrl: string) {
|
|
14
|
+
constructor(opts: { apiUrl: string; removeVersioning?: boolean }) {
|
|
15
|
+
const { apiUrl, removeVersioning = false } = opts
|
|
16
|
+
|
|
17
|
+
if (removeVersioning) {
|
|
18
|
+
this.apiUrl = apiUrl.replace(ENDS_WITH_VERSIONING_REGEX, "")
|
|
19
|
+
return
|
|
20
|
+
}
|
|
12
21
|
this.apiUrl = apiUrl
|
|
13
22
|
}
|
|
14
23
|
|
|
@@ -33,7 +42,7 @@ export abstract class ApiClient {
|
|
|
33
42
|
const { method, body, queryParams = {}, ...restOptions } = options
|
|
34
43
|
|
|
35
44
|
// If last character in apiUrl is forward slash we are removing it
|
|
36
|
-
const authApiUrlRoute = this.apiUrl.replace(
|
|
45
|
+
const authApiUrlRoute = this.apiUrl.replace(TRAILING_SLASH_REGEX, "")
|
|
37
46
|
const url = new URL(`${authApiUrlRoute}${endpoint}`)
|
|
38
47
|
|
|
39
48
|
// Removes falsy values (e.g. null, undefined etc.) from query params and
|
package/src/api/portal.ts
CHANGED
|
@@ -6,25 +6,19 @@ type PortalStatistics = {
|
|
|
6
6
|
tvl: number
|
|
7
7
|
currentUsdPerBtc: string
|
|
8
8
|
currentUsdPerEth: string
|
|
9
|
+
currentUsdPerTToken: string
|
|
9
10
|
usdPerBtc24hChange: string
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
type PortalMats = {
|
|
13
|
-
address: string
|
|
14
14
|
totalMats: number
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
matsFromSecondaryReferrals: number
|
|
18
|
-
netMatsTransferred: number
|
|
19
|
-
dailyMats: number
|
|
20
|
-
dailyMatsFromDeposits: number
|
|
21
|
-
dailyMatsFromReferrals: number
|
|
22
|
-
dailyMatsFromSecondaryReferrals: number
|
|
15
|
+
inactiveMats: number
|
|
16
|
+
matsActivated: boolean
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
export const PORTAL_API_ENDPOINTS_BY_ENV = {
|
|
26
|
-
mainnet: "https://api.mezo.org/api/
|
|
27
|
-
testnet: "https://api.test.mezo.org/api/
|
|
20
|
+
mainnet: "https://api.mezo.org/api/",
|
|
21
|
+
testnet: "https://api.test.mezo.org/api/",
|
|
28
22
|
}
|
|
29
23
|
|
|
30
24
|
export class PortalApiClient extends ApiClient {
|
|
@@ -32,11 +26,14 @@ export class PortalApiClient extends ApiClient {
|
|
|
32
26
|
environment: keyof typeof PORTAL_API_ENDPOINTS_BY_ENV = "mainnet",
|
|
33
27
|
apiUrl?: string,
|
|
34
28
|
) {
|
|
35
|
-
super(
|
|
29
|
+
super({
|
|
30
|
+
apiUrl: apiUrl ?? PORTAL_API_ENDPOINTS_BY_ENV[environment],
|
|
31
|
+
removeVersioning: true,
|
|
32
|
+
})
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
async getPortalStatistics() {
|
|
39
|
-
const data = await this.handleRequest<PortalStatistics>("/statistics", {
|
|
36
|
+
const data = await this.handleRequest<PortalStatistics>("/v1/statistics", {
|
|
40
37
|
method: "GET",
|
|
41
38
|
})
|
|
42
39
|
|
|
@@ -45,7 +42,7 @@ export class PortalApiClient extends ApiClient {
|
|
|
45
42
|
|
|
46
43
|
async getPortalMats(address: string) {
|
|
47
44
|
const data = await this.handleRequest<PortalMats>(
|
|
48
|
-
`/
|
|
45
|
+
`/v2/account/${address}/mats`,
|
|
49
46
|
{
|
|
50
47
|
method: "GET",
|
|
51
48
|
},
|
|
@@ -1,54 +1,74 @@
|
|
|
1
|
-
import { Block, ButtonProps, useStyletron } from "@mezo-org/mezo-clay"
|
|
2
|
-
import React, { forwardRef, ReactNode } from "react"
|
|
1
|
+
import { Block, Button, ButtonProps, useStyletron } from "@mezo-org/mezo-clay"
|
|
2
|
+
import React, { forwardRef, ReactNode, useMemo } from "react"
|
|
3
3
|
|
|
4
|
-
type ConnectedTriggerProps = Omit<ButtonProps, "children"> & {
|
|
4
|
+
type ConnectedTriggerProps = Omit<ButtonProps, "children" | "size"> & {
|
|
5
5
|
avatar: ReactNode
|
|
6
|
+
size?: "medium" | "large"
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
const ConnectedTrigger = forwardRef<HTMLButtonElement, ConnectedTriggerProps>(
|
|
9
10
|
(props, ref) => {
|
|
10
|
-
const { onClick, avatar, ...restProps } = props
|
|
11
|
+
const { onClick, avatar, size = "medium", ...restProps } = props
|
|
11
12
|
|
|
12
13
|
const [, theme] = useStyletron()
|
|
13
14
|
|
|
15
|
+
const avatarSize = useMemo(() => {
|
|
16
|
+
const sizeMap = {
|
|
17
|
+
medium: theme.sizing.scale950,
|
|
18
|
+
large: theme.sizing.scale1400,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return sizeMap[size]
|
|
22
|
+
}, [theme, size])
|
|
23
|
+
|
|
24
|
+
const buttonPadding = useMemo(() => {
|
|
25
|
+
const paddingMap = {
|
|
26
|
+
medium: theme.sizing.scale0,
|
|
27
|
+
large: theme.sizing.scale100,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return paddingMap[size]
|
|
31
|
+
}, [theme, size])
|
|
32
|
+
|
|
14
33
|
return (
|
|
15
|
-
<
|
|
16
|
-
as="button"
|
|
34
|
+
<Button
|
|
17
35
|
overrides={{
|
|
18
|
-
|
|
36
|
+
BaseButton: {
|
|
19
37
|
props: { ref, ...restProps },
|
|
20
38
|
style: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
padding:
|
|
24
|
-
margin: 0,
|
|
25
|
-
cursor: "pointer",
|
|
39
|
+
borderRadius: "100%",
|
|
40
|
+
overflow: "hidden",
|
|
41
|
+
padding: buttonPadding,
|
|
26
42
|
},
|
|
27
43
|
},
|
|
28
44
|
}}
|
|
29
45
|
onClick={onClick}
|
|
30
46
|
>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
{typeof avatar === "string" ? (
|
|
48
|
+
<Block
|
|
49
|
+
width={avatarSize}
|
|
50
|
+
height={avatarSize}
|
|
51
|
+
as="img"
|
|
52
|
+
src={avatar}
|
|
53
|
+
alt=""
|
|
54
|
+
/>
|
|
55
|
+
) : (
|
|
56
|
+
<Block
|
|
57
|
+
width={avatarSize}
|
|
58
|
+
height={avatarSize}
|
|
59
|
+
overrides={{
|
|
60
|
+
Block: {
|
|
61
|
+
style: {
|
|
62
|
+
borderRadius: "100%",
|
|
63
|
+
overflow: "hidden",
|
|
64
|
+
},
|
|
41
65
|
},
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
avatar
|
|
49
|
-
)}
|
|
50
|
-
</Block>
|
|
51
|
-
</Block>
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{avatar}
|
|
69
|
+
</Block>
|
|
70
|
+
)}
|
|
71
|
+
</Button>
|
|
52
72
|
)
|
|
53
73
|
},
|
|
54
74
|
)
|
|
@@ -1,78 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import React, { useCallback } from "react"
|
|
10
|
-
import { useDisconnect } from "wagmi"
|
|
11
|
-
import { useSignOut } from "../../hooks"
|
|
12
|
-
import { DropdownData } from "../../hooks/useDropdownData"
|
|
13
|
-
import AccountAddress from "./AccountAddress"
|
|
14
|
-
import AccountAssets from "./AccountAssets"
|
|
15
|
-
import AccountBalance from "./AccountBalance"
|
|
16
|
-
import WelcomeBlock from "./WelcomeBlock"
|
|
17
|
-
|
|
18
|
-
function MatsnetLabel() {
|
|
19
|
-
const [, theme] = useStyletron()
|
|
20
|
-
return (
|
|
21
|
-
<ParagraphSmall color={theme.colors.contentTertiary}>
|
|
22
|
-
<Mats
|
|
23
|
-
color="currentColor"
|
|
24
|
-
size={theme.sizing.scale400}
|
|
25
|
-
overrides={{
|
|
26
|
-
Svg: {
|
|
27
|
-
style: {
|
|
28
|
-
marginRight: theme.sizing.scale300,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
}}
|
|
32
|
-
/>
|
|
33
|
-
Matsnet Assets
|
|
34
|
-
</ParagraphSmall>
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
type DropdownContentProps = {
|
|
39
|
-
data: DropdownData
|
|
1
|
+
import { Block, useStyletron } from "@mezo-org/mezo-clay"
|
|
2
|
+
import React, { useEffect } from "react"
|
|
3
|
+
import useDropdownStore, { DropdownView } from "../../stores/dropdownStore"
|
|
4
|
+
import Root from "./Root/Root"
|
|
5
|
+
import Receive from "./Receive/Receive"
|
|
6
|
+
import TestnetTopBanner from "./TestnetTopBanner"
|
|
7
|
+
|
|
8
|
+
type ContentProps = {
|
|
40
9
|
onSignOut?: () => void
|
|
10
|
+
onOtherAssetsClick?: () => void
|
|
41
11
|
}
|
|
42
12
|
|
|
43
|
-
|
|
44
|
-
const {
|
|
45
|
-
|
|
46
|
-
const [, theme] = useStyletron()
|
|
13
|
+
function Content(props: ContentProps) {
|
|
14
|
+
const { onSignOut, onOtherAssetsClick } = props
|
|
47
15
|
|
|
48
|
-
const
|
|
49
|
-
mezoId,
|
|
50
|
-
address,
|
|
51
|
-
walletType,
|
|
52
|
-
totalBalanceInUsd,
|
|
53
|
-
formattedNativeAssets,
|
|
54
|
-
matsnet,
|
|
55
|
-
} = data
|
|
16
|
+
const [_, theme] = useStyletron()
|
|
56
17
|
|
|
57
|
-
const
|
|
58
|
-
const
|
|
18
|
+
const currentView = useDropdownStore((state) => state.view)
|
|
19
|
+
const setView = useDropdownStore((state) => state.setView)
|
|
59
20
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
signOut()
|
|
67
|
-
disconnect()
|
|
68
|
-
}, [signOut, disconnect, onSignOut])
|
|
21
|
+
useEffect(
|
|
22
|
+
() => () => {
|
|
23
|
+
setView(DropdownView.ROOT)
|
|
24
|
+
},
|
|
25
|
+
[setView],
|
|
26
|
+
)
|
|
69
27
|
|
|
70
28
|
return (
|
|
71
29
|
<Block
|
|
72
30
|
display="inline-flex"
|
|
73
31
|
flexDirection="column"
|
|
74
32
|
backgroundColor={theme.colors.backgroundPrimary}
|
|
75
|
-
padding={theme.sizing.scale500}
|
|
76
33
|
width="100%"
|
|
77
34
|
overrides={{
|
|
78
35
|
Block: {
|
|
@@ -82,67 +39,15 @@ export default function DropdownContent(props: DropdownContentProps) {
|
|
|
82
39
|
},
|
|
83
40
|
}}
|
|
84
41
|
>
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
<Block
|
|
88
|
-
display="flex"
|
|
89
|
-
flexDirection="column"
|
|
90
|
-
backgroundColor={theme.colors.backgroundSecondary}
|
|
91
|
-
overflow="hidden"
|
|
92
|
-
overrides={{
|
|
93
|
-
Block: { style: { borderRadius: theme.borders.radius300 } },
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
96
|
-
<AccountAddress address={address} type={walletType} />
|
|
42
|
+
<TestnetTopBanner />
|
|
97
43
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<AccountAssets label="Assets" assets={formattedNativeAssets} />
|
|
101
|
-
</Block>
|
|
102
|
-
|
|
103
|
-
{matsnet.formattedAssets.length > 0 && (
|
|
104
|
-
<Block
|
|
105
|
-
marginTop={theme.sizing.scale600}
|
|
106
|
-
backgroundColor={theme.colors.backgroundSecondary}
|
|
107
|
-
overflow="hidden"
|
|
108
|
-
overrides={{
|
|
109
|
-
Block: { style: { borderRadius: theme.borders.radius300 } },
|
|
110
|
-
}}
|
|
111
|
-
>
|
|
112
|
-
<AccountAssets
|
|
113
|
-
label={<MatsnetLabel />}
|
|
114
|
-
assets={matsnet.formattedAssets}
|
|
115
|
-
/>
|
|
116
|
-
</Block>
|
|
44
|
+
{currentView === DropdownView.ROOT && (
|
|
45
|
+
<Root onSignOut={onSignOut} onOtherAssetsClick={onOtherAssetsClick} />
|
|
117
46
|
)}
|
|
118
47
|
|
|
119
|
-
<
|
|
120
|
-
marginTop={theme.sizing.scale700}
|
|
121
|
-
padding={`0 ${theme.sizing.scale100}`}
|
|
122
|
-
>
|
|
123
|
-
<Button
|
|
124
|
-
size="small"
|
|
125
|
-
kind="tertiary"
|
|
126
|
-
startEnhancer={<LogOut01 color="currentColor" size={12} />}
|
|
127
|
-
onClick={() => handleLogOut()}
|
|
128
|
-
overrides={{
|
|
129
|
-
Root: {
|
|
130
|
-
style: {
|
|
131
|
-
":hover": {
|
|
132
|
-
backgroundColor: theme.colors.backgroundSecondary,
|
|
133
|
-
boxShadow: "none",
|
|
134
|
-
},
|
|
135
|
-
":active": {
|
|
136
|
-
backgroundColor: theme.colors.backgroundSecondary,
|
|
137
|
-
color: theme.colors.contentPrimary,
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
}}
|
|
142
|
-
>
|
|
143
|
-
Log out
|
|
144
|
-
</Button>
|
|
145
|
-
</Block>
|
|
48
|
+
{currentView === DropdownView.RECEIVE && <Receive />}
|
|
146
49
|
</Block>
|
|
147
50
|
)
|
|
148
51
|
}
|
|
52
|
+
|
|
53
|
+
export default Content
|