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
@@ -3,7 +3,9 @@
|
|
3
3
|
import { type UseQueryOptions, useQuery } from "@tanstack/react-query";
|
4
4
|
import type React from "react";
|
5
5
|
import type { JSX } from "react";
|
6
|
+
import type { Chain } from "../../../../../chains/types.js";
|
6
7
|
import { getChainMetadata } from "../../../../../chains/utils.js";
|
8
|
+
import { getFunctionId } from "../../../../../utils/function-id.js";
|
7
9
|
import { useChainContext } from "./provider.js";
|
8
10
|
|
9
11
|
/**
|
@@ -155,19 +157,19 @@ export function ChainName({
|
|
155
157
|
}: ChainNameProps) {
|
156
158
|
const { chain } = useChainContext();
|
157
159
|
const nameQuery = useQuery({
|
158
|
-
queryKey: [
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
}
|
169
|
-
|
170
|
-
},
|
160
|
+
queryKey: [
|
161
|
+
"_internal_chain_name_",
|
162
|
+
chain.id,
|
163
|
+
{
|
164
|
+
resolver:
|
165
|
+
typeof nameResolver === "string"
|
166
|
+
? nameResolver
|
167
|
+
: typeof nameResolver === "function"
|
168
|
+
? getFunctionId(nameResolver)
|
169
|
+
: undefined,
|
170
|
+
},
|
171
|
+
] as const,
|
172
|
+
queryFn: async () => fetchChainName({ chain, nameResolver }),
|
171
173
|
...queryOptions,
|
172
174
|
});
|
173
175
|
|
@@ -183,3 +185,23 @@ export function ChainName({
|
|
183
185
|
|
184
186
|
return <span {...restProps}>{displayValue}</span>;
|
185
187
|
}
|
188
|
+
|
189
|
+
/**
|
190
|
+
* @internal Exported for tests only
|
191
|
+
*/
|
192
|
+
export async function fetchChainName(props: {
|
193
|
+
chain: Chain;
|
194
|
+
nameResolver?: string | (() => string) | (() => Promise<string>);
|
195
|
+
}) {
|
196
|
+
const { nameResolver, chain } = props;
|
197
|
+
if (typeof nameResolver === "string") {
|
198
|
+
return nameResolver;
|
199
|
+
}
|
200
|
+
if (typeof nameResolver === "function") {
|
201
|
+
return nameResolver();
|
202
|
+
}
|
203
|
+
if (chain.name) {
|
204
|
+
return chain.name;
|
205
|
+
}
|
206
|
+
return getChainMetadata(chain).then((data) => data.name);
|
207
|
+
}
|
@@ -3,6 +3,7 @@
|
|
3
3
|
import { type UseQueryOptions, useQuery } from "@tanstack/react-query";
|
4
4
|
import type { JSX } from "react";
|
5
5
|
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
6
|
+
import { getFunctionId } from "../../../../../utils/function-id.js";
|
6
7
|
import { useNFTContext } from "./provider.js";
|
7
8
|
import { getNFTInfo } from "./utils.js";
|
8
9
|
|
@@ -100,7 +101,7 @@ export function NFTDescription({
|
|
100
101
|
typeof descriptionResolver === "string"
|
101
102
|
? descriptionResolver
|
102
103
|
: typeof descriptionResolver === "function"
|
103
|
-
? descriptionResolver
|
104
|
+
? getFunctionId(descriptionResolver)
|
104
105
|
: undefined,
|
105
106
|
},
|
106
107
|
],
|
@@ -1,6 +1,9 @@
|
|
1
|
+
"use client";
|
2
|
+
|
1
3
|
import { type UseQueryOptions, useQuery } from "@tanstack/react-query";
|
2
4
|
import type { JSX } from "react";
|
3
5
|
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
6
|
+
import { getFunctionId } from "../../../../../utils/function-id.js";
|
4
7
|
import { MediaRenderer } from "../../MediaRenderer/MediaRenderer.js";
|
5
8
|
import type { MediaRendererProps } from "../../MediaRenderer/types.js";
|
6
9
|
import { useNFTContext } from "./provider.js";
|
@@ -138,7 +141,7 @@ export function NFTMedia({
|
|
138
141
|
typeof mediaResolver === "object"
|
139
142
|
? mediaResolver
|
140
143
|
: typeof mediaResolver === "function"
|
141
|
-
? mediaResolver
|
144
|
+
? getFunctionId(mediaResolver)
|
142
145
|
: undefined,
|
143
146
|
},
|
144
147
|
],
|
@@ -1,6 +1,9 @@
|
|
1
|
+
"use client";
|
2
|
+
|
1
3
|
import { type UseQueryOptions, useQuery } from "@tanstack/react-query";
|
2
4
|
import type { JSX } from "react";
|
3
5
|
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
6
|
+
import { getFunctionId } from "../../../../../utils/function-id.js";
|
4
7
|
import { useNFTContext } from "./provider.js";
|
5
8
|
import { getNFTInfo } from "./utils.js";
|
6
9
|
|
@@ -100,7 +103,7 @@ export function NFTName({
|
|
100
103
|
typeof nameResolver === "string"
|
101
104
|
? nameResolver
|
102
105
|
: typeof nameResolver === "function"
|
103
|
-
? nameResolver
|
106
|
+
? getFunctionId(nameResolver)
|
104
107
|
: undefined,
|
105
108
|
},
|
106
109
|
],
|
@@ -1,9 +1,12 @@
|
|
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 { NATIVE_TOKEN_ADDRESS } from "../../../../../constants/addresses.js";
|
5
7
|
import { getContract } from "../../../../../contract/contract.js";
|
6
8
|
import { getContractMetadata } from "../../../../../extensions/common/read/getContractMetadata.js";
|
9
|
+
import { getFunctionId } from "../../../../../utils/function-id.js";
|
7
10
|
import { resolveScheme } from "../../../../../utils/ipfs.js";
|
8
11
|
import { useTokenContext } from "./provider.js";
|
9
12
|
|
@@ -115,7 +118,19 @@ export function TokenIcon({
|
|
115
118
|
}: TokenIconProps) {
|
116
119
|
const { address, client, chain } = useTokenContext();
|
117
120
|
const iconQuery = useQuery({
|
118
|
-
queryKey: [
|
121
|
+
queryKey: [
|
122
|
+
"_internal_token_icon_",
|
123
|
+
chain.id,
|
124
|
+
address,
|
125
|
+
{
|
126
|
+
resolver:
|
127
|
+
typeof iconResolver === "string"
|
128
|
+
? iconResolver
|
129
|
+
: typeof iconResolver === "function"
|
130
|
+
? getFunctionId(iconResolver)
|
131
|
+
: undefined,
|
132
|
+
},
|
133
|
+
] as const,
|
119
134
|
queryFn: async () => {
|
120
135
|
if (typeof iconResolver === "string") {
|
121
136
|
return iconResolver;
|
@@ -0,0 +1,148 @@
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
2
|
+
import { ANVIL_CHAIN } from "~test/chains.js";
|
3
|
+
import {} from "~test/react-render.js";
|
4
|
+
import { TEST_CLIENT } from "~test/test-clients.js";
|
5
|
+
import {
|
6
|
+
UNISWAPV3_FACTORY_CONTRACT,
|
7
|
+
USDT_CONTRACT,
|
8
|
+
} from "~test/test-contracts.js";
|
9
|
+
import { ethereum } from "../../../../../chains/chain-definitions/ethereum.js";
|
10
|
+
import { NATIVE_TOKEN_ADDRESS } from "../../../../../constants/addresses.js";
|
11
|
+
import { getFunctionId } from "../../../../../utils/function-id.js";
|
12
|
+
import { fetchTokenName, getQueryKeys } from "./name.js";
|
13
|
+
|
14
|
+
const client = TEST_CLIENT;
|
15
|
+
|
16
|
+
describe.runIf(process.env.TW_SECRET_KEY)("TokenName component", () => {
|
17
|
+
it("fetchTokenName should respect the nameResolver being a string", async () => {
|
18
|
+
const res = await fetchTokenName({
|
19
|
+
address: "thing",
|
20
|
+
client,
|
21
|
+
chain: ANVIL_CHAIN,
|
22
|
+
nameResolver: "tw",
|
23
|
+
});
|
24
|
+
expect(res).toBe("tw");
|
25
|
+
});
|
26
|
+
|
27
|
+
it("fetchTokenName should respect the nameResolver being a non-async function", async () => {
|
28
|
+
const res = await fetchTokenName({
|
29
|
+
address: "thing",
|
30
|
+
client,
|
31
|
+
chain: ANVIL_CHAIN,
|
32
|
+
nameResolver: () => "tw",
|
33
|
+
});
|
34
|
+
|
35
|
+
expect(res).toBe("tw");
|
36
|
+
});
|
37
|
+
|
38
|
+
it("fetchTokenName should respect the nameResolver being an async function", async () => {
|
39
|
+
const res = await fetchTokenName({
|
40
|
+
address: "thing",
|
41
|
+
client,
|
42
|
+
chain: ANVIL_CHAIN,
|
43
|
+
nameResolver: async () => {
|
44
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
45
|
+
return "tw";
|
46
|
+
},
|
47
|
+
});
|
48
|
+
|
49
|
+
expect(res).toBe("tw");
|
50
|
+
});
|
51
|
+
|
52
|
+
it("fetchTokenName should work for contract with `name` function", async () => {
|
53
|
+
const res = await fetchTokenName({
|
54
|
+
address: USDT_CONTRACT.address,
|
55
|
+
client,
|
56
|
+
chain: USDT_CONTRACT.chain,
|
57
|
+
});
|
58
|
+
|
59
|
+
expect(res).toBe("Tether USD");
|
60
|
+
});
|
61
|
+
|
62
|
+
it("fetchTokenName should work for native token", async () => {
|
63
|
+
const res = await fetchTokenName({
|
64
|
+
address: NATIVE_TOKEN_ADDRESS,
|
65
|
+
client,
|
66
|
+
chain: ethereum,
|
67
|
+
});
|
68
|
+
|
69
|
+
expect(res).toBe("Ether");
|
70
|
+
});
|
71
|
+
|
72
|
+
it("fetchTokenName should try to fallback to the contract metadata if fails to resolves from `name()`", async () => {
|
73
|
+
// todo: find a contract with name in contractMetadata, but does not have a name function
|
74
|
+
});
|
75
|
+
|
76
|
+
it("fetchTokenName should throw in the end where all fallback solutions failed to resolve to any name", async () => {
|
77
|
+
await expect(() =>
|
78
|
+
fetchTokenName({
|
79
|
+
address: UNISWAPV3_FACTORY_CONTRACT.address,
|
80
|
+
client,
|
81
|
+
chain: UNISWAPV3_FACTORY_CONTRACT.chain,
|
82
|
+
}),
|
83
|
+
).rejects.toThrowError(
|
84
|
+
"Failed to resolve name from both name() and contract metadata",
|
85
|
+
);
|
86
|
+
});
|
87
|
+
|
88
|
+
it("getQueryKeys should work without resolver", () => {
|
89
|
+
expect(getQueryKeys({ chainId: 1, address: "0x" })).toStrictEqual([
|
90
|
+
"_internal_token_name_",
|
91
|
+
1,
|
92
|
+
"0x",
|
93
|
+
{
|
94
|
+
resolver: undefined,
|
95
|
+
},
|
96
|
+
]);
|
97
|
+
});
|
98
|
+
|
99
|
+
it("getQueryKeys should work with resolver being a string", () => {
|
100
|
+
expect(
|
101
|
+
getQueryKeys({ chainId: 1, address: "0x", nameResolver: "tw" }),
|
102
|
+
).toStrictEqual([
|
103
|
+
"_internal_token_name_",
|
104
|
+
1,
|
105
|
+
"0x",
|
106
|
+
{
|
107
|
+
resolver: "tw",
|
108
|
+
},
|
109
|
+
]);
|
110
|
+
});
|
111
|
+
|
112
|
+
it("getQueryKeys should work with resolver being a non-async fn that returns a string", () => {
|
113
|
+
const fn = () => "tw";
|
114
|
+
const fnId = getFunctionId(fn);
|
115
|
+
expect(
|
116
|
+
getQueryKeys({ chainId: 1, address: "0x", nameResolver: fn }),
|
117
|
+
).toStrictEqual([
|
118
|
+
"_internal_token_name_",
|
119
|
+
1,
|
120
|
+
"0x",
|
121
|
+
{
|
122
|
+
resolver: fnId,
|
123
|
+
},
|
124
|
+
]);
|
125
|
+
});
|
126
|
+
|
127
|
+
it("getQueryKeys should work with resolver being an async fn that returns a string", () => {
|
128
|
+
const fn = async () => {
|
129
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
130
|
+
return "tw";
|
131
|
+
};
|
132
|
+
const fnId = getFunctionId(fn);
|
133
|
+
expect(
|
134
|
+
getQueryKeys({
|
135
|
+
chainId: 1,
|
136
|
+
address: "0x",
|
137
|
+
nameResolver: fn,
|
138
|
+
}),
|
139
|
+
).toStrictEqual([
|
140
|
+
"_internal_token_name_",
|
141
|
+
1,
|
142
|
+
"0x",
|
143
|
+
{
|
144
|
+
resolver: fnId,
|
145
|
+
},
|
146
|
+
]);
|
147
|
+
});
|
148
|
+
});
|
@@ -3,11 +3,14 @@
|
|
3
3
|
import { type UseQueryOptions, useQuery } from "@tanstack/react-query";
|
4
4
|
import type React from "react";
|
5
5
|
import type { JSX } from "react";
|
6
|
+
import type { Chain } from "../../../../../chains/types.js";
|
6
7
|
import { getChainMetadata } from "../../../../../chains/utils.js";
|
8
|
+
import type { ThirdwebClient } from "../../../../../client/client.js";
|
7
9
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../../constants/addresses.js";
|
8
10
|
import { getContract } from "../../../../../contract/contract.js";
|
9
11
|
import { getContractMetadata } from "../../../../../extensions/common/read/getContractMetadata.js";
|
10
12
|
import { name } from "../../../../../extensions/common/read/name.js";
|
13
|
+
import { getFunctionId } from "../../../../../utils/function-id.js";
|
11
14
|
import { useTokenContext } from "./provider.js";
|
12
15
|
|
13
16
|
/**
|
@@ -157,33 +160,9 @@ export function TokenName({
|
|
157
160
|
}: TokenNameProps) {
|
158
161
|
const { address, client, chain } = useTokenContext();
|
159
162
|
const nameQuery = useQuery({
|
160
|
-
queryKey:
|
161
|
-
queryFn: async () =>
|
162
|
-
|
163
|
-
return nameResolver;
|
164
|
-
}
|
165
|
-
if (typeof nameResolver === "function") {
|
166
|
-
return nameResolver();
|
167
|
-
}
|
168
|
-
if (address.toLowerCase() === NATIVE_TOKEN_ADDRESS.toLowerCase()) {
|
169
|
-
// Don't wanna use `getChainNativeCurrencyName` because it has some side effect (it catches error and defaults to "ETH")
|
170
|
-
return getChainMetadata(chain).then((data) => data.nativeCurrency.name);
|
171
|
-
}
|
172
|
-
// Try to fetch the name from both the `name()` function and the contract metadata
|
173
|
-
// then prioritize the `name()`
|
174
|
-
const contract = getContract({ address, client, chain });
|
175
|
-
const [_name, contractMetadata] = await Promise.all([
|
176
|
-
name({ contract }),
|
177
|
-
getContractMetadata({ contract }),
|
178
|
-
]);
|
179
|
-
if (!_name && !contractMetadata.name) {
|
180
|
-
throw new Error(
|
181
|
-
"Failed to resolve name from both name() and contract metadata",
|
182
|
-
);
|
183
|
-
}
|
184
|
-
|
185
|
-
return _name || contractMetadata.name;
|
186
|
-
},
|
163
|
+
queryKey: getQueryKeys({ chainId: chain.id, nameResolver, address }),
|
164
|
+
queryFn: async () =>
|
165
|
+
fetchTokenName({ address, chain, client, nameResolver }),
|
187
166
|
...queryOptions,
|
188
167
|
});
|
189
168
|
|
@@ -195,7 +174,72 @@ export function TokenName({
|
|
195
174
|
return fallbackComponent || null;
|
196
175
|
}
|
197
176
|
|
198
|
-
|
177
|
+
if (formatFn && typeof formatFn === "function") {
|
178
|
+
return <span {...restProps}>{formatFn(nameQuery.data)}</span>;
|
179
|
+
}
|
180
|
+
|
181
|
+
return <span {...restProps}>{nameQuery.data}</span>;
|
182
|
+
}
|
183
|
+
|
184
|
+
/**
|
185
|
+
* @internal Exported for tests only
|
186
|
+
*/
|
187
|
+
export async function fetchTokenName(props: {
|
188
|
+
address: string;
|
189
|
+
client: ThirdwebClient;
|
190
|
+
chain: Chain;
|
191
|
+
nameResolver?: string | (() => string) | (() => Promise<string>);
|
192
|
+
}) {
|
193
|
+
const { nameResolver, address, client, chain } = props;
|
194
|
+
if (typeof nameResolver === "string") {
|
195
|
+
return nameResolver;
|
196
|
+
}
|
197
|
+
if (typeof nameResolver === "function") {
|
198
|
+
return nameResolver();
|
199
|
+
}
|
200
|
+
if (address.toLowerCase() === NATIVE_TOKEN_ADDRESS.toLowerCase()) {
|
201
|
+
// Don't wanna use `getChainName` because it has some side effect (it catches error and defaults to "ETH")
|
202
|
+
return getChainMetadata(chain).then((data) => data.nativeCurrency.name);
|
203
|
+
}
|
204
|
+
|
205
|
+
// Try to fetch the name from both the `name` function and the contract metadata
|
206
|
+
// then prioritize its result
|
207
|
+
const contract = getContract({ address, client, chain });
|
208
|
+
const [_name, contractMetadata] = await Promise.all([
|
209
|
+
name({ contract }).catch(() => undefined),
|
210
|
+
getContractMetadata({ contract }).catch(() => undefined),
|
211
|
+
]);
|
212
|
+
if (typeof _name === "string") {
|
213
|
+
return _name;
|
214
|
+
}
|
215
|
+
if (typeof contractMetadata?.name === "string") {
|
216
|
+
return contractMetadata.name;
|
217
|
+
}
|
218
|
+
throw new Error(
|
219
|
+
"Failed to resolve name from both name() and contract metadata",
|
220
|
+
);
|
221
|
+
}
|
199
222
|
|
200
|
-
|
223
|
+
/**
|
224
|
+
* @internal
|
225
|
+
*/
|
226
|
+
export function getQueryKeys(props: {
|
227
|
+
chainId: number;
|
228
|
+
address: string;
|
229
|
+
nameResolver?: string | (() => string) | (() => Promise<string>);
|
230
|
+
}) {
|
231
|
+
const { chainId, address, nameResolver } = props;
|
232
|
+
return [
|
233
|
+
"_internal_token_name_",
|
234
|
+
chainId,
|
235
|
+
address,
|
236
|
+
{
|
237
|
+
resolver:
|
238
|
+
typeof nameResolver === "string"
|
239
|
+
? nameResolver
|
240
|
+
: typeof nameResolver === "function"
|
241
|
+
? getFunctionId(nameResolver)
|
242
|
+
: undefined,
|
243
|
+
},
|
244
|
+
] as const;
|
201
245
|
}
|
@@ -5,6 +5,7 @@ import { ethereum } from "../../../../../chains/chain-definitions/ethereum.js";
|
|
5
5
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../../constants/addresses.js";
|
6
6
|
import { TokenName } from "./name.js";
|
7
7
|
import { TokenProvider } from "./provider.js";
|
8
|
+
import { TokenSymbol } from "./symbol.js";
|
8
9
|
|
9
10
|
describe.runIf(process.env.TW_SECRET_KEY)("TokenProvider component", () => {
|
10
11
|
it("should render children correctly", () => {
|
@@ -29,6 +30,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("TokenProvider component", () => {
|
|
29
30
|
chain={ethereum}
|
30
31
|
>
|
31
32
|
<TokenName />
|
33
|
+
<TokenSymbol />
|
32
34
|
</TokenProvider>,
|
33
35
|
);
|
34
36
|
|
@@ -40,5 +42,14 @@ describe.runIf(process.env.TW_SECRET_KEY)("TokenProvider component", () => {
|
|
40
42
|
}),
|
41
43
|
).toBeInTheDocument(),
|
42
44
|
);
|
45
|
+
|
46
|
+
waitFor(() =>
|
47
|
+
expect(
|
48
|
+
screen.getByText("ETH", {
|
49
|
+
exact: true,
|
50
|
+
selector: "span",
|
51
|
+
}),
|
52
|
+
).toBeInTheDocument(),
|
53
|
+
);
|
43
54
|
});
|
44
55
|
});
|
@@ -1,30 +1,148 @@
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
2
|
-
import {
|
2
|
+
import { ANVIL_CHAIN } from "~test/chains.js";
|
3
|
+
import {} from "~test/react-render.js";
|
3
4
|
import { TEST_CLIENT } from "~test/test-clients.js";
|
5
|
+
import {
|
6
|
+
UNISWAPV3_FACTORY_CONTRACT,
|
7
|
+
USDT_CONTRACT,
|
8
|
+
} from "~test/test-contracts.js";
|
4
9
|
import { ethereum } from "../../../../../chains/chain-definitions/ethereum.js";
|
5
10
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../../constants/addresses.js";
|
6
|
-
import {
|
7
|
-
import {
|
11
|
+
import { getFunctionId } from "../../../../../utils/function-id.js";
|
12
|
+
import { fetchTokenSymbol, getQueryKeys } from "./symbol.js";
|
13
|
+
|
14
|
+
const client = TEST_CLIENT;
|
8
15
|
|
9
16
|
describe.runIf(process.env.TW_SECRET_KEY)("TokenSymbol component", () => {
|
10
|
-
it("should
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
it("fetchTokenSymbol should respect the symbolResolver being a string", async () => {
|
18
|
+
const res = await fetchTokenSymbol({
|
19
|
+
address: "thing",
|
20
|
+
client,
|
21
|
+
chain: ANVIL_CHAIN,
|
22
|
+
symbolResolver: "tw",
|
23
|
+
});
|
24
|
+
expect(res).toBe("tw");
|
25
|
+
});
|
26
|
+
|
27
|
+
it("fetchTokenSymbol should respect the symbolResolver being a non-async function", async () => {
|
28
|
+
const res = await fetchTokenSymbol({
|
29
|
+
address: "thing",
|
30
|
+
client,
|
31
|
+
chain: ANVIL_CHAIN,
|
32
|
+
symbolResolver: () => "tw",
|
33
|
+
});
|
34
|
+
|
35
|
+
expect(res).toBe("tw");
|
36
|
+
});
|
37
|
+
|
38
|
+
it("fetchTokenSymbol should respect the symbolResolver being an async function", async () => {
|
39
|
+
const res = await fetchTokenSymbol({
|
40
|
+
address: "thing",
|
41
|
+
client,
|
42
|
+
chain: ANVIL_CHAIN,
|
43
|
+
symbolResolver: async () => {
|
44
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
45
|
+
return "tw";
|
46
|
+
},
|
47
|
+
});
|
48
|
+
|
49
|
+
expect(res).toBe("tw");
|
50
|
+
});
|
51
|
+
|
52
|
+
it("fetchTokenSymbol should work for contract with `symbol` function", async () => {
|
53
|
+
const res = await fetchTokenSymbol({
|
54
|
+
address: USDT_CONTRACT.address,
|
55
|
+
client,
|
56
|
+
chain: USDT_CONTRACT.chain,
|
57
|
+
});
|
58
|
+
|
59
|
+
expect(res).toBe("USDT");
|
60
|
+
});
|
61
|
+
|
62
|
+
it("fetchTokenSymbol should work for native token", async () => {
|
63
|
+
const res = await fetchTokenSymbol({
|
64
|
+
address: NATIVE_TOKEN_ADDRESS,
|
65
|
+
client,
|
66
|
+
chain: ethereum,
|
67
|
+
});
|
20
68
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
69
|
+
expect(res).toBe("ETH");
|
70
|
+
});
|
71
|
+
|
72
|
+
it("fetchTokenSymbol should try to fallback to the contract metadata if fails to resolves from `symbol()`", async () => {
|
73
|
+
// todo: find a contract with symbol in contractMetadata, but does not have a symbol function
|
74
|
+
});
|
75
|
+
|
76
|
+
it("fetchTokenSymbol should throw in the end where all fallback solutions failed to resolve to any symbol", async () => {
|
77
|
+
await expect(() =>
|
78
|
+
fetchTokenSymbol({
|
79
|
+
address: UNISWAPV3_FACTORY_CONTRACT.address,
|
80
|
+
client,
|
81
|
+
chain: UNISWAPV3_FACTORY_CONTRACT.chain,
|
82
|
+
}),
|
83
|
+
).rejects.toThrowError(
|
84
|
+
"Failed to resolve symbol from both symbol() and contract metadata",
|
28
85
|
);
|
29
86
|
});
|
87
|
+
|
88
|
+
it("getQueryKeys should work without resolver", () => {
|
89
|
+
expect(getQueryKeys({ chainId: 1, address: "0x" })).toStrictEqual([
|
90
|
+
"_internal_token_symbol_",
|
91
|
+
1,
|
92
|
+
"0x",
|
93
|
+
{
|
94
|
+
resolver: undefined,
|
95
|
+
},
|
96
|
+
]);
|
97
|
+
});
|
98
|
+
|
99
|
+
it("getQueryKeys should work with resolver being a string", () => {
|
100
|
+
expect(
|
101
|
+
getQueryKeys({ chainId: 1, address: "0x", symbolResolver: "tw" }),
|
102
|
+
).toStrictEqual([
|
103
|
+
"_internal_token_symbol_",
|
104
|
+
1,
|
105
|
+
"0x",
|
106
|
+
{
|
107
|
+
resolver: "tw",
|
108
|
+
},
|
109
|
+
]);
|
110
|
+
});
|
111
|
+
|
112
|
+
it("getQueryKeys should work with resolver being a non-async fn that returns a string", () => {
|
113
|
+
const fn = () => "tw";
|
114
|
+
const fnId = getFunctionId(fn);
|
115
|
+
expect(
|
116
|
+
getQueryKeys({ chainId: 1, address: "0x", symbolResolver: fn }),
|
117
|
+
).toStrictEqual([
|
118
|
+
"_internal_token_symbol_",
|
119
|
+
1,
|
120
|
+
"0x",
|
121
|
+
{
|
122
|
+
resolver: fnId,
|
123
|
+
},
|
124
|
+
]);
|
125
|
+
});
|
126
|
+
|
127
|
+
it("getQueryKeys should work with resolver being an async fn that returns a string", () => {
|
128
|
+
const fn = async () => {
|
129
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
130
|
+
return "tw";
|
131
|
+
};
|
132
|
+
const fnId = getFunctionId(fn);
|
133
|
+
expect(
|
134
|
+
getQueryKeys({
|
135
|
+
chainId: 1,
|
136
|
+
address: "0x",
|
137
|
+
symbolResolver: fn,
|
138
|
+
}),
|
139
|
+
).toStrictEqual([
|
140
|
+
"_internal_token_symbol_",
|
141
|
+
1,
|
142
|
+
"0x",
|
143
|
+
{
|
144
|
+
resolver: fnId,
|
145
|
+
},
|
146
|
+
]);
|
147
|
+
});
|
30
148
|
});
|