thirdweb 5.71.0 → 5.72.0-nightly-a98550d229e7fd124e1977fcc64dbd1b602ce656-20241126000403

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.
Files changed (45) hide show
  1. package/dist/cjs/exports/react.js +8 -1
  2. package/dist/cjs/exports/react.js.map +1 -1
  3. package/dist/cjs/react/web/ui/prebuilt/Chain/icon.js +96 -0
  4. package/dist/cjs/react/web/ui/prebuilt/Chain/icon.js.map +1 -0
  5. package/dist/cjs/react/web/ui/prebuilt/Chain/name.js +124 -0
  6. package/dist/cjs/react/web/ui/prebuilt/Chain/name.js.map +1 -0
  7. package/dist/cjs/react/web/ui/prebuilt/Chain/provider.js +54 -0
  8. package/dist/cjs/react/web/ui/prebuilt/Chain/provider.js.map +1 -0
  9. package/dist/cjs/react/web/ui/prebuilt/Token/icon.js.map +1 -1
  10. package/dist/cjs/version.js +1 -1
  11. package/dist/cjs/version.js.map +1 -1
  12. package/dist/esm/exports/react.js +4 -0
  13. package/dist/esm/exports/react.js.map +1 -1
  14. package/dist/esm/react/web/ui/prebuilt/Chain/icon.js +93 -0
  15. package/dist/esm/react/web/ui/prebuilt/Chain/icon.js.map +1 -0
  16. package/dist/esm/react/web/ui/prebuilt/Chain/name.js +121 -0
  17. package/dist/esm/react/web/ui/prebuilt/Chain/name.js.map +1 -0
  18. package/dist/esm/react/web/ui/prebuilt/Chain/provider.js +50 -0
  19. package/dist/esm/react/web/ui/prebuilt/Chain/provider.js.map +1 -0
  20. package/dist/esm/react/web/ui/prebuilt/Token/icon.js.map +1 -1
  21. package/dist/esm/version.js +1 -1
  22. package/dist/esm/version.js.map +1 -1
  23. package/dist/types/exports/react.d.ts +3 -0
  24. package/dist/types/exports/react.d.ts.map +1 -1
  25. package/dist/types/react/web/ui/prebuilt/Chain/icon.d.ts +106 -0
  26. package/dist/types/react/web/ui/prebuilt/Chain/icon.d.ts.map +1 -0
  27. package/dist/types/react/web/ui/prebuilt/Chain/name.d.ts +142 -0
  28. package/dist/types/react/web/ui/prebuilt/Chain/name.d.ts.map +1 -0
  29. package/dist/types/react/web/ui/prebuilt/Chain/provider.d.ts +48 -0
  30. package/dist/types/react/web/ui/prebuilt/Chain/provider.d.ts.map +1 -0
  31. package/dist/types/react/web/ui/prebuilt/Token/icon.d.ts +5 -0
  32. package/dist/types/react/web/ui/prebuilt/Token/icon.d.ts.map +1 -1
  33. package/dist/types/version.d.ts +1 -1
  34. package/dist/types/version.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/exports/react.ts +14 -0
  37. package/src/react/web/ui/prebuilt/Chain/icon.tsx +154 -0
  38. package/src/react/web/ui/prebuilt/Chain/name.test.tsx +73 -0
  39. package/src/react/web/ui/prebuilt/Chain/name.tsx +185 -0
  40. package/src/react/web/ui/prebuilt/Chain/provider.test.tsx +34 -0
  41. package/src/react/web/ui/prebuilt/Chain/provider.tsx +73 -0
  42. package/src/react/web/ui/prebuilt/Token/icon.tsx +5 -0
  43. package/src/react/web/ui/prebuilt/Token/provider.test.tsx +44 -0
  44. package/src/react/web/ui/prebuilt/Token/symbol.test.tsx +30 -0
  45. package/src/version.ts +1 -1
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext } from "react";
4
+ const ChainProviderContext = /* @__PURE__ */ createContext(undefined);
5
+ /**
6
+ * A React context provider component that supplies Chain-related data to its child components.
7
+ *
8
+ * This component serves as a wrapper around the `ChainProviderContext.Provider` and passes
9
+ * the provided chain data down to all of its child components through the context API.
10
+ *
11
+ * @example
12
+ * ### Basic usage
13
+ * ```tsx
14
+ * import { ChainProvider, ChainIcon, ChainName } from "thirdweb/react";
15
+ * import { ethereum } from "thirdweb/chains";
16
+ *
17
+ * <ChainProvider chain={ethereum}>
18
+ * <ChainIcon />
19
+ * <ChainName />
20
+ * </ChainProvider>
21
+ * ```
22
+ *
23
+ * ### Usage with defineChain
24
+ * ```tsx
25
+ * import { defineChain } from "thirdweb/chains"l
26
+ * import { ChainProvider, ChainName } from "thirdweb/react";
27
+ *
28
+ * const chainId = someNumber;
29
+ *
30
+ * <ChainProvider chain={defineChain(chainId)}>
31
+ * <ChainName />
32
+ * </ChainProvider>
33
+ * ```
34
+ * @component
35
+ * @chain
36
+ */
37
+ export function ChainProvider(props) {
38
+ return (_jsx(ChainProviderContext.Provider, { value: props, children: props.children }));
39
+ }
40
+ /**
41
+ * @internal
42
+ */
43
+ export function useChainContext() {
44
+ const ctx = useContext(ChainProviderContext);
45
+ if (!ctx) {
46
+ throw new Error("ChainProviderContext not found. Make sure you are using ChainName, ChainIcon, etc. inside a <ChainProvider /> component");
47
+ }
48
+ return ctx;
49
+ }
50
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/prebuilt/Chain/provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAYlD,MAAM,oBAAoB,GAAG,eAAe,CAAC,aAAa,CAExD,SAAS,CAAC,CAAC;AAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAkD;IAElD,OAAO,CACL,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACxC,KAAK,CAAC,QAAQ,GACe,CACjC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,GAAG,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAC7C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,yHAAyH,CAC1H,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"icon.js","sourceRoot":"","sources":["../../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AAG,MAAM,mBAAmB,CAAC;gBACjD,QAAQ,EAAE,WAAW,CAAC;oBACpB,OAAO;oBACP,KAAK;oBACL,MAAM;iBACP,CAAC;aACH,CAAC,CAAC;YAEH,IACE,CAAC,gBAAgB,CAAC,KAAK;gBACvB,OAAO,gBAAgB,CAAC,KAAK,KAAK,QAAQ,EAC1C,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;YACzE,CAAC;YAED,OAAO,aAAa,CAAC;gBACnB,GAAG,EAAE,gBAAgB,CAAC,KAAK;gBAC3B,MAAM;aACP,CAAC,CAAC;QACL,CAAC;QACD,GAAG,YAAY;KAChB,CAAC,CAAC;IAEH,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;QACxB,OAAO,gBAAgB,IAAI,IAAI,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACpB,OAAO,iBAAiB,IAAI,IAAI,CAAC;IACnC,CAAC;IAED,OAAO,cAAK,GAAG,EAAE,SAAS,CAAC,IAAI,KAAM,SAAS,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,GAAI,CAAC;AACzE,CAAC"}
@@ -1,2 +1,2 @@
1
- export const version = "5.71.0";
1
+ export const version = "5.72.0-nightly-a98550d229e7fd124e1977fcc64dbd1b602ce656-20241126000403";
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,wEAAwE,CAAC"}
@@ -97,4 +97,7 @@ export { TokenProvider, type TokenProviderProps, } from "../react/web/ui/prebuil
97
97
  export { TokenName, type TokenNameProps, } from "../react/web/ui/prebuilt/Token/name.js";
