@talismn/orb 0.3.4 → 0.3.6
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/index.d.mts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +261 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +221 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +24 -15
- package/CHANGELOG.md +0 -61
- package/dist/declarations/src/components/TalismanOrb.d.ts +0 -3
- package/dist/declarations/src/components/TalismanOrbLogo.d.ts +0 -5
- package/dist/declarations/src/components/TalismanOrbRectangle.d.ts +0 -3
- package/dist/declarations/src/components/index.d.ts +0 -4
- package/dist/declarations/src/components/types.d.ts +0 -6
- package/dist/declarations/src/components/useTalismanOrb.d.ts +0 -10
- package/dist/declarations/src/index.d.ts +0 -2
- package/dist/declarations/src/util/getTalismanOrbDataUrl.d.ts +0 -4
- package/dist/declarations/src/util/index.d.ts +0 -1
- package/dist/talismn-orb.cjs.d.ts +0 -1
- package/dist/talismn-orb.cjs.dev.js +0 -291
- package/dist/talismn-orb.cjs.js +0 -7
- package/dist/talismn-orb.cjs.prod.js +0 -291
- package/dist/talismn-orb.esm.js +0 -280
- package/src/components/TalismanOrb.tsx +0 -46
- package/src/components/TalismanOrbLogo.tsx +0 -60
- package/src/components/TalismanOrbRectangle.tsx +0 -40
- package/src/components/index.ts +0 -4
- package/src/components/types.ts +0 -1
- package/src/components/useTalismanOrb.ts +0 -70
- package/src/index.ts +0 -2
- package/src/util/getTalismanOrbDataUrl.tsx +0 -14
- package/src/util/index.ts +0 -1
- package/tsconfig.json +0 -5
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import * as _talismn_crypto from '@talismn/crypto';
|
|
3
|
+
|
|
4
|
+
type TalismanOrbProps = {
|
|
5
|
+
seed: string;
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare const TalismanOrb: FC<TalismanOrbProps>;
|
|
12
|
+
|
|
13
|
+
declare const TalismanOrbRectangle: FC<TalismanOrbProps>;
|
|
14
|
+
|
|
15
|
+
declare const useTalismanOrb: (seed: string) => {
|
|
16
|
+
id: string;
|
|
17
|
+
bgColor1: string;
|
|
18
|
+
bgColor2: string;
|
|
19
|
+
glowColor: string;
|
|
20
|
+
transform: string;
|
|
21
|
+
cx: number;
|
|
22
|
+
cy: number;
|
|
23
|
+
platform: _talismn_crypto.AccountPlatform;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns a base64 encoded data url for the Talisman Orb svg
|
|
28
|
+
*/
|
|
29
|
+
declare const getTalismanOrbDataUrl: (address: string) => `data:image/svg+xml;base64,${string}`;
|
|
30
|
+
|
|
31
|
+
export { TalismanOrb, type TalismanOrbProps, TalismanOrbRectangle, getTalismanOrbDataUrl, useTalismanOrb };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import * as _talismn_crypto from '@talismn/crypto';
|
|
3
|
+
|
|
4
|
+
type TalismanOrbProps = {
|
|
5
|
+
seed: string;
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare const TalismanOrb: FC<TalismanOrbProps>;
|
|
12
|
+
|
|
13
|
+
declare const TalismanOrbRectangle: FC<TalismanOrbProps>;
|
|
14
|
+
|
|
15
|
+
declare const useTalismanOrb: (seed: string) => {
|
|
16
|
+
id: string;
|
|
17
|
+
bgColor1: string;
|
|
18
|
+
bgColor2: string;
|
|
19
|
+
glowColor: string;
|
|
20
|
+
transform: string;
|
|
21
|
+
cx: number;
|
|
22
|
+
cy: number;
|
|
23
|
+
platform: _talismn_crypto.AccountPlatform;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns a base64 encoded data url for the Talisman Orb svg
|
|
28
|
+
*/
|
|
29
|
+
declare const getTalismanOrbDataUrl: (address: string) => `data:image/svg+xml;base64,${string}`;
|
|
30
|
+
|
|
31
|
+
export { TalismanOrb, type TalismanOrbProps, TalismanOrbRectangle, getTalismanOrbDataUrl, useTalismanOrb };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
TalismanOrb: () => TalismanOrb,
|
|
34
|
+
TalismanOrbRectangle: () => TalismanOrbRectangle,
|
|
35
|
+
getTalismanOrbDataUrl: () => getTalismanOrbDataUrl,
|
|
36
|
+
useTalismanOrb: () => useTalismanOrb
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(index_exports);
|
|
39
|
+
|
|
40
|
+
// src/components/TalismanOrbLogo.tsx
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
+
var TalismanOrbLogo = ({ platform }) => {
|
|
43
|
+
switch (platform) {
|
|
44
|
+
case "ethereum":
|
|
45
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { opacity: "0.75", transform: "scale(0.7) translate(14 14)", className: "orb-type", children: [
|
|
46
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
47
|
+
"path",
|
|
48
|
+
{
|
|
49
|
+
d: "M12.8101 32.76L32.0001 44.62L51.1901 32.76L32.0001 -0.0699997L12.8101 32.76Z",
|
|
50
|
+
fill: "white"
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
54
|
+
"path",
|
|
55
|
+
{
|
|
56
|
+
d: "M12.8101 36.48L32.0001 48.43L51.1901 36.48L32.0001 63.93L12.8101 36.48Z",
|
|
57
|
+
fill: "white"
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] });
|
|
61
|
+
case "polkadot":
|
|
62
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { opacity: "0.75", transform: "scale(2.2) translate(4.5 3.9)", className: "orb-type", children: [
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
+
"path",
|
|
65
|
+
{
|
|
66
|
+
d: "M9.99937 4.4612C12.1176 4.4612 13.8347 3.46253 13.8347 2.2306C13.8347 0.998674 12.1176 0 9.99937 0C7.88119 0 6.16406 0.998674 6.16406 2.2306C6.16406 3.46253 7.88119 4.4612 9.99937 4.4612Z",
|
|
67
|
+
fill: "white"
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
71
|
+
"path",
|
|
72
|
+
{
|
|
73
|
+
d: "M9.99937 21.2683C12.1176 21.2683 13.8347 20.2697 13.8347 19.0377C13.8347 17.8058 12.1176 16.8071 9.99937 16.8071C7.88119 16.8071 6.16406 17.8058 6.16406 19.0377C6.16406 20.2697 7.88119 21.2683 9.99937 21.2683Z",
|
|
74
|
+
fill: "white"
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
78
|
+
"path",
|
|
79
|
+
{
|
|
80
|
+
d: "M4.65427 7.54892C5.71336 5.71457 5.70649 3.72787 4.63892 3.11149C3.57135 2.49511 1.84735 3.48246 0.788259 5.31681C-0.270832 7.15115 -0.263958 9.13786 0.803612 9.75424C1.87118 10.3706 3.59518 9.38326 4.65427 7.54892Z",
|
|
81
|
+
fill: "white"
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
85
|
+
"path",
|
|
86
|
+
{
|
|
87
|
+
d: "M19.2083 15.9515C20.2674 14.1171 20.2611 12.1307 19.1943 11.5148C18.1274 10.8988 16.404 11.8865 15.3449 13.7209C14.2858 15.5552 14.2921 17.5416 15.3589 18.1575C16.4258 18.7735 18.1492 17.7858 19.2083 15.9515Z",
|
|
88
|
+
fill: "white"
|
|
89
|
+
}
|
|
90
|
+
),
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
92
|
+
"path",
|
|
93
|
+
{
|
|
94
|
+
d: "M4.6399 18.1571C5.70747 17.5407 5.71434 15.554 4.65525 13.7196C3.59616 11.8853 1.87216 10.8979 0.804589 11.5143C-0.262981 12.1307 -0.269855 14.1174 0.789235 15.9517C1.84833 17.7861 3.57233 18.7734 4.6399 18.1571Z",
|
|
95
|
+
fill: "white"
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
|
+
"path",
|
|
100
|
+
{
|
|
101
|
+
d: "M19.1952 9.75475C20.2621 9.13878 20.2684 7.15241 19.2093 5.31807C18.1502 3.48372 16.4268 2.49603 15.3599 3.11199C14.2931 3.72796 14.2868 5.71433 15.3459 7.54867C16.405 9.38302 18.1284 10.3707 19.1952 9.75475Z",
|
|
102
|
+
fill: "white"
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] });
|
|
106
|
+
case "solana":
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { opacity: "0.75", className: "orb-type", transform: "scale(0.45) translate(37.5, 37.5)", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
108
|
+
"path",
|
|
109
|
+
{
|
|
110
|
+
d: "M70.6648 50.1769L58.9393 62.775C58.6844 63.0486 58.376 63.2668 58.0332 63.4159C57.6905 63.5651 57.3208 63.6419 56.9472 63.6417H1.36128C1.09605 63.6417 0.836598 63.5641 0.614804 63.4184C0.393011 63.2727 0.218536 63.0652 0.112817 62.8215C0.00709765 62.5779 -0.0252603 62.3085 0.0197186 62.0467C0.0646974 61.7848 0.185054 61.5418 0.366 61.3476L12.1006 48.7496C12.3548 48.4766 12.6623 48.2589 13.0039 48.1098C13.3455 47.9607 13.714 47.8834 14.0866 47.8828H69.6695C69.9348 47.8828 70.1942 47.9604 70.416 48.1062C70.6378 48.2519 70.8123 48.4593 70.918 48.703C71.0237 48.9467 71.0561 49.216 71.0111 49.4778C70.9661 49.7397 70.8458 49.9827 70.6648 50.1769V50.1769ZM58.9393 24.8081C58.6844 24.5345 58.376 24.3163 58.0332 24.1672C57.6905 24.0181 57.3208 23.9412 56.9472 23.9414H1.36128C1.09605 23.9414 0.836598 24.019 0.614804 24.1647C0.393011 24.3105 0.218536 24.5179 0.112817 24.7616C0.00709765 25.0053 -0.0252603 25.2746 0.0197186 25.5364C0.0646974 25.7983 0.185054 26.0413 0.366 26.2355L12.1006 38.8336C12.3548 39.1065 12.6623 39.3242 13.0039 39.4733C13.3455 39.6224 13.714 39.6997 14.0866 39.7003H69.6695C69.9348 39.7003 70.1942 39.6227 70.416 39.477C70.6378 39.3313 70.8123 39.1238 70.918 38.8801C71.0237 38.6365 71.0561 38.3671 71.0111 38.1053C70.9661 37.8434 70.8458 37.6004 70.6648 37.4062L58.9393 24.8081ZM1.36128 15.7589H56.9472C57.3208 15.7591 57.6905 15.6822 58.0332 15.5331C58.376 15.384 58.6844 15.1658 58.9393 14.8922L70.6648 2.29413C70.8458 2.09986 70.9661 1.85688 71.0111 1.59502C71.0561 1.33317 71.0237 1.06385 70.918 0.820169C70.8123 0.576485 70.6378 0.369047 70.416 0.223341C70.1942 0.0776352 69.9348 8.97308e-06 69.6695 0L14.0866 0C13.714 0.000635258 13.3455 0.077888 13.0039 0.226975C12.6623 0.376063 12.3548 0.593811 12.1006 0.866739L0.369025 13.4648C0.188254 13.6588 0.0679503 13.9016 0.0228694 14.1631C-0.0222115 14.4247 0.00988974 14.6938 0.115236 14.9373C0.220583 15.1809 0.394595 15.3884 0.615931 15.5343C0.837268 15.6802 1.09631 15.7583 1.36128 15.7589V15.7589Z",
|
|
111
|
+
fill: "white"
|
|
112
|
+
}
|
|
113
|
+
) });
|
|
114
|
+
default:
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/components/useTalismanOrb.ts
|
|
120
|
+
var import_crypto = require("@talismn/crypto");
|
|
121
|
+
var import_blueimp_md5 = __toESM(require("blueimp-md5"));
|
|
122
|
+
var import_color = __toESM(require("color"));
|
|
123
|
+
var import_react = require("react");
|
|
124
|
+
var djb2 = (str) => {
|
|
125
|
+
let hash = 5381;
|
|
126
|
+
for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash + str.charCodeAt(i);
|
|
127
|
+
return hash;
|
|
128
|
+
};
|
|
129
|
+
var valueFromHash = (hash, max) => {
|
|
130
|
+
return (max + djb2(hash)) % max;
|
|
131
|
+
};
|
|
132
|
+
var colorFromHash = (hash) => {
|
|
133
|
+
const hue = valueFromHash(hash, 360);
|
|
134
|
+
return import_color.default.hsv(hue, 100, 100);
|
|
135
|
+
};
|
|
136
|
+
var rotateText = (text, nbChars = 0) => text.slice(nbChars) + text.slice(0, nbChars);
|
|
137
|
+
var useTalismanOrb = (seed) => {
|
|
138
|
+
const id = (0, import_react.useId)();
|
|
139
|
+
return (0, import_react.useMemo)(() => {
|
|
140
|
+
try {
|
|
141
|
+
var platform = (0, import_crypto.getAccountPlatformFromAddress)(seed);
|
|
142
|
+
var address = (0, import_crypto.normalizeAddress)(seed);
|
|
143
|
+
} catch {
|
|
144
|
+
platform = "polkadot";
|
|
145
|
+
address = seed;
|
|
146
|
+
}
|
|
147
|
+
const hash1 = (0, import_blueimp_md5.default)(address);
|
|
148
|
+
const hash2 = rotateText(hash1, 1);
|
|
149
|
+
const hash3 = rotateText(hash1, 2);
|
|
150
|
+
const colors = [colorFromHash(hash1), colorFromHash(hash2), colorFromHash(hash3)].sort(
|
|
151
|
+
(c1, c2) => c1.lightness() - c2.lightness()
|
|
152
|
+
);
|
|
153
|
+
const dotX = 10 + valueFromHash(hash1, 10);
|
|
154
|
+
const dotY = 10 + valueFromHash(hash2, 10);
|
|
155
|
+
const rotation = valueFromHash(hash1, 360);
|
|
156
|
+
return {
|
|
157
|
+
id,
|
|
158
|
+
//multiple avatars should cohabit on the same page
|
|
159
|
+
bgColor1: colors[0].hex(),
|
|
160
|
+
bgColor2: colors[1].hex(),
|
|
161
|
+
glowColor: colors[2].hex(),
|
|
162
|
+
transform: `rotate(${rotation} 32 32)`,
|
|
163
|
+
cx: dotX,
|
|
164
|
+
cy: dotY,
|
|
165
|
+
platform
|
|
166
|
+
};
|
|
167
|
+
}, [id, seed]);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// src/components/TalismanOrb.tsx
|
|
171
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
172
|
+
var TalismanOrb = ({
|
|
173
|
+
seed,
|
|
174
|
+
width = "1em",
|
|
175
|
+
height = "1em",
|
|
176
|
+
className
|
|
177
|
+
}) => {
|
|
178
|
+
const { id, bgColor1, bgColor2, transform, glowColor, cx, cy, platform } = useTalismanOrb(seed);
|
|
179
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
180
|
+
"svg",
|
|
181
|
+
{
|
|
182
|
+
width,
|
|
183
|
+
height,
|
|
184
|
+
viewBox: `0 0 64 64`,
|
|
185
|
+
className,
|
|
186
|
+
version: "1.1",
|
|
187
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
188
|
+
children: [
|
|
189
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("defs", { children: [
|
|
190
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("linearGradient", { id: `${id}-bg`, children: [
|
|
191
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "20%", stopColor: bgColor1 }),
|
|
192
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "100%", stopColor: bgColor2 })
|
|
193
|
+
] }),
|
|
194
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("radialGradient", { id: `${id}-circle`, children: [
|
|
195
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "10%", stopColor: glowColor }),
|
|
196
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "100%", stopColor: "transparent" })
|
|
197
|
+
] }),
|
|
198
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("clipPath", { id: `${id}-clip`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "32", cy: "32", r: "32" }) })
|
|
199
|
+
] }),
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("g", { clipPath: `url(#${id}-clip)`, children: [
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("g", { transform, children: [
|
|
202
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { fill: `url(#${id}-bg)`, x: 0, y: 0, width: 64, height: 64 }),
|
|
203
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { fill: `url(#${id}-circle)`, cx, cy, r: 45, opacity: 0.7 })
|
|
204
|
+
] }),
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TalismanOrbLogo, { platform })
|
|
206
|
+
] })
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// src/components/TalismanOrbRectangle.tsx
|
|
213
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
214
|
+
var TalismanOrbRectangle = ({ width, height, seed, className }) => {
|
|
215
|
+
const { id, bgColor1, bgColor2, transform, glowColor, cx, cy } = useTalismanOrb(seed);
|
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
217
|
+
"svg",
|
|
218
|
+
{
|
|
219
|
+
width,
|
|
220
|
+
height,
|
|
221
|
+
viewBox: `0 0 64 64`,
|
|
222
|
+
preserveAspectRatio: "none",
|
|
223
|
+
className,
|
|
224
|
+
version: "1.1",
|
|
225
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("defs", { children: [
|
|
228
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("linearGradient", { id: `${id}-bg`, children: [
|
|
229
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("stop", { offset: "20%", stopColor: bgColor1 }),
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("stop", { offset: "100%", stopColor: bgColor2 })
|
|
231
|
+
] }),
|
|
232
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("radialGradient", { id: `${id}-circle`, children: [
|
|
233
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("stop", { offset: "10%", stopColor: glowColor }),
|
|
234
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("stop", { offset: "100%", stopColor: "transparent" })
|
|
235
|
+
] }),
|
|
236
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("clipPath", { id: `${id}-clip`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "32", cy: "32", r: "48" }) })
|
|
237
|
+
] }),
|
|
238
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("g", { clipPath: `url(#${id}-clip)`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("g", { transform, children: [
|
|
239
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { fill: `url(#${id}-bg)`, x: -16, y: -16, width: 96, height: 96 }),
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { fill: `url(#${id}-circle)`, cx, cy, r: 45, opacity: 0.7 })
|
|
241
|
+
] }) })
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// src/util/getTalismanOrbDataUrl.tsx
|
|
248
|
+
var import_server = __toESM(require("react-dom/server"));
|
|
249
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
250
|
+
var getTalismanOrbDataUrl = (address) => {
|
|
251
|
+
const svg = import_server.default.renderToStaticMarkup(/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TalismanOrb, { seed: address }));
|
|
252
|
+
return `data:image/svg+xml;base64,${Buffer.from(svg).toString("base64")}`;
|
|
253
|
+
};
|
|
254
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
255
|
+
0 && (module.exports = {
|
|
256
|
+
TalismanOrb,
|
|
257
|
+
TalismanOrbRectangle,
|
|
258
|
+
getTalismanOrbDataUrl,
|
|
259
|
+
useTalismanOrb
|
|
260
|
+
});
|
|
261
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/components/TalismanOrbLogo.tsx","../src/components/useTalismanOrb.ts","../src/components/TalismanOrb.tsx","../src/components/TalismanOrbRectangle.tsx","../src/util/getTalismanOrbDataUrl.tsx"],"sourcesContent":["export * from \"./components\"\nexport * from \"./util\"\n","import type { AccountPlatform } from \"@talismn/crypto\"\nimport type { FC } from \"react\"\n\nexport const TalismanOrbLogo: FC<{ platform: AccountPlatform }> = ({ platform }) => {\n switch (platform) {\n case \"ethereum\":\n return (\n <g opacity=\"0.75\" transform=\"scale(0.7) translate(14 14)\" className=\"orb-type\">\n <path\n d=\"M12.8101 32.76L32.0001 44.62L51.1901 32.76L32.0001 -0.0699997L12.8101 32.76Z\"\n fill=\"white\"\n />\n <path\n d=\"M12.8101 36.48L32.0001 48.43L51.1901 36.48L32.0001 63.93L12.8101 36.48Z\"\n fill=\"white\"\n />\n </g>\n )\n case \"polkadot\":\n return (\n <g opacity=\"0.75\" transform=\"scale(2.2) translate(4.5 3.9)\" className=\"orb-type\">\n <path\n d=\"M9.99937 4.4612C12.1176 4.4612 13.8347 3.46253 13.8347 2.2306C13.8347 0.998674 12.1176 0 9.99937 0C7.88119 0 6.16406 0.998674 6.16406 2.2306C6.16406 3.46253 7.88119 4.4612 9.99937 4.4612Z\"\n fill=\"white\"\n />\n <path\n d=\"M9.99937 21.2683C12.1176 21.2683 13.8347 20.2697 13.8347 19.0377C13.8347 17.8058 12.1176 16.8071 9.99937 16.8071C7.88119 16.8071 6.16406 17.8058 6.16406 19.0377C6.16406 20.2697 7.88119 21.2683 9.99937 21.2683Z\"\n fill=\"white\"\n />\n <path\n d=\"M4.65427 7.54892C5.71336 5.71457 5.70649 3.72787 4.63892 3.11149C3.57135 2.49511 1.84735 3.48246 0.788259 5.31681C-0.270832 7.15115 -0.263958 9.13786 0.803612 9.75424C1.87118 10.3706 3.59518 9.38326 4.65427 7.54892Z\"\n fill=\"white\"\n />\n <path\n d=\"M19.2083 15.9515C20.2674 14.1171 20.2611 12.1307 19.1943 11.5148C18.1274 10.8988 16.404 11.8865 15.3449 13.7209C14.2858 15.5552 14.2921 17.5416 15.3589 18.1575C16.4258 18.7735 18.1492 17.7858 19.2083 15.9515Z\"\n fill=\"white\"\n />\n <path\n d=\"M4.6399 18.1571C5.70747 17.5407 5.71434 15.554 4.65525 13.7196C3.59616 11.8853 1.87216 10.8979 0.804589 11.5143C-0.262981 12.1307 -0.269855 14.1174 0.789235 15.9517C1.84833 17.7861 3.57233 18.7734 4.6399 18.1571Z\"\n fill=\"white\"\n />\n <path\n d=\"M19.1952 9.75475C20.2621 9.13878 20.2684 7.15241 19.2093 5.31807C18.1502 3.48372 16.4268 2.49603 15.3599 3.11199C14.2931 3.72796 14.2868 5.71433 15.3459 7.54867C16.405 9.38302 18.1284 10.3707 19.1952 9.75475Z\"\n fill=\"white\"\n />\n </g>\n )\n case \"solana\":\n return (\n <g opacity=\"0.75\" className=\"orb-type\" transform=\"scale(0.45) translate(37.5, 37.5)\">\n <path\n d=\"M70.6648 50.1769L58.9393 62.775C58.6844 63.0486 58.376 63.2668 58.0332 63.4159C57.6905 63.5651 57.3208 63.6419 56.9472 63.6417H1.36128C1.09605 63.6417 0.836598 63.5641 0.614804 63.4184C0.393011 63.2727 0.218536 63.0652 0.112817 62.8215C0.00709765 62.5779 -0.0252603 62.3085 0.0197186 62.0467C0.0646974 61.7848 0.185054 61.5418 0.366 61.3476L12.1006 48.7496C12.3548 48.4766 12.6623 48.2589 13.0039 48.1098C13.3455 47.9607 13.714 47.8834 14.0866 47.8828H69.6695C69.9348 47.8828 70.1942 47.9604 70.416 48.1062C70.6378 48.2519 70.8123 48.4593 70.918 48.703C71.0237 48.9467 71.0561 49.216 71.0111 49.4778C70.9661 49.7397 70.8458 49.9827 70.6648 50.1769V50.1769ZM58.9393 24.8081C58.6844 24.5345 58.376 24.3163 58.0332 24.1672C57.6905 24.0181 57.3208 23.9412 56.9472 23.9414H1.36128C1.09605 23.9414 0.836598 24.019 0.614804 24.1647C0.393011 24.3105 0.218536 24.5179 0.112817 24.7616C0.00709765 25.0053 -0.0252603 25.2746 0.0197186 25.5364C0.0646974 25.7983 0.185054 26.0413 0.366 26.2355L12.1006 38.8336C12.3548 39.1065 12.6623 39.3242 13.0039 39.4733C13.3455 39.6224 13.714 39.6997 14.0866 39.7003H69.6695C69.9348 39.7003 70.1942 39.6227 70.416 39.477C70.6378 39.3313 70.8123 39.1238 70.918 38.8801C71.0237 38.6365 71.0561 38.3671 71.0111 38.1053C70.9661 37.8434 70.8458 37.6004 70.6648 37.4062L58.9393 24.8081ZM1.36128 15.7589H56.9472C57.3208 15.7591 57.6905 15.6822 58.0332 15.5331C58.376 15.384 58.6844 15.1658 58.9393 14.8922L70.6648 2.29413C70.8458 2.09986 70.9661 1.85688 71.0111 1.59502C71.0561 1.33317 71.0237 1.06385 70.918 0.820169C70.8123 0.576485 70.6378 0.369047 70.416 0.223341C70.1942 0.0776352 69.9348 8.97308e-06 69.6695 0L14.0866 0C13.714 0.000635258 13.3455 0.077888 13.0039 0.226975C12.6623 0.376063 12.3548 0.593811 12.1006 0.866739L0.369025 13.4648C0.188254 13.6588 0.0679503 13.9016 0.0228694 14.1631C-0.0222115 14.4247 0.00988974 14.6938 0.115236 14.9373C0.220583 15.1809 0.394595 15.3884 0.615931 15.5343C0.837268 15.6802 1.09631 15.7583 1.36128 15.7589V15.7589Z\"\n fill=\"white\"\n />\n </g>\n )\n default:\n return null\n }\n}\n","import { getAccountPlatformFromAddress, normalizeAddress } from \"@talismn/crypto\"\nimport md5 from \"blueimp-md5\"\nimport Color from \"color\"\nimport { useId, useMemo } from \"react\"\n\nconst djb2 = (str: string) => {\n let hash = 5381\n for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash + str.charCodeAt(i)\n return hash\n}\n\nconst valueFromHash = (hash: string, max: number) => {\n return (max + djb2(hash)) % max\n}\n\nconst colorFromHash = (hash: string) => {\n const hue = valueFromHash(hash, 360)\n return Color.hsv(hue, 100, 100)\n}\n\nconst rotateText = (text: string, nbChars = 0) => text.slice(nbChars) + text.slice(0, nbChars)\n\nexport const useTalismanOrb = (seed: string) => {\n const id = useId()\n\n return useMemo(() => {\n try {\n // those break if seed is empty or an invalid address\n\n // biome-ignore lint/correctness/noInnerDeclarations: hack\n var platform = getAccountPlatformFromAddress(seed)\n\n // seed may be specific to a ss58 prefix, get the base address\n // biome-ignore lint/correctness/noInnerDeclarations: hack\n var address = normalizeAddress(seed)\n } catch {\n platform = \"polkadot\"\n address = seed\n }\n\n // derive 3 hashs from the seed, used to generate the 3 colors\n const hash1 = md5(address)\n const hash2 = rotateText(hash1, 1)\n const hash3 = rotateText(hash1, 2)\n\n // the 2 darkest ones will be used as gradient BG\n // the lightest one will be used as gradient circle, to mimic a 3D lighting effect\n const colors = [colorFromHash(hash1), colorFromHash(hash2), colorFromHash(hash3)].sort(\n (c1, c2) => c1.lightness() - c2.lightness()\n )\n\n // random location in top left corner, avoid beeing to close from the center\n const dotX = 10 + valueFromHash(hash1, 10)\n const dotY = 10 + valueFromHash(hash2, 10)\n\n // global rotation\n const rotation = valueFromHash(hash1, 360)\n\n return {\n id, //multiple avatars should cohabit on the same page\n bgColor1: colors[0].hex(),\n bgColor2: colors[1].hex(),\n glowColor: colors[2].hex(),\n transform: `rotate(${rotation} 32 32)`,\n cx: dotX,\n cy: dotY,\n platform,\n }\n }, [id, seed])\n}\n","import type { FC } from \"react\"\n\nimport { TalismanOrbLogo } from \"./TalismanOrbLogo\"\nimport type { TalismanOrbProps } from \"./types\"\nimport { useTalismanOrb } from \"./useTalismanOrb\"\n\nexport const TalismanOrb: FC<TalismanOrbProps> = ({\n seed,\n width = \"1em\",\n height = \"1em\",\n className,\n}) => {\n const { id, bgColor1, bgColor2, transform, glowColor, cx, cy, platform } = useTalismanOrb(seed)\n\n return (\n <svg\n width={width}\n height={height}\n viewBox={`0 0 64 64`}\n className={className}\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <defs>\n <linearGradient id={`${id}-bg`}>\n <stop offset=\"20%\" stopColor={bgColor1} />\n <stop offset=\"100%\" stopColor={bgColor2} />\n </linearGradient>\n <radialGradient id={`${id}-circle`}>\n <stop offset=\"10%\" stopColor={glowColor} />\n <stop offset=\"100%\" stopColor=\"transparent\" />\n </radialGradient>\n <clipPath id={`${id}-clip`}>\n <circle cx=\"32\" cy=\"32\" r=\"32\" />\n </clipPath>\n </defs>\n <g clipPath={`url(#${id}-clip)`}>\n <g transform={transform}>\n <rect fill={`url(#${id}-bg)`} x={0} y={0} width={64} height={64} />\n <circle fill={`url(#${id}-circle)`} cx={cx} cy={cy} r={45} opacity={0.7} />\n </g>\n <TalismanOrbLogo platform={platform} />\n </g>\n </svg>\n )\n}\n","import type { FC } from \"react\"\n\nimport type { TalismanOrbProps } from \"./types\"\nimport { useTalismanOrb } from \"./useTalismanOrb\"\n\nexport const TalismanOrbRectangle: FC<TalismanOrbProps> = ({ width, height, seed, className }) => {\n const { id, bgColor1, bgColor2, transform, glowColor, cx, cy } = useTalismanOrb(seed)\n\n return (\n <svg\n width={width}\n height={height}\n viewBox={`0 0 64 64`}\n preserveAspectRatio=\"none\"\n className={className}\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <defs>\n <linearGradient id={`${id}-bg`}>\n <stop offset=\"20%\" stopColor={bgColor1} />\n <stop offset=\"100%\" stopColor={bgColor2} />\n </linearGradient>\n <radialGradient id={`${id}-circle`}>\n <stop offset=\"10%\" stopColor={glowColor} />\n <stop offset=\"100%\" stopColor=\"transparent\" />\n </radialGradient>\n <clipPath id={`${id}-clip`}>\n <circle cx=\"32\" cy=\"32\" r=\"48\" />\n </clipPath>\n </defs>\n <g clipPath={`url(#${id}-clip)`}>\n <g transform={transform}>\n <rect fill={`url(#${id}-bg)`} x={-16} y={-16} width={96} height={96} />\n <circle fill={`url(#${id}-circle)`} cx={cx} cy={cy} r={45} opacity={0.7} />\n </g>\n </g>\n </svg>\n )\n}\n","import ReactDOMServer from \"react-dom/server\"\n\nimport { TalismanOrb } from \"../components\"\n\n/**\n * Returns a base64 encoded data url for the Talisman Orb svg\n */\nexport const getTalismanOrbDataUrl = (address: string): `data:image/svg+xml;base64,${string}` => {\n // render the TalismanOrb component and output the SVG as text\n const svg = ReactDOMServer.renderToStaticMarkup(<TalismanOrb seed={address} />)\n\n // convert to data url\n return `data:image/svg+xml;base64,${Buffer.from(svg).toString(\"base64\")}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOQ;AAJD,IAAM,kBAAqD,CAAC,EAAE,SAAS,MAAM;AAClF,UAAQ,UAAU;AAAA,IAChB,KAAK;AACH,aACE,6CAAC,OAAE,SAAQ,QAAO,WAAU,+BAA8B,WAAU,YAClE;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACP;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACP;AAAA,SACF;AAAA,IAEJ,KAAK;AACH,aACE,6CAAC,OAAE,SAAQ,QAAO,WAAU,iCAAgC,WAAU,YACpE;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACP;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,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YACzC,6CAAC,UAAK,QAAO,QAAO,WAAU,eAAc;AAAA,aAC9C;AAAA,UACA,6CAAC,cAAS,IAAI,GAAG,EAAE,SACjB,uDAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,MAAK,GACjC;AAAA,WACF;AAAA,QACA,6CAAC,OAAE,UAAU,QAAQ,EAAE,UACrB,wDAAC,OAAE,WACD;AAAA,uDAAC,UAAK,MAAM,QAAQ,EAAE,QAAQ,GAAG,KAAK,GAAG,KAAK,OAAO,IAAI,QAAQ,IAAI;AAAA,UACrE,6CAAC,YAAO,MAAM,QAAQ,EAAE,YAAY,IAAQ,IAAQ,GAAG,IAAI,SAAS,KAAK;AAAA,WAC3E,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;;;ACvCA,oBAA2B;AASuB,IAAAC,sBAAA;AAF3C,IAAM,wBAAwB,CAAC,YAA2D;AAE/F,QAAM,MAAM,cAAAC,QAAe,qBAAqB,6CAAC,eAAY,MAAM,SAAS,CAAE;AAG9E,SAAO,6BAA6B,OAAO,KAAK,GAAG,EAAE,SAAS,QAAQ,CAAC;AACzE;","names":["Color","md5","import_jsx_runtime","import_jsx_runtime","import_jsx_runtime","ReactDOMServer"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// src/components/TalismanOrbLogo.tsx
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
var TalismanOrbLogo = ({ platform }) => {
|
|
4
|
+
switch (platform) {
|
|
5
|
+
case "ethereum":
|
|
6
|
+
return /* @__PURE__ */ jsxs("g", { opacity: "0.75", transform: "scale(0.7) translate(14 14)", className: "orb-type", children: [
|
|
7
|
+
/* @__PURE__ */ jsx(
|
|
8
|
+
"path",
|
|
9
|
+
{
|
|
10
|
+
d: "M12.8101 32.76L32.0001 44.62L51.1901 32.76L32.0001 -0.0699997L12.8101 32.76Z",
|
|
11
|
+
fill: "white"
|
|
12
|
+
}
|
|
13
|
+
),
|
|
14
|
+
/* @__PURE__ */ jsx(
|
|
15
|
+
"path",
|
|
16
|
+
{
|
|
17
|
+
d: "M12.8101 36.48L32.0001 48.43L51.1901 36.48L32.0001 63.93L12.8101 36.48Z",
|
|
18
|
+
fill: "white"
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
] });
|
|
22
|
+
case "polkadot":
|
|
23
|
+
return /* @__PURE__ */ jsxs("g", { opacity: "0.75", transform: "scale(2.2) translate(4.5 3.9)", className: "orb-type", children: [
|
|
24
|
+
/* @__PURE__ */ jsx(
|
|
25
|
+
"path",
|
|
26
|
+
{
|
|
27
|
+
d: "M9.99937 4.4612C12.1176 4.4612 13.8347 3.46253 13.8347 2.2306C13.8347 0.998674 12.1176 0 9.99937 0C7.88119 0 6.16406 0.998674 6.16406 2.2306C6.16406 3.46253 7.88119 4.4612 9.99937 4.4612Z",
|
|
28
|
+
fill: "white"
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
/* @__PURE__ */ jsx(
|
|
32
|
+
"path",
|
|
33
|
+
{
|
|
34
|
+
d: "M9.99937 21.2683C12.1176 21.2683 13.8347 20.2697 13.8347 19.0377C13.8347 17.8058 12.1176 16.8071 9.99937 16.8071C7.88119 16.8071 6.16406 17.8058 6.16406 19.0377C6.16406 20.2697 7.88119 21.2683 9.99937 21.2683Z",
|
|
35
|
+
fill: "white"
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
"path",
|
|
40
|
+
{
|
|
41
|
+
d: "M4.65427 7.54892C5.71336 5.71457 5.70649 3.72787 4.63892 3.11149C3.57135 2.49511 1.84735 3.48246 0.788259 5.31681C-0.270832 7.15115 -0.263958 9.13786 0.803612 9.75424C1.87118 10.3706 3.59518 9.38326 4.65427 7.54892Z",
|
|
42
|
+
fill: "white"
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
/* @__PURE__ */ jsx(
|
|
46
|
+
"path",
|
|
47
|
+
{
|
|
48
|
+
d: "M19.2083 15.9515C20.2674 14.1171 20.2611 12.1307 19.1943 11.5148C18.1274 10.8988 16.404 11.8865 15.3449 13.7209C14.2858 15.5552 14.2921 17.5416 15.3589 18.1575C16.4258 18.7735 18.1492 17.7858 19.2083 15.9515Z",
|
|
49
|
+
fill: "white"
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
"path",
|
|
54
|
+
{
|
|
55
|
+
d: "M4.6399 18.1571C5.70747 17.5407 5.71434 15.554 4.65525 13.7196C3.59616 11.8853 1.87216 10.8979 0.804589 11.5143C-0.262981 12.1307 -0.269855 14.1174 0.789235 15.9517C1.84833 17.7861 3.57233 18.7734 4.6399 18.1571Z",
|
|
56
|
+
fill: "white"
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ jsx(
|
|
60
|
+
"path",
|
|
61
|
+
{
|
|
62
|
+
d: "M19.1952 9.75475C20.2621 9.13878 20.2684 7.15241 19.2093 5.31807C18.1502 3.48372 16.4268 2.49603 15.3599 3.11199C14.2931 3.72796 14.2868 5.71433 15.3459 7.54867C16.405 9.38302 18.1284 10.3707 19.1952 9.75475Z",
|
|
63
|
+
fill: "white"
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
] });
|
|
67
|
+
case "solana":
|
|
68
|
+
return /* @__PURE__ */ jsx("g", { opacity: "0.75", className: "orb-type", transform: "scale(0.45) translate(37.5, 37.5)", children: /* @__PURE__ */ jsx(
|
|
69
|
+
"path",
|
|
70
|
+
{
|
|
71
|
+
d: "M70.6648 50.1769L58.9393 62.775C58.6844 63.0486 58.376 63.2668 58.0332 63.4159C57.6905 63.5651 57.3208 63.6419 56.9472 63.6417H1.36128C1.09605 63.6417 0.836598 63.5641 0.614804 63.4184C0.393011 63.2727 0.218536 63.0652 0.112817 62.8215C0.00709765 62.5779 -0.0252603 62.3085 0.0197186 62.0467C0.0646974 61.7848 0.185054 61.5418 0.366 61.3476L12.1006 48.7496C12.3548 48.4766 12.6623 48.2589 13.0039 48.1098C13.3455 47.9607 13.714 47.8834 14.0866 47.8828H69.6695C69.9348 47.8828 70.1942 47.9604 70.416 48.1062C70.6378 48.2519 70.8123 48.4593 70.918 48.703C71.0237 48.9467 71.0561 49.216 71.0111 49.4778C70.9661 49.7397 70.8458 49.9827 70.6648 50.1769V50.1769ZM58.9393 24.8081C58.6844 24.5345 58.376 24.3163 58.0332 24.1672C57.6905 24.0181 57.3208 23.9412 56.9472 23.9414H1.36128C1.09605 23.9414 0.836598 24.019 0.614804 24.1647C0.393011 24.3105 0.218536 24.5179 0.112817 24.7616C0.00709765 25.0053 -0.0252603 25.2746 0.0197186 25.5364C0.0646974 25.7983 0.185054 26.0413 0.366 26.2355L12.1006 38.8336C12.3548 39.1065 12.6623 39.3242 13.0039 39.4733C13.3455 39.6224 13.714 39.6997 14.0866 39.7003H69.6695C69.9348 39.7003 70.1942 39.6227 70.416 39.477C70.6378 39.3313 70.8123 39.1238 70.918 38.8801C71.0237 38.6365 71.0561 38.3671 71.0111 38.1053C70.9661 37.8434 70.8458 37.6004 70.6648 37.4062L58.9393 24.8081ZM1.36128 15.7589H56.9472C57.3208 15.7591 57.6905 15.6822 58.0332 15.5331C58.376 15.384 58.6844 15.1658 58.9393 14.8922L70.6648 2.29413C70.8458 2.09986 70.9661 1.85688 71.0111 1.59502C71.0561 1.33317 71.0237 1.06385 70.918 0.820169C70.8123 0.576485 70.6378 0.369047 70.416 0.223341C70.1942 0.0776352 69.9348 8.97308e-06 69.6695 0L14.0866 0C13.714 0.000635258 13.3455 0.077888 13.0039 0.226975C12.6623 0.376063 12.3548 0.593811 12.1006 0.866739L0.369025 13.4648C0.188254 13.6588 0.0679503 13.9016 0.0228694 14.1631C-0.0222115 14.4247 0.00988974 14.6938 0.115236 14.9373C0.220583 15.1809 0.394595 15.3884 0.615931 15.5343C0.837268 15.6802 1.09631 15.7583 1.36128 15.7589V15.7589Z",
|
|
72
|
+
fill: "white"
|
|
73
|
+
}
|
|
74
|
+
) });
|
|
75
|
+
default:
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/components/useTalismanOrb.ts
|
|
81
|
+
import { getAccountPlatformFromAddress, normalizeAddress } from "@talismn/crypto";
|
|
82
|
+
import md5 from "blueimp-md5";
|
|
83
|
+
import Color from "color";
|
|
84
|
+
import { useId, useMemo } from "react";
|
|
85
|
+
var djb2 = (str) => {
|
|
86
|
+
let hash = 5381;
|
|
87
|
+
for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash + str.charCodeAt(i);
|
|
88
|
+
return hash;
|
|
89
|
+
};
|
|
90
|
+
var valueFromHash = (hash, max) => {
|
|
91
|
+
return (max + djb2(hash)) % max;
|
|
92
|
+
};
|
|
93
|
+
var colorFromHash = (hash) => {
|
|
94
|
+
const hue = valueFromHash(hash, 360);
|
|
95
|
+
return Color.hsv(hue, 100, 100);
|
|
96
|
+
};
|
|
97
|
+
var rotateText = (text, nbChars = 0) => text.slice(nbChars) + text.slice(0, nbChars);
|
|
98
|
+
var useTalismanOrb = (seed) => {
|
|
99
|
+
const id = useId();
|
|
100
|
+
return useMemo(() => {
|
|
101
|
+
try {
|
|
102
|
+
var platform = getAccountPlatformFromAddress(seed);
|
|
103
|
+
var address = normalizeAddress(seed);
|
|
104
|
+
} catch {
|
|
105
|
+
platform = "polkadot";
|
|
106
|
+
address = seed;
|
|
107
|
+
}
|
|
108
|
+
const hash1 = md5(address);
|
|
109
|
+
const hash2 = rotateText(hash1, 1);
|
|
110
|
+
const hash3 = rotateText(hash1, 2);
|
|
111
|
+
const colors = [colorFromHash(hash1), colorFromHash(hash2), colorFromHash(hash3)].sort(
|
|
112
|
+
(c1, c2) => c1.lightness() - c2.lightness()
|
|
113
|
+
);
|
|
114
|
+
const dotX = 10 + valueFromHash(hash1, 10);
|
|
115
|
+
const dotY = 10 + valueFromHash(hash2, 10);
|
|
116
|
+
const rotation = valueFromHash(hash1, 360);
|
|
117
|
+
return {
|
|
118
|
+
id,
|
|
119
|
+
//multiple avatars should cohabit on the same page
|
|
120
|
+
bgColor1: colors[0].hex(),
|
|
121
|
+
bgColor2: colors[1].hex(),
|
|
122
|
+
glowColor: colors[2].hex(),
|
|
123
|
+
transform: `rotate(${rotation} 32 32)`,
|
|
124
|
+
cx: dotX,
|
|
125
|
+
cy: dotY,
|
|
126
|
+
platform
|
|
127
|
+
};
|
|
128
|
+
}, [id, seed]);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// src/components/TalismanOrb.tsx
|
|
132
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
133
|
+
var TalismanOrb = ({
|
|
134
|
+
seed,
|
|
135
|
+
width = "1em",
|
|
136
|
+
height = "1em",
|
|
137
|
+
className
|
|
138
|
+
}) => {
|
|
139
|
+
const { id, bgColor1, bgColor2, transform, glowColor, cx, cy, platform } = useTalismanOrb(seed);
|
|
140
|
+
return /* @__PURE__ */ jsxs2(
|
|
141
|
+
"svg",
|
|
142
|
+
{
|
|
143
|
+
width,
|
|
144
|
+
height,
|
|
145
|
+
viewBox: `0 0 64 64`,
|
|
146
|
+
className,
|
|
147
|
+
version: "1.1",
|
|
148
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ jsxs2("defs", { children: [
|
|
151
|
+
/* @__PURE__ */ jsxs2("linearGradient", { id: `${id}-bg`, children: [
|
|
152
|
+
/* @__PURE__ */ jsx2("stop", { offset: "20%", stopColor: bgColor1 }),
|
|
153
|
+
/* @__PURE__ */ jsx2("stop", { offset: "100%", stopColor: bgColor2 })
|
|
154
|
+
] }),
|
|
155
|
+
/* @__PURE__ */ jsxs2("radialGradient", { id: `${id}-circle`, children: [
|
|
156
|
+
/* @__PURE__ */ jsx2("stop", { offset: "10%", stopColor: glowColor }),
|
|
157
|
+
/* @__PURE__ */ jsx2("stop", { offset: "100%", stopColor: "transparent" })
|
|
158
|
+
] }),
|
|
159
|
+
/* @__PURE__ */ jsx2("clipPath", { id: `${id}-clip`, children: /* @__PURE__ */ jsx2("circle", { cx: "32", cy: "32", r: "32" }) })
|
|
160
|
+
] }),
|
|
161
|
+
/* @__PURE__ */ jsxs2("g", { clipPath: `url(#${id}-clip)`, children: [
|
|
162
|
+
/* @__PURE__ */ jsxs2("g", { transform, children: [
|
|
163
|
+
/* @__PURE__ */ jsx2("rect", { fill: `url(#${id}-bg)`, x: 0, y: 0, width: 64, height: 64 }),
|
|
164
|
+
/* @__PURE__ */ jsx2("circle", { fill: `url(#${id}-circle)`, cx, cy, r: 45, opacity: 0.7 })
|
|
165
|
+
] }),
|
|
166
|
+
/* @__PURE__ */ jsx2(TalismanOrbLogo, { platform })
|
|
167
|
+
] })
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// src/components/TalismanOrbRectangle.tsx
|
|
174
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
175
|
+
var TalismanOrbRectangle = ({ width, height, seed, className }) => {
|
|
176
|
+
const { id, bgColor1, bgColor2, transform, glowColor, cx, cy } = useTalismanOrb(seed);
|
|
177
|
+
return /* @__PURE__ */ jsxs3(
|
|
178
|
+
"svg",
|
|
179
|
+
{
|
|
180
|
+
width,
|
|
181
|
+
height,
|
|
182
|
+
viewBox: `0 0 64 64`,
|
|
183
|
+
preserveAspectRatio: "none",
|
|
184
|
+
className,
|
|
185
|
+
version: "1.1",
|
|
186
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
187
|
+
children: [
|
|
188
|
+
/* @__PURE__ */ jsxs3("defs", { children: [
|
|
189
|
+
/* @__PURE__ */ jsxs3("linearGradient", { id: `${id}-bg`, children: [
|
|
190
|
+
/* @__PURE__ */ jsx3("stop", { offset: "20%", stopColor: bgColor1 }),
|
|
191
|
+
/* @__PURE__ */ jsx3("stop", { offset: "100%", stopColor: bgColor2 })
|
|
192
|
+
] }),
|
|
193
|
+
/* @__PURE__ */ jsxs3("radialGradient", { id: `${id}-circle`, children: [
|
|
194
|
+
/* @__PURE__ */ jsx3("stop", { offset: "10%", stopColor: glowColor }),
|
|
195
|
+
/* @__PURE__ */ jsx3("stop", { offset: "100%", stopColor: "transparent" })
|
|
196
|
+
] }),
|
|
197
|
+
/* @__PURE__ */ jsx3("clipPath", { id: `${id}-clip`, children: /* @__PURE__ */ jsx3("circle", { cx: "32", cy: "32", r: "48" }) })
|
|
198
|
+
] }),
|
|
199
|
+
/* @__PURE__ */ jsx3("g", { clipPath: `url(#${id}-clip)`, children: /* @__PURE__ */ jsxs3("g", { transform, children: [
|
|
200
|
+
/* @__PURE__ */ jsx3("rect", { fill: `url(#${id}-bg)`, x: -16, y: -16, width: 96, height: 96 }),
|
|
201
|
+
/* @__PURE__ */ jsx3("circle", { fill: `url(#${id}-circle)`, cx, cy, r: 45, opacity: 0.7 })
|
|
202
|
+
] }) })
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// src/util/getTalismanOrbDataUrl.tsx
|
|
209
|
+
import ReactDOMServer from "react-dom/server";
|
|
210
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
211
|
+
var getTalismanOrbDataUrl = (address) => {
|
|
212
|
+
const svg = ReactDOMServer.renderToStaticMarkup(/* @__PURE__ */ jsx4(TalismanOrb, { seed: address }));
|
|
213
|
+
return `data:image/svg+xml;base64,${Buffer.from(svg).toString("base64")}`;
|
|
214
|
+
};
|
|
215
|
+
export {
|
|
216
|
+
TalismanOrb,
|
|
217
|
+
TalismanOrbRectangle,
|
|
218
|
+
getTalismanOrbDataUrl,
|
|
219
|
+
useTalismanOrb
|
|
220
|
+
};
|
|
221
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/TalismanOrbLogo.tsx","../src/components/useTalismanOrb.ts","../src/components/TalismanOrb.tsx","../src/components/TalismanOrbRectangle.tsx","../src/util/getTalismanOrbDataUrl.tsx"],"sourcesContent":["import type { AccountPlatform } from \"@talismn/crypto\"\nimport type { FC } from \"react\"\n\nexport const TalismanOrbLogo: FC<{ platform: AccountPlatform }> = ({ platform }) => {\n switch (platform) {\n case \"ethereum\":\n return (\n <g opacity=\"0.75\" transform=\"scale(0.7) translate(14 14)\" className=\"orb-type\">\n <path\n d=\"M12.8101 32.76L32.0001 44.62L51.1901 32.76L32.0001 -0.0699997L12.8101 32.76Z\"\n fill=\"white\"\n />\n <path\n d=\"M12.8101 36.48L32.0001 48.43L51.1901 36.48L32.0001 63.93L12.8101 36.48Z\"\n fill=\"white\"\n />\n </g>\n )\n case \"polkadot\":\n return (\n <g opacity=\"0.75\" transform=\"scale(2.2) translate(4.5 3.9)\" className=\"orb-type\">\n <path\n d=\"M9.99937 4.4612C12.1176 4.4612 13.8347 3.46253 13.8347 2.2306C13.8347 0.998674 12.1176 0 9.99937 0C7.88119 0 6.16406 0.998674 6.16406 2.2306C6.16406 3.46253 7.88119 4.4612 9.99937 4.4612Z\"\n fill=\"white\"\n />\n <path\n d=\"M9.99937 21.2683C12.1176 21.2683 13.8347 20.2697 13.8347 19.0377C13.8347 17.8058 12.1176 16.8071 9.99937 16.8071C7.88119 16.8071 6.16406 17.8058 6.16406 19.0377C6.16406 20.2697 7.88119 21.2683 9.99937 21.2683Z\"\n fill=\"white\"\n />\n <path\n d=\"M4.65427 7.54892C5.71336 5.71457 5.70649 3.72787 4.63892 3.11149C3.57135 2.49511 1.84735 3.48246 0.788259 5.31681C-0.270832 7.15115 -0.263958 9.13786 0.803612 9.75424C1.87118 10.3706 3.59518 9.38326 4.65427 7.54892Z\"\n fill=\"white\"\n />\n <path\n d=\"M19.2083 15.9515C20.2674 14.1171 20.2611 12.1307 19.1943 11.5148C18.1274 10.8988 16.404 11.8865 15.3449 13.7209C14.2858 15.5552 14.2921 17.5416 15.3589 18.1575C16.4258 18.7735 18.1492 17.7858 19.2083 15.9515Z\"\n fill=\"white\"\n />\n <path\n d=\"M4.6399 18.1571C5.70747 17.5407 5.71434 15.554 4.65525 13.7196C3.59616 11.8853 1.87216 10.8979 0.804589 11.5143C-0.262981 12.1307 -0.269855 14.1174 0.789235 15.9517C1.84833 17.7861 3.57233 18.7734 4.6399 18.1571Z\"\n fill=\"white\"\n />\n <path\n d=\"M19.1952 9.75475C20.2621 9.13878 20.2684 7.15241 19.2093 5.31807C18.1502 3.48372 16.4268 2.49603 15.3599 3.11199C14.2931 3.72796 14.2868 5.71433 15.3459 7.54867C16.405 9.38302 18.1284 10.3707 19.1952 9.75475Z\"\n fill=\"white\"\n />\n </g>\n )\n case \"solana\":\n return (\n <g opacity=\"0.75\" className=\"orb-type\" transform=\"scale(0.45) translate(37.5, 37.5)\">\n <path\n d=\"M70.6648 50.1769L58.9393 62.775C58.6844 63.0486 58.376 63.2668 58.0332 63.4159C57.6905 63.5651 57.3208 63.6419 56.9472 63.6417H1.36128C1.09605 63.6417 0.836598 63.5641 0.614804 63.4184C0.393011 63.2727 0.218536 63.0652 0.112817 62.8215C0.00709765 62.5779 -0.0252603 62.3085 0.0197186 62.0467C0.0646974 61.7848 0.185054 61.5418 0.366 61.3476L12.1006 48.7496C12.3548 48.4766 12.6623 48.2589 13.0039 48.1098C13.3455 47.9607 13.714 47.8834 14.0866 47.8828H69.6695C69.9348 47.8828 70.1942 47.9604 70.416 48.1062C70.6378 48.2519 70.8123 48.4593 70.918 48.703C71.0237 48.9467 71.0561 49.216 71.0111 49.4778C70.9661 49.7397 70.8458 49.9827 70.6648 50.1769V50.1769ZM58.9393 24.8081C58.6844 24.5345 58.376 24.3163 58.0332 24.1672C57.6905 24.0181 57.3208 23.9412 56.9472 23.9414H1.36128C1.09605 23.9414 0.836598 24.019 0.614804 24.1647C0.393011 24.3105 0.218536 24.5179 0.112817 24.7616C0.00709765 25.0053 -0.0252603 25.2746 0.0197186 25.5364C0.0646974 25.7983 0.185054 26.0413 0.366 26.2355L12.1006 38.8336C12.3548 39.1065 12.6623 39.3242 13.0039 39.4733C13.3455 39.6224 13.714 39.6997 14.0866 39.7003H69.6695C69.9348 39.7003 70.1942 39.6227 70.416 39.477C70.6378 39.3313 70.8123 39.1238 70.918 38.8801C71.0237 38.6365 71.0561 38.3671 71.0111 38.1053C70.9661 37.8434 70.8458 37.6004 70.6648 37.4062L58.9393 24.8081ZM1.36128 15.7589H56.9472C57.3208 15.7591 57.6905 15.6822 58.0332 15.5331C58.376 15.384 58.6844 15.1658 58.9393 14.8922L70.6648 2.29413C70.8458 2.09986 70.9661 1.85688 71.0111 1.59502C71.0561 1.33317 71.0237 1.06385 70.918 0.820169C70.8123 0.576485 70.6378 0.369047 70.416 0.223341C70.1942 0.0776352 69.9348 8.97308e-06 69.6695 0L14.0866 0C13.714 0.000635258 13.3455 0.077888 13.0039 0.226975C12.6623 0.376063 12.3548 0.593811 12.1006 0.866739L0.369025 13.4648C0.188254 13.6588 0.0679503 13.9016 0.0228694 14.1631C-0.0222115 14.4247 0.00988974 14.6938 0.115236 14.9373C0.220583 15.1809 0.394595 15.3884 0.615931 15.5343C0.837268 15.6802 1.09631 15.7583 1.36128 15.7589V15.7589Z\"\n fill=\"white\"\n />\n </g>\n )\n default:\n return null\n }\n}\n","import { getAccountPlatformFromAddress, normalizeAddress } from \"@talismn/crypto\"\nimport md5 from \"blueimp-md5\"\nimport Color from \"color\"\nimport { useId, useMemo } from \"react\"\n\nconst djb2 = (str: string) => {\n let hash = 5381\n for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash + str.charCodeAt(i)\n return hash\n}\n\nconst valueFromHash = (hash: string, max: number) => {\n return (max + djb2(hash)) % max\n}\n\nconst colorFromHash = (hash: string) => {\n const hue = valueFromHash(hash, 360)\n return Color.hsv(hue, 100, 100)\n}\n\nconst rotateText = (text: string, nbChars = 0) => text.slice(nbChars) + text.slice(0, nbChars)\n\nexport const useTalismanOrb = (seed: string) => {\n const id = useId()\n\n return useMemo(() => {\n try {\n // those break if seed is empty or an invalid address\n\n // biome-ignore lint/correctness/noInnerDeclarations: hack\n var platform = getAccountPlatformFromAddress(seed)\n\n // seed may be specific to a ss58 prefix, get the base address\n // biome-ignore lint/correctness/noInnerDeclarations: hack\n var address = normalizeAddress(seed)\n } catch {\n platform = \"polkadot\"\n address = seed\n }\n\n // derive 3 hashs from the seed, used to generate the 3 colors\n const hash1 = md5(address)\n const hash2 = rotateText(hash1, 1)\n const hash3 = rotateText(hash1, 2)\n\n // the 2 darkest ones will be used as gradient BG\n // the lightest one will be used as gradient circle, to mimic a 3D lighting effect\n const colors = [colorFromHash(hash1), colorFromHash(hash2), colorFromHash(hash3)].sort(\n (c1, c2) => c1.lightness() - c2.lightness()\n )\n\n // random location in top left corner, avoid beeing to close from the center\n const dotX = 10 + valueFromHash(hash1, 10)\n const dotY = 10 + valueFromHash(hash2, 10)\n\n // global rotation\n const rotation = valueFromHash(hash1, 360)\n\n return {\n id, //multiple avatars should cohabit on the same page\n bgColor1: colors[0].hex(),\n bgColor2: colors[1].hex(),\n glowColor: colors[2].hex(),\n transform: `rotate(${rotation} 32 32)`,\n cx: dotX,\n cy: dotY,\n platform,\n }\n }, [id, seed])\n}\n","import type { FC } from \"react\"\n\nimport { TalismanOrbLogo } from \"./TalismanOrbLogo\"\nimport type { TalismanOrbProps } from \"./types\"\nimport { useTalismanOrb } from \"./useTalismanOrb\"\n\nexport const TalismanOrb: FC<TalismanOrbProps> = ({\n seed,\n width = \"1em\",\n height = \"1em\",\n className,\n}) => {\n const { id, bgColor1, bgColor2, transform, glowColor, cx, cy, platform } = useTalismanOrb(seed)\n\n return (\n <svg\n width={width}\n height={height}\n viewBox={`0 0 64 64`}\n className={className}\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <defs>\n <linearGradient id={`${id}-bg`}>\n <stop offset=\"20%\" stopColor={bgColor1} />\n <stop offset=\"100%\" stopColor={bgColor2} />\n </linearGradient>\n <radialGradient id={`${id}-circle`}>\n <stop offset=\"10%\" stopColor={glowColor} />\n <stop offset=\"100%\" stopColor=\"transparent\" />\n </radialGradient>\n <clipPath id={`${id}-clip`}>\n <circle cx=\"32\" cy=\"32\" r=\"32\" />\n </clipPath>\n </defs>\n <g clipPath={`url(#${id}-clip)`}>\n <g transform={transform}>\n <rect fill={`url(#${id}-bg)`} x={0} y={0} width={64} height={64} />\n <circle fill={`url(#${id}-circle)`} cx={cx} cy={cy} r={45} opacity={0.7} />\n </g>\n <TalismanOrbLogo platform={platform} />\n </g>\n </svg>\n )\n}\n","import type { FC } from \"react\"\n\nimport type { TalismanOrbProps } from \"./types\"\nimport { useTalismanOrb } from \"./useTalismanOrb\"\n\nexport const TalismanOrbRectangle: FC<TalismanOrbProps> = ({ width, height, seed, className }) => {\n const { id, bgColor1, bgColor2, transform, glowColor, cx, cy } = useTalismanOrb(seed)\n\n return (\n <svg\n width={width}\n height={height}\n viewBox={`0 0 64 64`}\n preserveAspectRatio=\"none\"\n className={className}\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <defs>\n <linearGradient id={`${id}-bg`}>\n <stop offset=\"20%\" stopColor={bgColor1} />\n <stop offset=\"100%\" stopColor={bgColor2} />\n </linearGradient>\n <radialGradient id={`${id}-circle`}>\n <stop offset=\"10%\" stopColor={glowColor} />\n <stop offset=\"100%\" stopColor=\"transparent\" />\n </radialGradient>\n <clipPath id={`${id}-clip`}>\n <circle cx=\"32\" cy=\"32\" r=\"48\" />\n </clipPath>\n </defs>\n <g clipPath={`url(#${id}-clip)`}>\n <g transform={transform}>\n <rect fill={`url(#${id}-bg)`} x={-16} y={-16} width={96} height={96} />\n <circle fill={`url(#${id}-circle)`} cx={cx} cy={cy} r={45} opacity={0.7} />\n </g>\n </g>\n </svg>\n )\n}\n","import ReactDOMServer from \"react-dom/server\"\n\nimport { TalismanOrb } from \"../components\"\n\n/**\n * Returns a base64 encoded data url for the Talisman Orb svg\n */\nexport const getTalismanOrbDataUrl = (address: string): `data:image/svg+xml;base64,${string}` => {\n // render the TalismanOrb component and output the SVG as text\n const svg = ReactDOMServer.renderToStaticMarkup(<TalismanOrb seed={address} />)\n\n // convert to data url\n return `data:image/svg+xml;base64,${Buffer.from(svg).toString(\"base64\")}`\n}\n"],"mappings":";AAOQ,SACE,KADF;AAJD,IAAM,kBAAqD,CAAC,EAAE,SAAS,MAAM;AAClF,UAAQ,UAAU;AAAA,IAChB,KAAK;AACH,aACE,qBAAC,OAAE,SAAQ,QAAO,WAAU,+BAA8B,WAAU,YAClE;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACP;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACP;AAAA,SACF;AAAA,IAEJ,KAAK;AACH,aACE,qBAAC,OAAE,SAAQ,QAAO,WAAU,iCAAgC,WAAU,YACpE;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACP;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACP;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACP;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACP;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACP;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,GAAE;AAAA,YACF,MAAK;AAAA;AAAA,QACP;AAAA,SACF;AAAA,IAEJ,KAAK;AACH,aACE,oBAAC,OAAE,SAAQ,QAAO,WAAU,YAAW,WAAU,qCAC/C;AAAA,QAAC;AAAA;AAAA,UACC,GAAE;AAAA,UACF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