@gearbox-protocol/ui-kit 4.0.2 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/rounded-image/rounded-image.cjs +1 -1
- package/dist/cjs/components/token-icon/token-icon-source.cjs +1 -1
- package/dist/cjs/components/token-icon/token-icon.cjs +1 -1
- package/dist/esm/components/rounded-image/rounded-image.js +25 -25
- package/dist/esm/components/token-icon/token-icon-source.js +51 -44
- package/dist/esm/components/token-icon/token-icon.js +28 -136
- package/dist/types/components/token-icon/token-icon-source.d.ts +4 -42
- package/dist/types/components/token-icon/token-icon.d.ts +6 -17
- package/dist/types/components/token-symbol/token-symbol.d.ts +1 -1
- package/dist/types/types/common.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),c=require("react"),I=require("../../utils/cn.cjs");require("@gearbox-protocol/sdk/onchain");require("../../utils/z-index.cjs");const L=require("../../utils/internal/static.cjs");function S(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),c=require("react"),I=require("../../utils/cn.cjs");require("@gearbox-protocol/sdk/onchain");require("../../utils/z-index.cjs");const L=require("../../utils/internal/static.cjs");function S(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const w=S(c),g=L.getStatic("/tokens/default.svg"),m=new Map;function f(e){return m.get(e)?g:e}const b=w.forwardRef(({className:e,size:r,rounded:n=!0,style:a,src:s,defaultIcon:p=g,fit:y="cover",...R},o)=>{const[j,l]=c.useState(void 0),[h,u]=c.useState(!1),i=c.useRef(!1),d=c.useRef(null),v=t=>{d.current=t,typeof o=="function"?o(t):o&&(o.current=t),t?.complete&&t.naturalWidth>0&&u(!0)};c.useEffect(()=>{f(s),l(void 0),i.current=!1;const t=d.current;u(!!t?.complete&&t.naturalWidth>0)},[s]);const O=t=>{i.current||(i.current=!0,m.set(t.currentTarget.src,!0),l(p))},_=()=>{u(!0)};return q.jsx("img",{ref:v,src:j||f(s),alt:"",className:I.cn(y==="cover"?"object-cover":"object-contain object-center",n&&"rounded-full",!h&&"bg-gray-90 dark:bg-gray-110 rounded-full",e),style:{width:r,height:r,...a},loading:"lazy",decoding:"async",onError:O,onLoad:_,...R})});b.displayName="RoundedImage";exports.RoundedImage=b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../utils/internal/static.cjs"),e=d.getStatic("/tokens/default.svg"),r=d.getStatic("/logo/logo_symbol.png");function u(t){return t.replaceAll("/","").replaceAll(" ","").toLowerCase()}const w={"crvusdfrax-f":"crvusdfrax","crvusdusdc-f":"crvusdusdc","crvusdusdt-f":"crvusdusdt","cvxcrvusdfrax-f":"cvxcrvusdfrax","cvxcrvusdusdc-f":"cvxcrvusdusdc","cvxcrvusdusdt-f":"cvxcrvusdusdt","stkcvxcrvusdfrax-f":"stkcvxcrvusdfrax","stkcvxcrvusdusdc-f":"stkcvxcrvusdusdc","stkcvxcrvusdusdt-f":"stkcvxcrvusdusdt","wdwsteth[cp0xlrt]":"wdwsteth","wdwsteth[pzeth]":"wdwsteth","wdwsteth[re7lrt]":"wdwsteth","wdwsteth[rsteth]":"wdwsteth","wdwsteth[steaklrt]":"wdwsteth",wdiusd:"iusd",wdrseth:"rseth","dwbtc-v3-0":"dwbtcv3","dwethv3-cp0x":"dwethv3",fweth:"weth",fwsteth:"wsteth",kpkfrxusd:"frxusd",kpkweth:"weth",kpkwsteth:"wsteth",stkrlusdusdc:"rlusdusdc",syusd:"yusd",xtz:"wxtz","cyb-cbbtc":"cbbtc","cyb-tbtc":"tbtc","cyb-wbtc":"wbtc",re7tbtc:"tbtc",re7usdc:"usdc"};function v(t){const s=typeof t=="string"?t:t?.symbol;if(!s)return e;if(s==="GEAR")return r;const c=u(s);return c?d.getStatic(`/tokens/${w[c]??c}.svg`):e}exports.getTokenIconUrl=v;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),i=require("react"),I=require("./token-icon-source.cjs"),m=require("../rounded-image/rounded-image.cjs"),n=i.forwardRef(function({token:o,symbol:t,size:e=48,fit:c="contain",rounded:r=!1,className:u,...a},s){return d.jsx(m.RoundedImage,{ref:s,className:u,src:I.getTokenIconUrl(o??t),alt:"",rounded:r,fit:c,width:e,height:e,size:e,...a})});n.displayName="TokenIcon";exports.TokenIcon=n;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { useState as i, useRef as
|
|
4
|
-
import { cn as
|
|
1
|
+
import { jsx as I } from "react/jsx-runtime";
|
|
2
|
+
import * as w from "react";
|
|
3
|
+
import { useState as i, useRef as f, useEffect as N } from "react";
|
|
4
|
+
import { cn as k } from "../../utils/cn.js";
|
|
5
5
|
import "@gearbox-protocol/sdk/onchain";
|
|
6
6
|
import "../../utils/z-index.js";
|
|
7
|
-
import { getStatic as
|
|
8
|
-
const u =
|
|
9
|
-
function
|
|
7
|
+
import { getStatic as x } from "../../utils/internal/static.js";
|
|
8
|
+
const u = x("/tokens/default.svg"), m = /* @__PURE__ */ new Map();
|
|
9
|
+
function l(t) {
|
|
10
10
|
return m.get(t) ? u : t;
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const C = w.forwardRef(
|
|
13
13
|
({
|
|
14
14
|
className: t,
|
|
15
15
|
size: c,
|
|
@@ -20,26 +20,26 @@ const U = k.forwardRef(
|
|
|
20
20
|
fit: R = "cover",
|
|
21
21
|
...y
|
|
22
22
|
}, r) => {
|
|
23
|
-
const [v, s] = i(void 0), [b,
|
|
24
|
-
d.current = e, typeof r == "function" ? r(e) : r && (r.current = e), e?.complete && e.naturalWidth > 0 &&
|
|
23
|
+
const [v, s] = i(void 0), [b, a] = i(!1), n = f(!1), d = f(null), L = (e) => {
|
|
24
|
+
d.current = e, typeof r == "function" ? r(e) : r && (r.current = e), e?.complete && e.naturalWidth > 0 && a(!0);
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
N(() => {
|
|
27
|
+
l(o), s(void 0), n.current = !1;
|
|
28
28
|
const e = d.current;
|
|
29
|
-
|
|
29
|
+
a(!!e?.complete && e.naturalWidth > 0);
|
|
30
30
|
}, [o]);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
|
|
31
|
+
const j = (e) => {
|
|
32
|
+
n.current || (n.current = !0, m.set(e.currentTarget.src, !0), s(h));
|
|
33
|
+
}, E = () => {
|
|
34
|
+
a(!0);
|
|
35
35
|
};
|
|
36
|
-
return /* @__PURE__ */
|
|
36
|
+
return /* @__PURE__ */ I(
|
|
37
37
|
"img",
|
|
38
38
|
{
|
|
39
|
-
ref:
|
|
40
|
-
src: v ||
|
|
39
|
+
ref: L,
|
|
40
|
+
src: v || l(o),
|
|
41
41
|
alt: "",
|
|
42
|
-
className:
|
|
42
|
+
className: k(
|
|
43
43
|
R === "cover" ? "object-cover" : "object-contain object-center",
|
|
44
44
|
g && "rounded-full",
|
|
45
45
|
!b && "bg-gray-90 dark:bg-gray-110 rounded-full",
|
|
@@ -52,14 +52,14 @@ const U = k.forwardRef(
|
|
|
52
52
|
},
|
|
53
53
|
loading: "lazy",
|
|
54
54
|
decoding: "async",
|
|
55
|
-
onError:
|
|
56
|
-
onLoad:
|
|
55
|
+
onError: j,
|
|
56
|
+
onLoad: E,
|
|
57
57
|
...y
|
|
58
58
|
}
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
);
|
|
62
|
-
|
|
62
|
+
C.displayName = "RoundedImage";
|
|
63
63
|
export {
|
|
64
|
-
|
|
64
|
+
C as RoundedImage
|
|
65
65
|
};
|
|
@@ -1,48 +1,55 @@
|
|
|
1
|
-
import { getStatic as
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
{ prefix: "sd", requiresVersion: !0 },
|
|
6
|
-
{ prefix: "d", requiresVersion: !0 }
|
|
7
|
-
];
|
|
8
|
-
function c(e) {
|
|
9
|
-
for (const { prefix: i, requiresVersion: t } of u) {
|
|
10
|
-
if (!e.startsWith(i)) continue;
|
|
11
|
-
let r = e.slice(i.length);
|
|
12
|
-
if (r.endsWith(o) && (r = r.slice(0, -o.length)), n.test(r))
|
|
13
|
-
r = r.replace(n, "");
|
|
14
|
-
else if (t)
|
|
15
|
-
continue;
|
|
16
|
-
if (r) return r;
|
|
17
|
-
}
|
|
1
|
+
import { getStatic as d } from "../../utils/internal/static.js";
|
|
2
|
+
const r = d("/tokens/default.svg"), u = d("/logo/logo_symbol.png");
|
|
3
|
+
function e(t) {
|
|
4
|
+
return t.replaceAll("/", "").replaceAll(" ", "").toLowerCase();
|
|
18
5
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
6
|
+
const w = {
|
|
7
|
+
// Curve factory pools, on the base pool's icon.
|
|
8
|
+
"crvusdfrax-f": "crvusdfrax",
|
|
9
|
+
"crvusdusdc-f": "crvusdusdc",
|
|
10
|
+
"crvusdusdt-f": "crvusdusdt",
|
|
11
|
+
"cvxcrvusdfrax-f": "cvxcrvusdfrax",
|
|
12
|
+
"cvxcrvusdusdc-f": "cvxcrvusdusdc",
|
|
13
|
+
"cvxcrvusdusdt-f": "cvxcrvusdusdt",
|
|
14
|
+
"stkcvxcrvusdfrax-f": "stkcvxcrvusdfrax",
|
|
15
|
+
"stkcvxcrvusdusdc-f": "stkcvxcrvusdusdc",
|
|
16
|
+
"stkcvxcrvusdusdt-f": "stkcvxcrvusdusdt",
|
|
17
|
+
// Mellow withdrawal phantoms. The SDK reports all of them as one `wdwstETH`;
|
|
18
|
+
// only the backend tells the vaults apart, and the icon never did.
|
|
19
|
+
"wdwsteth[cp0xlrt]": "wdwsteth",
|
|
20
|
+
"wdwsteth[pzeth]": "wdwsteth",
|
|
21
|
+
"wdwsteth[re7lrt]": "wdwsteth",
|
|
22
|
+
"wdwsteth[rsteth]": "wdwsteth",
|
|
23
|
+
"wdwsteth[steaklrt]": "wdwsteth",
|
|
24
|
+
// Withdrawal phantoms of a single asset.
|
|
25
|
+
wdiusd: "iusd",
|
|
26
|
+
wdrseth: "rseth",
|
|
27
|
+
// Curator variants of a pool share token.
|
|
28
|
+
"dwbtc-v3-0": "dwbtcv3",
|
|
29
|
+
"dwethv3-cp0x": "dwethv3",
|
|
30
|
+
// Wrappers and staked versions, on the asset they hold.
|
|
31
|
+
fweth: "weth",
|
|
32
|
+
fwsteth: "wsteth",
|
|
33
|
+
kpkfrxusd: "frxusd",
|
|
34
|
+
kpkweth: "weth",
|
|
35
|
+
kpkwsteth: "wsteth",
|
|
36
|
+
stkrlusdusdc: "rlusdusdc",
|
|
37
|
+
syusd: "yusd",
|
|
38
|
+
xtz: "wxtz",
|
|
39
|
+
// Curated vaults, on their underlying.
|
|
40
|
+
"cyb-cbbtc": "cbbtc",
|
|
41
|
+
"cyb-tbtc": "tbtc",
|
|
42
|
+
"cyb-wbtc": "wbtc",
|
|
43
|
+
re7tbtc: "tbtc",
|
|
44
|
+
re7usdc: "usdc"
|
|
45
|
+
};
|
|
46
|
+
function f(t) {
|
|
47
|
+
const s = typeof t == "string" ? t : t?.symbol;
|
|
48
|
+
if (!s) return r;
|
|
49
|
+
if (s === "GEAR") return u;
|
|
50
|
+
const c = e(s);
|
|
51
|
+
return c ? d(`/tokens/${w[c] ?? c}.svg`) : r;
|
|
44
52
|
}
|
|
45
53
|
export {
|
|
46
|
-
|
|
47
|
-
c as parseShareTokenUnderlying
|
|
54
|
+
f as getTokenIconUrl
|
|
48
55
|
};
|
|
@@ -1,143 +1,35 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return typeof t == "object" && t !== null && "kind" in t && t.kind === "composite";
|
|
18
|
-
}
|
|
19
|
-
function T(t) {
|
|
20
|
-
if (t.type === "url") return t.url;
|
|
21
|
-
const e = w(t.symbol);
|
|
22
|
-
return e ? k(`/tokens/${e}.svg`) : u;
|
|
23
|
-
}
|
|
24
|
-
function j(t) {
|
|
25
|
-
if (!t || N(t))
|
|
26
|
-
return u;
|
|
27
|
-
if (_(t))
|
|
28
|
-
return t.icon;
|
|
29
|
-
const e = w(t);
|
|
30
|
-
return e ? k(`/tokens/${e}.svg`) : u;
|
|
31
|
-
}
|
|
32
|
-
const F = 0.65;
|
|
33
|
-
function L(t, e) {
|
|
34
|
-
return t !== void 0 ? I(t) : typeof e == "string" ? I(e) : e;
|
|
35
|
-
}
|
|
36
|
-
const v = b.forwardRef(function({
|
|
37
|
-
token: e,
|
|
38
|
-
symbol: n,
|
|
39
|
-
size: o = 48,
|
|
40
|
-
fit: c = "contain",
|
|
41
|
-
rounded: s = !1,
|
|
42
|
-
className: a,
|
|
43
|
-
...l
|
|
44
|
-
}, f) {
|
|
45
|
-
const i = L(e, n);
|
|
46
|
-
if (N(i))
|
|
47
|
-
return /* @__PURE__ */ r(
|
|
48
|
-
C,
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import i from "react";
|
|
3
|
+
import { getTokenIconUrl as d } from "./token-icon-source.js";
|
|
4
|
+
import { RoundedImage as p } from "../rounded-image/rounded-image.js";
|
|
5
|
+
const l = i.forwardRef(
|
|
6
|
+
function({
|
|
7
|
+
token: n,
|
|
8
|
+
symbol: r,
|
|
9
|
+
size: o = 48,
|
|
10
|
+
fit: t = "contain",
|
|
11
|
+
rounded: e = !1,
|
|
12
|
+
className: m,
|
|
13
|
+
...a
|
|
14
|
+
}, c) {
|
|
15
|
+
return /* @__PURE__ */ f(
|
|
16
|
+
p,
|
|
49
17
|
{
|
|
50
|
-
ref:
|
|
51
|
-
|
|
18
|
+
ref: c,
|
|
19
|
+
className: m,
|
|
20
|
+
src: d(n ?? r),
|
|
21
|
+
alt: "",
|
|
22
|
+
rounded: e,
|
|
23
|
+
fit: t,
|
|
24
|
+
width: o,
|
|
25
|
+
height: o,
|
|
52
26
|
size: o,
|
|
53
|
-
|
|
54
|
-
rounded: s,
|
|
55
|
-
className: a
|
|
27
|
+
...a
|
|
56
28
|
}
|
|
57
29
|
);
|
|
58
|
-
const p = j(i);
|
|
59
|
-
return /* @__PURE__ */ r(
|
|
60
|
-
m,
|
|
61
|
-
{
|
|
62
|
-
ref: f,
|
|
63
|
-
className: a,
|
|
64
|
-
src: p,
|
|
65
|
-
alt: "",
|
|
66
|
-
rounded: s,
|
|
67
|
-
fit: c,
|
|
68
|
-
width: o,
|
|
69
|
-
height: o,
|
|
70
|
-
size: o,
|
|
71
|
-
...l
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
}), C = b.forwardRef(function({ composite: e, size: n, fit: o, rounded: c, className: s }, a) {
|
|
75
|
-
const { preset: l, layers: f, scaleFactor: i = F } = e, [p, S] = f, g = T(p), U = T(S), d = Math.round(n * i);
|
|
76
|
-
let h;
|
|
77
|
-
switch (l) {
|
|
78
|
-
case "centered_foreground":
|
|
79
|
-
h = /* @__PURE__ */ x(R, { children: [
|
|
80
|
-
/* @__PURE__ */ r(
|
|
81
|
-
m,
|
|
82
|
-
{
|
|
83
|
-
className: "absolute inset-0",
|
|
84
|
-
style: { zIndex: 0 },
|
|
85
|
-
src: g,
|
|
86
|
-
alt: "background",
|
|
87
|
-
rounded: c,
|
|
88
|
-
fit: o,
|
|
89
|
-
size: n
|
|
90
|
-
}
|
|
91
|
-
),
|
|
92
|
-
/* @__PURE__ */ r(
|
|
93
|
-
"div",
|
|
94
|
-
{
|
|
95
|
-
className: y(
|
|
96
|
-
"absolute left-1/2 top-1/2 z-[1] -translate-x-1/2 -translate-y-1/2",
|
|
97
|
-
"flex items-center justify-center"
|
|
98
|
-
),
|
|
99
|
-
style: {
|
|
100
|
-
width: d,
|
|
101
|
-
height: d
|
|
102
|
-
},
|
|
103
|
-
children: /* @__PURE__ */ r(
|
|
104
|
-
m,
|
|
105
|
-
{
|
|
106
|
-
src: U,
|
|
107
|
-
alt: "foreground",
|
|
108
|
-
rounded: c,
|
|
109
|
-
fit: o,
|
|
110
|
-
size: d
|
|
111
|
-
}
|
|
112
|
-
)
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
] });
|
|
116
|
-
break;
|
|
117
|
-
default:
|
|
118
|
-
return console.error("Unknown TokenIcon composite preset", l), /* @__PURE__ */ r(
|
|
119
|
-
m,
|
|
120
|
-
{
|
|
121
|
-
src: g,
|
|
122
|
-
alt: "error",
|
|
123
|
-
rounded: c,
|
|
124
|
-
fit: o,
|
|
125
|
-
size: n
|
|
126
|
-
}
|
|
127
|
-
);
|
|
128
30
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
{
|
|
132
|
-
ref: a,
|
|
133
|
-
className: y("relative inline-block shrink-0", s),
|
|
134
|
-
style: { width: n, height: n },
|
|
135
|
-
children: h
|
|
136
|
-
}
|
|
137
|
-
);
|
|
138
|
-
});
|
|
139
|
-
C.displayName = "TokenIconComposite";
|
|
140
|
-
v.displayName = "TokenIcon";
|
|
31
|
+
);
|
|
32
|
+
l.displayName = "TokenIcon";
|
|
141
33
|
export {
|
|
142
|
-
|
|
34
|
+
l as TokenIcon
|
|
143
35
|
};
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
/** One layer of a composite icon: a token symbol to resolve, or a ready URL. */
|
|
2
|
-
export type TokenIconLayerSource = {
|
|
3
|
-
type: "symbol";
|
|
4
|
-
symbol: string;
|
|
5
|
-
} | {
|
|
6
|
-
type: "url";
|
|
7
|
-
url: string;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Named layout preset for a composite icon. The pixel layout is `TokenIcon`'s,
|
|
11
|
-
* never an API payload's — which is why these types live here and not in the
|
|
12
|
-
* SDK read model.
|
|
13
|
-
*
|
|
14
|
-
* `centered_foreground`: background full size, foreground centered at ~65%
|
|
15
|
-
* (a token on a plate).
|
|
16
|
-
*/
|
|
17
|
-
export type TokenIconCompositePreset = "centered_foreground";
|
|
18
|
-
/** Client-composed token icon: layers stacked by preset. */
|
|
19
|
-
export type IconComposite = {
|
|
20
|
-
kind: "composite";
|
|
21
|
-
preset: TokenIconCompositePreset;
|
|
22
|
-
scaleFactor?: number;
|
|
23
|
-
/** Exactly two layers (bottom then top). */
|
|
24
|
-
layers: readonly [TokenIconLayerSource, TokenIconLayerSource];
|
|
25
|
-
};
|
|
26
|
-
/** Same shape as `TokenIcon`'s `symbol` prop — kept here to avoid a cycle. */
|
|
27
|
-
export type TokenIconSource = string | {
|
|
28
|
-
icon: string;
|
|
29
|
-
} | IconComposite;
|
|
30
1
|
/**
|
|
31
2
|
* Everything the resolver needs from a token. Structural on purpose so the SDK
|
|
32
3
|
* read-model `Token`, the `TokenData` class, and bare metadata all fit without
|
|
@@ -36,17 +7,8 @@ export interface TokenIconInput {
|
|
|
36
7
|
symbol: string;
|
|
37
8
|
}
|
|
38
9
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
export declare function parseShareTokenUnderlying(symbol: string): string | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* Resolve a token (or bare symbol) into the value `TokenIcon` renders.
|
|
46
|
-
*
|
|
47
|
-
* Pure front-end concern: share token composites and the GEAR logo special
|
|
48
|
-
* case are derived from the symbol alone — callers must not pre-bake `icon` /
|
|
49
|
-
* `iconUrl`, and should hand the token to `TokenIcon` rather than calling this
|
|
50
|
-
* directly.
|
|
10
|
+
* CDN asset for a token (or bare symbol). Every symbol maps to its own file —
|
|
11
|
+
* share tokens included, the CDN ships `dusdcv3.svg`, `sdwethv3.svg`,
|
|
12
|
+
* `wdwsteth.svg` and friends.
|
|
51
13
|
*/
|
|
52
|
-
export declare function
|
|
14
|
+
export declare function getTokenIconUrl(token: TokenIconInput | string | undefined): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TokenIconInput } from './token-icon-source';
|
|
3
3
|
import { RoundedImageProps } from '../rounded-image/rounded-image';
|
|
4
4
|
/**
|
|
5
5
|
* TokenIcon — component for displaying token/asset icons.
|
|
@@ -10,9 +10,8 @@ import { RoundedImageProps } from '../rounded-image/rounded-image';
|
|
|
10
10
|
*
|
|
11
11
|
* Props:
|
|
12
12
|
* - `token` — token as it comes from the SDK/backend, or a bare symbol (preferred).
|
|
13
|
-
* The component resolves the
|
|
14
|
-
*
|
|
15
|
-
* - `symbol` — already-resolved source: direct icon URL or `IconComposite` (legacy).
|
|
13
|
+
* The component resolves the CDN url itself, so callers never pass one.
|
|
14
|
+
* - `symbol` — bare symbol, same thing for call sites that have no token object.
|
|
16
15
|
* - `size` — icon size in pixels (defaults to 48).
|
|
17
16
|
*
|
|
18
17
|
* Note: Fetches icon from Gearbox static CDN based on symbol.
|
|
@@ -20,26 +19,16 @@ import { RoundedImageProps } from '../rounded-image/rounded-image';
|
|
|
20
19
|
* Symbol is normalized (removes "/", spaces, "-f", converts "-" to "_", lowercased).
|
|
21
20
|
* Icon displays in its original shape (not clipped).
|
|
22
21
|
*
|
|
23
|
-
* **Ref behavior:** In the default single-image mode, `ref` is attached to the underlying `<img>`.
|
|
24
|
-
* In composite mode, `ref` is attached to the outer wrapper `div` (see `TokenIconProps` / `forwardRef` generic).
|
|
25
|
-
*
|
|
26
22
|
* Do NOT use TokenIcon:
|
|
27
23
|
* - for address identifiers (use Identicon component).
|
|
28
24
|
* - for custom images or logos (use Image component).
|
|
29
25
|
*/
|
|
30
|
-
type DirectIcon = {
|
|
31
|
-
icon: string;
|
|
32
|
-
};
|
|
33
|
-
export type SymbolOrIcon = string | DirectIcon | IconComposite;
|
|
34
26
|
export interface TokenIconProps extends Omit<RoundedImageProps, "src" | "size"> {
|
|
35
|
-
/**
|
|
36
|
-
* Token (or bare symbol). When set, takes precedence over `symbol` and is
|
|
37
|
-
* resolved via `getTokenIcon` (diesel composites, GEAR logo, etc.).
|
|
38
|
-
*/
|
|
27
|
+
/** Token (or bare symbol). Takes precedence over `symbol` when both are set. */
|
|
39
28
|
token?: TokenIconInput | string;
|
|
40
|
-
symbol?:
|
|
29
|
+
symbol?: string | undefined;
|
|
41
30
|
size?: number;
|
|
42
31
|
className?: string;
|
|
43
32
|
}
|
|
44
|
-
declare const TokenIcon: React.ForwardRefExoticComponent<TokenIconProps & React.RefAttributes<
|
|
33
|
+
declare const TokenIcon: React.ForwardRefExoticComponent<TokenIconProps & React.RefAttributes<HTMLImageElement>>;
|
|
45
34
|
export { TokenIcon };
|
|
@@ -9,7 +9,7 @@ declare const tokenSymbolVariants: (props?: ({
|
|
|
9
9
|
export interface TokenSymbolProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title">, VariantProps<typeof tokenSymbolVariants> {
|
|
10
10
|
/**
|
|
11
11
|
* SDK `Token`, `TokenMetaInfo`, or bare symbol string. Passed straight to
|
|
12
|
-
* `TokenIcon`, which resolves the
|
|
12
|
+
* `TokenIcon`, which resolves the CDN url from the symbol.
|
|
13
13
|
*/
|
|
14
14
|
token?: Token | TokenMetaInfo | string;
|
|
15
15
|
/**
|
|
@@ -2,7 +2,7 @@ import { Address } from 'viem';
|
|
|
2
2
|
/**
|
|
3
3
|
* Token metadata as it arrives from the SDK or backend. Deliberately carries no
|
|
4
4
|
* icon field: icons are a front-end concern resolved from the symbol by
|
|
5
|
-
* `
|
|
5
|
+
* `getTokenIconUrl` inside `TokenIcon`.
|
|
6
6
|
*/
|
|
7
7
|
export type TokenMetaInfo = {
|
|
8
8
|
symbol: string;
|