98
98
  export { TokenSymbol, type TokenSymbolProps, } from "../react/web/ui/prebuilt/Token/symbol.js";
99
99
  export { TokenIcon, type TokenIconProps, } from "../react/web/ui/prebuilt/Token/icon.js";
100
+ export { ChainProvider, type ChainProviderProps, } from "../react/web/ui/prebuilt/Chain/provider.js";
101
+ export { ChainName, type ChainNameProps, } from "../react/web/ui/prebuilt/Chain/name.js";
102
+ export { ChainIcon, type ChainIconProps, } from "../react/web/ui/prebuilt/Chain/icon.js";
100
103
  //# sourceMappingURL=react.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/exports/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAC7E,YAAY,EACV,KAAK,EACL,cAAc,GACf,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,qDAAqD,CAAC;AACnF,YAAY,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAE7F,YAAY,EACV,kBAAkB,EAClB,kCAAkC,EAClC,iCAAiC,EACjC,kCAAkC,EAClC,iCAAiC,GAClC,MAAM,sDAAsD,CAAC;AAC9D,YAAY,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,YAAY,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AACpF,YAAY,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,YAAY,EAAE,sBAAsB,EAAE,MAAM,6DAA6D,CAAC;AAE1G,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAG/E,YAAY,EACV,eAAe,EACf,SAAS,GACV,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,aAAa,EACb,eAAe,GAChB,MAAM,sCAAsC,CAAC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6CAA6C,CAAC;AACrD,OAAO,EACL,cAAc,EACd,KAAK,mBAAmB,GACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,WAAW,EACX,KAAK,gBAAgB,GACtB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAC7E,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,GAC1B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACL,SAAS,EACT,KAAK,cAAc,GACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,WAAW,EACX,KAAK,gBAAgB,GACtB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,SAAS,EACT,KAAK,cAAc,GACpB,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACL,SAAS,EACT,KAAK,cAAc,GACpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,SAAS,EACT,KAAK,cAAc,GACpB,MAAM,wCAAwC,CAAC"}
