@0xchain/better-link 0.0.1
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/README.md +11 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +101 -0
- package/package.json +24 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
interface IGotoAddressOptions {
|
|
2
|
+
chain: string;
|
|
3
|
+
address: string;
|
|
4
|
+
contract?: boolean;
|
|
5
|
+
params?: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
interface IGotoTokenOptions {
|
|
8
|
+
chain: string;
|
|
9
|
+
address?: string;
|
|
10
|
+
params?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
interface IGotoPersonOptions {
|
|
13
|
+
slug: string;
|
|
14
|
+
params?: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
interface IGotoProjectOptions {
|
|
17
|
+
slug: string;
|
|
18
|
+
params?: Record<string, string>;
|
|
19
|
+
}
|
|
20
|
+
interface IGotoOrganizationOptions {
|
|
21
|
+
slug: string;
|
|
22
|
+
params?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
interface IGotoTransactionOptions {
|
|
25
|
+
chain: string;
|
|
26
|
+
hash: string;
|
|
27
|
+
params?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
interface IGotoBlockOptions {
|
|
30
|
+
chain: string;
|
|
31
|
+
height: string | number;
|
|
32
|
+
type?: string;
|
|
33
|
+
params?: Record<string, string>;
|
|
34
|
+
}
|
|
35
|
+
interface IGotoEntityOptions {
|
|
36
|
+
slug: string;
|
|
37
|
+
params?: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
interface IGotoETFOptions {
|
|
40
|
+
region: string;
|
|
41
|
+
slug: string;
|
|
42
|
+
tokenSymbol: string;
|
|
43
|
+
params?: Record<string, string>;
|
|
44
|
+
}
|
|
45
|
+
interface IGotoExplorerOptions {
|
|
46
|
+
chain: string;
|
|
47
|
+
params?: Record<string, string>;
|
|
48
|
+
}
|
|
49
|
+
interface IGotoMarketOptions {
|
|
50
|
+
page?: number;
|
|
51
|
+
params?: Record<string, string>;
|
|
52
|
+
}
|
|
53
|
+
interface IGotoChatOptions {
|
|
54
|
+
locale?: string;
|
|
55
|
+
q?: string;
|
|
56
|
+
}
|
|
57
|
+
interface IGotoAISQLOptions {
|
|
58
|
+
locale?: string;
|
|
59
|
+
q?: string;
|
|
60
|
+
}
|
|
61
|
+
interface IGotoLoginOptions {
|
|
62
|
+
locale: string;
|
|
63
|
+
redirect: string;
|
|
64
|
+
}
|
|
65
|
+
export default function BetterLink(): {
|
|
66
|
+
gotoAddress: (options: IGotoAddressOptions) => string;
|
|
67
|
+
gotoToken: (options: IGotoTokenOptions) => string;
|
|
68
|
+
gotoProject: (options: IGotoProjectOptions) => string;
|
|
69
|
+
gotoPerson: (options: IGotoPersonOptions) => string;
|
|
70
|
+
gotoOrganization: (options: IGotoOrganizationOptions) => string;
|
|
71
|
+
gotoTransaction: (options: IGotoTransactionOptions) => string;
|
|
72
|
+
gotoBlock: (options: IGotoBlockOptions) => string;
|
|
73
|
+
gotoEntity: (options: IGotoEntityOptions) => string;
|
|
74
|
+
gotoETF: (options: IGotoETFOptions) => string;
|
|
75
|
+
gotoExplorer: (options: IGotoExplorerOptions) => string;
|
|
76
|
+
gotoMarket: (options: IGotoMarketOptions) => string;
|
|
77
|
+
gotoNews: (options: IGotoMarketOptions) => string;
|
|
78
|
+
gotoChat(options: IGotoChatOptions): string;
|
|
79
|
+
gotoAISQL(options: IGotoAISQLOptions): string;
|
|
80
|
+
gotoExplorerSearch(params: Record<string, string>): string;
|
|
81
|
+
gotoLogin(options: IGotoLoginOptions): string;
|
|
82
|
+
};
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts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ethereum", "eth"],
|
|
7
|
+
["solana", "sol"],
|
|
8
|
+
["terra", "terra"],
|
|
9
|
+
["near", "near"],
|
|
10
|
+
["polygon", "matic"],
|
|
11
|
+
["avalanche", "avax"],
|
|
12
|
+
["binance", "bsc"],
|
|
13
|
+
["bnb chain", "bnb"]
|
|
14
|
+
]);
|
|
15
|
+
function a(e) {
|
|
16
|
+
return i.get(e == null ? void 0 : e.toLowerCase()) || (e == null ? void 0 : e.toLowerCase());
|
|
17
|
+
}
|
|
18
|
+
function n(e) {
|
|
19
|
+
var o;
|
|
20
|
+
const r = {};
|
|
21
|
+
return e && Object.keys(e).forEach((t) => {
|
|
22
|
+
e[t] && (r[t] = e[t]);
|
|
23
|
+
}), ((o = Object.keys(r)) == null ? void 0 : o.length) > 0 ? `?${new URLSearchParams(r).toString()}` : "";
|
|
24
|
+
}
|
|
25
|
+
function u() {
|
|
26
|
+
return {
|
|
27
|
+
gotoAddress: (e) => {
|
|
28
|
+
const { chain: r, address: o, params: t } = e, s = n(t);
|
|
29
|
+
return `/explorer/${a(r)}/address/${o}${s}`;
|
|
30
|
+
},
|
|
31
|
+
gotoToken: (e) => {
|
|
32
|
+
const { chain: r, address: o, params: t } = e, s = n(t);
|
|
33
|
+
return `/explorer/${a(r)}/token${o && o.length > 10 ? `/${o}` : ""}${s}`;
|
|
34
|
+
},
|
|
35
|
+
gotoProject: (e) => {
|
|
36
|
+
const { slug: r, params: o } = e, t = n(o);
|
|
37
|
+
return `/project/${r}${t}`;
|
|
38
|
+
},
|
|
39
|
+
gotoPerson: (e) => {
|
|
40
|
+
const { slug: r, params: o } = e, t = n(o);
|
|
41
|
+
return `/person/${r}${t}`;
|
|
42
|
+
},
|
|
43
|
+
gotoOrganization: (e) => {
|
|
44
|
+
const { slug: r, params: o } = e, t = n(o);
|
|
45
|
+
return `/organization/${r}${t}`;
|
|
46
|
+
},
|
|
47
|
+
gotoTransaction: (e) => {
|
|
48
|
+
const { chain: r, hash: o, params: t } = e, s = n(t);
|
|
49
|
+
return `/explorer/${a(r)}/tx/${o}${s}`;
|
|
50
|
+
},
|
|
51
|
+
gotoBlock: (e) => {
|
|
52
|
+
const { chain: r, height: o, type: t, params: s } = e, c = n(s), $ = typeof o == "number" ? o : o != null && o.includes("coinbase_") ? `0x${o == null ? void 0 : o.replace("coinbase_", "")}` : o;
|
|
53
|
+
return `/explorer/${a(r)}/block${t ? `/${t}` : ""}/${$}${c}`;
|
|
54
|
+
},
|
|
55
|
+
gotoEntity: (e) => {
|
|
56
|
+
const { slug: r, params: o } = e, t = n(o);
|
|
57
|
+
return `/entity/${r}${t}`;
|
|
58
|
+
},
|
|
59
|
+
gotoETF: (e) => {
|
|
60
|
+
const { region: r, slug: o, tokenSymbol: t, params: s } = e, c = n(s), $ = r == null ? void 0 : r.toLowerCase(), l = t == null ? void 0 : t.toLowerCase(), g = `/etf/${l}-${$}`;
|
|
61
|
+
return l === o ? `${g}${c}` : `${g}/${o}${c}`;
|
|
62
|
+
},
|
|
63
|
+
gotoExplorer: (e) => {
|
|
64
|
+
const { chain: r, params: o } = e, t = n(o);
|
|
65
|
+
return `/explorer/${a(r)}${t}`;
|
|
66
|
+
},
|
|
67
|
+
gotoMarket: (e) => {
|
|
68
|
+
const { page: r, params: o } = e, t = n(o);
|
|
69
|
+
return `/market${r ? `/${r}` : ""}${t}`;
|
|
70
|
+
},
|
|
71
|
+
gotoNews: (e) => {
|
|
72
|
+
const { page: r, params: o } = e, t = n(o);
|
|
73
|
+
return `/news${r ? `/${r}` : ""}${t}`;
|
|
74
|
+
},
|
|
75
|
+
gotoChat(e) {
|
|
76
|
+
const { locale: r, q: o } = e, t = n({ q: o || "" });
|
|
77
|
+
return `${process.env.NEXT_PUBLIC_BASE_URL}${r ? `/${r}` : ""}/${t}`;
|
|
78
|
+
},
|
|
79
|
+
gotoAISQL(e) {
|
|
80
|
+
const { locale: r, q: o } = e, t = n({ q: o || "" });
|
|
81
|
+
return `${process.env.NEXT_PUBLIC_BASE_URL}${r ? `/${r}` : ""}/sql${t}`;
|
|
82
|
+
},
|
|
83
|
+
gotoExplorerSearch(e) {
|
|
84
|
+
var o, t;
|
|
85
|
+
return `/explorer/search${n({
|
|
86
|
+
chain: i.get((o = e == null ? void 0 : e.chain) == null ? void 0 : o.toLowerCase()) || ((t = e == null ? void 0 : e.chain) == null ? void 0 : t.toLowerCase()) || "",
|
|
87
|
+
q: (e == null ? void 0 : e.q) || "",
|
|
88
|
+
type: (e == null ? void 0 : e.type) || "",
|
|
89
|
+
_t: Date.now().toString()
|
|
90
|
+
// 添加时间戳强制刷新
|
|
91
|
+
})}`;
|
|
92
|
+
},
|
|
93
|
+
gotoLogin(e) {
|
|
94
|
+
const { locale: r, redirect: o } = e, t = n({ redirect_uri: o || "" });
|
|
95
|
+
return `${r ? `/${r}` : ""}/login${t}`;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
u as default
|
|
101
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@0xchain/better-link",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"!**/*.tsbuildinfo"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
}
|
|
24
|
+
}
|