thirdweb 5.76.0 → 5.77.0-nightly-a0fabb205916a7b06938fafbea5d80d9506d342e-20241212000351
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/contract/deployment/deploy-with-abi.js +1 -1
- package/dist/cjs/contract/deployment/deploy-with-abi.js.map +1 -1
- package/dist/cjs/exports/react.js +4 -1
- package/dist/cjs/exports/react.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/deploy-published.js +25 -6
- package/dist/cjs/extensions/prebuilts/deploy-published.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/process-ref-deployments.js +117 -0
- package/dist/cjs/extensions/prebuilts/process-ref-deployments.js.map +1 -0
- package/dist/cjs/extensions/thirdweb/write/publish.js +1 -0
- package/dist/cjs/extensions/thirdweb/write/publish.js.map +1 -1
- package/dist/cjs/react/core/hooks/wallets/useAddConnectedWallet.js +1 -1
- package/dist/cjs/react/core/hooks/wallets/useAddConnectedWallet.js.map +1 -1
- package/dist/cjs/react/core/hooks/wallets/useAutoConnect.js +1 -1
- package/dist/cjs/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/cjs/react/core/utils/storage.js +4 -3
- package/dist/cjs/react/core/utils/storage.js.map +1 -1
- package/dist/cjs/react/core/utils/wallet.js +2 -1
- package/dist/cjs/react/core/utils/wallet.js.map +1 -1
- package/dist/cjs/react/native/hooks/wallets/useLinkProfile.js +14 -4
- package/dist/cjs/react/native/hooks/wallets/useLinkProfile.js.map +1 -1
- package/dist/cjs/react/native/hooks/wallets/useProfiles.js +15 -6
- package/dist/cjs/react/native/hooks/wallets/useProfiles.js.map +1 -1
- package/dist/cjs/react/web/hooks/wallets/useLinkProfile.js +14 -4
- package/dist/cjs/react/web/hooks/wallets/useLinkProfile.js.map +1 -1
- package/dist/cjs/react/web/hooks/wallets/useProfiles.js +15 -6
- package/dist/cjs/react/web/hooks/wallets/useProfiles.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/locale/br.js +120 -0
- package/dist/cjs/react/web/ui/ConnectWallet/locale/br.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/locale/getConnectLocale.js +3 -0
- package/dist/cjs/react/web/ui/ConnectWallet/locale/getConnectLocale.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/LinkProfileScreen.js +6 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/LinkProfileScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/Account/avatar.js +6 -1
- package/dist/cjs/react/web/ui/prebuilt/Account/avatar.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/Account/blobbie.js +1 -0
- package/dist/cjs/react/web/ui/prebuilt/Account/blobbie.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/Account/name.js +6 -1
- package/dist/cjs/react/web/ui/prebuilt/Account/name.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/Account/provider.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/Chain/icon.js +13 -1
- package/dist/cjs/react/web/ui/prebuilt/Chain/icon.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/Chain/name.js +30 -13
- package/dist/cjs/react/web/ui/prebuilt/Chain/name.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/NFT/description.js +2 -1
- package/dist/cjs/react/web/ui/prebuilt/NFT/description.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/NFT/media.js +3 -1
- package/dist/cjs/react/web/ui/prebuilt/NFT/media.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/NFT/name.js +3 -1
- package/dist/cjs/react/web/ui/prebuilt/NFT/name.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/NFT/provider.js +1 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/provider.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/Token/icon.js +14 -1
- package/dist/cjs/react/web/ui/prebuilt/Token/icon.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/Token/name.js +57 -26
- package/dist/cjs/react/web/ui/prebuilt/Token/name.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/Token/symbol.js +57 -26
- package/dist/cjs/react/web/ui/prebuilt/Token/symbol.js.map +1 -1
- package/dist/cjs/react/web/utils/storage.js +26 -0
- package/dist/cjs/react/web/utils/storage.js.map +1 -0
- package/dist/cjs/react/web/wallets/injected/locale/br.js +27 -0
- package/dist/cjs/react/web/wallets/injected/locale/br.js.map +1 -0
- package/dist/cjs/react/web/wallets/injected/locale/getInjectedWalletLocale.js +3 -0
- package/dist/cjs/react/web/wallets/injected/locale/getInjectedWalletLocale.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/locale/br.js +59 -0
- package/dist/cjs/react/web/wallets/shared/locale/br.js.map +1 -0
- package/dist/cjs/react/web/wallets/shared/locale/getConnectLocale.js +3 -0
- package/dist/cjs/react/web/wallets/shared/locale/getConnectLocale.js.map +1 -1
- package/dist/cjs/react/web/wallets/smartWallet/locale/br.js +13 -0
- package/dist/cjs/react/web/wallets/smartWallet/locale/br.js.map +1 -0
- package/dist/cjs/react/web/wallets/smartWallet/locale/getSmartWalletLocale.js +3 -0
- package/dist/cjs/react/web/wallets/smartWallet/locale/getSmartWalletLocale.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/manager/index.js +3 -2
- package/dist/cjs/wallets/manager/index.js.map +1 -1
- package/dist/esm/contract/deployment/deploy-with-abi.js +1 -1
- package/dist/esm/contract/deployment/deploy-with-abi.js.map +1 -1
- package/dist/esm/exports/react.js +2 -0
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/extensions/prebuilts/deploy-published.js +25 -6
- package/dist/esm/extensions/prebuilts/deploy-published.js.map +1 -1
- package/dist/esm/extensions/prebuilts/process-ref-deployments.js +114 -0
- package/dist/esm/extensions/prebuilts/process-ref-deployments.js.map +1 -0
- package/dist/esm/extensions/thirdweb/write/publish.js +1 -0
- package/dist/esm/extensions/thirdweb/write/publish.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useAddConnectedWallet.js +1 -1
- package/dist/esm/react/core/hooks/wallets/useAddConnectedWallet.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useAutoConnect.js +1 -1
- package/dist/esm/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
- package/dist/esm/react/core/utils/storage.js +1 -1
- package/dist/esm/react/core/utils/storage.js.map +1 -1
- package/dist/esm/react/core/utils/wallet.js +2 -1
- package/dist/esm/react/core/utils/wallet.js.map +1 -1
- package/dist/esm/react/native/hooks/wallets/useLinkProfile.js +15 -5
- package/dist/esm/react/native/hooks/wallets/useLinkProfile.js.map +1 -1
- package/dist/esm/react/native/hooks/wallets/useProfiles.js +15 -6
- package/dist/esm/react/native/hooks/wallets/useProfiles.js.map +1 -1
- package/dist/esm/react/web/hooks/wallets/useLinkProfile.js +15 -5
- package/dist/esm/react/web/hooks/wallets/useLinkProfile.js.map +1 -1
- package/dist/esm/react/web/hooks/wallets/useProfiles.js +15 -6
- package/dist/esm/react/web/hooks/wallets/useProfiles.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/locale/br.js +118 -0
- package/dist/esm/react/web/ui/ConnectWallet/locale/br.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/locale/getConnectLocale.js +3 -0
- package/dist/esm/react/web/ui/ConnectWallet/locale/getConnectLocale.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/LinkProfileScreen.js +6 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/LinkProfileScreen.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/Account/avatar.js +6 -1
- package/dist/esm/react/web/ui/prebuilt/Account/avatar.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/Account/blobbie.js +1 -0
- package/dist/esm/react/web/ui/prebuilt/Account/blobbie.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/Account/name.js +6 -1
- package/dist/esm/react/web/ui/prebuilt/Account/name.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/Account/provider.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/Chain/icon.js +13 -1
- package/dist/esm/react/web/ui/prebuilt/Chain/icon.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/Chain/name.js +29 -13
- package/dist/esm/react/web/ui/prebuilt/Chain/name.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/NFT/description.js +2 -1
- package/dist/esm/react/web/ui/prebuilt/NFT/description.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/NFT/media.js +3 -1
- package/dist/esm/react/web/ui/prebuilt/NFT/media.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/NFT/name.js +3 -1
- package/dist/esm/react/web/ui/prebuilt/NFT/name.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/NFT/provider.js +1 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/provider.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/Token/icon.js +14 -1
- package/dist/esm/react/web/ui/prebuilt/Token/icon.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/Token/name.js +55 -26
- package/dist/esm/react/web/ui/prebuilt/Token/name.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/Token/symbol.js +55 -26
- package/dist/esm/react/web/ui/prebuilt/Token/symbol.js.map +1 -1
- package/dist/esm/react/web/utils/storage.js +23 -0
- package/dist/esm/react/web/utils/storage.js.map +1 -0
- package/dist/esm/react/web/wallets/injected/locale/br.js +25 -0
- package/dist/esm/react/web/wallets/injected/locale/br.js.map +1 -0
- package/dist/esm/react/web/wallets/injected/locale/getInjectedWalletLocale.js +3 -0
- package/dist/esm/react/web/wallets/injected/locale/getInjectedWalletLocale.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/locale/br.js +57 -0
- package/dist/esm/react/web/wallets/shared/locale/br.js.map +1 -0
- package/dist/esm/react/web/wallets/shared/locale/getConnectLocale.js +3 -0
- package/dist/esm/react/web/wallets/shared/locale/getConnectLocale.js.map +1 -1
- package/dist/esm/react/web/wallets/smartWallet/locale/br.js +11 -0
- package/dist/esm/react/web/wallets/smartWallet/locale/br.js.map +1 -0
- package/dist/esm/react/web/wallets/smartWallet/locale/getSmartWalletLocale.js +3 -0
- package/dist/esm/react/web/wallets/smartWallet/locale/getSmartWalletLocale.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/manager/index.js +3 -2
- package/dist/esm/wallets/manager/index.js.map +1 -1
- package/dist/types/exports/react.d.ts +1 -0
- package/dist/types/exports/react.d.ts.map +1 -1
- package/dist/types/extensions/prebuilts/deploy-published.d.ts.map +1 -1
- package/dist/types/extensions/prebuilts/process-ref-deployments.d.ts +17 -0
- package/dist/types/extensions/prebuilts/process-ref-deployments.d.ts.map +1 -0
- package/dist/types/extensions/thirdweb/write/publish.d.ts.map +1 -1
- package/dist/types/react/core/hooks/wallets/useAddConnectedWallet.d.ts +1 -1
- package/dist/types/react/core/hooks/wallets/useAddConnectedWallet.d.ts.map +1 -1
- package/dist/types/react/core/utils/storage.d.ts +1 -0
- package/dist/types/react/core/utils/storage.d.ts.map +1 -1
- package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
- package/dist/types/react/native/hooks/wallets/useLinkProfile.d.ts +1 -1
- package/dist/types/react/native/hooks/wallets/useLinkProfile.d.ts.map +1 -1
- package/dist/types/react/native/hooks/wallets/useProfiles.d.ts.map +1 -1
- package/dist/types/react/web/hooks/wallets/useLinkProfile.d.ts.map +1 -1
- package/dist/types/react/web/hooks/wallets/useProfiles.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/MenuButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/WalletEntryButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/locale/br.d.ts +4 -0
- package/dist/types/react/web/ui/ConnectWallet/locale/br.d.ts.map +1 -0
- package/dist/types/react/web/ui/ConnectWallet/locale/getConnectLocale.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/LinkProfileScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/Drawer.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/FadeIn.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/Modal.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/Overlay.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/basic.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/buttons.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/formElements.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/modalElements.d.ts.map +1 -1
- package/dist/types/react/web/ui/components/text.d.ts.map +1 -1
- package/dist/types/react/web/ui/design-system/animations.d.ts +18 -3
- package/dist/types/react/web/ui/design-system/animations.d.ts.map +1 -1
- package/dist/types/react/web/ui/design-system/elements.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/Account/avatar.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/Account/blobbie.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/Account/name.d.ts +1 -1
- package/dist/types/react/web/ui/prebuilt/Account/name.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/Account/provider.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/Chain/icon.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/Chain/name.d.ts +8 -0
- package/dist/types/react/web/ui/prebuilt/Chain/name.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/NFT/description.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/NFT/media.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/NFT/name.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/NFT/provider.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/Token/icon.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/Token/name.d.ts +21 -0
- package/dist/types/react/web/ui/prebuilt/Token/name.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/Token/symbol.d.ts +21 -0
- package/dist/types/react/web/ui/prebuilt/Token/symbol.d.ts.map +1 -1
- package/dist/types/react/web/ui/types.d.ts +1 -1
- package/dist/types/react/web/ui/types.d.ts.map +1 -1
- package/dist/types/react/web/utils/storage.d.ts +19 -0
- package/dist/types/react/web/utils/storage.d.ts.map +1 -0
- package/dist/types/react/web/wallets/injected/locale/br.d.ts +7 -0
- package/dist/types/react/web/wallets/injected/locale/br.d.ts.map +1 -0
- package/dist/types/react/web/wallets/injected/locale/getInjectedWalletLocale.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/locale/br.d.ts +58 -0
- package/dist/types/react/web/wallets/shared/locale/br.d.ts.map +1 -0
- package/dist/types/react/web/wallets/shared/locale/getConnectLocale.d.ts.map +1 -1
- package/dist/types/react/web/wallets/smartWallet/locale/br.d.ts +4 -0
- package/dist/types/react/web/wallets/smartWallet/locale/br.d.ts.map +1 -0
- package/dist/types/react/web/wallets/smartWallet/locale/getSmartWalletLocale.d.ts.map +1 -1
- package/dist/types/utils/any-evm/deploy-metadata.d.ts +19 -0
- package/dist/types/utils/any-evm/deploy-metadata.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/manager/index.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/contract/deployment/deploy-with-abi.ts +1 -1
- package/src/exports/react.ts +3 -0
- package/src/extensions/prebuilts/deploy-published.ts +36 -6
- package/src/extensions/prebuilts/process-ref-deployments.test.ts +196 -0
- package/src/extensions/prebuilts/process-ref-deployments.ts +167 -0
- package/src/extensions/thirdweb/write/publish.ts +1 -0
- package/src/react/core/hooks/wallets/useAddConnectedWallet.ts +1 -1
- package/src/react/core/hooks/wallets/useAutoConnect.ts +1 -1
- package/src/react/core/utils/storage.ts +1 -1
- package/src/react/core/utils/wallet.test.ts +77 -0
- package/src/react/core/utils/wallet.ts +2 -1
- package/src/react/native/hooks/wallets/useLinkProfile.ts +17 -8
- package/src/react/native/hooks/wallets/useProfiles.ts +17 -8
- package/src/react/web/hooks/wallets/useLinkProfile.ts +16 -7
- package/src/react/web/hooks/wallets/useProfiles.ts +17 -8
- package/src/react/web/ui/ConnectWallet/locale/br.ts +124 -0
- package/src/react/web/ui/ConnectWallet/locale/getConnectLocale.ts +3 -0
- package/src/react/web/ui/ConnectWallet/screens/LinkProfileScreen.tsx +6 -2
- package/src/react/web/ui/prebuilt/Account/avatar.tsx +6 -1
- package/src/react/web/ui/prebuilt/Account/blobbie.tsx +2 -0
- package/src/react/web/ui/prebuilt/Account/name.tsx +7 -2
- package/src/react/web/ui/prebuilt/Account/provider.tsx +1 -0
- package/src/react/web/ui/prebuilt/Chain/icon.tsx +15 -1
- package/src/react/web/ui/prebuilt/Chain/name.test.tsx +36 -9
- package/src/react/web/ui/prebuilt/Chain/name.tsx +35 -13
- package/src/react/web/ui/prebuilt/NFT/description.tsx +2 -1
- package/src/react/web/ui/prebuilt/NFT/media.tsx +4 -1
- package/src/react/web/ui/prebuilt/NFT/name.tsx +4 -1
- package/src/react/web/ui/prebuilt/NFT/provider.tsx +2 -0
- package/src/react/web/ui/prebuilt/Token/icon.tsx +16 -1
- package/src/react/web/ui/prebuilt/Token/name.test.tsx +148 -0
- package/src/react/web/ui/prebuilt/Token/name.tsx +73 -29
- package/src/react/web/ui/prebuilt/Token/provider.test.tsx +11 -0
- package/src/react/web/ui/prebuilt/Token/symbol.test.tsx +138 -20
- package/src/react/web/ui/prebuilt/Token/symbol.tsx +73 -32
- package/src/react/web/ui/types.ts +2 -1
- package/src/react/web/utils/storage.test.ts +34 -0
- package/src/react/web/utils/storage.ts +23 -0
- package/src/react/web/wallets/injected/locale/br.ts +27 -0
- package/src/react/web/wallets/injected/locale/getInjectedWalletLocale.ts +3 -0
- package/src/react/web/wallets/shared/locale/br.ts +62 -0
- package/src/react/web/wallets/shared/locale/getConnectLocale.ts +3 -0
- package/src/react/web/wallets/smartWallet/locale/br.ts +13 -0
- package/src/react/web/wallets/smartWallet/locale/getSmartWalletLocale.ts +3 -0
- package/src/utils/any-evm/deploy-metadata.ts +29 -0
- package/src/version.ts +1 -1
- package/src/wallets/manager/index.ts +6 -2
@@ -0,0 +1,77 @@
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
2
|
+
import type { Wallet } from "../../../wallets/interfaces/wallet";
|
3
|
+
import { hasSponsoredTransactionsEnabled } from "./wallet";
|
4
|
+
|
5
|
+
describe("hasSponsoredTransactionsEnabled", () => {
|
6
|
+
it("should return false for undefined wallet", () => {
|
7
|
+
expect(hasSponsoredTransactionsEnabled(undefined)).toBe(false);
|
8
|
+
});
|
9
|
+
|
10
|
+
it("should handle smart wallet with sponsorGas config", () => {
|
11
|
+
const mockSmartWallet = {
|
12
|
+
id: "smart",
|
13
|
+
getConfig: () => ({ sponsorGas: true }),
|
14
|
+
} as Wallet;
|
15
|
+
expect(hasSponsoredTransactionsEnabled(mockSmartWallet)).toBe(true);
|
16
|
+
|
17
|
+
const mockSmartWalletDisabled = {
|
18
|
+
id: "smart",
|
19
|
+
getConfig: () => ({ sponsorGas: false }),
|
20
|
+
} as Wallet;
|
21
|
+
expect(hasSponsoredTransactionsEnabled(mockSmartWalletDisabled)).toBe(
|
22
|
+
false,
|
23
|
+
);
|
24
|
+
});
|
25
|
+
|
26
|
+
it("should handle smart wallet with gasless config", () => {
|
27
|
+
const mockSmartWallet = {
|
28
|
+
id: "smart",
|
29
|
+
getConfig: () => ({ gasless: true }),
|
30
|
+
} as Wallet;
|
31
|
+
expect(hasSponsoredTransactionsEnabled(mockSmartWallet)).toBe(true);
|
32
|
+
});
|
33
|
+
|
34
|
+
it("should handle inApp wallet with smartAccount config", () => {
|
35
|
+
const mockInAppWallet = {
|
36
|
+
id: "inApp",
|
37
|
+
getConfig: () => ({
|
38
|
+
smartAccount: {
|
39
|
+
sponsorGas: true,
|
40
|
+
},
|
41
|
+
}),
|
42
|
+
} as Wallet;
|
43
|
+
expect(hasSponsoredTransactionsEnabled(mockInAppWallet)).toBe(true);
|
44
|
+
|
45
|
+
const mockInAppWalletDisabled = {
|
46
|
+
id: "inApp",
|
47
|
+
getConfig: () => ({
|
48
|
+
smartAccount: {
|
49
|
+
sponsorGas: false,
|
50
|
+
},
|
51
|
+
}),
|
52
|
+
} as Wallet;
|
53
|
+
expect(hasSponsoredTransactionsEnabled(mockInAppWalletDisabled)).toBe(
|
54
|
+
false,
|
55
|
+
);
|
56
|
+
});
|
57
|
+
|
58
|
+
it("should handle inApp wallet with gasless config", () => {
|
59
|
+
const mockInAppWallet = {
|
60
|
+
id: "inApp",
|
61
|
+
getConfig: () => ({
|
62
|
+
smartAccount: {
|
63
|
+
gasless: true,
|
64
|
+
},
|
65
|
+
}),
|
66
|
+
} as Wallet;
|
67
|
+
expect(hasSponsoredTransactionsEnabled(mockInAppWallet)).toBe(true);
|
68
|
+
});
|
69
|
+
|
70
|
+
it("should return false for regular wallet without smart account config", () => {
|
71
|
+
const mockRegularWallet = {
|
72
|
+
id: "inApp",
|
73
|
+
getConfig: () => ({}),
|
74
|
+
} as Wallet;
|
75
|
+
expect(hasSponsoredTransactionsEnabled(mockRegularWallet)).toBe(false);
|
76
|
+
});
|
77
|
+
});
|
@@ -7,6 +7,7 @@ import { resolveName } from "../../../extensions/ens/resolve-name.js";
|
|
7
7
|
import { shortenAddress } from "../../../utils/address.js";
|
8
8
|
import { parseAvatarRecord } from "../../../utils/ens/avatar.js";
|
9
9
|
import { getWalletInfo } from "../../../wallets/__generated__/getWalletInfo.js";
|
10
|
+
import { isEcosystemWallet } from "../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
10
11
|
import type { Account, Wallet } from "../../../wallets/interfaces/wallet.js";
|
11
12
|
import type { WalletInfo } from "../../../wallets/wallet-info.js";
|
12
13
|
import type { WalletId } from "../../../wallets/wallet-types.js";
|
@@ -223,7 +224,7 @@ export function hasSponsoredTransactionsEnabled(wallet: Wallet | undefined) {
|
|
223
224
|
sponsoredTransactionsEnabled = options.gasless;
|
224
225
|
}
|
225
226
|
}
|
226
|
-
if (wallet && wallet.id === "inApp") {
|
227
|
+
if (wallet && (wallet.id === "inApp" || isEcosystemWallet(wallet))) {
|
227
228
|
const options = (wallet as Wallet<"inApp">).getConfig();
|
228
229
|
if (options && "smartAccount" in options && options.smartAccount) {
|
229
230
|
const smartOptions = options.smartAccount;
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { useMutation } from "@tanstack/react-query";
|
1
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
2
2
|
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
3
3
|
import type { AuthArgsType } from "../../../../wallets/in-app/core/authentication/types.js";
|
4
4
|
import type { Ecosystem } from "../../../../wallets/in-app/core/wallet/types.js";
|
5
5
|
import { linkProfile } from "../../../../wallets/in-app/web/lib/auth/index.js";
|
6
|
-
import {
|
6
|
+
import { useConnectedWallets } from "../../../core/hooks/wallets/useConnectedWallets.js";
|
7
7
|
|
8
8
|
/**
|
9
9
|
* Links a web2 or web3 profile to the connected in-app or ecosystem account.
|
@@ -77,16 +77,25 @@ import { useAdminWallet } from "../../../core/hooks/wallets/useAdminWallet.js";
|
|
77
77
|
* @wallet
|
78
78
|
*/
|
79
79
|
export function useLinkProfile() {
|
80
|
-
const
|
80
|
+
const wallets = useConnectedWallets();
|
81
|
+
const queryClient = useQueryClient();
|
81
82
|
return useMutation({
|
82
83
|
mutationKey: ["profiles"],
|
83
|
-
mutationFn: async (options:
|
84
|
-
const
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
mutationFn: async (options: AuthArgsType) => {
|
85
|
+
const ecosystemWallet = wallets.find((w) => isEcosystemWallet(w));
|
86
|
+
const ecosystem: Ecosystem | undefined = ecosystemWallet
|
87
|
+
? {
|
88
|
+
id: ecosystemWallet.id,
|
89
|
+
partnerId: ecosystemWallet.getConfig()?.partnerId,
|
90
|
+
}
|
91
|
+
: undefined;
|
88
92
|
const optionsWithEcosystem = { ...options, ecosystem } as AuthArgsType;
|
89
93
|
return linkProfile(optionsWithEcosystem);
|
90
94
|
},
|
95
|
+
onSuccess() {
|
96
|
+
setTimeout(() => {
|
97
|
+
queryClient.invalidateQueries({ queryKey: ["profiles"] });
|
98
|
+
}, 500);
|
99
|
+
},
|
91
100
|
});
|
92
101
|
}
|
@@ -4,7 +4,7 @@ import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wa
|
|
4
4
|
import type { Profile } from "../../../../wallets/in-app/core/authentication/types.js";
|
5
5
|
import type { Ecosystem } from "../../../../wallets/in-app/core/wallet/types.js";
|
6
6
|
import { getProfiles } from "../../../../wallets/in-app/web/lib/auth/index.js";
|
7
|
-
import {
|
7
|
+
import { useConnectedWallets } from "../../../core/hooks/wallets/useConnectedWallets.js";
|
8
8
|
|
9
9
|
/**
|
10
10
|
* Retrieves all linked profiles of the connected in-app or ecosystem account.
|
@@ -29,15 +29,24 @@ import { useAdminWallet } from "../../../core/hooks/wallets/useAdminWallet.js";
|
|
29
29
|
export function useProfiles(args: {
|
30
30
|
client: ThirdwebClient;
|
31
31
|
}): UseQueryResult<Profile[]> {
|
32
|
-
const
|
32
|
+
const wallets = useConnectedWallets();
|
33
|
+
const enabled =
|
34
|
+
wallets.length > 0 &&
|
35
|
+
wallets.some((w) => w.id === "inApp" || isEcosystemWallet(w));
|
33
36
|
return useQuery({
|
34
|
-
queryKey: [
|
35
|
-
|
37
|
+
queryKey: [
|
38
|
+
"profiles",
|
39
|
+
wallets.map((w) => `${w.id}-${w.getAccount()?.address}`),
|
40
|
+
],
|
41
|
+
enabled,
|
36
42
|
queryFn: async () => {
|
37
|
-
const
|
38
|
-
|
39
|
-
|
40
|
-
|
43
|
+
const ecosystemWallet = wallets.find((w) => isEcosystemWallet(w));
|
44
|
+
const ecosystem: Ecosystem | undefined = ecosystemWallet
|
45
|
+
? {
|
46
|
+
id: ecosystemWallet.id,
|
47
|
+
partnerId: ecosystemWallet.getConfig()?.partnerId,
|
48
|
+
}
|
49
|
+
: undefined;
|
41
50
|
return getProfiles({
|
42
51
|
client: args.client,
|
43
52
|
ecosystem,
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { useMutation } from "@tanstack/react-query";
|
1
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
2
2
|
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
3
3
|
import type { AuthArgsType } from "../../../../wallets/in-app/core/authentication/types.js";
|
4
4
|
import type { Ecosystem } from "../../../../wallets/in-app/core/wallet/types.js";
|
5
5
|
import { linkProfile } from "../../../../wallets/in-app/web/lib/auth/index.js";
|
6
|
-
import {
|
6
|
+
import { useConnectedWallets } from "../../../core/hooks/wallets/useConnectedWallets.js";
|
7
7
|
|
8
8
|
/**
|
9
9
|
* Links a web2 or web3 profile to the connected in-app or ecosystem account.
|
@@ -76,16 +76,25 @@ import { useAdminWallet } from "../../../core/hooks/wallets/useAdminWallet.js";
|
|
76
76
|
* @wallet
|
77
77
|
*/
|
78
78
|
export function useLinkProfile() {
|
79
|
-
const
|
79
|
+
const wallets = useConnectedWallets();
|
80
|
+
const queryClient = useQueryClient();
|
80
81
|
return useMutation({
|
81
82
|
mutationKey: ["profiles"],
|
82
83
|
mutationFn: async (options: AuthArgsType) => {
|
83
|
-
const
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
const ecosystemWallet = wallets.find((w) => isEcosystemWallet(w));
|
85
|
+
const ecosystem: Ecosystem | undefined = ecosystemWallet
|
86
|
+
? {
|
87
|
+
id: ecosystemWallet.id,
|
88
|
+
partnerId: ecosystemWallet.getConfig()?.partnerId,
|
89
|
+
}
|
90
|
+
: undefined;
|
87
91
|
const optionsWithEcosystem = { ...options, ecosystem } as AuthArgsType;
|
88
92
|
return linkProfile(optionsWithEcosystem);
|
89
93
|
},
|
94
|
+
onSuccess() {
|
95
|
+
setTimeout(() => {
|
96
|
+
queryClient.invalidateQueries({ queryKey: ["profiles"] });
|
97
|
+
}, 500);
|
98
|
+
},
|
90
99
|
});
|
91
100
|
}
|
@@ -4,7 +4,7 @@ import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wa
|
|
4
4
|
import type { Profile } from "../../../../wallets/in-app/core/authentication/types.js";
|
5
5
|
import type { Ecosystem } from "../../../../wallets/in-app/core/wallet/types.js";
|
6
6
|
import { getProfiles } from "../../../../wallets/in-app/web/lib/auth/index.js";
|
7
|
-
import {
|
7
|
+
import { useConnectedWallets } from "../../../core/hooks/wallets/useConnectedWallets.js";
|
8
8
|
|
9
9
|
/**
|
10
10
|
* Retrieves all linked profiles of the connected in-app or ecosystem account.
|
@@ -29,15 +29,24 @@ import { useAdminWallet } from "../../../core/hooks/wallets/useAdminWallet.js";
|
|
29
29
|
export function useProfiles(args: {
|
30
30
|
client: ThirdwebClient;
|
31
31
|
}): UseQueryResult<Profile[]> {
|
32
|
-
const
|
32
|
+
const wallets = useConnectedWallets();
|
33
|
+
const enabled =
|
34
|
+
wallets.length > 0 &&
|
35
|
+
wallets.some((w) => w.id === "inApp" || isEcosystemWallet(w));
|
33
36
|
return useQuery({
|
34
|
-
queryKey: [
|
35
|
-
|
37
|
+
queryKey: [
|
38
|
+
"profiles",
|
39
|
+
wallets.map((w) => `${w.id}-${w.getAccount()?.address}`),
|
40
|
+
],
|
41
|
+
enabled,
|
36
42
|
queryFn: async () => {
|
37
|
-
const
|
38
|
-
|
39
|
-
|
40
|
-
|
43
|
+
const ecosystemWallet = wallets.find((w) => isEcosystemWallet(w));
|
44
|
+
const ecosystem: Ecosystem | undefined = ecosystemWallet
|
45
|
+
? {
|
46
|
+
id: ecosystemWallet.id,
|
47
|
+
partnerId: ecosystemWallet.getConfig()?.partnerId,
|
48
|
+
}
|
49
|
+
: undefined;
|
41
50
|
return getProfiles({
|
42
51
|
client: args.client,
|
43
52
|
ecosystem,
|
@@ -0,0 +1,124 @@
|
|
1
|
+
import type { ConnectLocale } from "./types.js";
|
2
|
+
|
3
|
+
const connectWalletLocalPtBr: ConnectLocale = {
|
4
|
+
id: "pt_BR",
|
5
|
+
signIn: "Entrar",
|
6
|
+
defaultButtonTitle: "Conectar carteira",
|
7
|
+
connecting: "Conectando",
|
8
|
+
switchNetwork: "Trocar de rede",
|
9
|
+
switchingNetwork: "Trocando de rede",
|
10
|
+
defaultModalTitle: "Conectar",
|
11
|
+
recommended: "Recomendado",
|
12
|
+
installed: "Instalado",
|
13
|
+
continueAsGuest: "Continuar como convidado",
|
14
|
+
connectAWallet: "Conectar uma carteira",
|
15
|
+
newToWallets: "Novo em carteiras?",
|
16
|
+
getStarted: "Começar",
|
17
|
+
guest: "Convidado",
|
18
|
+
send: "Enviar",
|
19
|
+
receive: "Receber",
|
20
|
+
buy: "Comprar",
|
21
|
+
transactions: "Transações",
|
22
|
+
payTransactions: "Transações Fiat",
|
23
|
+
walletTransactions: "Transações de Carteira",
|
24
|
+
viewAllTransactions: "Ver todas as transações",
|
25
|
+
currentNetwork: "Rede atual",
|
26
|
+
switchAccount: "Trocar conta",
|
27
|
+
requestTestnetFunds: "Solicitar fundos para Testnet",
|
28
|
+
backupWallet: "Fazer backup da carteira",
|
29
|
+
guestWalletWarning:
|
30
|
+
"Esta é uma carteira de convidado temporária. Faça um backup se não quiser perder o acesso a ela",
|
31
|
+
switchTo: "Trocar para",
|
32
|
+
connectedToSmartWallet: "carteira inteligente",
|
33
|
+
confirmInWallet: "Confirmar na carteira",
|
34
|
+
disconnectWallet: "Desconectar carteira",
|
35
|
+
copyAddress: "Copiar endereço",
|
36
|
+
personalWallet: "Carteira pessoal",
|
37
|
+
smartWallet: "Carteira inteligente",
|
38
|
+
or: "Ou",
|
39
|
+
goBackButton: "Voltar",
|
40
|
+
passkeys: {
|
41
|
+
title: "Chave de acesso",
|
42
|
+
linkPasskey: "Vincular uma chave de acesso",
|
43
|
+
},
|
44
|
+
welcomeScreen: {
|
45
|
+
defaultTitle: "Sua porta de entrada para o mundo descentralizado",
|
46
|
+
defaultSubtitle: "Conecte uma carteira para começar",
|
47
|
+
},
|
48
|
+
agreement: {
|
49
|
+
prefix: "Ao conectar, você aceita os",
|
50
|
+
termsOfService: "Termos de serviço",
|
51
|
+
and: "e",
|
52
|
+
privacyPolicy: "Política de privacidade",
|
53
|
+
},
|
54
|
+
networkSelector: {
|
55
|
+
title: "Selecionar rede",
|
56
|
+
mainnets: "Redes principais",
|
57
|
+
testnets: "Redes de teste",
|
58
|
+
allNetworks: "Todas",
|
59
|
+
addCustomNetwork: "Adicionar rede personalizada",
|
60
|
+
inputPlaceholder: "Buscar rede ou ID da cadeia",
|
61
|
+
categoryLabel: {
|
62
|
+
recentlyUsed: "Usadas recentemente",
|
63
|
+
popular: "Populares",
|
64
|
+
others: "Outras redes",
|
65
|
+
},
|
66
|
+
loading: "Carregando",
|
67
|
+
failedToSwitch: "Erro ao trocar de rede",
|
68
|
+
},
|
69
|
+
receiveFundsScreen: {
|
70
|
+
title: "Receber fundos",
|
71
|
+
instruction:
|
72
|
+
"Copie o endereço da carteira para enviar fundos para esta carteira",
|
73
|
+
},
|
74
|
+
sendFundsScreen: {
|
75
|
+
title: "Enviar fundos",
|
76
|
+
submitButton: "Enviar",
|
77
|
+
token: "Token",
|
78
|
+
sendTo: "Enviar para",
|
79
|
+
amount: "Quantidade",
|
80
|
+
successMessage: "Transação bem-sucedida",
|
81
|
+
invalidAddress: "Endereço inválido",
|
82
|
+
noTokensFound: "Nenhum token encontrado",
|
83
|
+
searchToken: "Buscar ou colar o endereço do token",
|
84
|
+
transactionFailed: "Transação falhou",
|
85
|
+
transactionRejected: "Transação rejeitada",
|
86
|
+
insufficientFunds: "Fundos insuficientes",
|
87
|
+
selectTokenTitle: "Selecione um Token",
|
88
|
+
sending: "Enviando",
|
89
|
+
},
|
90
|
+
signatureScreen: {
|
91
|
+
instructionScreen: {
|
92
|
+
title: "Entrar",
|
93
|
+
instruction:
|
94
|
+
"Por favor, assine a solicitação de mensagem na sua carteira para continuar",
|
95
|
+
signInButton: "Entrar",
|
96
|
+
disconnectWallet: "Desconectar carteira",
|
97
|
+
},
|
98
|
+
signingScreen: {
|
99
|
+
title: "Entrando",
|
100
|
+
prompt: "Assine a solicitação de assinatura na sua carteira",
|
101
|
+
promptForSafe:
|
102
|
+
"Assine a solicitação de assinatura na sua carteira e aprove a transação no Safe",
|
103
|
+
approveTransactionInSafe: "Aprovar transação no Safe",
|
104
|
+
tryAgain: "Tentar novamente",
|
105
|
+
failedToSignIn: "Erro ao entrar",
|
106
|
+
inProgress: "Aguardando confirmação",
|
107
|
+
},
|
108
|
+
},
|
109
|
+
manageWallet: {
|
110
|
+
title: "Gerenciar Carteira",
|
111
|
+
linkedProfiles: "Perfis vinculados",
|
112
|
+
linkProfile: "Vincular um perfil",
|
113
|
+
connectAnApp: "Conectar um Aplicativo",
|
114
|
+
exportPrivateKey: "Exportar chave privada",
|
115
|
+
},
|
116
|
+
viewFunds: {
|
117
|
+
title: "Ver Fundos",
|
118
|
+
viewNFTs: "Ver NFTs",
|
119
|
+
viewTokens: "Ver Tokens",
|
120
|
+
viewAssets: "Ver Ativos",
|
121
|
+
},
|
122
|
+
};
|
123
|
+
|
124
|
+
export default connectWalletLocalPtBr;
|
@@ -24,6 +24,9 @@ export async function getConnectLocale(localeId: LocaleId) {
|
|
24
24
|
case "fr_FR": {
|
25
25
|
return (await import("./fr.js")).default;
|
26
26
|
}
|
27
|
+
case "pt_BR": {
|
28
|
+
return (await import("./br.js")).default;
|
29
|
+
}
|
27
30
|
default: {
|
28
31
|
return (await import("./en.js")).default;
|
29
32
|
}
|
@@ -43,7 +43,9 @@ export function LinkProfileScreen(props: {
|
|
43
43
|
walletConnect={props.walletConnect}
|
44
44
|
wallet={activeWallet as Wallet<"inApp">}
|
45
45
|
done={() => {
|
46
|
-
|
46
|
+
setTimeout(() => {
|
47
|
+
queryClient.invalidateQueries({ queryKey: ["profiles"] });
|
48
|
+
}, 500);
|
47
49
|
props.onBack();
|
48
50
|
}}
|
49
51
|
connectLocale={props.locale}
|
@@ -67,7 +69,9 @@ export function LinkProfileScreen(props: {
|
|
67
69
|
<EcosystemWalletConnectUI
|
68
70
|
wallet={activeWallet as Wallet<EcosystemWalletId>}
|
69
71
|
done={() => {
|
70
|
-
|
72
|
+
setTimeout(() => {
|
73
|
+
queryClient.invalidateQueries({ queryKey: ["profiles"] });
|
74
|
+
}, 500);
|
71
75
|
props.onBack();
|
72
76
|
}}
|
73
77
|
connectLocale={props.locale}
|
@@ -164,7 +164,12 @@ export function AccountAvatar({
|
|
164
164
|
}: AccountAvatarProps) {
|
165
165
|
const { address, client } = useAccountContext();
|
166
166
|
const avatarQuery = useQuery({
|
167
|
-
queryKey: [
|
167
|
+
queryKey: [
|
168
|
+
"account-avatar",
|
169
|
+
address,
|
170
|
+
{ socialType },
|
171
|
+
{ resolverAddress, resolverChain },
|
172
|
+
],
|
168
173
|
queryFn: async (): Promise<string> => {
|
169
174
|
const [socialData, ensName] = await Promise.all([
|
170
175
|
getSocialProfiles({ address, client }),
|
@@ -57,7 +57,7 @@ export interface AccountNameProps
|
|
57
57
|
/**
|
58
58
|
* Optional `useQuery` params
|
59
59
|
*/
|
60
|
-
queryOptions?: Omit<UseQueryOptions<string>, "
|
60
|
+
queryOptions?: Omit<UseQueryOptions<string>, "queryFn" | "queryKey">;
|
61
61
|
}
|
62
62
|
|
63
63
|
/**
|
@@ -138,7 +138,12 @@ export function AccountName({
|
|
138
138
|
}: AccountNameProps) {
|
139
139
|
const { address, client } = useAccountContext();
|
140
140
|
const nameQuery = useQuery({
|
141
|
-
queryKey: [
|
141
|
+
queryKey: [
|
142
|
+
"account-name",
|
143
|
+
address,
|
144
|
+
{ socialType },
|
145
|
+
{ resolverAddress, resolverChain },
|
146
|
+
],
|
142
147
|
queryFn: async () => {
|
143
148
|
const [socialData, ensName] = await Promise.all([
|
144
149
|
getSocialProfiles({ address, client }),
|
@@ -1,7 +1,10 @@
|
|
1
|
+
"use client";
|
2
|
+
|
1
3
|
import { type UseQueryOptions, useQuery } from "@tanstack/react-query";
|
2
4
|
import type { JSX } from "react";
|
3
5
|
import { getChainMetadata } from "../../../../../chains/utils.js";
|
4
6
|
import type { ThirdwebClient } from "../../../../../client/client.js";
|
7
|
+
import { getFunctionId } from "../../../../../utils/function-id.js";
|
5
8
|
import { resolveScheme } from "../../../../../utils/ipfs.js";
|
6
9
|
import { useChainContext } from "./provider.js";
|
7
10
|
|
@@ -119,7 +122,18 @@ export function ChainIcon({
|
|
119
122
|
}: ChainIconProps) {
|
120
123
|
const { chain } = useChainContext();
|
121
124
|
const iconQuery = useQuery({
|
122
|
-
queryKey: [
|
125
|
+
queryKey: [
|
126
|
+
"_internal_chain_icon_",
|
127
|
+
chain.id,
|
128
|
+
{
|
129
|
+
resolver:
|
130
|
+
typeof iconResolver === "string"
|
131
|
+
? iconResolver
|
132
|
+
: typeof iconResolver === "function"
|
133
|
+
? getFunctionId(iconResolver)
|
134
|
+
: undefined,
|
135
|
+
},
|
136
|
+
] as const,
|
123
137
|
queryFn: async () => {
|
124
138
|
if (typeof iconResolver === "string") {
|
125
139
|
return iconResolver;
|
@@ -2,17 +2,17 @@ import { describe, expect, it } from "vitest";
|
|
2
2
|
import { render, screen, waitFor } from "~test/react-render.js";
|
3
3
|
import { ethereum } from "../../../../../chains/chain-definitions/ethereum.js";
|
4
4
|
import { defineChain } from "../../../../../chains/utils.js";
|
5
|
-
import { ChainName } from "./name.js";
|
5
|
+
import { ChainName, fetchChainName } from "./name.js";
|
6
6
|
import { ChainProvider } from "./provider.js";
|
7
7
|
|
8
8
|
describe.runIf(process.env.TW_SECRET_KEY)("ChainName component", () => {
|
9
|
-
it("should return the correct chain name, if the name exists in the chain object", () => {
|
9
|
+
it("should return the correct chain name, if the name exists in the chain object", async () => {
|
10
10
|
render(
|
11
11
|
<ChainProvider chain={ethereum}>
|
12
12
|
<ChainName />
|
13
13
|
</ChainProvider>,
|
14
14
|
);
|
15
|
-
waitFor(() =>
|
15
|
+
await waitFor(() =>
|
16
16
|
expect(
|
17
17
|
screen.getByText("Ethereum", {
|
18
18
|
exact: true,
|
@@ -22,13 +22,13 @@ describe.runIf(process.env.TW_SECRET_KEY)("ChainName component", () => {
|
|
22
22
|
);
|
23
23
|
});
|
24
24
|
|
25
|
-
it("should return the correct chain name, if the name is loaded from the server", () => {
|
25
|
+
it("should return the correct chain name, if the name is loaded from the server", async () => {
|
26
26
|
render(
|
27
27
|
<ChainProvider chain={defineChain(1)}>
|
28
28
|
<ChainName />
|
29
29
|
</ChainProvider>,
|
30
30
|
);
|
31
|
-
waitFor(() =>
|
31
|
+
await waitFor(() =>
|
32
32
|
expect(
|
33
33
|
screen.getByText("Ethereum Mainnet", {
|
34
34
|
exact: true,
|
@@ -38,13 +38,13 @@ describe.runIf(process.env.TW_SECRET_KEY)("ChainName component", () => {
|
|
38
38
|
);
|
39
39
|
});
|
40
40
|
|
41
|
-
it("should return the correct FORMATTED chain name", () => {
|
41
|
+
it("should return the correct FORMATTED chain name", async () => {
|
42
42
|
render(
|
43
43
|
<ChainProvider chain={ethereum}>
|
44
44
|
<ChainName formatFn={(str: string) => `${str}-formatted`} />
|
45
45
|
</ChainProvider>,
|
46
46
|
);
|
47
|
-
waitFor(() =>
|
47
|
+
await waitFor(() =>
|
48
48
|
expect(
|
49
49
|
screen.getByText("Ethereum-formatted", {
|
50
50
|
exact: true,
|
@@ -54,14 +54,14 @@ describe.runIf(process.env.TW_SECRET_KEY)("ChainName component", () => {
|
|
54
54
|
);
|
55
55
|
});
|
56
56
|
|
57
|
-
it("should fallback properly when fail to resolve chain name", () => {
|
57
|
+
it("should fallback properly when fail to resolve chain name", async () => {
|
58
58
|
render(
|
59
59
|
<ChainProvider chain={defineChain(-1)}>
|
60
60
|
<ChainName fallbackComponent={<span>oops</span>} />
|
61
61
|
</ChainProvider>,
|
62
62
|
);
|
63
63
|
|
64
|
-
waitFor(() =>
|
64
|
+
await waitFor(() =>
|
65
65
|
expect(
|
66
66
|
screen.getByText("oops", {
|
67
67
|
exact: true,
|
@@ -70,4 +70,31 @@ describe.runIf(process.env.TW_SECRET_KEY)("ChainName component", () => {
|
|
70
70
|
).toBeInTheDocument(),
|
71
71
|
);
|
72
72
|
});
|
73
|
+
|
74
|
+
it("fetchChainName should respect nameResolver as a string", async () => {
|
75
|
+
const res = await fetchChainName({
|
76
|
+
chain: ethereum,
|
77
|
+
nameResolver: "eth_mainnet",
|
78
|
+
});
|
79
|
+
expect(res).toBe("eth_mainnet");
|
80
|
+
});
|
81
|
+
|
82
|
+
it("fetchChainName should respect nameResolver as a non-async function", async () => {
|
83
|
+
const res = await fetchChainName({
|
84
|
+
chain: ethereum,
|
85
|
+
nameResolver: () => "eth_mainnet",
|
86
|
+
});
|
87
|
+
expect(res).toBe("eth_mainnet");
|
88
|
+
});
|
89
|
+
|
90
|
+
it("fetchChainName should respect nameResolver as an async function", async () => {
|
91
|
+
const res = await fetchChainName({
|
92
|
+
chain: ethereum,
|
93
|
+
nameResolver: async () => {
|
94
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
95
|
+
return "eth_mainnet";
|
96
|
+
},
|
97
|
+
});
|
98
|
+
expect(res).toBe("eth_mainnet");
|
99
|
+
});
|
73
100
|
});
|