@@ -0,0 +1,106 @@
1
+ import { type UseQueryOptions } from "@tanstack/react-query";
2
+ import type { JSX } from "react";
3
+ import type { ThirdwebClient } from "../../../../../client/client.js";
4
+ /**
5
+ * Props for the ChainIcon component
6
+ * @chain
7
+ * @component
8
+ */
9
+ export interface ChainIconProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src"> {
10
+ /**
11
+ * You need a ThirdwebClient to resolve the icon which is hosted on IPFS.
12
+ * (since most chain icons are hosted on IPFS, loading them via thirdweb gateway will ensure better performance)
13
+ */
14
+ client: ThirdwebClient;
15
+ /**
16
+ * This prop can be a string or a (async) function that resolves to a string, representing the icon url of the chain
17
+ * This is particularly useful if you already have a way to fetch the chain icon.
18
+ */
19
+ iconResolver?: string | (() => string) | (() => Promise<string>);
20
+ /**
21
+ * This component will be shown while the avatar of the icon is being fetched
22
+ * If not passed, the component will return `null`.
23
+ *
24
+ * You can pass a loading sign or spinner to this prop.
25
+ * @example
26
+ * ```tsx
27
+ * <ChainIcon loadingComponent={<Spinner />} />
28
+ * ```
29
+ */
30
+ loadingComponent?: JSX.Element;
31
+ /**
32
+ * This component will be shown if the request for fetching the avatar is done
33
+ * but could not retreive any result.
34
+ * You can pass a dummy avatar/image to this prop.
35
+ *
36
+ * If not passed, the component will return `null`
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * <ChainIcon fallbackComponent={<DummyImage />} />
41
+ * ```
42
+ */
43
+ fallbackComponent?: JSX.Element;
44
+ /**
45
+ * Optional query options for `useQuery`
46
+ */
47
+ queryOptions?: Omit<UseQueryOptions<string>, "queryFn" | "queryKey">;
48
+ }
49
+ /**
50
+ * This component tries to resolve the icon of a given chain, then return an image.
51
+ * @returns an <img /> with the src of the chain icon
52
+ *
53
+ * @example
54
+ * ### Basic usage
55
+ * ```tsx
56
+ * import { ChainProvider, ChainIcon } from "thirdweb/react";
57
+ *
58
+ * <ChainProvider chain={chain}>
59
+ * <ChainIcon />
60
+ * </ChainProvider>
61
+ * ```
62
+ *
63
+ * Result: An <img /> component with the src of the icon
64
+ * ```html
65
+ * <img src="chain-icon.png" />
66
+ * ```
67
+ *
68
+ * ### Override the icon with the `iconResolver` prop
69
+ * If you already have the icon url, you can skip the network requests and pass it directly to the ChainIcon
70
+ * ```tsx
71
+ * <ChainIcon iconResolver="/ethereum-icon.png" />
72
+ * ```
73
+ *
74
+ * You can also pass in your own custom (async) function that retrieves the icon url
75
+ * ```tsx
76
+ * const getIcon = async () => {
77
+ * const icon = getIconFromCoinMarketCap(chainId, etc);
78
+ * return icon;
79
+ * };
80
+ *
81
+ * <ChainIcon iconResolver={getIcon} />
82
+ * ```
83
+ *
84
+ * ### Show a loading sign while the icon is being loaded
85
+ * ```tsx
86
+ * <ChainIcon loadingComponent={<Spinner />} />
87
+ * ```
88
+ *
89
+ * ### Fallback to a dummy image if the chain icon fails to resolve
90
+ * ```tsx
91
+ * <ChainIcon fallbackComponent={<img src="blank-image.png" />} />
92
+ * ```
93
+ *
94
+ * ### Usage with queryOptions
95
+ * ChainIcon uses useQuery() from tanstack query internally.
96
+ * It allows you to pass a custom queryOptions of your choice for more control of the internal fetching logic
97
+ * ```tsx
98
+ * <ChainIcon queryOptions={{ enabled: someLogic, retry: 3, }} />
99
+ * ```
100
+ *
101
+ * @component
102
+ * @chain
103
+ * @beta
104
+ */
105
+ export declare function ChainIcon({ iconResolver, loadingComponent, fallbackComponent, queryOptions, client, ...restProps }: ChainIconProps): import("react/jsx-runtime.js").JSX.Element | null;
106
+ //# sourceMappingURL=icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/prebuilt/Chain/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAItE;;;;GAIG;AACH,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC;IAC9D;;;OAGG;IACH,MAAM,EAAE,cAAc,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAC/B;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAEhC;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC;CACtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,wBAAgB,SAAS,CAAC,EACxB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,MAAM,EACN,GAAG,SAAS,EACb,EAAE,cAAc,qDAmChB"}
@@ -0,0 +1,142 @@
1
+ import { type UseQueryOptions } from "@tanstack/react-query";
2
+ import type React from "react";
3
+ import type { JSX } from "react";
4
+ /**
5
+ * Props for the ChainName component
6
+ * @component
7
+ * @chain
8
+ */
9
+ export interface ChainNameProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "children"> {
10
+ /**
11
+ * This prop can be a string or a (async) function that resolves to a string, representing the name of the chain
12
+ * This is particularly useful if you already have a way to fetch the chain name.
13
+ */
14
+ nameResolver?: string | (() => string) | (() => Promise<string>);
15
+ /**
16
+ * A function to format the name's display value
17
+ * Particularly useful to avoid overflowing-UI issues
18
+ *
19
+ * ```tsx
20
+ * <ChainName formatFn={(str: string) => doSomething()} />
21
+ * ```
22
+ */
23
+ formatFn?: (str: string) => string;
24
+ /**
25
+ * This component will be shown while the name of the chain is being fetched
26
+ * If not passed, the component will return `null`.
27
+ *
28
+ * You can/should pass a loading sign or spinner to this prop.
29
+ * @example
30
+ * ```tsx
31
+ * <ChainName loadingComponent={<Spinner />} />
32
+ * ```
33
+ */
34
+ loadingComponent?: JSX.Element;
35
+ /**
36
+ * This component will be shown if the name fails to be retreived
37
+ * If not passed, the component will return `null`.
38
+ *
39
+ * You can/should pass a descriptive text/component to this prop, indicating that the
40
+ * name was not fetched succesfully
41
+ * @example
42
+ * ```tsx
43
+ * <ChainName fallbackComponent={"Failed to load"}
44
+ * />
45
+ * ```
46
+ */
47
+ fallbackComponent?: JSX.Element;
48
+ /**
49
+ * Optional `useQuery` params
50
+ */
51
+ queryOptions?: Omit<UseQueryOptions<string>, "queryFn" | "queryKey">;
52
+ }
53
+ /**
54
+ * This component fetches then shows the name of a chain.
55
+ * It inherits all the attributes of a HTML <span> component, hence you can style it just like how you would style a normal <span>
56
+ *
57
+ *
58
+ * @example
59
+ * ### Basic usage
60
+ * ```tsx
61
+ * import { ChainProvider, ChainName } from "thirdweb/react";
62
+ * import { ethereum } from "thirdweb/chains";
63
+ *
64
+ * <ChainProvider {...props}>
65
+ * <ChainName />
66
+ * </ChainProvider>
67
+ * ```
68
+ * Result:
69
+ * ```html
70
+ * <span>Ethereum Mainnet</span>
71
+ * ```
72
+ *
73
+ * ### Custom name resolver
74
+ * By default ChainName will call the thirdweb API to retrieve the chain name.
75
+ * However if you have a different way to fetch the name, you can pass the function to the `nameResolver` prop.
76
+ * Note: nameResolver should either be a string or a function (async) that returns a string.
77
+ * ```tsx
78
+ * async function fetchNameMethod() {
79
+ * // your own fetching logic
80
+ * return "the chain name";
81
+ * }
82
+ *
83
+ * <ChainName nameResolver={fetchNameMethod} />
84
+ * ```
85
+ *
86
+ * Alternatively you can also pass in a string directly:
87
+ * ```tsx
88
+ * <ChainName nameResolver="ETH Mainnet" />
89
+ * ```
90
+ *
91
+ *
92
+ * ### Format the name (capitalize, truncate, etc.)
93
+ * The ChainName component accepts a `formatFn` which takes in a string and outputs a string
94
+ * The function is used to modify the name of the chain
95
+ *
96
+ * ```tsx
97
+ * const concatStr = (str: string):string => str + "Network"
98
+ *
99
+ * <ChainProvider {...props}>
100
+ * <ChainName formatFn={concatStr} />
101
+ * </ChainProvider>
102
+ * ```
103
+ *
104
+ * Result:
105
+ * ```html
106
+ * <span>Ethereum Mainnet Network</span>
107
+ * ```
108
+ *
109
+ * ### Show a loading sign when the name is being fetched
110
+ * ```tsx
111
+ * import { ChainProvider, ChainName } from "thirdweb/react";
112
+ *
113
+ * <ChainProvider {...props}>
114
+ * <ChainName loadingComponent={<Spinner />} />
115
+ * </ChainProvider>
116
+ * ```
117
+ *
118
+ * ### Fallback to something when the name fails to resolve
119
+ * ```tsx
120
+ * <ChainProvider {...props}>
121
+ * <ChainName fallbackComponent={"Failed to load"} />
122
+ * </ChainProvider>
123
+ * ```
124
+ *
125
+ * ### Custom query options for useQuery
126
+ * This component uses `@tanstack-query`'s useQuery internally.
127
+ * You can use the `queryOptions` prop for more fine-grained control
128
+ * ```tsx
129
+ * <ChainName
130
+ * queryOptions={{
131
+ * enabled: isEnabled,
132
+ * retry: 4,
133
+ * }}
134
+ * />
135
+ * ```
136
+ *
137
+ * @component
138
+ * @chain
139
+ * @beta
140
+ */
141
+ export declare function ChainName({ nameResolver, formatFn, loadingComponent, fallbackComponent, queryOptions, ...restProps }: ChainNameProps): import("react/jsx-runtime.js").JSX.Element | null;
142
+ //# sourceMappingURL=name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/prebuilt/Chain/name.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAIjC;;;;GAIG;AACH,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC;IAC/D;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAC/B;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAChC;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC;CACtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AACH,wBAAgB,SAAS,CAAC,EACxB,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,GAAG,SAAS,EACb,EAAE,cAAc,qDA8BhB"}
@@ -0,0 +1,48 @@
1
+ import type React from "react";
2
+ import type { Chain } from "../../../../../chains/types.js";
3
+ /**
4
+ * Props for the <ChainProvider /> component
5
+ * @component
6
+ * @chain
7
+ */
8
+ export type ChainProviderProps = {
9
+ chain: Chain;
10
+ };
11
+ /**
12
+ * A React context provider component that supplies Chain-related data to its child components.
13
+ *
14
+ * This component serves as a wrapper around the `ChainProviderContext.Provider` and passes
15
+ * the provided chain data down to all of its child components through the context API.
16
+ *
17
+ * @example
18
+ * ### Basic usage
19
+ * ```tsx
20
+ * import { ChainProvider, ChainIcon, ChainName } from "thirdweb/react";
21
+ * import { ethereum } from "thirdweb/chains";
22
+ *
23
+ * <ChainProvider chain={ethereum}>
24
+ * <ChainIcon />
25
+ * <ChainName />
26
+ * </ChainProvider>
27
+ * ```
28
+ *
29
+ * ### Usage with defineChain
30
+ * ```tsx
31
+ * import { defineChain } from "thirdweb/chains"l
32
+ * import { ChainProvider, ChainName } from "thirdweb/react";
33
+ *
34
+ * const chainId = someNumber;
35
+ *
36
+ * <ChainProvider chain={defineChain(chainId)}>
37
+ * <ChainName />
38
+ * </ChainProvider>
39
+ * ```
40
+ * @component
41
+ * @chain
42
+ */
43
+ export declare function ChainProvider(props: React.PropsWithChildren<ChainProviderProps>): import("react/jsx-runtime.js").JSX.Element;
44
+ /**
45
+ * @internal
46
+ */
47
+ export declare function useChainContext(): ChainProviderProps;
48
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/prebuilt/Chain/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,8CAOnD;AAED;;GAEG;AACH,wBAAgB,eAAe,uBAQ9B"}
@@ -1,5 +1,10 @@
1
1
  import { type UseQueryOptions } from "@tanstack/react-query";
2
2
  import type { JSX } from "react";
3
+ /**
4
+ * Props for the TokenIcon component
5
+ * @component
6
+ * @token
7
+ */
3
8
  export interface TokenIconProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src"> {
4
9
  /**
5
10
  * This prop can be a string or a (async) function that resolves to a string, representing the icon url of the token
@@ -1 +1 @@
1
- {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/prebuilt/Token/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAQjC,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC;IAC9D;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,MAAM,OAAO,CAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,wBAAgB,SAAS,CAAC,EACxB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,GAAG,SAAS,EACb,EAAE,cAAc,qDAsDhB"}
@@ -1,2 +1,2 @@
1
- export declare const version = "5.71.0";
1
+ export declare const version = "5.72.0-nightly-a98550d229e7fd124e1977fcc64dbd1b602ce656-20241126000403";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,2EAA2E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thirdweb",
3
- "version": "5.71.0",
3
+ "version": "5.72.0-nightly-a98550d229e7fd124e1977fcc64dbd1b602ce656-20241126000403",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/thirdweb-dev/js.git#main"
@@ -253,3 +253,17 @@ export {
253
253
  TokenIcon,
254
254
  type TokenIconProps,
255
255
  } from "../react/web/ui/prebuilt/Token/icon.js";
256
+
257
+ // Chain
258
+ export {
259
+ ChainProvider,
260
+ type ChainProviderProps,
261
+ } from "../react/web/ui/prebuilt/Chain/provider.js";
262
+ export {
263
+ ChainName,
264
+ type ChainNameProps,
265
+ } from "../react/web/ui/prebuilt/Chain/name.js";
266
+ export {
267
+ ChainIcon,
268
+ type ChainIconProps,
269
+ } from "../react/web/ui/prebuilt/Chain/icon.js";
@@ -0,0 +1,154 @@
1
+ import { type UseQueryOptions, useQuery } from "@tanstack/react-query";
2
+ import type { JSX } from "react";
3
+ import { getChainMetadata } from "../../../../../chains/utils.js";
4
+ import type { ThirdwebClient } from "../../../../../client/client.js";
5
+ import { resolveScheme } from "../../../../../utils/ipfs.js";
6
+ import { useChainContext } from "./provider.js";
7
+
8
+ /**
9
+ * Props for the ChainIcon component
10
+ * @chain
11
+ * @component
12
+ */
13
+ export interface ChainIconProps
14
+ extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src"> {
15
+ /**
16
+ * You need a ThirdwebClient to resolve the icon which is hosted on IPFS.
17
+ * (since most chain icons are hosted on IPFS, loading them via thirdweb gateway will ensure better performance)
18
+ */
19
+ client: ThirdwebClient;
20
+ /**
21
+ * This prop can be a string or a (async) function that resolves to a string, representing the icon url of the chain
22
+ * This is particularly useful if you already have a way to fetch the chain icon.
23
+ */
24
+ iconResolver?: string | (() => string) | (() => Promise<string>);
25
+ /**
26
+ * This component will be shown while the avatar of the icon is being fetched
27
+ * If not passed, the component will return `null`.
28
+ *
29
+ * You can pass a loading sign or spinner to this prop.
30
+ * @example
31
+ * ```tsx
32
+ * <ChainIcon loadingComponent={<Spinner />} />
33
+ * ```
34
+ */
35
+ loadingComponent?: JSX.Element;
36
+ /**
37
+ * This component will be shown if the request for fetching the avatar is done
38
+ * but could not retreive any result.
39
+ * You can pass a dummy avatar/image to this prop.
40
+ *
41
+ * If not passed, the component will return `null`
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * <ChainIcon fallbackComponent={<DummyImage />} />
46
+ * ```
47
+ */
48
+ fallbackComponent?: JSX.Element;
49
+
50
+ /**
51
+ * Optional query options for `useQuery`
52
+ */
53
+ queryOptions?: Omit<UseQueryOptions<string>, "queryFn" | "queryKey">;
54
+ }
55
+
56
+ /**
57
+ * This component tries to resolve the icon of a given chain, then return an image.
58
+ * @returns an <img /> with the src of the chain icon
59
+ *
60
+ * @example
61
+ * ### Basic usage
62
+ * ```tsx
63
+ * import { ChainProvider, ChainIcon } from "thirdweb/react";
64
+ *
65
+ * <ChainProvider chain={chain}>
66
+ * <ChainIcon />
67
+ * </ChainProvider>
68
+ * ```
69
+ *
70
+ * Result: An <img /> component with the src of the icon
71
+ * ```html
72
+ * <img src="chain-icon.png" />
73
+ * ```
74
+ *
75
+ * ### Override the icon with the `iconResolver` prop
76
+ * If you already have the icon url, you can skip the network requests and pass it directly to the ChainIcon
77
+ * ```tsx
78
+ * <ChainIcon iconResolver="/ethereum-icon.png" />
79
+ * ```
80
+ *
81
+ * You can also pass in your own custom (async) function that retrieves the icon url
82
+ * ```tsx
83
+ * const getIcon = async () => {
84
+ * const icon = getIconFromCoinMarketCap(chainId, etc);
85
+ * return icon;
86
+ * };
87
+ *
88
+ * <ChainIcon iconResolver={getIcon} />
89
+ * ```
90
+ *
91
+ * ### Show a loading sign while the icon is being loaded
92
+ * ```tsx
93
+ * <ChainIcon loadingComponent={<Spinner />} />
94
+ * ```
95
+ *
96
+ * ### Fallback to a dummy image if the chain icon fails to resolve
97
+ * ```tsx
98
+ * <ChainIcon fallbackComponent={<img src="blank-image.png" />} />
99
+ * ```
100
+ *
101
+ * ### Usage with queryOptions
102
+ * ChainIcon uses useQuery() from tanstack query internally.
103
+ * It allows you to pass a custom queryOptions of your choice for more control of the internal fetching logic
104
+ * ```tsx
105
+ * <ChainIcon queryOptions={{ enabled: someLogic, retry: 3, }} />
106
+ * ```
107
+ *
108
+ * @component
109
+ * @chain
110
+ * @beta
111
+ */
112
+ export function ChainIcon({
113
+ iconResolver,
114
+ loadingComponent,
115
+ fallbackComponent,
116
+ queryOptions,
117
+ client,
118
+ ...restProps
119
+ }: ChainIconProps) {
120
+ const { chain } = useChainContext();
121
+ const iconQuery = useQuery({
122
+ queryKey: ["_internal_chain_icon_", chain.id] as const,
123
+ queryFn: async () => {
124
+ if (typeof iconResolver === "string") {
125
+ return iconResolver;
126
+ }
127
+ if (typeof iconResolver === "function") {
128
+ return iconResolver();
129
+ }
130
+ // Check if the chain object already has "icon"
131
+ if (chain.icon?.url) {
132
+ return chain.icon.url;
133
+ }
134
+ const possibleUrl = await getChainMetadata(chain).then(
135
+ (data) => data.icon?.url,
136
+ );
137
+ if (!possibleUrl) {
138
+ throw new Error("Failed to resolve icon for chain");
139
+ }
140
+ return resolveScheme({ uri: possibleUrl, client });
141
+ },
142
+ ...queryOptions,
143
+ });
144
+
145
+ if (iconQuery.isLoading) {
146
+ return loadingComponent || null;
147
+ }
148
+
149
+ if (!iconQuery.data) {
150
+ return fallbackComponent || null;
151
+ }
152
+
153
+ return <img src={iconQuery.data} {...restProps} alt={restProps.alt} />;
154
+ }