keyring-chatbot-agent-sdk-test 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 +151 -0
- package/dist/chat-widget-wc.es.js +32722 -0
- package/dist/chat-widget-wc.umd.js +273 -0
- package/dist/chat-widget.es.js +3648 -0
- package/dist/chat-widget.umd.js +31 -0
- package/dist/lib.d.ts +57 -0
- package/dist/vite.svg +1 -0
- package/package.json +94 -0
|
@@ -0,0 +1,3648 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".chat-button{position:fixed;bottom:24px;right:24px;width:56px;height:56px;border-radius:50%;background:linear-gradient(135deg,#667eea,#764ba2);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 12px #00000026;transition:all .3s ease;z-index:9998}.chat-button:hover{transform:scale(1.1);box-shadow:0 6px 16px #0003}.chat-button:active{transform:scale(.95)}.chat-modal-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:transparent;display:flex;align-items:flex-end;justify-content:flex-end;z-index:9999;pointer-events:all;animation:fadeIn .2s ease}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.chat-modal{width:90%;max-width:480px;height:700px;max-height:85vh;background:#f5f5f7;border-radius:24px;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 20px 60px #0000004d;margin:20px;pointer-events:all;animation:slideUp .3s ease}@keyframes slideUp{0%{transform:translateY(30px);opacity:0}to{transform:translateY(0);opacity:1}}.chat-modal-header{background:#fff;padding:16px 20px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #e5e5e7}.chat-modal-header-left{display:flex;align-items:center;gap:12px}.keyring-logo{width:32px;height:32px}.chat-modal-header h3{margin:0;font-size:18px;font-weight:700;color:#1a1a1d}.close-button{background:transparent;border:none;cursor:pointer;padding:8px;border-radius:8px;color:#666;transition:all .2s}.close-button:hover{background:#f5f5f7;color:#000}.chat-user-info{background:#fff;padding:12px 20px;display:flex;align-items:center;gap:10px;border-bottom:1px solid #e5e5e7}.user-avatar{width:20px;height:20px;border-radius:50%}.user-wallet{font-size:14px;font-weight:500;color:#1a1a1d}.chat-modal-messages{flex:1;padding:20px;overflow-y:auto;display:flex;flex-direction:column;gap:12px}.date-separator{text-align:center;font-size:12px;font-weight:600;color:#666;background:#e5e5e7;padding:6px 16px;border-radius:12px;align-self:center;width:fit-content;margin:8px auto}.message{display:flex;animation:messageSlide .3s ease;position:relative}.message:hover .message-reply-button{opacity:1}@keyframes messageSlide{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.message-reply-button{position:absolute;top:50%;transform:translateY(-50%);background:#fff;border:1px solid #e5e5e7;border-radius:8px;padding:6px;cursor:pointer;opacity:0;transition:all .2s;box-shadow:0 2px 8px #0000001a;z-index:10}.message-bot .message-reply-button{right:20px}.message-user .message-reply-button{left:20px}.message-reply-button:hover{background:#f5f5f7;transform:translateY(-50%) scale(1.1)}.message-reply-button svg{display:block;width:16px;height:16px;color:#666}.message-bot{justify-content:flex-start}.message-user{justify-content:flex-end}.message-bubble{max-width:85%;padding:14px 16px;border-radius:20px}.message-bot .message-bubble{background:#fff;box-shadow:0 2px 8px #0000000f;border-bottom-left-radius:4px}.message-user .message-bubble{background:#5b7fff;color:#fff;border-bottom-right-radius:4px}.message-reply-to{background:#0000000d;padding:8px 12px;border-radius:12px;margin-bottom:8px;border-left:3px solid #5b7fff}.message-bot .message-reply-to{background:#f5f5f7}.message-user .message-reply-to{background:#ffffff26;border-left-color:#ffffff80}.message-reply-to-label{font-size:11px;font-weight:600;margin-bottom:4px}.message-bot .message-reply-to-label{color:#5b7fff}.message-user .message-reply-to-label{color:#ffffffe6}.message-reply-to-text{font-size:12px;opacity:.8;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.message-text{font-size:14px;line-height:1.5;margin-bottom:6px;word-wrap:break-word;white-space:pre-line}.message-bot .message-text{color:#1a1a1d}.message-user .message-text{color:#fff}.message-buttons{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px;margin-bottom:8px}.message-button{flex:0 1 calc(33.333% - 6px);min-width:100px;padding:10px 16px;background:#fffffff2;border:1px solid #e0e0e0;border-radius:12px;font-size:13px;font-weight:500;color:#1a1a1d;cursor:pointer;transition:all .2s ease;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.message-button.full-width{flex:1 1 100%;text-align:left;white-space:normal;padding:12px 16px;font-size:14px}.message-buttons:not(:has(.full-width)) .message-button{flex:1 1 calc(25% - 6px);min-width:60px}.message-buttons:has(.message-button:not(.full-width)):not(:has(.message-button.full-width)) .message-button{flex:1 1 calc(25% - 6px);min-width:60px}.message-button:hover{background:#fff;border-color:#007aff;color:#007aff;transform:translateY(-1px);box-shadow:0 2px 8px #007aff26}.message-button:active{transform:translateY(0);box-shadow:0 1px 4px #007aff1a}.message-user .message-button{background:#fff3;border-color:#ffffff4d;color:#fff}.message-user .message-button:hover{background:#ffffff4d;border-color:#ffffff80}.message-timestamp{font-size:11px;color:#999;display:flex;align-items:center;gap:4px;justify-content:flex-end}.message-user .message-timestamp{color:#ffffffb3}.check-icon{width:14px;height:14px}.typing-indicator .message-bubble{padding:12px 18px;display:flex;gap:6px;min-width:60px}.typing-dot{width:8px;height:8px;border-radius:50%;background:#999;animation:typingDot 1.4s infinite ease-in-out}.typing-dot:nth-child(1){animation-delay:0s}.typing-dot:nth-child(2){animation-delay:.2s}.typing-dot:nth-child(3){animation-delay:.4s}@keyframes typingDot{0%,60%,to{transform:translateY(0);opacity:.7}30%{transform:translateY(-8px);opacity:1}}.suggestions-container{display:flex;flex-direction:column;gap:10px;margin-top:8px}.suggestion-button{background:#d4d8f0;border:none;padding:14px 18px;border-radius:16px;display:flex;align-items:center;gap:12px;cursor:pointer;transition:all .2s;font-size:14px;font-weight:500;color:#1a1a1d;width:100%;text-align:left}.suggestion-button:hover{background:#c5caeb;transform:translateY(-1px)}.suggestion-icon{font-size:18px}.chat-modal-input{padding:16px 20px;background:#fff;border-top:1px solid #e5e5e7;display:flex;flex-direction:column;gap:12px}.reply-preview{background:#f5f5f7;padding:10px 14px;border-radius:12px;border-left:3px solid #5b7fff;display:flex;justify-content:space-between;align-items:flex-start;gap:10px}.reply-preview-content{flex:1;min-width:0}.reply-preview-label{font-size:11px;color:#5b7fff;font-weight:600;margin-bottom:4px}.reply-preview-text{font-size:13px;color:#666;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.reply-preview-close{background:transparent;border:none;cursor:pointer;padding:2px;color:#999;transition:color .2s;flex-shrink:0}.reply-preview-close:hover{color:#666}.chat-modal-input-row{display:flex;gap:12px}.chat-modal-input input{flex:1;padding:14px 18px;border:1px solid #e5e5e7;border-radius:24px;outline:none;font-size:14px;color:#1a1a1d;transition:all .2s}.chat-modal-input input::placeholder{color:#999}.chat-modal-input input:focus{border-color:#5b7fff;box-shadow:0 0 0 3px #5b7fff1a}.chat-modal-input input:disabled{opacity:.6;cursor:not-allowed;background:#f5f5f7}.send-button{width:44px;height:44px;border-radius:50%;background:#5b7fff;border:none;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .2s}.send-button:hover:not(:disabled){background:#4a6fee;transform:scale(1.05)}.send-button:disabled{opacity:.4;cursor:not-allowed}.chat-modal-messages::-webkit-scrollbar{width:6px}.chat-modal-messages::-webkit-scrollbar-thumb{background:#d1d1d6;border-radius:3px}@media(max-width:640px){.chat-modal{width:100%;height:100%;max-height:100%;border-radius:0}}.message-content{display:block;word-wrap:break-word;overflow-wrap:break-word;max-width:100%;overflow:hidden;font-size:inherit;line-height:1.5}.mc-line{min-height:1.2em;word-break:break-word}.mc-empty-line{height:.5em}.mc-heading{font-weight:600;margin:.3em 0;word-break:break-word}.mc-h1{font-size:1.4em}.mc-h2{font-size:1.2em}.mc-h3{font-size:1.05em}.mc-inline-code{background:#afb8c133;padding:1px 5px;border-radius:3px;font-family:Monaco,Menlo,Ubuntu Mono,Consolas,monospace;font-size:.88em}.mc-codeblock{background:#f6f8fa;border:1px solid #d0d7de;border-radius:6px;margin:6px 0;overflow:hidden;max-width:100%}.mc-codeblock-lang{background:#e8ecf0;padding:3px 10px;font-size:.75em;font-weight:600;color:#57606a;text-transform:uppercase;font-family:Monaco,Menlo,monospace;border-bottom:1px solid #d0d7de}.mc-codeblock pre{margin:0;padding:10px;overflow-x:auto}.mc-codeblock code{font-family:Monaco,Menlo,Ubuntu Mono,Consolas,monospace;font-size:.85em;line-height:1.5;color:#24292f;white-space:pre}.mc-link{color:#0969da;text-decoration:none;word-break:break-word}.mc-link:hover{text-decoration:underline}.mc-image{max-width:100%;height:auto;border-radius:6px;margin:4px 0;display:block}.mc-image-inline{width:20px;height:20px;border-radius:50%;margin:0 4px;display:inline-block;vertical-align:middle;object-fit:cover}.mc-blockquote{margin:4px 0;padding:2px 0 2px 12px;color:#57606a;border-left:3px solid #d0d7de}.mc-hr{height:1px;border:0;background:#d0d7de;margin:.4em 0}.message-content strong{font-weight:600}.message-content del{text-decoration:line-through}")),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
+
import { jsx as k, jsxs as V, Fragment as pn } from "react/jsx-runtime";
|
|
3
|
+
import { memo as mn, createContext as Ot, useContext as Lt, useState as Ae, useEffect as Te, useRef as It, useCallback as Q, useMemo as gn } from "react";
|
|
4
|
+
const bn = mn(({ onClick: e }) => /* @__PURE__ */ k(
|
|
5
|
+
"button",
|
|
6
|
+
{
|
|
7
|
+
className: "chat-button",
|
|
8
|
+
onClick: e,
|
|
9
|
+
onKeyDown: (n) => {
|
|
10
|
+
(n.key === "Enter" || n.key === " ") && (n.preventDefault(), e());
|
|
11
|
+
},
|
|
12
|
+
"aria-label": "Open chat",
|
|
13
|
+
title: "Open chat support",
|
|
14
|
+
type: "button",
|
|
15
|
+
children: /* @__PURE__ */ k(
|
|
16
|
+
"svg",
|
|
17
|
+
{
|
|
18
|
+
width: "24",
|
|
19
|
+
height: "24",
|
|
20
|
+
viewBox: "0 0 24 24",
|
|
21
|
+
fill: "none",
|
|
22
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
23
|
+
children: /* @__PURE__ */ k(
|
|
24
|
+
"path",
|
|
25
|
+
{
|
|
26
|
+
d: "M20 2H4C2.9 2 2.01 2.9 2.01 4L2 22L6 18H20C21.1 18 22 17.1 22 16V4C22 2.9 21.1 2 20 2ZM18 14H6V12H18V14ZM18 11H6V9H18V11ZM18 8H6V6H18V8Z",
|
|
27
|
+
fill: "white"
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
)), Y = [];
|
|
34
|
+
for (let e = 0; e < 256; ++e)
|
|
35
|
+
Y.push((e + 256).toString(16).slice(1));
|
|
36
|
+
function yn(e, t = 0) {
|
|
37
|
+
return (Y[e[t + 0]] + Y[e[t + 1]] + Y[e[t + 2]] + Y[e[t + 3]] + "-" + Y[e[t + 4]] + Y[e[t + 5]] + "-" + Y[e[t + 6]] + Y[e[t + 7]] + "-" + Y[e[t + 8]] + Y[e[t + 9]] + "-" + Y[e[t + 10]] + Y[e[t + 11]] + Y[e[t + 12]] + Y[e[t + 13]] + Y[e[t + 14]] + Y[e[t + 15]]).toLowerCase();
|
|
38
|
+
}
|
|
39
|
+
let tt;
|
|
40
|
+
const xn = new Uint8Array(16);
|
|
41
|
+
function wn() {
|
|
42
|
+
if (!tt) {
|
|
43
|
+
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
44
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
45
|
+
tt = crypto.getRandomValues.bind(crypto);
|
|
46
|
+
}
|
|
47
|
+
return tt(xn);
|
|
48
|
+
}
|
|
49
|
+
const In = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), vt = { randomUUID: In };
|
|
50
|
+
function vn(e, t, n) {
|
|
51
|
+
e = e || {};
|
|
52
|
+
const r = e.random ?? e.rng?.() ?? wn();
|
|
53
|
+
if (r.length < 16)
|
|
54
|
+
throw new Error("Random bytes length must be >= 16");
|
|
55
|
+
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, yn(r);
|
|
56
|
+
}
|
|
57
|
+
function qe(e, t, n) {
|
|
58
|
+
return vt.randomUUID && !e ? vt.randomUUID() : vn(e);
|
|
59
|
+
}
|
|
60
|
+
const En = "chat_widget_messages";
|
|
61
|
+
function ve(e) {
|
|
62
|
+
const t = {
|
|
63
|
+
formatters: void 0,
|
|
64
|
+
fees: void 0,
|
|
65
|
+
serializers: void 0,
|
|
66
|
+
...e
|
|
67
|
+
};
|
|
68
|
+
function n(r) {
|
|
69
|
+
return (s) => {
|
|
70
|
+
const c = typeof s == "function" ? s(r) : s, l = { ...r, ...c };
|
|
71
|
+
return Object.assign(l, { extend: n(l) });
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return Object.assign(t, {
|
|
75
|
+
extend: n(t)
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const zt = "2.45.1";
|
|
79
|
+
let nt = {
|
|
80
|
+
getDocsUrl: ({ docsBaseUrl: e, docsPath: t = "", docsSlug: n }) => t ? `${e ?? "https://viem.sh"}${t}${n ? `#${n}` : ""}` : void 0,
|
|
81
|
+
version: `viem@${zt}`
|
|
82
|
+
};
|
|
83
|
+
class D extends Error {
|
|
84
|
+
constructor(t, n = {}) {
|
|
85
|
+
const r = n.cause instanceof D ? n.cause.details : n.cause?.message ? n.cause.message : n.details, s = n.cause instanceof D && n.cause.docsPath || n.docsPath, c = nt.getDocsUrl?.({ ...n, docsPath: s }), l = [
|
|
86
|
+
t || "An error occurred.",
|
|
87
|
+
"",
|
|
88
|
+
...n.metaMessages ? [...n.metaMessages, ""] : [],
|
|
89
|
+
...c ? [`Docs: ${c}`] : [],
|
|
90
|
+
...r ? [`Details: ${r}`] : [],
|
|
91
|
+
...nt.version ? [`Version: ${nt.version}`] : []
|
|
92
|
+
].join(`
|
|
93
|
+
`);
|
|
94
|
+
super(l, n.cause ? { cause: n.cause } : void 0), Object.defineProperty(this, "details", {
|
|
95
|
+
enumerable: !0,
|
|
96
|
+
configurable: !0,
|
|
97
|
+
writable: !0,
|
|
98
|
+
value: void 0
|
|
99
|
+
}), Object.defineProperty(this, "docsPath", {
|
|
100
|
+
enumerable: !0,
|
|
101
|
+
configurable: !0,
|
|
102
|
+
writable: !0,
|
|
103
|
+
value: void 0
|
|
104
|
+
}), Object.defineProperty(this, "metaMessages", {
|
|
105
|
+
enumerable: !0,
|
|
106
|
+
configurable: !0,
|
|
107
|
+
writable: !0,
|
|
108
|
+
value: void 0
|
|
109
|
+
}), Object.defineProperty(this, "shortMessage", {
|
|
110
|
+
enumerable: !0,
|
|
111
|
+
configurable: !0,
|
|
112
|
+
writable: !0,
|
|
113
|
+
value: void 0
|
|
114
|
+
}), Object.defineProperty(this, "version", {
|
|
115
|
+
enumerable: !0,
|
|
116
|
+
configurable: !0,
|
|
117
|
+
writable: !0,
|
|
118
|
+
value: void 0
|
|
119
|
+
}), Object.defineProperty(this, "name", {
|
|
120
|
+
enumerable: !0,
|
|
121
|
+
configurable: !0,
|
|
122
|
+
writable: !0,
|
|
123
|
+
value: "BaseError"
|
|
124
|
+
}), this.details = r, this.docsPath = s, this.metaMessages = n.metaMessages, this.name = n.name ?? this.name, this.shortMessage = t, this.version = zt;
|
|
125
|
+
}
|
|
126
|
+
walk(t) {
|
|
127
|
+
return Ft(this, t);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function Ft(e, t) {
|
|
131
|
+
return t?.(e) ? e : e && typeof e == "object" && "cause" in e && e.cause !== void 0 ? Ft(e.cause, t) : t ? null : e;
|
|
132
|
+
}
|
|
133
|
+
class Dt extends D {
|
|
134
|
+
constructor({ max: t, min: n, signed: r, size: s, value: c }) {
|
|
135
|
+
super(`Number "${c}" is not in safe ${s ? `${s * 8}-bit ${r ? "signed" : "unsigned"} ` : ""}integer range ${t ? `(${n} to ${t})` : `(above ${n})`}`, { name: "IntegerOutOfRangeError" });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
class An extends D {
|
|
139
|
+
constructor({ givenSize: t, maxSize: n }) {
|
|
140
|
+
super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function De(e, { strict: t = !0 } = {}) {
|
|
144
|
+
return !e || typeof e != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(e) : e.startsWith("0x");
|
|
145
|
+
}
|
|
146
|
+
function Be(e) {
|
|
147
|
+
return De(e, { strict: !1 }) ? Math.ceil((e.length - 2) / 2) : e.length;
|
|
148
|
+
}
|
|
149
|
+
function Ye(e, { dir: t = "left" } = {}) {
|
|
150
|
+
let n = typeof e == "string" ? e.replace("0x", "") : e, r = 0;
|
|
151
|
+
for (let s = 0; s < n.length - 1 && n[t === "left" ? s : n.length - s - 1].toString() === "0"; s++)
|
|
152
|
+
r++;
|
|
153
|
+
return n = t === "left" ? n.slice(r) : n.slice(0, n.length - r), typeof e == "string" ? (n.length === 1 && t === "right" && (n = `${n}0`), `0x${n.length % 2 === 1 ? `0${n}` : n}`) : n;
|
|
154
|
+
}
|
|
155
|
+
class Tn extends D {
|
|
156
|
+
constructor({ offset: t, position: n, size: r }) {
|
|
157
|
+
super(`Slice ${n === "start" ? "starting" : "ending"} at offset "${t}" is out-of-bounds (size: ${r}).`, { name: "SliceOffsetOutOfBoundsError" });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
class $t extends D {
|
|
161
|
+
constructor({ size: t, targetSize: n, type: r }) {
|
|
162
|
+
super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function ke(e, { dir: t, size: n = 32 } = {}) {
|
|
166
|
+
return typeof e == "string" ? Bn(e, { dir: t, size: n }) : kn(e, { dir: t, size: n });
|
|
167
|
+
}
|
|
168
|
+
function Bn(e, { dir: t, size: n = 32 } = {}) {
|
|
169
|
+
if (n === null)
|
|
170
|
+
return e;
|
|
171
|
+
const r = e.replace("0x", "");
|
|
172
|
+
if (r.length > n * 2)
|
|
173
|
+
throw new $t({
|
|
174
|
+
size: Math.ceil(r.length / 2),
|
|
175
|
+
targetSize: n,
|
|
176
|
+
type: "hex"
|
|
177
|
+
});
|
|
178
|
+
return `0x${r[t === "right" ? "padEnd" : "padStart"](n * 2, "0")}`;
|
|
179
|
+
}
|
|
180
|
+
function kn(e, { dir: t, size: n = 32 } = {}) {
|
|
181
|
+
if (n === null)
|
|
182
|
+
return e;
|
|
183
|
+
if (e.length > n)
|
|
184
|
+
throw new $t({
|
|
185
|
+
size: e.length,
|
|
186
|
+
targetSize: n,
|
|
187
|
+
type: "bytes"
|
|
188
|
+
});
|
|
189
|
+
const r = new Uint8Array(n);
|
|
190
|
+
for (let s = 0; s < n; s++) {
|
|
191
|
+
const c = t === "right";
|
|
192
|
+
r[c ? s : n - s - 1] = e[c ? s : e.length - s - 1];
|
|
193
|
+
}
|
|
194
|
+
return r;
|
|
195
|
+
}
|
|
196
|
+
const Pn = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
197
|
+
function Le(e, t = {}) {
|
|
198
|
+
return typeof e == "number" || typeof e == "bigint" ? z(e, t) : typeof e == "string" ? Un(e, t) : typeof e == "boolean" ? Nn(e, t) : ge(e, t);
|
|
199
|
+
}
|
|
200
|
+
function Nn(e, t = {}) {
|
|
201
|
+
const n = `0x${Number(e)}`;
|
|
202
|
+
return typeof t.size == "number" ? (Pe(n, { size: t.size }), ke(n, { size: t.size })) : n;
|
|
203
|
+
}
|
|
204
|
+
function ge(e, t = {}) {
|
|
205
|
+
let n = "";
|
|
206
|
+
for (let s = 0; s < e.length; s++)
|
|
207
|
+
n += Pn[e[s]];
|
|
208
|
+
const r = `0x${n}`;
|
|
209
|
+
return typeof t.size == "number" ? (Pe(r, { size: t.size }), ke(r, { dir: "right", size: t.size })) : r;
|
|
210
|
+
}
|
|
211
|
+
function z(e, t = {}) {
|
|
212
|
+
const { signed: n, size: r } = t, s = BigInt(e);
|
|
213
|
+
let c;
|
|
214
|
+
r ? n ? c = (1n << BigInt(r) * 8n - 1n) - 1n : c = 2n ** (BigInt(r) * 8n) - 1n : typeof e == "number" && (c = BigInt(Number.MAX_SAFE_INTEGER));
|
|
215
|
+
const l = typeof c == "bigint" && n ? -c - 1n : 0;
|
|
216
|
+
if (c && s > c || s < l) {
|
|
217
|
+
const w = typeof e == "bigint" ? "n" : "";
|
|
218
|
+
throw new Dt({
|
|
219
|
+
max: c ? `${c}${w}` : void 0,
|
|
220
|
+
min: `${l}${w}`,
|
|
221
|
+
signed: n,
|
|
222
|
+
size: r,
|
|
223
|
+
value: `${e}${w}`
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
const b = `0x${(n && s < 0 ? (1n << BigInt(r * 8)) + BigInt(s) : s).toString(16)}`;
|
|
227
|
+
return r ? ke(b, { size: r }) : b;
|
|
228
|
+
}
|
|
229
|
+
const Sn = /* @__PURE__ */ new TextEncoder();
|
|
230
|
+
function Un(e, t = {}) {
|
|
231
|
+
const n = Sn.encode(e);
|
|
232
|
+
return ge(n, t);
|
|
233
|
+
}
|
|
234
|
+
const Cn = /* @__PURE__ */ new TextEncoder();
|
|
235
|
+
function Gt(e, t = {}) {
|
|
236
|
+
return typeof e == "number" || typeof e == "bigint" ? On(e, t) : typeof e == "boolean" ? Mn(e, t) : De(e) ? ye(e, t) : _t(e, t);
|
|
237
|
+
}
|
|
238
|
+
function Mn(e, t = {}) {
|
|
239
|
+
const n = new Uint8Array(1);
|
|
240
|
+
return n[0] = Number(e), typeof t.size == "number" ? (Pe(n, { size: t.size }), ke(n, { size: t.size })) : n;
|
|
241
|
+
}
|
|
242
|
+
const le = {
|
|
243
|
+
zero: 48,
|
|
244
|
+
nine: 57,
|
|
245
|
+
A: 65,
|
|
246
|
+
F: 70,
|
|
247
|
+
a: 97,
|
|
248
|
+
f: 102
|
|
249
|
+
};
|
|
250
|
+
function Et(e) {
|
|
251
|
+
if (e >= le.zero && e <= le.nine)
|
|
252
|
+
return e - le.zero;
|
|
253
|
+
if (e >= le.A && e <= le.F)
|
|
254
|
+
return e - (le.A - 10);
|
|
255
|
+
if (e >= le.a && e <= le.f)
|
|
256
|
+
return e - (le.a - 10);
|
|
257
|
+
}
|
|
258
|
+
function ye(e, t = {}) {
|
|
259
|
+
let n = e;
|
|
260
|
+
t.size && (Pe(n, { size: t.size }), n = ke(n, { dir: "right", size: t.size }));
|
|
261
|
+
let r = n.slice(2);
|
|
262
|
+
r.length % 2 && (r = `0${r}`);
|
|
263
|
+
const s = r.length / 2, c = new Uint8Array(s);
|
|
264
|
+
for (let l = 0, b = 0; l < s; l++) {
|
|
265
|
+
const w = Et(r.charCodeAt(b++)), E = Et(r.charCodeAt(b++));
|
|
266
|
+
if (w === void 0 || E === void 0)
|
|
267
|
+
throw new D(`Invalid byte sequence ("${r[b - 2]}${r[b - 1]}" in "${r}").`);
|
|
268
|
+
c[l] = w * 16 + E;
|
|
269
|
+
}
|
|
270
|
+
return c;
|
|
271
|
+
}
|
|
272
|
+
function On(e, t) {
|
|
273
|
+
const n = z(e, t);
|
|
274
|
+
return ye(n);
|
|
275
|
+
}
|
|
276
|
+
function _t(e, t = {}) {
|
|
277
|
+
const n = Cn.encode(e);
|
|
278
|
+
return typeof t.size == "number" ? (Pe(n, { size: t.size }), ke(n, { dir: "right", size: t.size })) : n;
|
|
279
|
+
}
|
|
280
|
+
function Pe(e, { size: t }) {
|
|
281
|
+
if (Be(e) > t)
|
|
282
|
+
throw new An({
|
|
283
|
+
givenSize: Be(e),
|
|
284
|
+
maxSize: t
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
function Ee(e, t = {}) {
|
|
288
|
+
const { signed: n } = t;
|
|
289
|
+
t.size && Pe(e, { size: t.size });
|
|
290
|
+
const r = BigInt(e);
|
|
291
|
+
if (!n)
|
|
292
|
+
return r;
|
|
293
|
+
const s = (e.length - 2) / 2, c = (1n << BigInt(s) * 8n - 1n) - 1n;
|
|
294
|
+
return r <= c ? r : r - BigInt(`0x${"f".padStart(s * 2, "f")}`) - 1n;
|
|
295
|
+
}
|
|
296
|
+
function Ke(e, t = {}) {
|
|
297
|
+
const n = Ee(e, t), r = Number(n);
|
|
298
|
+
if (!Number.isSafeInteger(r))
|
|
299
|
+
throw new Dt({
|
|
300
|
+
max: `${Number.MAX_SAFE_INTEGER}`,
|
|
301
|
+
min: `${Number.MIN_SAFE_INTEGER}`,
|
|
302
|
+
signed: t.signed,
|
|
303
|
+
size: t.size,
|
|
304
|
+
value: `${n}n`
|
|
305
|
+
});
|
|
306
|
+
return r;
|
|
307
|
+
}
|
|
308
|
+
function dt(e, t) {
|
|
309
|
+
return ({ exclude: n, format: r }) => ({
|
|
310
|
+
exclude: n,
|
|
311
|
+
format: (s, c) => {
|
|
312
|
+
const l = t(s, c);
|
|
313
|
+
if (n)
|
|
314
|
+
for (const b of n)
|
|
315
|
+
delete l[b];
|
|
316
|
+
return {
|
|
317
|
+
...l,
|
|
318
|
+
...r(s, c)
|
|
319
|
+
};
|
|
320
|
+
},
|
|
321
|
+
type: e
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
const Ht = {
|
|
325
|
+
"0x0": "legacy",
|
|
326
|
+
"0x1": "eip2930",
|
|
327
|
+
"0x2": "eip1559",
|
|
328
|
+
"0x3": "eip4844",
|
|
329
|
+
"0x4": "eip7702"
|
|
330
|
+
};
|
|
331
|
+
function ht(e, t) {
|
|
332
|
+
const n = {
|
|
333
|
+
...e,
|
|
334
|
+
blockHash: e.blockHash ? e.blockHash : null,
|
|
335
|
+
blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
|
|
336
|
+
chainId: e.chainId ? Ke(e.chainId) : void 0,
|
|
337
|
+
gas: e.gas ? BigInt(e.gas) : void 0,
|
|
338
|
+
gasPrice: e.gasPrice ? BigInt(e.gasPrice) : void 0,
|
|
339
|
+
maxFeePerBlobGas: e.maxFeePerBlobGas ? BigInt(e.maxFeePerBlobGas) : void 0,
|
|
340
|
+
maxFeePerGas: e.maxFeePerGas ? BigInt(e.maxFeePerGas) : void 0,
|
|
341
|
+
maxPriorityFeePerGas: e.maxPriorityFeePerGas ? BigInt(e.maxPriorityFeePerGas) : void 0,
|
|
342
|
+
nonce: e.nonce ? Ke(e.nonce) : void 0,
|
|
343
|
+
to: e.to ? e.to : null,
|
|
344
|
+
transactionIndex: e.transactionIndex ? Number(e.transactionIndex) : null,
|
|
345
|
+
type: e.type ? Ht[e.type] : void 0,
|
|
346
|
+
typeHex: e.type ? e.type : void 0,
|
|
347
|
+
value: e.value ? BigInt(e.value) : void 0,
|
|
348
|
+
v: e.v ? BigInt(e.v) : void 0
|
|
349
|
+
};
|
|
350
|
+
return e.authorizationList && (n.authorizationList = zn(e.authorizationList)), n.yParity = (() => {
|
|
351
|
+
if (e.yParity)
|
|
352
|
+
return Number(e.yParity);
|
|
353
|
+
if (typeof n.v == "bigint") {
|
|
354
|
+
if (n.v === 0n || n.v === 27n)
|
|
355
|
+
return 0;
|
|
356
|
+
if (n.v === 1n || n.v === 28n)
|
|
357
|
+
return 1;
|
|
358
|
+
if (n.v >= 35n)
|
|
359
|
+
return n.v % 2n === 0n ? 1 : 0;
|
|
360
|
+
}
|
|
361
|
+
})(), n.type === "legacy" && (delete n.accessList, delete n.maxFeePerBlobGas, delete n.maxFeePerGas, delete n.maxPriorityFeePerGas, delete n.yParity), n.type === "eip2930" && (delete n.maxFeePerBlobGas, delete n.maxFeePerGas, delete n.maxPriorityFeePerGas), n.type === "eip1559" && delete n.maxFeePerBlobGas, n;
|
|
362
|
+
}
|
|
363
|
+
const Ln = /* @__PURE__ */ dt("transaction", ht);
|
|
364
|
+
function zn(e) {
|
|
365
|
+
return e.map((t) => ({
|
|
366
|
+
address: t.address,
|
|
367
|
+
chainId: Number(t.chainId),
|
|
368
|
+
nonce: Number(t.nonce),
|
|
369
|
+
r: t.r,
|
|
370
|
+
s: t.s,
|
|
371
|
+
yParity: Number(t.yParity)
|
|
372
|
+
}));
|
|
373
|
+
}
|
|
374
|
+
function Fn(e, t) {
|
|
375
|
+
const n = (e.transactions ?? []).map((r) => typeof r == "string" ? r : ht(r));
|
|
376
|
+
return {
|
|
377
|
+
...e,
|
|
378
|
+
baseFeePerGas: e.baseFeePerGas ? BigInt(e.baseFeePerGas) : null,
|
|
379
|
+
blobGasUsed: e.blobGasUsed ? BigInt(e.blobGasUsed) : void 0,
|
|
380
|
+
difficulty: e.difficulty ? BigInt(e.difficulty) : void 0,
|
|
381
|
+
excessBlobGas: e.excessBlobGas ? BigInt(e.excessBlobGas) : void 0,
|
|
382
|
+
gasLimit: e.gasLimit ? BigInt(e.gasLimit) : void 0,
|
|
383
|
+
gasUsed: e.gasUsed ? BigInt(e.gasUsed) : void 0,
|
|
384
|
+
hash: e.hash ? e.hash : null,
|
|
385
|
+
logsBloom: e.logsBloom ? e.logsBloom : null,
|
|
386
|
+
nonce: e.nonce ? e.nonce : null,
|
|
387
|
+
number: e.number ? BigInt(e.number) : null,
|
|
388
|
+
size: e.size ? BigInt(e.size) : void 0,
|
|
389
|
+
timestamp: e.timestamp ? BigInt(e.timestamp) : void 0,
|
|
390
|
+
transactions: n,
|
|
391
|
+
totalDifficulty: e.totalDifficulty ? BigInt(e.totalDifficulty) : null
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
const Dn = /* @__PURE__ */ dt("block", Fn);
|
|
395
|
+
function $n(e, { args: t, eventName: n } = {}) {
|
|
396
|
+
return {
|
|
397
|
+
...e,
|
|
398
|
+
blockHash: e.blockHash ? e.blockHash : null,
|
|
399
|
+
blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
|
|
400
|
+
blockTimestamp: e.blockTimestamp ? BigInt(e.blockTimestamp) : e.blockTimestamp === null ? null : void 0,
|
|
401
|
+
logIndex: e.logIndex ? Number(e.logIndex) : null,
|
|
402
|
+
transactionHash: e.transactionHash ? e.transactionHash : null,
|
|
403
|
+
transactionIndex: e.transactionIndex ? Number(e.transactionIndex) : null,
|
|
404
|
+
...n ? { args: t, eventName: n } : {}
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
const Gn = {
|
|
408
|
+
"0x0": "reverted",
|
|
409
|
+
"0x1": "success"
|
|
410
|
+
};
|
|
411
|
+
function _n(e, t) {
|
|
412
|
+
const n = {
|
|
413
|
+
...e,
|
|
414
|
+
blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
|
|
415
|
+
contractAddress: e.contractAddress ? e.contractAddress : null,
|
|
416
|
+
cumulativeGasUsed: e.cumulativeGasUsed ? BigInt(e.cumulativeGasUsed) : null,
|
|
417
|
+
effectiveGasPrice: e.effectiveGasPrice ? BigInt(e.effectiveGasPrice) : null,
|
|
418
|
+
gasUsed: e.gasUsed ? BigInt(e.gasUsed) : null,
|
|
419
|
+
logs: e.logs ? e.logs.map((r) => $n(r)) : null,
|
|
420
|
+
to: e.to ? e.to : null,
|
|
421
|
+
transactionIndex: e.transactionIndex ? Ke(e.transactionIndex) : null,
|
|
422
|
+
status: e.status ? Gn[e.status] : null,
|
|
423
|
+
type: e.type ? Ht[e.type] || e.type : null
|
|
424
|
+
};
|
|
425
|
+
return e.blobGasPrice && (n.blobGasPrice = BigInt(e.blobGasPrice)), e.blobGasUsed && (n.blobGasUsed = BigInt(e.blobGasUsed)), n;
|
|
426
|
+
}
|
|
427
|
+
const Hn = /* @__PURE__ */ dt("transactionReceipt", _n), pt = 2n ** 256n - 1n;
|
|
428
|
+
function $e(e) {
|
|
429
|
+
return `0x${e.reduce((t, n) => t + n.replace("0x", ""), "")}`;
|
|
430
|
+
}
|
|
431
|
+
class At extends D {
|
|
432
|
+
constructor({ offset: t }) {
|
|
433
|
+
super(`Offset \`${t}\` cannot be negative.`, {
|
|
434
|
+
name: "NegativeOffsetError"
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
class Rn extends D {
|
|
439
|
+
constructor({ length: t, position: n }) {
|
|
440
|
+
super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`, { name: "PositionOutOfBoundsError" });
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
class Vn extends D {
|
|
444
|
+
constructor({ count: t, limit: n }) {
|
|
445
|
+
super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`, { name: "RecursiveReadLimitExceededError" });
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
const jn = {
|
|
449
|
+
bytes: new Uint8Array(),
|
|
450
|
+
dataView: new DataView(new ArrayBuffer(0)),
|
|
451
|
+
position: 0,
|
|
452
|
+
positionReadCount: /* @__PURE__ */ new Map(),
|
|
453
|
+
recursiveReadCount: 0,
|
|
454
|
+
recursiveReadLimit: Number.POSITIVE_INFINITY,
|
|
455
|
+
assertReadLimit() {
|
|
456
|
+
if (this.recursiveReadCount >= this.recursiveReadLimit)
|
|
457
|
+
throw new Vn({
|
|
458
|
+
count: this.recursiveReadCount + 1,
|
|
459
|
+
limit: this.recursiveReadLimit
|
|
460
|
+
});
|
|
461
|
+
},
|
|
462
|
+
assertPosition(e) {
|
|
463
|
+
if (e < 0 || e > this.bytes.length - 1)
|
|
464
|
+
throw new Rn({
|
|
465
|
+
length: this.bytes.length,
|
|
466
|
+
position: e
|
|
467
|
+
});
|
|
468
|
+
},
|
|
469
|
+
decrementPosition(e) {
|
|
470
|
+
if (e < 0)
|
|
471
|
+
throw new At({ offset: e });
|
|
472
|
+
const t = this.position - e;
|
|
473
|
+
this.assertPosition(t), this.position = t;
|
|
474
|
+
},
|
|
475
|
+
getReadCount(e) {
|
|
476
|
+
return this.positionReadCount.get(e || this.position) || 0;
|
|
477
|
+
},
|
|
478
|
+
incrementPosition(e) {
|
|
479
|
+
if (e < 0)
|
|
480
|
+
throw new At({ offset: e });
|
|
481
|
+
const t = this.position + e;
|
|
482
|
+
this.assertPosition(t), this.position = t;
|
|
483
|
+
},
|
|
484
|
+
inspectByte(e) {
|
|
485
|
+
const t = e ?? this.position;
|
|
486
|
+
return this.assertPosition(t), this.bytes[t];
|
|
487
|
+
},
|
|
488
|
+
inspectBytes(e, t) {
|
|
489
|
+
const n = t ?? this.position;
|
|
490
|
+
return this.assertPosition(n + e - 1), this.bytes.subarray(n, n + e);
|
|
491
|
+
},
|
|
492
|
+
inspectUint8(e) {
|
|
493
|
+
const t = e ?? this.position;
|
|
494
|
+
return this.assertPosition(t), this.bytes[t];
|
|
495
|
+
},
|
|
496
|
+
inspectUint16(e) {
|
|
497
|
+
const t = e ?? this.position;
|
|
498
|
+
return this.assertPosition(t + 1), this.dataView.getUint16(t);
|
|
499
|
+
},
|
|
500
|
+
inspectUint24(e) {
|
|
501
|
+
const t = e ?? this.position;
|
|
502
|
+
return this.assertPosition(t + 2), (this.dataView.getUint16(t) << 8) + this.dataView.getUint8(t + 2);
|
|
503
|
+
},
|
|
504
|
+
inspectUint32(e) {
|
|
505
|
+
const t = e ?? this.position;
|
|
506
|
+
return this.assertPosition(t + 3), this.dataView.getUint32(t);
|
|
507
|
+
},
|
|
508
|
+
pushByte(e) {
|
|
509
|
+
this.assertPosition(this.position), this.bytes[this.position] = e, this.position++;
|
|
510
|
+
},
|
|
511
|
+
pushBytes(e) {
|
|
512
|
+
this.assertPosition(this.position + e.length - 1), this.bytes.set(e, this.position), this.position += e.length;
|
|
513
|
+
},
|
|
514
|
+
pushUint8(e) {
|
|
515
|
+
this.assertPosition(this.position), this.bytes[this.position] = e, this.position++;
|
|
516
|
+
},
|
|
517
|
+
pushUint16(e) {
|
|
518
|
+
this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, e), this.position += 2;
|
|
519
|
+
},
|
|
520
|
+
pushUint24(e) {
|
|
521
|
+
this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, e >> 8), this.dataView.setUint8(this.position + 2, e & 255), this.position += 3;
|
|
522
|
+
},
|
|
523
|
+
pushUint32(e) {
|
|
524
|
+
this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, e), this.position += 4;
|
|
525
|
+
},
|
|
526
|
+
readByte() {
|
|
527
|
+
this.assertReadLimit(), this._touch();
|
|
528
|
+
const e = this.inspectByte();
|
|
529
|
+
return this.position++, e;
|
|
530
|
+
},
|
|
531
|
+
readBytes(e, t) {
|
|
532
|
+
this.assertReadLimit(), this._touch();
|
|
533
|
+
const n = this.inspectBytes(e);
|
|
534
|
+
return this.position += t ?? e, n;
|
|
535
|
+
},
|
|
536
|
+
readUint8() {
|
|
537
|
+
this.assertReadLimit(), this._touch();
|
|
538
|
+
const e = this.inspectUint8();
|
|
539
|
+
return this.position += 1, e;
|
|
540
|
+
},
|
|
541
|
+
readUint16() {
|
|
542
|
+
this.assertReadLimit(), this._touch();
|
|
543
|
+
const e = this.inspectUint16();
|
|
544
|
+
return this.position += 2, e;
|
|
545
|
+
},
|
|
546
|
+
readUint24() {
|
|
547
|
+
this.assertReadLimit(), this._touch();
|
|
548
|
+
const e = this.inspectUint24();
|
|
549
|
+
return this.position += 3, e;
|
|
550
|
+
},
|
|
551
|
+
readUint32() {
|
|
552
|
+
this.assertReadLimit(), this._touch();
|
|
553
|
+
const e = this.inspectUint32();
|
|
554
|
+
return this.position += 4, e;
|
|
555
|
+
},
|
|
556
|
+
get remaining() {
|
|
557
|
+
return this.bytes.length - this.position;
|
|
558
|
+
},
|
|
559
|
+
setPosition(e) {
|
|
560
|
+
const t = this.position;
|
|
561
|
+
return this.assertPosition(e), this.position = e, () => this.position = t;
|
|
562
|
+
},
|
|
563
|
+
_touch() {
|
|
564
|
+
if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
|
|
565
|
+
return;
|
|
566
|
+
const e = this.getReadCount();
|
|
567
|
+
this.positionReadCount.set(this.position, e + 1), e > 0 && this.recursiveReadCount++;
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
function Rt(e, { recursiveReadLimit: t = 8192 } = {}) {
|
|
571
|
+
const n = Object.create(jn);
|
|
572
|
+
return n.bytes = e, n.dataView = new DataView(e.buffer ?? e, e.byteOffset, e.byteLength), n.positionReadCount = /* @__PURE__ */ new Map(), n.recursiveReadLimit = t, n;
|
|
573
|
+
}
|
|
574
|
+
function xe(e, t = "hex") {
|
|
575
|
+
const n = Vt(e), r = Rt(new Uint8Array(n.length));
|
|
576
|
+
return n.encode(r), t === "hex" ? ge(r.bytes) : r.bytes;
|
|
577
|
+
}
|
|
578
|
+
function Vt(e) {
|
|
579
|
+
return Array.isArray(e) ? qn(e.map((t) => Vt(t))) : Yn(e);
|
|
580
|
+
}
|
|
581
|
+
function qn(e) {
|
|
582
|
+
const t = e.reduce((s, c) => s + c.length, 0), n = jt(t);
|
|
583
|
+
return {
|
|
584
|
+
length: t <= 55 ? 1 + t : 1 + n + t,
|
|
585
|
+
encode(s) {
|
|
586
|
+
t <= 55 ? s.pushByte(192 + t) : (s.pushByte(247 + n), n === 1 ? s.pushUint8(t) : n === 2 ? s.pushUint16(t) : n === 3 ? s.pushUint24(t) : s.pushUint32(t));
|
|
587
|
+
for (const { encode: c } of e)
|
|
588
|
+
c(s);
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
function Yn(e) {
|
|
593
|
+
const t = typeof e == "string" ? ye(e) : e, n = jt(t.length);
|
|
594
|
+
return {
|
|
595
|
+
length: t.length === 1 && t[0] < 128 ? 1 : t.length <= 55 ? 1 + t.length : 1 + n + t.length,
|
|
596
|
+
encode(s) {
|
|
597
|
+
t.length === 1 && t[0] < 128 ? s.pushBytes(t) : t.length <= 55 ? (s.pushByte(128 + t.length), s.pushBytes(t)) : (s.pushByte(183 + n), n === 1 ? s.pushUint8(t.length) : n === 2 ? s.pushUint16(t.length) : n === 3 ? s.pushUint24(t.length) : s.pushUint32(t.length), s.pushBytes(t));
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
function jt(e) {
|
|
602
|
+
if (e < 2 ** 8)
|
|
603
|
+
return 1;
|
|
604
|
+
if (e < 2 ** 16)
|
|
605
|
+
return 2;
|
|
606
|
+
if (e < 2 ** 24)
|
|
607
|
+
return 3;
|
|
608
|
+
if (e < 2 ** 32)
|
|
609
|
+
return 4;
|
|
610
|
+
throw new D("Length is too large.");
|
|
611
|
+
}
|
|
612
|
+
const Kn = {
|
|
613
|
+
ether: -9,
|
|
614
|
+
wei: 9
|
|
615
|
+
};
|
|
616
|
+
function Qn(e, t) {
|
|
617
|
+
let n = e.toString();
|
|
618
|
+
const r = n.startsWith("-");
|
|
619
|
+
r && (n = n.slice(1)), n = n.padStart(t, "0");
|
|
620
|
+
let [s, c] = [
|
|
621
|
+
n.slice(0, n.length - t),
|
|
622
|
+
n.slice(n.length - t)
|
|
623
|
+
];
|
|
624
|
+
return c = c.replace(/(0+)$/, ""), `${r ? "-" : ""}${s || "0"}${c ? `.${c}` : ""}`;
|
|
625
|
+
}
|
|
626
|
+
function ut(e, t = "wei") {
|
|
627
|
+
return Qn(e, Kn[t]);
|
|
628
|
+
}
|
|
629
|
+
function Zn(e) {
|
|
630
|
+
const t = Object.entries(e).map(([r, s]) => s === void 0 || s === !1 ? null : [r, s]).filter(Boolean), n = t.reduce((r, [s]) => Math.max(r, s.length), 0);
|
|
631
|
+
return t.map(([r, s]) => ` ${`${r}:`.padEnd(n + 1)} ${s}`).join(`
|
|
632
|
+
`);
|
|
633
|
+
}
|
|
634
|
+
class Wn extends D {
|
|
635
|
+
constructor({ v: t }) {
|
|
636
|
+
super(`Invalid \`v\` value "${t}". Expected 27 or 28.`, {
|
|
637
|
+
name: "InvalidLegacyVError"
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
class Jn extends D {
|
|
642
|
+
constructor({ transaction: t }) {
|
|
643
|
+
super("Cannot infer a transaction type from provided transaction.", {
|
|
644
|
+
metaMessages: [
|
|
645
|
+
"Provided Transaction:",
|
|
646
|
+
"{",
|
|
647
|
+
Zn(t),
|
|
648
|
+
"}",
|
|
649
|
+
"",
|
|
650
|
+
"To infer the type, either provide:",
|
|
651
|
+
"- a `type` to the Transaction, or",
|
|
652
|
+
"- an EIP-1559 Transaction with `maxFeePerGas`, or",
|
|
653
|
+
"- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
|
|
654
|
+
"- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or",
|
|
655
|
+
"- an EIP-7702 Transaction with `authorizationList`, or",
|
|
656
|
+
"- a Legacy Transaction with `gasPrice`"
|
|
657
|
+
],
|
|
658
|
+
name: "InvalidSerializableTransactionError"
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
class Xn extends D {
|
|
663
|
+
constructor({ storageKey: t }) {
|
|
664
|
+
super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length - 2) / 2)} bytes.`, { name: "InvalidStorageKeySizeError" });
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
function es(e) {
|
|
668
|
+
if (!e || e.length === 0)
|
|
669
|
+
return [];
|
|
670
|
+
const t = [];
|
|
671
|
+
for (const n of e) {
|
|
672
|
+
const { chainId: r, nonce: s, ...c } = n, l = n.address;
|
|
673
|
+
t.push([
|
|
674
|
+
r ? Le(r) : "0x",
|
|
675
|
+
l,
|
|
676
|
+
s ? Le(s) : "0x",
|
|
677
|
+
...Ge({}, c)
|
|
678
|
+
]);
|
|
679
|
+
}
|
|
680
|
+
return t;
|
|
681
|
+
}
|
|
682
|
+
function qt(e) {
|
|
683
|
+
const { kzg: t } = e, n = e.to ?? (typeof e.blobs[0] == "string" ? "hex" : "bytes"), r = typeof e.blobs[0] == "string" ? e.blobs.map((c) => ye(c)) : e.blobs, s = [];
|
|
684
|
+
for (const c of r)
|
|
685
|
+
s.push(Uint8Array.from(t.blobToKzgCommitment(c)));
|
|
686
|
+
return n === "bytes" ? s : s.map((c) => ge(c));
|
|
687
|
+
}
|
|
688
|
+
function Yt(e) {
|
|
689
|
+
const { kzg: t } = e, n = e.to ?? (typeof e.blobs[0] == "string" ? "hex" : "bytes"), r = typeof e.blobs[0] == "string" ? e.blobs.map((l) => ye(l)) : e.blobs, s = typeof e.commitments[0] == "string" ? e.commitments.map((l) => ye(l)) : e.commitments, c = [];
|
|
690
|
+
for (let l = 0; l < r.length; l++) {
|
|
691
|
+
const b = r[l], w = s[l];
|
|
692
|
+
c.push(Uint8Array.from(t.computeBlobKzgProof(b, w)));
|
|
693
|
+
}
|
|
694
|
+
return n === "bytes" ? c : c.map((l) => ge(l));
|
|
695
|
+
}
|
|
696
|
+
function ts(e) {
|
|
697
|
+
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
698
|
+
}
|
|
699
|
+
function Tt(e) {
|
|
700
|
+
if (!Number.isSafeInteger(e) || e < 0)
|
|
701
|
+
throw new Error("positive integer expected, got " + e);
|
|
702
|
+
}
|
|
703
|
+
function ze(e, ...t) {
|
|
704
|
+
if (!ts(e))
|
|
705
|
+
throw new Error("Uint8Array expected");
|
|
706
|
+
if (t.length > 0 && !t.includes(e.length))
|
|
707
|
+
throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
|
|
708
|
+
}
|
|
709
|
+
function Qe(e, t = !0) {
|
|
710
|
+
if (e.destroyed)
|
|
711
|
+
throw new Error("Hash instance has been destroyed");
|
|
712
|
+
if (t && e.finished)
|
|
713
|
+
throw new Error("Hash#digest() has already been called");
|
|
714
|
+
}
|
|
715
|
+
function Kt(e, t) {
|
|
716
|
+
ze(e);
|
|
717
|
+
const n = t.outputLen;
|
|
718
|
+
if (e.length < n)
|
|
719
|
+
throw new Error("digestInto() expects output buffer of length at least " + n);
|
|
720
|
+
}
|
|
721
|
+
function ns(e) {
|
|
722
|
+
return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
|
|
723
|
+
}
|
|
724
|
+
function Fe(...e) {
|
|
725
|
+
for (let t = 0; t < e.length; t++)
|
|
726
|
+
e[t].fill(0);
|
|
727
|
+
}
|
|
728
|
+
function st(e) {
|
|
729
|
+
return new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
730
|
+
}
|
|
731
|
+
function ce(e, t) {
|
|
732
|
+
return e << 32 - t | e >>> t;
|
|
733
|
+
}
|
|
734
|
+
const ss = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
735
|
+
function rs(e) {
|
|
736
|
+
return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
|
|
737
|
+
}
|
|
738
|
+
function is(e) {
|
|
739
|
+
for (let t = 0; t < e.length; t++)
|
|
740
|
+
e[t] = rs(e[t]);
|
|
741
|
+
return e;
|
|
742
|
+
}
|
|
743
|
+
const Bt = ss ? (e) => e : is;
|
|
744
|
+
function os(e) {
|
|
745
|
+
if (typeof e != "string")
|
|
746
|
+
throw new Error("string expected");
|
|
747
|
+
return new Uint8Array(new TextEncoder().encode(e));
|
|
748
|
+
}
|
|
749
|
+
function mt(e) {
|
|
750
|
+
return typeof e == "string" && (e = os(e)), ze(e), e;
|
|
751
|
+
}
|
|
752
|
+
class Qt {
|
|
753
|
+
}
|
|
754
|
+
function Zt(e) {
|
|
755
|
+
const t = (r) => e().update(mt(r)).digest(), n = e();
|
|
756
|
+
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
757
|
+
}
|
|
758
|
+
function as(e, t, n, r) {
|
|
759
|
+
if (typeof e.setBigUint64 == "function")
|
|
760
|
+
return e.setBigUint64(t, n, r);
|
|
761
|
+
const s = BigInt(32), c = BigInt(4294967295), l = Number(n >> s & c), b = Number(n & c), w = r ? 4 : 0, E = r ? 0 : 4;
|
|
762
|
+
e.setUint32(t + w, l, r), e.setUint32(t + E, b, r);
|
|
763
|
+
}
|
|
764
|
+
function cs(e, t, n) {
|
|
765
|
+
return e & t ^ ~e & n;
|
|
766
|
+
}
|
|
767
|
+
function ls(e, t, n) {
|
|
768
|
+
return e & t ^ e & n ^ t & n;
|
|
769
|
+
}
|
|
770
|
+
class us extends Qt {
|
|
771
|
+
constructor(t, n, r, s) {
|
|
772
|
+
super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = s, this.buffer = new Uint8Array(t), this.view = st(this.buffer);
|
|
773
|
+
}
|
|
774
|
+
update(t) {
|
|
775
|
+
Qe(this), t = mt(t), ze(t);
|
|
776
|
+
const { view: n, buffer: r, blockLen: s } = this, c = t.length;
|
|
777
|
+
for (let l = 0; l < c; ) {
|
|
778
|
+
const b = Math.min(s - this.pos, c - l);
|
|
779
|
+
if (b === s) {
|
|
780
|
+
const w = st(t);
|
|
781
|
+
for (; s <= c - l; l += s)
|
|
782
|
+
this.process(w, l);
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
785
|
+
r.set(t.subarray(l, l + b), this.pos), this.pos += b, l += b, this.pos === s && (this.process(n, 0), this.pos = 0);
|
|
786
|
+
}
|
|
787
|
+
return this.length += t.length, this.roundClean(), this;
|
|
788
|
+
}
|
|
789
|
+
digestInto(t) {
|
|
790
|
+
Qe(this), Kt(t, this), this.finished = !0;
|
|
791
|
+
const { buffer: n, view: r, blockLen: s, isLE: c } = this;
|
|
792
|
+
let { pos: l } = this;
|
|
793
|
+
n[l++] = 128, Fe(this.buffer.subarray(l)), this.padOffset > s - l && (this.process(r, 0), l = 0);
|
|
794
|
+
for (let B = l; B < s; B++)
|
|
795
|
+
n[B] = 0;
|
|
796
|
+
as(r, s - 8, BigInt(this.length * 8), c), this.process(r, 0);
|
|
797
|
+
const b = st(t), w = this.outputLen;
|
|
798
|
+
if (w % 4)
|
|
799
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
800
|
+
const E = w / 4, A = this.get();
|
|
801
|
+
if (E > A.length)
|
|
802
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
803
|
+
for (let B = 0; B < E; B++)
|
|
804
|
+
b.setUint32(4 * B, A[B], c);
|
|
805
|
+
}
|
|
806
|
+
digest() {
|
|
807
|
+
const { buffer: t, outputLen: n } = this;
|
|
808
|
+
this.digestInto(t);
|
|
809
|
+
const r = t.slice(0, n);
|
|
810
|
+
return this.destroy(), r;
|
|
811
|
+
}
|
|
812
|
+
_cloneInto(t) {
|
|
813
|
+
t || (t = new this.constructor()), t.set(...this.get());
|
|
814
|
+
const { blockLen: n, buffer: r, length: s, finished: c, destroyed: l, pos: b } = this;
|
|
815
|
+
return t.destroyed = l, t.finished = c, t.length = s, t.pos = b, s % n && t.buffer.set(r), t;
|
|
816
|
+
}
|
|
817
|
+
clone() {
|
|
818
|
+
return this._cloneInto();
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
const de = /* @__PURE__ */ Uint32Array.from([
|
|
822
|
+
1779033703,
|
|
823
|
+
3144134277,
|
|
824
|
+
1013904242,
|
|
825
|
+
2773480762,
|
|
826
|
+
1359893119,
|
|
827
|
+
2600822924,
|
|
828
|
+
528734635,
|
|
829
|
+
1541459225
|
|
830
|
+
]), _e = /* @__PURE__ */ BigInt(2 ** 32 - 1), kt = /* @__PURE__ */ BigInt(32);
|
|
831
|
+
function fs(e, t = !1) {
|
|
832
|
+
return t ? { h: Number(e & _e), l: Number(e >> kt & _e) } : { h: Number(e >> kt & _e) | 0, l: Number(e & _e) | 0 };
|
|
833
|
+
}
|
|
834
|
+
function ds(e, t = !1) {
|
|
835
|
+
const n = e.length;
|
|
836
|
+
let r = new Uint32Array(n), s = new Uint32Array(n);
|
|
837
|
+
for (let c = 0; c < n; c++) {
|
|
838
|
+
const { h: l, l: b } = fs(e[c], t);
|
|
839
|
+
[r[c], s[c]] = [l, b];
|
|
840
|
+
}
|
|
841
|
+
return [r, s];
|
|
842
|
+
}
|
|
843
|
+
const hs = (e, t, n) => e << n | t >>> 32 - n, ps = (e, t, n) => t << n | e >>> 32 - n, ms = (e, t, n) => t << n - 32 | e >>> 64 - n, gs = (e, t, n) => e << n - 32 | t >>> 64 - n, bs = /* @__PURE__ */ Uint32Array.from([
|
|
844
|
+
1116352408,
|
|
845
|
+
1899447441,
|
|
846
|
+
3049323471,
|
|
847
|
+
3921009573,
|
|
848
|
+
961987163,
|
|
849
|
+
1508970993,
|
|
850
|
+
2453635748,
|
|
851
|
+
2870763221,
|
|
852
|
+
3624381080,
|
|
853
|
+
310598401,
|
|
854
|
+
607225278,
|
|
855
|
+
1426881987,
|
|
856
|
+
1925078388,
|
|
857
|
+
2162078206,
|
|
858
|
+
2614888103,
|
|
859
|
+
3248222580,
|
|
860
|
+
3835390401,
|
|
861
|
+
4022224774,
|
|
862
|
+
264347078,
|
|
863
|
+
604807628,
|
|
864
|
+
770255983,
|
|
865
|
+
1249150122,
|
|
866
|
+
1555081692,
|
|
867
|
+
1996064986,
|
|
868
|
+
2554220882,
|
|
869
|
+
2821834349,
|
|
870
|
+
2952996808,
|
|
871
|
+
3210313671,
|
|
872
|
+
3336571891,
|
|
873
|
+
3584528711,
|
|
874
|
+
113926993,
|
|
875
|
+
338241895,
|
|
876
|
+
666307205,
|
|
877
|
+
773529912,
|
|
878
|
+
1294757372,
|
|
879
|
+
1396182291,
|
|
880
|
+
1695183700,
|
|
881
|
+
1986661051,
|
|
882
|
+
2177026350,
|
|
883
|
+
2456956037,
|
|
884
|
+
2730485921,
|
|
885
|
+
2820302411,
|
|
886
|
+
3259730800,
|
|
887
|
+
3345764771,
|
|
888
|
+
3516065817,
|
|
889
|
+
3600352804,
|
|
890
|
+
4094571909,
|
|
891
|
+
275423344,
|
|
892
|
+
430227734,
|
|
893
|
+
506948616,
|
|
894
|
+
659060556,
|
|
895
|
+
883997877,
|
|
896
|
+
958139571,
|
|
897
|
+
1322822218,
|
|
898
|
+
1537002063,
|
|
899
|
+
1747873779,
|
|
900
|
+
1955562222,
|
|
901
|
+
2024104815,
|
|
902
|
+
2227730452,
|
|
903
|
+
2361852424,
|
|
904
|
+
2428436474,
|
|
905
|
+
2756734187,
|
|
906
|
+
3204031479,
|
|
907
|
+
3329325298
|
|
908
|
+
]), he = /* @__PURE__ */ new Uint32Array(64);
|
|
909
|
+
class ys extends us {
|
|
910
|
+
constructor(t = 32) {
|
|
911
|
+
super(64, t, 8, !1), this.A = de[0] | 0, this.B = de[1] | 0, this.C = de[2] | 0, this.D = de[3] | 0, this.E = de[4] | 0, this.F = de[5] | 0, this.G = de[6] | 0, this.H = de[7] | 0;
|
|
912
|
+
}
|
|
913
|
+
get() {
|
|
914
|
+
const { A: t, B: n, C: r, D: s, E: c, F: l, G: b, H: w } = this;
|
|
915
|
+
return [t, n, r, s, c, l, b, w];
|
|
916
|
+
}
|
|
917
|
+
// prettier-ignore
|
|
918
|
+
set(t, n, r, s, c, l, b, w) {
|
|
919
|
+
this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = s | 0, this.E = c | 0, this.F = l | 0, this.G = b | 0, this.H = w | 0;
|
|
920
|
+
}
|
|
921
|
+
process(t, n) {
|
|
922
|
+
for (let B = 0; B < 16; B++, n += 4)
|
|
923
|
+
he[B] = t.getUint32(n, !1);
|
|
924
|
+
for (let B = 16; B < 64; B++) {
|
|
925
|
+
const C = he[B - 15], O = he[B - 2], F = ce(C, 7) ^ ce(C, 18) ^ C >>> 3, H = ce(O, 17) ^ ce(O, 19) ^ O >>> 10;
|
|
926
|
+
he[B] = H + he[B - 7] + F + he[B - 16] | 0;
|
|
927
|
+
}
|
|
928
|
+
let { A: r, B: s, C: c, D: l, E: b, F: w, G: E, H: A } = this;
|
|
929
|
+
for (let B = 0; B < 64; B++) {
|
|
930
|
+
const C = ce(b, 6) ^ ce(b, 11) ^ ce(b, 25), O = A + C + cs(b, w, E) + bs[B] + he[B] | 0, H = (ce(r, 2) ^ ce(r, 13) ^ ce(r, 22)) + ls(r, s, c) | 0;
|
|
931
|
+
A = E, E = w, w = b, b = l + O | 0, l = c, c = s, s = r, r = O + H | 0;
|
|
932
|
+
}
|
|
933
|
+
r = r + this.A | 0, s = s + this.B | 0, c = c + this.C | 0, l = l + this.D | 0, b = b + this.E | 0, w = w + this.F | 0, E = E + this.G | 0, A = A + this.H | 0, this.set(r, s, c, l, b, w, E, A);
|
|
934
|
+
}
|
|
935
|
+
roundClean() {
|
|
936
|
+
Fe(he);
|
|
937
|
+
}
|
|
938
|
+
destroy() {
|
|
939
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), Fe(this.buffer);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
const xs = /* @__PURE__ */ Zt(() => new ys()), ws = xs;
|
|
943
|
+
function Is(e, t) {
|
|
944
|
+
return ws(De(e, { strict: !1 }) ? Gt(e) : e);
|
|
945
|
+
}
|
|
946
|
+
function vs(e) {
|
|
947
|
+
const { commitment: t, version: n = 1 } = e, r = e.to ?? (typeof t == "string" ? "hex" : "bytes"), s = Is(t);
|
|
948
|
+
return s.set([n], 0), r === "bytes" ? s : ge(s);
|
|
949
|
+
}
|
|
950
|
+
function Es(e) {
|
|
951
|
+
const { commitments: t, version: n } = e, r = e.to ?? (typeof t[0] == "string" ? "hex" : "bytes"), s = [];
|
|
952
|
+
for (const c of t)
|
|
953
|
+
s.push(vs({
|
|
954
|
+
commitment: c,
|
|
955
|
+
to: r,
|
|
956
|
+
version: n
|
|
957
|
+
}));
|
|
958
|
+
return s;
|
|
959
|
+
}
|
|
960
|
+
const Pt = 6, Wt = 32, gt = 4096, Jt = Wt * gt, Nt = Jt * Pt - // terminator byte (0x80).
|
|
961
|
+
1 - // zero byte (0x00) appended to each field element.
|
|
962
|
+
1 * gt * Pt, Xt = 1;
|
|
963
|
+
class As extends D {
|
|
964
|
+
constructor({ maxSize: t, size: n }) {
|
|
965
|
+
super("Blob size is too large.", {
|
|
966
|
+
metaMessages: [`Max: ${t} bytes`, `Given: ${n} bytes`],
|
|
967
|
+
name: "BlobSizeTooLargeError"
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
class en extends D {
|
|
972
|
+
constructor() {
|
|
973
|
+
super("Blob data must not be empty.", { name: "EmptyBlobError" });
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
class Ts extends D {
|
|
977
|
+
constructor({ hash: t, size: n }) {
|
|
978
|
+
super(`Versioned hash "${t}" size is invalid.`, {
|
|
979
|
+
metaMessages: ["Expected: 32", `Received: ${n}`],
|
|
980
|
+
name: "InvalidVersionedHashSizeError"
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
class Bs extends D {
|
|
985
|
+
constructor({ hash: t, version: n }) {
|
|
986
|
+
super(`Versioned hash "${t}" version is invalid.`, {
|
|
987
|
+
metaMessages: [
|
|
988
|
+
`Expected: ${Xt}`,
|
|
989
|
+
`Received: ${n}`
|
|
990
|
+
],
|
|
991
|
+
name: "InvalidVersionedHashVersionError"
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
function ks(e) {
|
|
996
|
+
const t = e.to ?? (typeof e.data == "string" ? "hex" : "bytes"), n = typeof e.data == "string" ? ye(e.data) : e.data, r = Be(n);
|
|
997
|
+
if (!r)
|
|
998
|
+
throw new en();
|
|
999
|
+
if (r > Nt)
|
|
1000
|
+
throw new As({
|
|
1001
|
+
maxSize: Nt,
|
|
1002
|
+
size: r
|
|
1003
|
+
});
|
|
1004
|
+
const s = [];
|
|
1005
|
+
let c = !0, l = 0;
|
|
1006
|
+
for (; c; ) {
|
|
1007
|
+
const b = Rt(new Uint8Array(Jt));
|
|
1008
|
+
let w = 0;
|
|
1009
|
+
for (; w < gt; ) {
|
|
1010
|
+
const E = n.slice(l, l + (Wt - 1));
|
|
1011
|
+
if (b.pushByte(0), b.pushBytes(E), E.length < 31) {
|
|
1012
|
+
b.pushByte(128), c = !1;
|
|
1013
|
+
break;
|
|
1014
|
+
}
|
|
1015
|
+
w++, l += 31;
|
|
1016
|
+
}
|
|
1017
|
+
s.push(b);
|
|
1018
|
+
}
|
|
1019
|
+
return t === "bytes" ? s.map((b) => b.bytes) : s.map((b) => ge(b.bytes));
|
|
1020
|
+
}
|
|
1021
|
+
function Ps(e) {
|
|
1022
|
+
const { data: t, kzg: n, to: r } = e, s = e.blobs ?? ks({ data: t, to: r }), c = e.commitments ?? qt({ blobs: s, kzg: n, to: r }), l = e.proofs ?? Yt({ blobs: s, commitments: c, kzg: n, to: r }), b = [];
|
|
1023
|
+
for (let w = 0; w < s.length; w++)
|
|
1024
|
+
b.push({
|
|
1025
|
+
blob: s[w],
|
|
1026
|
+
commitment: c[w],
|
|
1027
|
+
proof: l[w]
|
|
1028
|
+
});
|
|
1029
|
+
return b;
|
|
1030
|
+
}
|
|
1031
|
+
class we extends D {
|
|
1032
|
+
constructor({ address: t }) {
|
|
1033
|
+
super(`Address "${t}" is invalid.`, {
|
|
1034
|
+
metaMessages: [
|
|
1035
|
+
"- Address must be a hex value of 20 bytes (40 hex characters).",
|
|
1036
|
+
"- Address must match its checksum counterpart."
|
|
1037
|
+
],
|
|
1038
|
+
name: "InvalidAddressError"
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
class We extends D {
|
|
1043
|
+
constructor({ chainId: t }) {
|
|
1044
|
+
super(typeof t == "number" ? `Chain ID "${t}" is invalid.` : "Chain ID is invalid.", { name: "InvalidChainIdError" });
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
class Je extends D {
|
|
1048
|
+
constructor({ cause: t, maxFeePerGas: n } = {}) {
|
|
1049
|
+
super(`The fee cap (\`maxFeePerGas\`${n ? ` = ${ut(n)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
|
|
1050
|
+
cause: t,
|
|
1051
|
+
name: "FeeCapTooHighError"
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
Object.defineProperty(Je, "nodeMessage", {
|
|
1056
|
+
enumerable: !0,
|
|
1057
|
+
configurable: !0,
|
|
1058
|
+
writable: !0,
|
|
1059
|
+
value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
|
|
1060
|
+
});
|
|
1061
|
+
class tn extends D {
|
|
1062
|
+
constructor({ cause: t, maxPriorityFeePerGas: n, maxFeePerGas: r } = {}) {
|
|
1063
|
+
super([
|
|
1064
|
+
`The provided tip (\`maxPriorityFeePerGas\`${n ? ` = ${ut(n)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r ? ` = ${ut(r)} gwei` : ""}).`
|
|
1065
|
+
].join(`
|
|
1066
|
+
`), {
|
|
1067
|
+
cause: t,
|
|
1068
|
+
name: "TipAboveFeeCapError"
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
Object.defineProperty(tn, "nodeMessage", {
|
|
1073
|
+
enumerable: !0,
|
|
1074
|
+
configurable: !0,
|
|
1075
|
+
writable: !0,
|
|
1076
|
+
value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
|
|
1077
|
+
});
|
|
1078
|
+
class nn extends Map {
|
|
1079
|
+
constructor(t) {
|
|
1080
|
+
super(), Object.defineProperty(this, "maxSize", {
|
|
1081
|
+
enumerable: !0,
|
|
1082
|
+
configurable: !0,
|
|
1083
|
+
writable: !0,
|
|
1084
|
+
value: void 0
|
|
1085
|
+
}), this.maxSize = t;
|
|
1086
|
+
}
|
|
1087
|
+
get(t) {
|
|
1088
|
+
const n = super.get(t);
|
|
1089
|
+
return super.has(t) && n !== void 0 && (this.delete(t), super.set(t, n)), n;
|
|
1090
|
+
}
|
|
1091
|
+
set(t, n) {
|
|
1092
|
+
if (super.set(t, n), this.maxSize && this.size > this.maxSize) {
|
|
1093
|
+
const r = this.keys().next().value;
|
|
1094
|
+
r && this.delete(r);
|
|
1095
|
+
}
|
|
1096
|
+
return this;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
const Ns = BigInt(0), Ce = BigInt(1), Ss = BigInt(2), Us = BigInt(7), Cs = BigInt(256), Ms = BigInt(113), sn = [], rn = [], on = [];
|
|
1100
|
+
for (let e = 0, t = Ce, n = 1, r = 0; e < 24; e++) {
|
|
1101
|
+
[n, r] = [r, (2 * n + 3 * r) % 5], sn.push(2 * (5 * r + n)), rn.push((e + 1) * (e + 2) / 2 % 64);
|
|
1102
|
+
let s = Ns;
|
|
1103
|
+
for (let c = 0; c < 7; c++)
|
|
1104
|
+
t = (t << Ce ^ (t >> Us) * Ms) % Cs, t & Ss && (s ^= Ce << (Ce << /* @__PURE__ */ BigInt(c)) - Ce);
|
|
1105
|
+
on.push(s);
|
|
1106
|
+
}
|
|
1107
|
+
const an = ds(on, !0), Os = an[0], Ls = an[1], St = (e, t, n) => n > 32 ? ms(e, t, n) : hs(e, t, n), Ut = (e, t, n) => n > 32 ? gs(e, t, n) : ps(e, t, n);
|
|
1108
|
+
function zs(e, t = 24) {
|
|
1109
|
+
const n = new Uint32Array(10);
|
|
1110
|
+
for (let r = 24 - t; r < 24; r++) {
|
|
1111
|
+
for (let l = 0; l < 10; l++)
|
|
1112
|
+
n[l] = e[l] ^ e[l + 10] ^ e[l + 20] ^ e[l + 30] ^ e[l + 40];
|
|
1113
|
+
for (let l = 0; l < 10; l += 2) {
|
|
1114
|
+
const b = (l + 8) % 10, w = (l + 2) % 10, E = n[w], A = n[w + 1], B = St(E, A, 1) ^ n[b], C = Ut(E, A, 1) ^ n[b + 1];
|
|
1115
|
+
for (let O = 0; O < 50; O += 10)
|
|
1116
|
+
e[l + O] ^= B, e[l + O + 1] ^= C;
|
|
1117
|
+
}
|
|
1118
|
+
let s = e[2], c = e[3];
|
|
1119
|
+
for (let l = 0; l < 24; l++) {
|
|
1120
|
+
const b = rn[l], w = St(s, c, b), E = Ut(s, c, b), A = sn[l];
|
|
1121
|
+
s = e[A], c = e[A + 1], e[A] = w, e[A + 1] = E;
|
|
1122
|
+
}
|
|
1123
|
+
for (let l = 0; l < 50; l += 10) {
|
|
1124
|
+
for (let b = 0; b < 10; b++)
|
|
1125
|
+
n[b] = e[l + b];
|
|
1126
|
+
for (let b = 0; b < 10; b++)
|
|
1127
|
+
e[l + b] ^= ~n[(b + 2) % 10] & n[(b + 4) % 10];
|
|
1128
|
+
}
|
|
1129
|
+
e[0] ^= Os[r], e[1] ^= Ls[r];
|
|
1130
|
+
}
|
|
1131
|
+
Fe(n);
|
|
1132
|
+
}
|
|
1133
|
+
class bt extends Qt {
|
|
1134
|
+
// NOTE: we accept arguments in bytes instead of bits here.
|
|
1135
|
+
constructor(t, n, r, s = !1, c = 24) {
|
|
1136
|
+
if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = t, this.suffix = n, this.outputLen = r, this.enableXOF = s, this.rounds = c, Tt(r), !(0 < t && t < 200))
|
|
1137
|
+
throw new Error("only keccak-f1600 function is supported");
|
|
1138
|
+
this.state = new Uint8Array(200), this.state32 = ns(this.state);
|
|
1139
|
+
}
|
|
1140
|
+
clone() {
|
|
1141
|
+
return this._cloneInto();
|
|
1142
|
+
}
|
|
1143
|
+
keccak() {
|
|
1144
|
+
Bt(this.state32), zs(this.state32, this.rounds), Bt(this.state32), this.posOut = 0, this.pos = 0;
|
|
1145
|
+
}
|
|
1146
|
+
update(t) {
|
|
1147
|
+
Qe(this), t = mt(t), ze(t);
|
|
1148
|
+
const { blockLen: n, state: r } = this, s = t.length;
|
|
1149
|
+
for (let c = 0; c < s; ) {
|
|
1150
|
+
const l = Math.min(n - this.pos, s - c);
|
|
1151
|
+
for (let b = 0; b < l; b++)
|
|
1152
|
+
r[this.pos++] ^= t[c++];
|
|
1153
|
+
this.pos === n && this.keccak();
|
|
1154
|
+
}
|
|
1155
|
+
return this;
|
|
1156
|
+
}
|
|
1157
|
+
finish() {
|
|
1158
|
+
if (this.finished)
|
|
1159
|
+
return;
|
|
1160
|
+
this.finished = !0;
|
|
1161
|
+
const { state: t, suffix: n, pos: r, blockLen: s } = this;
|
|
1162
|
+
t[r] ^= n, (n & 128) !== 0 && r === s - 1 && this.keccak(), t[s - 1] ^= 128, this.keccak();
|
|
1163
|
+
}
|
|
1164
|
+
writeInto(t) {
|
|
1165
|
+
Qe(this, !1), ze(t), this.finish();
|
|
1166
|
+
const n = this.state, { blockLen: r } = this;
|
|
1167
|
+
for (let s = 0, c = t.length; s < c; ) {
|
|
1168
|
+
this.posOut >= r && this.keccak();
|
|
1169
|
+
const l = Math.min(r - this.posOut, c - s);
|
|
1170
|
+
t.set(n.subarray(this.posOut, this.posOut + l), s), this.posOut += l, s += l;
|
|
1171
|
+
}
|
|
1172
|
+
return t;
|
|
1173
|
+
}
|
|
1174
|
+
xofInto(t) {
|
|
1175
|
+
if (!this.enableXOF)
|
|
1176
|
+
throw new Error("XOF is not possible for this instance");
|
|
1177
|
+
return this.writeInto(t);
|
|
1178
|
+
}
|
|
1179
|
+
xof(t) {
|
|
1180
|
+
return Tt(t), this.xofInto(new Uint8Array(t));
|
|
1181
|
+
}
|
|
1182
|
+
digestInto(t) {
|
|
1183
|
+
if (Kt(t, this), this.finished)
|
|
1184
|
+
throw new Error("digest() was already called");
|
|
1185
|
+
return this.writeInto(t), this.destroy(), t;
|
|
1186
|
+
}
|
|
1187
|
+
digest() {
|
|
1188
|
+
return this.digestInto(new Uint8Array(this.outputLen));
|
|
1189
|
+
}
|
|
1190
|
+
destroy() {
|
|
1191
|
+
this.destroyed = !0, Fe(this.state);
|
|
1192
|
+
}
|
|
1193
|
+
_cloneInto(t) {
|
|
1194
|
+
const { blockLen: n, suffix: r, outputLen: s, rounds: c, enableXOF: l } = this;
|
|
1195
|
+
return t || (t = new bt(n, r, s, l, c)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = c, t.suffix = r, t.outputLen = s, t.enableXOF = l, t.destroyed = this.destroyed, t;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
const Fs = (e, t, n) => Zt(() => new bt(t, e, n)), Ds = Fs(1, 136, 256 / 8);
|
|
1199
|
+
function $s(e, t) {
|
|
1200
|
+
return Ds(De(e, { strict: !1 }) ? Gt(e) : e);
|
|
1201
|
+
}
|
|
1202
|
+
const rt = /* @__PURE__ */ new nn(8192);
|
|
1203
|
+
function Gs(e, t) {
|
|
1204
|
+
if (rt.has(`${e}.${t}`))
|
|
1205
|
+
return rt.get(`${e}.${t}`);
|
|
1206
|
+
const n = e.substring(2).toLowerCase(), r = $s(_t(n)), s = n.split("");
|
|
1207
|
+
for (let l = 0; l < 40; l += 2)
|
|
1208
|
+
r[l >> 1] >> 4 >= 8 && s[l] && (s[l] = s[l].toUpperCase()), (r[l >> 1] & 15) >= 8 && s[l + 1] && (s[l + 1] = s[l + 1].toUpperCase());
|
|
1209
|
+
const c = `0x${s.join("")}`;
|
|
1210
|
+
return rt.set(`${e}.${t}`, c), c;
|
|
1211
|
+
}
|
|
1212
|
+
const _s = /^0x[a-fA-F0-9]{40}$/, it = /* @__PURE__ */ new nn(8192);
|
|
1213
|
+
function Ie(e, t) {
|
|
1214
|
+
const { strict: n = !0 } = t ?? {}, r = `${e}.${n}`;
|
|
1215
|
+
if (it.has(r))
|
|
1216
|
+
return it.get(r);
|
|
1217
|
+
const s = _s.test(e) ? e.toLowerCase() === e ? !0 : n ? Gs(e) === e : !0 : !1;
|
|
1218
|
+
return it.set(r, s), s;
|
|
1219
|
+
}
|
|
1220
|
+
function Hs(e, t, n, { strict: r } = {}) {
|
|
1221
|
+
return De(e, { strict: !1 }) ? Vs(e, t, n, {
|
|
1222
|
+
strict: r
|
|
1223
|
+
}) : Rs(e, t, n, {
|
|
1224
|
+
strict: r
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
function cn(e, t, n) {
|
|
1228
|
+
if (Be(e) !== n - t)
|
|
1229
|
+
throw new Tn({
|
|
1230
|
+
offset: n,
|
|
1231
|
+
position: "end",
|
|
1232
|
+
size: Be(e)
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
function Rs(e, t, n, { strict: r } = {}) {
|
|
1236
|
+
const s = e.slice(t, n);
|
|
1237
|
+
return r && cn(s, t, n), s;
|
|
1238
|
+
}
|
|
1239
|
+
function Vs(e, t, n, { strict: r } = {}) {
|
|
1240
|
+
const s = `0x${e.replace("0x", "").slice(t * 2, n * 2)}`;
|
|
1241
|
+
return r && cn(s, t, n), s;
|
|
1242
|
+
}
|
|
1243
|
+
function js(e) {
|
|
1244
|
+
const { authorizationList: t } = e;
|
|
1245
|
+
if (t)
|
|
1246
|
+
for (const n of t) {
|
|
1247
|
+
const { chainId: r } = n, s = n.address;
|
|
1248
|
+
if (!Ie(s))
|
|
1249
|
+
throw new we({ address: s });
|
|
1250
|
+
if (r < 0)
|
|
1251
|
+
throw new We({ chainId: r });
|
|
1252
|
+
}
|
|
1253
|
+
yt(e);
|
|
1254
|
+
}
|
|
1255
|
+
function qs(e) {
|
|
1256
|
+
const { blobVersionedHashes: t } = e;
|
|
1257
|
+
if (t) {
|
|
1258
|
+
if (t.length === 0)
|
|
1259
|
+
throw new en();
|
|
1260
|
+
for (const n of t) {
|
|
1261
|
+
const r = Be(n), s = Ke(Hs(n, 0, 1));
|
|
1262
|
+
if (r !== 32)
|
|
1263
|
+
throw new Ts({ hash: n, size: r });
|
|
1264
|
+
if (s !== Xt)
|
|
1265
|
+
throw new Bs({
|
|
1266
|
+
hash: n,
|
|
1267
|
+
version: s
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
yt(e);
|
|
1272
|
+
}
|
|
1273
|
+
function yt(e) {
|
|
1274
|
+
const { chainId: t, maxPriorityFeePerGas: n, maxFeePerGas: r, to: s } = e;
|
|
1275
|
+
if (t <= 0)
|
|
1276
|
+
throw new We({ chainId: t });
|
|
1277
|
+
if (s && !Ie(s))
|
|
1278
|
+
throw new we({ address: s });
|
|
1279
|
+
if (r && r > pt)
|
|
1280
|
+
throw new Je({ maxFeePerGas: r });
|
|
1281
|
+
if (n && r && n > r)
|
|
1282
|
+
throw new tn({ maxFeePerGas: r, maxPriorityFeePerGas: n });
|
|
1283
|
+
}
|
|
1284
|
+
function Ys(e) {
|
|
1285
|
+
const { chainId: t, maxPriorityFeePerGas: n, gasPrice: r, maxFeePerGas: s, to: c } = e;
|
|
1286
|
+
if (t <= 0)
|
|
1287
|
+
throw new We({ chainId: t });
|
|
1288
|
+
if (c && !Ie(c))
|
|
1289
|
+
throw new we({ address: c });
|
|
1290
|
+
if (n || s)
|
|
1291
|
+
throw new D("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");
|
|
1292
|
+
if (r && r > pt)
|
|
1293
|
+
throw new Je({ maxFeePerGas: r });
|
|
1294
|
+
}
|
|
1295
|
+
function Ks(e) {
|
|
1296
|
+
const { chainId: t, maxPriorityFeePerGas: n, gasPrice: r, maxFeePerGas: s, to: c } = e;
|
|
1297
|
+
if (c && !Ie(c))
|
|
1298
|
+
throw new we({ address: c });
|
|
1299
|
+
if (typeof t < "u" && t <= 0)
|
|
1300
|
+
throw new We({ chainId: t });
|
|
1301
|
+
if (n || s)
|
|
1302
|
+
throw new D("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");
|
|
1303
|
+
if (r && r > pt)
|
|
1304
|
+
throw new Je({ maxFeePerGas: r });
|
|
1305
|
+
}
|
|
1306
|
+
function Qs(e) {
|
|
1307
|
+
if (e.type)
|
|
1308
|
+
return e.type;
|
|
1309
|
+
if (typeof e.authorizationList < "u")
|
|
1310
|
+
return "eip7702";
|
|
1311
|
+
if (typeof e.blobs < "u" || typeof e.blobVersionedHashes < "u" || typeof e.maxFeePerBlobGas < "u" || typeof e.sidecars < "u")
|
|
1312
|
+
return "eip4844";
|
|
1313
|
+
if (typeof e.maxFeePerGas < "u" || typeof e.maxPriorityFeePerGas < "u")
|
|
1314
|
+
return "eip1559";
|
|
1315
|
+
if (typeof e.gasPrice < "u")
|
|
1316
|
+
return typeof e.accessList < "u" ? "eip2930" : "legacy";
|
|
1317
|
+
throw new Jn({ transaction: e });
|
|
1318
|
+
}
|
|
1319
|
+
function Xe(e) {
|
|
1320
|
+
if (!e || e.length === 0)
|
|
1321
|
+
return [];
|
|
1322
|
+
const t = [];
|
|
1323
|
+
for (let n = 0; n < e.length; n++) {
|
|
1324
|
+
const { address: r, storageKeys: s } = e[n];
|
|
1325
|
+
for (let c = 0; c < s.length; c++)
|
|
1326
|
+
if (s[c].length - 2 !== 64)
|
|
1327
|
+
throw new Xn({ storageKey: s[c] });
|
|
1328
|
+
if (!Ie(r, { strict: !1 }))
|
|
1329
|
+
throw new we({ address: r });
|
|
1330
|
+
t.push([r, s]);
|
|
1331
|
+
}
|
|
1332
|
+
return t;
|
|
1333
|
+
}
|
|
1334
|
+
function Zs(e, t) {
|
|
1335
|
+
const n = Qs(e);
|
|
1336
|
+
return n === "eip1559" ? Xs(e, t) : n === "eip2930" ? er(e, t) : n === "eip4844" ? Js(e, t) : n === "eip7702" ? Ws(e, t) : tr(e, t);
|
|
1337
|
+
}
|
|
1338
|
+
function Ws(e, t) {
|
|
1339
|
+
const { authorizationList: n, chainId: r, gas: s, nonce: c, to: l, value: b, maxFeePerGas: w, maxPriorityFeePerGas: E, accessList: A, data: B } = e;
|
|
1340
|
+
js(e);
|
|
1341
|
+
const C = Xe(A), O = es(n);
|
|
1342
|
+
return $e([
|
|
1343
|
+
"0x04",
|
|
1344
|
+
xe([
|
|
1345
|
+
z(r),
|
|
1346
|
+
c ? z(c) : "0x",
|
|
1347
|
+
E ? z(E) : "0x",
|
|
1348
|
+
w ? z(w) : "0x",
|
|
1349
|
+
s ? z(s) : "0x",
|
|
1350
|
+
l ?? "0x",
|
|
1351
|
+
b ? z(b) : "0x",
|
|
1352
|
+
B ?? "0x",
|
|
1353
|
+
C,
|
|
1354
|
+
O,
|
|
1355
|
+
...Ge(e, t)
|
|
1356
|
+
])
|
|
1357
|
+
]);
|
|
1358
|
+
}
|
|
1359
|
+
function Js(e, t) {
|
|
1360
|
+
const { chainId: n, gas: r, nonce: s, to: c, value: l, maxFeePerBlobGas: b, maxFeePerGas: w, maxPriorityFeePerGas: E, accessList: A, data: B } = e;
|
|
1361
|
+
qs(e);
|
|
1362
|
+
let C = e.blobVersionedHashes, O = e.sidecars;
|
|
1363
|
+
if (e.blobs && (typeof C > "u" || typeof O > "u")) {
|
|
1364
|
+
const K = typeof e.blobs[0] == "string" ? e.blobs : e.blobs.map(($) => ge($)), X = e.kzg, ee = qt({
|
|
1365
|
+
blobs: K,
|
|
1366
|
+
kzg: X
|
|
1367
|
+
});
|
|
1368
|
+
if (typeof C > "u" && (C = Es({
|
|
1369
|
+
commitments: ee
|
|
1370
|
+
})), typeof O > "u") {
|
|
1371
|
+
const $ = Yt({ blobs: K, commitments: ee, kzg: X });
|
|
1372
|
+
O = Ps({ blobs: K, commitments: ee, proofs: $ });
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
const F = Xe(A), H = [
|
|
1376
|
+
z(n),
|
|
1377
|
+
s ? z(s) : "0x",
|
|
1378
|
+
E ? z(E) : "0x",
|
|
1379
|
+
w ? z(w) : "0x",
|
|
1380
|
+
r ? z(r) : "0x",
|
|
1381
|
+
c ?? "0x",
|
|
1382
|
+
l ? z(l) : "0x",
|
|
1383
|
+
B ?? "0x",
|
|
1384
|
+
F,
|
|
1385
|
+
b ? z(b) : "0x",
|
|
1386
|
+
C ?? [],
|
|
1387
|
+
...Ge(e, t)
|
|
1388
|
+
], j = [], oe = [], v = [];
|
|
1389
|
+
if (O)
|
|
1390
|
+
for (let K = 0; K < O.length; K++) {
|
|
1391
|
+
const { blob: X, commitment: ee, proof: $ } = O[K];
|
|
1392
|
+
j.push(X), oe.push(ee), v.push($);
|
|
1393
|
+
}
|
|
1394
|
+
return $e([
|
|
1395
|
+
"0x03",
|
|
1396
|
+
// If sidecars are enabled, envelope turns into a "wrapper":
|
|
1397
|
+
xe(O ? [H, j, oe, v] : H)
|
|
1398
|
+
]);
|
|
1399
|
+
}
|
|
1400
|
+
function Xs(e, t) {
|
|
1401
|
+
const { chainId: n, gas: r, nonce: s, to: c, value: l, maxFeePerGas: b, maxPriorityFeePerGas: w, accessList: E, data: A } = e;
|
|
1402
|
+
yt(e);
|
|
1403
|
+
const B = Xe(E), C = [
|
|
1404
|
+
z(n),
|
|
1405
|
+
s ? z(s) : "0x",
|
|
1406
|
+
w ? z(w) : "0x",
|
|
1407
|
+
b ? z(b) : "0x",
|
|
1408
|
+
r ? z(r) : "0x",
|
|
1409
|
+
c ?? "0x",
|
|
1410
|
+
l ? z(l) : "0x",
|
|
1411
|
+
A ?? "0x",
|
|
1412
|
+
B,
|
|
1413
|
+
...Ge(e, t)
|
|
1414
|
+
];
|
|
1415
|
+
return $e([
|
|
1416
|
+
"0x02",
|
|
1417
|
+
xe(C)
|
|
1418
|
+
]);
|
|
1419
|
+
}
|
|
1420
|
+
function er(e, t) {
|
|
1421
|
+
const { chainId: n, gas: r, data: s, nonce: c, to: l, value: b, accessList: w, gasPrice: E } = e;
|
|
1422
|
+
Ys(e);
|
|
1423
|
+
const A = Xe(w), B = [
|
|
1424
|
+
z(n),
|
|
1425
|
+
c ? z(c) : "0x",
|
|
1426
|
+
E ? z(E) : "0x",
|
|
1427
|
+
r ? z(r) : "0x",
|
|
1428
|
+
l ?? "0x",
|
|
1429
|
+
b ? z(b) : "0x",
|
|
1430
|
+
s ?? "0x",
|
|
1431
|
+
A,
|
|
1432
|
+
...Ge(e, t)
|
|
1433
|
+
];
|
|
1434
|
+
return $e([
|
|
1435
|
+
"0x01",
|
|
1436
|
+
xe(B)
|
|
1437
|
+
]);
|
|
1438
|
+
}
|
|
1439
|
+
function tr(e, t) {
|
|
1440
|
+
const { chainId: n = 0, gas: r, data: s, nonce: c, to: l, value: b, gasPrice: w } = e;
|
|
1441
|
+
Ks(e);
|
|
1442
|
+
let E = [
|
|
1443
|
+
c ? z(c) : "0x",
|
|
1444
|
+
w ? z(w) : "0x",
|
|
1445
|
+
r ? z(r) : "0x",
|
|
1446
|
+
l ?? "0x",
|
|
1447
|
+
b ? z(b) : "0x",
|
|
1448
|
+
s ?? "0x"
|
|
1449
|
+
];
|
|
1450
|
+
if (t) {
|
|
1451
|
+
const A = (() => {
|
|
1452
|
+
if (t.v >= 35n)
|
|
1453
|
+
return (t.v - 35n) / 2n > 0 ? t.v : 27n + (t.v === 35n ? 0n : 1n);
|
|
1454
|
+
if (n > 0)
|
|
1455
|
+
return BigInt(n * 2) + BigInt(35n + t.v - 27n);
|
|
1456
|
+
const O = 27n + (t.v === 27n ? 0n : 1n);
|
|
1457
|
+
if (t.v !== O)
|
|
1458
|
+
throw new Wn({ v: t.v });
|
|
1459
|
+
return O;
|
|
1460
|
+
})(), B = Ye(t.r), C = Ye(t.s);
|
|
1461
|
+
E = [
|
|
1462
|
+
...E,
|
|
1463
|
+
z(A),
|
|
1464
|
+
B === "0x00" ? "0x" : B,
|
|
1465
|
+
C === "0x00" ? "0x" : C
|
|
1466
|
+
];
|
|
1467
|
+
} else n > 0 && (E = [
|
|
1468
|
+
...E,
|
|
1469
|
+
z(n),
|
|
1470
|
+
"0x",
|
|
1471
|
+
"0x"
|
|
1472
|
+
]);
|
|
1473
|
+
return xe(E);
|
|
1474
|
+
}
|
|
1475
|
+
function Ge(e, t) {
|
|
1476
|
+
const n = t ?? e, { v: r, yParity: s } = n;
|
|
1477
|
+
if (typeof n.r > "u")
|
|
1478
|
+
return [];
|
|
1479
|
+
if (typeof n.s > "u")
|
|
1480
|
+
return [];
|
|
1481
|
+
if (typeof r > "u" && typeof s > "u")
|
|
1482
|
+
return [];
|
|
1483
|
+
const c = Ye(n.r), l = Ye(n.s);
|
|
1484
|
+
return [typeof s == "number" ? s ? z(1) : "0x" : r === 0n ? "0x" : r === 1n ? z(1) : r === 27n ? "0x" : z(1), c === "0x00" ? "0x" : c, l === "0x00" ? "0x" : l];
|
|
1485
|
+
}
|
|
1486
|
+
const nr = {
|
|
1487
|
+
gasPriceOracle: { address: "0x420000000000000000000000000000000000000F" },
|
|
1488
|
+
l1Block: { address: "0x4200000000000000000000000000000000000015" },
|
|
1489
|
+
l2CrossDomainMessenger: {
|
|
1490
|
+
address: "0x4200000000000000000000000000000000000007"
|
|
1491
|
+
},
|
|
1492
|
+
l2Erc721Bridge: { address: "0x4200000000000000000000000000000000000014" },
|
|
1493
|
+
l2StandardBridge: { address: "0x4200000000000000000000000000000000000010" },
|
|
1494
|
+
l2ToL1MessagePasser: {
|
|
1495
|
+
address: "0x4200000000000000000000000000000000000016"
|
|
1496
|
+
}
|
|
1497
|
+
}, sr = {
|
|
1498
|
+
block: /* @__PURE__ */ Dn({
|
|
1499
|
+
format(e) {
|
|
1500
|
+
return {
|
|
1501
|
+
transactions: e.transactions?.map((n) => {
|
|
1502
|
+
if (typeof n == "string")
|
|
1503
|
+
return n;
|
|
1504
|
+
const r = ht(n);
|
|
1505
|
+
return r.typeHex === "0x7e" && (r.isSystemTx = n.isSystemTx, r.mint = n.mint ? Ee(n.mint) : void 0, r.sourceHash = n.sourceHash, r.type = "deposit"), r;
|
|
1506
|
+
}),
|
|
1507
|
+
stateRoot: e.stateRoot
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
}),
|
|
1511
|
+
transaction: /* @__PURE__ */ Ln({
|
|
1512
|
+
format(e) {
|
|
1513
|
+
const t = {};
|
|
1514
|
+
return e.type === "0x7e" && (t.isSystemTx = e.isSystemTx, t.mint = e.mint ? Ee(e.mint) : void 0, t.sourceHash = e.sourceHash, t.type = "deposit"), t;
|
|
1515
|
+
}
|
|
1516
|
+
}),
|
|
1517
|
+
transactionReceipt: /* @__PURE__ */ Hn({
|
|
1518
|
+
format(e) {
|
|
1519
|
+
return {
|
|
1520
|
+
l1GasPrice: e.l1GasPrice ? Ee(e.l1GasPrice) : null,
|
|
1521
|
+
l1GasUsed: e.l1GasUsed ? Ee(e.l1GasUsed) : null,
|
|
1522
|
+
l1Fee: e.l1Fee ? Ee(e.l1Fee) : null,
|
|
1523
|
+
l1FeeScalar: e.l1FeeScalar ? Number(e.l1FeeScalar) : null
|
|
1524
|
+
};
|
|
1525
|
+
}
|
|
1526
|
+
})
|
|
1527
|
+
};
|
|
1528
|
+
function rr(e, t) {
|
|
1529
|
+
return ar(e) ? or(e) : Zs(e, t);
|
|
1530
|
+
}
|
|
1531
|
+
const ir = {
|
|
1532
|
+
transaction: rr
|
|
1533
|
+
};
|
|
1534
|
+
function or(e) {
|
|
1535
|
+
cr(e);
|
|
1536
|
+
const { sourceHash: t, data: n, from: r, gas: s, isSystemTx: c, mint: l, to: b, value: w } = e, E = [
|
|
1537
|
+
t,
|
|
1538
|
+
r,
|
|
1539
|
+
b ?? "0x",
|
|
1540
|
+
l ? Le(l) : "0x",
|
|
1541
|
+
w ? Le(w) : "0x",
|
|
1542
|
+
s ? Le(s) : "0x",
|
|
1543
|
+
c ? "0x1" : "0x",
|
|
1544
|
+
n ?? "0x"
|
|
1545
|
+
];
|
|
1546
|
+
return $e([
|
|
1547
|
+
"0x7e",
|
|
1548
|
+
xe(E)
|
|
1549
|
+
]);
|
|
1550
|
+
}
|
|
1551
|
+
function ar(e) {
|
|
1552
|
+
return e.type === "deposit" || typeof e.sourceHash < "u";
|
|
1553
|
+
}
|
|
1554
|
+
function cr(e) {
|
|
1555
|
+
const { from: t, to: n } = e;
|
|
1556
|
+
if (t && !Ie(t))
|
|
1557
|
+
throw new we({ address: t });
|
|
1558
|
+
if (n && !Ie(n))
|
|
1559
|
+
throw new we({ address: n });
|
|
1560
|
+
}
|
|
1561
|
+
const Ze = {
|
|
1562
|
+
blockTime: 2e3,
|
|
1563
|
+
contracts: nr,
|
|
1564
|
+
formatters: sr,
|
|
1565
|
+
serializers: ir
|
|
1566
|
+
}, lr = /* @__PURE__ */ ve({
|
|
1567
|
+
id: 42161,
|
|
1568
|
+
name: "Arbitrum One",
|
|
1569
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
1570
|
+
blockTime: 250,
|
|
1571
|
+
rpcUrls: {
|
|
1572
|
+
default: {
|
|
1573
|
+
http: ["https://arb1.arbitrum.io/rpc"]
|
|
1574
|
+
}
|
|
1575
|
+
},
|
|
1576
|
+
blockExplorers: {
|
|
1577
|
+
default: {
|
|
1578
|
+
name: "Arbiscan",
|
|
1579
|
+
url: "https://arbiscan.io",
|
|
1580
|
+
apiUrl: "https://api.arbiscan.io/api"
|
|
1581
|
+
}
|
|
1582
|
+
},
|
|
1583
|
+
contracts: {
|
|
1584
|
+
multicall3: {
|
|
1585
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
1586
|
+
blockCreated: 7654707
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
}), Me = 1, ln = /* @__PURE__ */ ve({
|
|
1590
|
+
...Ze,
|
|
1591
|
+
id: 8453,
|
|
1592
|
+
name: "Base",
|
|
1593
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
1594
|
+
rpcUrls: {
|
|
1595
|
+
default: {
|
|
1596
|
+
http: ["https://mainnet.base.org"]
|
|
1597
|
+
}
|
|
1598
|
+
},
|
|
1599
|
+
blockExplorers: {
|
|
1600
|
+
default: {
|
|
1601
|
+
name: "Basescan",
|
|
1602
|
+
url: "https://basescan.org",
|
|
1603
|
+
apiUrl: "https://api.basescan.org/api"
|
|
1604
|
+
}
|
|
1605
|
+
},
|
|
1606
|
+
contracts: {
|
|
1607
|
+
...Ze.contracts,
|
|
1608
|
+
disputeGameFactory: {
|
|
1609
|
+
[Me]: {
|
|
1610
|
+
address: "0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"
|
|
1611
|
+
}
|
|
1612
|
+
},
|
|
1613
|
+
l2OutputOracle: {
|
|
1614
|
+
[Me]: {
|
|
1615
|
+
address: "0x56315b90c40730925ec5485cf004d835058518A0"
|
|
1616
|
+
}
|
|
1617
|
+
},
|
|
1618
|
+
multicall3: {
|
|
1619
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
1620
|
+
blockCreated: 5022
|
|
1621
|
+
},
|
|
1622
|
+
portal: {
|
|
1623
|
+
[Me]: {
|
|
1624
|
+
address: "0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",
|
|
1625
|
+
blockCreated: 17482143
|
|
1626
|
+
}
|
|
1627
|
+
},
|
|
1628
|
+
l1StandardBridge: {
|
|
1629
|
+
[Me]: {
|
|
1630
|
+
address: "0x3154Cf16ccdb4C6d922629664174b904d80F2C35",
|
|
1631
|
+
blockCreated: 17482143
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
},
|
|
1635
|
+
sourceId: Me
|
|
1636
|
+
});
|
|
1637
|
+
({
|
|
1638
|
+
...ln
|
|
1639
|
+
});
|
|
1640
|
+
const ur = /* @__PURE__ */ ve({
|
|
1641
|
+
id: 56,
|
|
1642
|
+
name: "BNB Smart Chain",
|
|
1643
|
+
blockTime: 750,
|
|
1644
|
+
nativeCurrency: {
|
|
1645
|
+
decimals: 18,
|
|
1646
|
+
name: "BNB",
|
|
1647
|
+
symbol: "BNB"
|
|
1648
|
+
},
|
|
1649
|
+
rpcUrls: {
|
|
1650
|
+
default: { http: ["https://56.rpc.thirdweb.com"] }
|
|
1651
|
+
},
|
|
1652
|
+
blockExplorers: {
|
|
1653
|
+
default: {
|
|
1654
|
+
name: "BscScan",
|
|
1655
|
+
url: "https://bscscan.com",
|
|
1656
|
+
apiUrl: "https://api.bscscan.com/api"
|
|
1657
|
+
}
|
|
1658
|
+
},
|
|
1659
|
+
contracts: {
|
|
1660
|
+
multicall3: {
|
|
1661
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
1662
|
+
blockCreated: 15921452
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
}), fr = /* @__PURE__ */ ve({
|
|
1666
|
+
id: 1,
|
|
1667
|
+
name: "Ethereum",
|
|
1668
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
1669
|
+
blockTime: 12e3,
|
|
1670
|
+
rpcUrls: {
|
|
1671
|
+
default: {
|
|
1672
|
+
http: ["https://eth.merkle.io"]
|
|
1673
|
+
}
|
|
1674
|
+
},
|
|
1675
|
+
blockExplorers: {
|
|
1676
|
+
default: {
|
|
1677
|
+
name: "Etherscan",
|
|
1678
|
+
url: "https://etherscan.io",
|
|
1679
|
+
apiUrl: "https://api.etherscan.io/api"
|
|
1680
|
+
}
|
|
1681
|
+
},
|
|
1682
|
+
contracts: {
|
|
1683
|
+
ensUniversalResolver: {
|
|
1684
|
+
address: "0xeeeeeeee14d718c2b47d9923deab1335e144eeee",
|
|
1685
|
+
blockCreated: 23085558
|
|
1686
|
+
},
|
|
1687
|
+
multicall3: {
|
|
1688
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
1689
|
+
blockCreated: 14353601
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
}), Oe = 1, dr = /* @__PURE__ */ ve({
|
|
1693
|
+
...Ze,
|
|
1694
|
+
id: 10,
|
|
1695
|
+
name: "OP Mainnet",
|
|
1696
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
1697
|
+
rpcUrls: {
|
|
1698
|
+
default: {
|
|
1699
|
+
http: ["https://mainnet.optimism.io"]
|
|
1700
|
+
}
|
|
1701
|
+
},
|
|
1702
|
+
blockExplorers: {
|
|
1703
|
+
default: {
|
|
1704
|
+
name: "Optimism Explorer",
|
|
1705
|
+
url: "https://optimistic.etherscan.io",
|
|
1706
|
+
apiUrl: "https://api-optimistic.etherscan.io/api"
|
|
1707
|
+
}
|
|
1708
|
+
},
|
|
1709
|
+
contracts: {
|
|
1710
|
+
...Ze.contracts,
|
|
1711
|
+
disputeGameFactory: {
|
|
1712
|
+
[Oe]: {
|
|
1713
|
+
address: "0xe5965Ab5962eDc7477C8520243A95517CD252fA9"
|
|
1714
|
+
}
|
|
1715
|
+
},
|
|
1716
|
+
l2OutputOracle: {
|
|
1717
|
+
[Oe]: {
|
|
1718
|
+
address: "0xdfe97868233d1aa22e815a266982f2cf17685a27"
|
|
1719
|
+
}
|
|
1720
|
+
},
|
|
1721
|
+
multicall3: {
|
|
1722
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
1723
|
+
blockCreated: 4286263
|
|
1724
|
+
},
|
|
1725
|
+
portal: {
|
|
1726
|
+
[Oe]: {
|
|
1727
|
+
address: "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
|
|
1728
|
+
}
|
|
1729
|
+
},
|
|
1730
|
+
l1StandardBridge: {
|
|
1731
|
+
[Oe]: {
|
|
1732
|
+
address: "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
},
|
|
1736
|
+
sourceId: Oe
|
|
1737
|
+
}), hr = /* @__PURE__ */ ve({
|
|
1738
|
+
id: 137,
|
|
1739
|
+
name: "Polygon",
|
|
1740
|
+
blockTime: 2e3,
|
|
1741
|
+
nativeCurrency: { name: "POL", symbol: "POL", decimals: 18 },
|
|
1742
|
+
rpcUrls: {
|
|
1743
|
+
default: {
|
|
1744
|
+
http: ["https://polygon-rpc.com"]
|
|
1745
|
+
}
|
|
1746
|
+
},
|
|
1747
|
+
blockExplorers: {
|
|
1748
|
+
default: {
|
|
1749
|
+
name: "PolygonScan",
|
|
1750
|
+
url: "https://polygonscan.com",
|
|
1751
|
+
apiUrl: "https://api.etherscan.io/v2/api"
|
|
1752
|
+
}
|
|
1753
|
+
},
|
|
1754
|
+
contracts: {
|
|
1755
|
+
multicall3: {
|
|
1756
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
1757
|
+
blockCreated: 25770160
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
}), xt = {
|
|
1761
|
+
1: {
|
|
1762
|
+
...fr,
|
|
1763
|
+
logo: "https://cryptologos.cc/logos/ethereum-eth-logo.png?v=024",
|
|
1764
|
+
chainId: 1,
|
|
1765
|
+
chainType: "ether",
|
|
1766
|
+
chainTypeMoralis: "eth",
|
|
1767
|
+
tokenTrendingDefault: [
|
|
1768
|
+
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
1769
|
+
//weth
|
|
1770
|
+
"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
|
|
1771
|
+
//wbtc
|
|
1772
|
+
]
|
|
1773
|
+
},
|
|
1774
|
+
10: {
|
|
1775
|
+
...dr,
|
|
1776
|
+
logo: "https://cryptologos.cc/logos/optimism-ethereum-op-logo.png?v=024",
|
|
1777
|
+
chainId: 10,
|
|
1778
|
+
chainType: "optimism",
|
|
1779
|
+
chainTypeMoralis: "optimism",
|
|
1780
|
+
tokenTrendingDefault: [
|
|
1781
|
+
"0x4200000000000000000000000000000000000006",
|
|
1782
|
+
//weth
|
|
1783
|
+
"0x68f180fcce6836688e9084f035309e29bf0a2095",
|
|
1784
|
+
//wbtc
|
|
1785
|
+
"0xc47da4cb96ce65a96844a01bfae509f9d5454534"
|
|
1786
|
+
//JPYT
|
|
1787
|
+
]
|
|
1788
|
+
},
|
|
1789
|
+
56: {
|
|
1790
|
+
...ur,
|
|
1791
|
+
logo: "https://cryptologos.cc/logos/bnb-bnb-logo.png?v=024",
|
|
1792
|
+
chainId: 56,
|
|
1793
|
+
chainType: "bsc",
|
|
1794
|
+
chainTypeMoralis: "bsc",
|
|
1795
|
+
tokenTrendingDefault: [
|
|
1796
|
+
"0x2170ed0880ac9a755fd29b2688956bd959f933f8",
|
|
1797
|
+
//weth
|
|
1798
|
+
"0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c"
|
|
1799
|
+
//wbtc
|
|
1800
|
+
]
|
|
1801
|
+
},
|
|
1802
|
+
137: {
|
|
1803
|
+
...hr,
|
|
1804
|
+
logo: "https://cryptologos.cc/logos/polygon-matic-logo.png?v=024",
|
|
1805
|
+
chainId: 137,
|
|
1806
|
+
chainType: "matic",
|
|
1807
|
+
chainTypeMoralis: "polygon",
|
|
1808
|
+
tokenTrendingDefault: [
|
|
1809
|
+
"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
|
|
1810
|
+
//weth
|
|
1811
|
+
"0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6"
|
|
1812
|
+
//wbtc
|
|
1813
|
+
]
|
|
1814
|
+
},
|
|
1815
|
+
8453: {
|
|
1816
|
+
...ln,
|
|
1817
|
+
logo: "https://cryptologos.cc/logos/base-base-logo.png?v=024",
|
|
1818
|
+
chainId: 8453,
|
|
1819
|
+
chainType: "base",
|
|
1820
|
+
chainTypeMoralis: "base",
|
|
1821
|
+
tokenTrendingDefault: [
|
|
1822
|
+
"0x4200000000000000000000000000000000000006",
|
|
1823
|
+
//weth
|
|
1824
|
+
"0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf",
|
|
1825
|
+
//wbtc
|
|
1826
|
+
"0xc47da4cb96ce65a96844a01bfae509f9d5454534"
|
|
1827
|
+
//JPYT
|
|
1828
|
+
]
|
|
1829
|
+
},
|
|
1830
|
+
42161: {
|
|
1831
|
+
...lr,
|
|
1832
|
+
logo: "https://cryptologos.cc/logos/arbitrum-arb-logo.png?v=024",
|
|
1833
|
+
chainId: 42161,
|
|
1834
|
+
chainType: "arbitrum",
|
|
1835
|
+
chainTypeMoralis: "arbitrum",
|
|
1836
|
+
tokenTrendingDefault: [
|
|
1837
|
+
"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
|
|
1838
|
+
"0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f"
|
|
1839
|
+
//wbtc
|
|
1840
|
+
]
|
|
1841
|
+
}
|
|
1842
|
+
}, pr = (e) => {
|
|
1843
|
+
const t = /* @__PURE__ */ new Date(), n = new Date(t);
|
|
1844
|
+
n.setDate(n.getDate() - 1);
|
|
1845
|
+
const r = new Date(e);
|
|
1846
|
+
return r.setHours(0, 0, 0, 0), t.setHours(0, 0, 0, 0), n.setHours(0, 0, 0, 0), r.getTime() === t.getTime() ? "Today" : r.getTime() === n.getTime() ? "Yesterday" : r.toLocaleDateString("en-US", {
|
|
1847
|
+
month: "short",
|
|
1848
|
+
day: "numeric",
|
|
1849
|
+
year: r.getFullYear() !== t.getFullYear() ? "numeric" : void 0
|
|
1850
|
+
});
|
|
1851
|
+
}, He = (e) => new Promise((t) => setTimeout(t, e || 0)), mr = (e, t = 5, n = 5) => (e = e || "", e?.length <= t + n ? e : `${e.substr(0, t)}...${e.substr(e.length - n, n)}`), gr = (e) => {
|
|
1852
|
+
const t = xt[e];
|
|
1853
|
+
return t ? t.chainTypeMoralis : "eth";
|
|
1854
|
+
}, br = (e) => {
|
|
1855
|
+
const t = xt[e];
|
|
1856
|
+
return t ? t.chainType : "ether";
|
|
1857
|
+
}, un = Ot(
|
|
1858
|
+
void 0
|
|
1859
|
+
), wt = () => {
|
|
1860
|
+
const e = Lt(un);
|
|
1861
|
+
if (!e)
|
|
1862
|
+
throw new Error("useConnect must be used within ConnectProvider");
|
|
1863
|
+
return {
|
|
1864
|
+
...e,
|
|
1865
|
+
chainData: xt[e.account?.chainId],
|
|
1866
|
+
chainId: e.account?.chainId || 1,
|
|
1867
|
+
chainType: br(e.account?.chainId || 1),
|
|
1868
|
+
chainTypeMoralis: gr(e.account?.chainId || 1)
|
|
1869
|
+
};
|
|
1870
|
+
}, yr = ({
|
|
1871
|
+
children: e,
|
|
1872
|
+
initialAccount: t
|
|
1873
|
+
}) => /* @__PURE__ */ k(un.Provider, { value: { account: t || null }, children: e }), ot = En, Re = [
|
|
1874
|
+
{
|
|
1875
|
+
id: qe(),
|
|
1876
|
+
text: "Welcome! 🚀",
|
|
1877
|
+
sender: "bot",
|
|
1878
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1879
|
+
},
|
|
1880
|
+
{
|
|
1881
|
+
id: qe(),
|
|
1882
|
+
text: "You're connected and ready to explore DeFi! I can help you trade, check prices, and analyze your portfolio when you need it.",
|
|
1883
|
+
sender: "bot",
|
|
1884
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1885
|
+
},
|
|
1886
|
+
{
|
|
1887
|
+
id: qe(),
|
|
1888
|
+
text: "Can I help you with anything?",
|
|
1889
|
+
sender: "bot",
|
|
1890
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1891
|
+
}
|
|
1892
|
+
];
|
|
1893
|
+
function xr() {
|
|
1894
|
+
const { account: e } = wt(), n = e?.address && e?.chainId ? `${ot}_${e.address}_${e.chainId}` : ot, r = () => {
|
|
1895
|
+
if (e?.address && e?.chainId) {
|
|
1896
|
+
const w = [];
|
|
1897
|
+
for (let E = 0; E < localStorage.length; E++) {
|
|
1898
|
+
const A = localStorage.key(E);
|
|
1899
|
+
A && A.startsWith(ot) && A !== n && w.push(A);
|
|
1900
|
+
}
|
|
1901
|
+
w.forEach((E) => localStorage.removeItem(E));
|
|
1902
|
+
}
|
|
1903
|
+
}, [s, c] = Ae(() => {
|
|
1904
|
+
const w = localStorage.getItem(n);
|
|
1905
|
+
if (w)
|
|
1906
|
+
try {
|
|
1907
|
+
return JSON.parse(w).map((A) => ({
|
|
1908
|
+
...A,
|
|
1909
|
+
timestamp: new Date(A.timestamp)
|
|
1910
|
+
}));
|
|
1911
|
+
} catch {
|
|
1912
|
+
}
|
|
1913
|
+
return Re;
|
|
1914
|
+
});
|
|
1915
|
+
return Te(() => {
|
|
1916
|
+
localStorage.setItem(n, JSON.stringify(s));
|
|
1917
|
+
}, [s, n]), Te(() => {
|
|
1918
|
+
const w = localStorage.getItem(n);
|
|
1919
|
+
if (w)
|
|
1920
|
+
try {
|
|
1921
|
+
const E = JSON.parse(w);
|
|
1922
|
+
c(
|
|
1923
|
+
E.map((A) => ({
|
|
1924
|
+
...A,
|
|
1925
|
+
timestamp: new Date(A.timestamp)
|
|
1926
|
+
}))
|
|
1927
|
+
);
|
|
1928
|
+
} catch {
|
|
1929
|
+
c(Re);
|
|
1930
|
+
}
|
|
1931
|
+
else
|
|
1932
|
+
c(Re);
|
|
1933
|
+
r();
|
|
1934
|
+
}, [e?.address, e?.chainId]), {
|
|
1935
|
+
messages: s,
|
|
1936
|
+
setMessages: c,
|
|
1937
|
+
addMessage: (w, E, A, B) => {
|
|
1938
|
+
const C = A ? s.find((F) => F.id === A) : void 0, O = {
|
|
1939
|
+
id: qe(),
|
|
1940
|
+
text: w,
|
|
1941
|
+
sender: E,
|
|
1942
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
1943
|
+
...C && {
|
|
1944
|
+
replyTo: {
|
|
1945
|
+
id: C.id,
|
|
1946
|
+
text: C.text,
|
|
1947
|
+
sender: C.sender
|
|
1948
|
+
}
|
|
1949
|
+
},
|
|
1950
|
+
...B && { buttons: B }
|
|
1951
|
+
};
|
|
1952
|
+
return c((F) => [...F, O]), O;
|
|
1953
|
+
},
|
|
1954
|
+
clearMessages: () => {
|
|
1955
|
+
c(Re), localStorage.removeItem(n);
|
|
1956
|
+
}
|
|
1957
|
+
};
|
|
1958
|
+
}
|
|
1959
|
+
var wr = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, at = Math.ceil, se = Math.floor, W = "[BigNumber Error] ", Ct = W + "Number primitive has more than 15 significant digits: ", ie = 1e14, U = 14, ct = 9007199254740991, lt = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], pe = 1e7, q = 1e9;
|
|
1960
|
+
function fn(e) {
|
|
1961
|
+
var t, n, r, s = v.prototype = { constructor: v, toString: null, valueOf: null }, c = new v(1), l = 20, b = 4, w = -7, E = 21, A = -1e7, B = 1e7, C = !1, O = 1, F = 0, H = {
|
|
1962
|
+
prefix: "",
|
|
1963
|
+
groupSize: 3,
|
|
1964
|
+
secondaryGroupSize: 0,
|
|
1965
|
+
groupSeparator: ",",
|
|
1966
|
+
decimalSeparator: ".",
|
|
1967
|
+
fractionGroupSize: 0,
|
|
1968
|
+
fractionGroupSeparator: " ",
|
|
1969
|
+
// non-breaking space
|
|
1970
|
+
suffix: ""
|
|
1971
|
+
}, j = "0123456789abcdefghijklmnopqrstuvwxyz", oe = !0;
|
|
1972
|
+
function v(i, o) {
|
|
1973
|
+
var a, m, f, p, x, u, h, y, g = this;
|
|
1974
|
+
if (!(g instanceof v)) return new v(i, o);
|
|
1975
|
+
if (o == null) {
|
|
1976
|
+
if (i && i._isBigNumber === !0) {
|
|
1977
|
+
g.s = i.s, !i.c || i.e > B ? g.c = g.e = null : i.e < A ? g.c = [g.e = 0] : (g.e = i.e, g.c = i.c.slice());
|
|
1978
|
+
return;
|
|
1979
|
+
}
|
|
1980
|
+
if ((u = typeof i == "number") && i * 0 == 0) {
|
|
1981
|
+
if (g.s = 1 / i < 0 ? (i = -i, -1) : 1, i === ~~i) {
|
|
1982
|
+
for (p = 0, x = i; x >= 10; x /= 10, p++) ;
|
|
1983
|
+
p > B ? g.c = g.e = null : (g.e = p, g.c = [i]);
|
|
1984
|
+
return;
|
|
1985
|
+
}
|
|
1986
|
+
y = String(i);
|
|
1987
|
+
} else {
|
|
1988
|
+
if (!wr.test(y = String(i))) return r(g, y, u);
|
|
1989
|
+
g.s = y.charCodeAt(0) == 45 ? (y = y.slice(1), -1) : 1;
|
|
1990
|
+
}
|
|
1991
|
+
(p = y.indexOf(".")) > -1 && (y = y.replace(".", "")), (x = y.search(/e/i)) > 0 ? (p < 0 && (p = x), p += +y.slice(x + 1), y = y.substring(0, x)) : p < 0 && (p = y.length);
|
|
1992
|
+
} else {
|
|
1993
|
+
if (G(o, 2, j.length, "Base"), o == 10 && oe)
|
|
1994
|
+
return g = new v(i), $(g, l + g.e + 1, b);
|
|
1995
|
+
if (y = String(i), u = typeof i == "number") {
|
|
1996
|
+
if (i * 0 != 0) return r(g, y, u, o);
|
|
1997
|
+
if (g.s = 1 / i < 0 ? (y = y.slice(1), -1) : 1, v.DEBUG && y.replace(/^0\.0*|\./, "").length > 15)
|
|
1998
|
+
throw Error(Ct + i);
|
|
1999
|
+
} else
|
|
2000
|
+
g.s = y.charCodeAt(0) === 45 ? (y = y.slice(1), -1) : 1;
|
|
2001
|
+
for (a = j.slice(0, o), p = x = 0, h = y.length; x < h; x++)
|
|
2002
|
+
if (a.indexOf(m = y.charAt(x)) < 0) {
|
|
2003
|
+
if (m == ".") {
|
|
2004
|
+
if (x > p) {
|
|
2005
|
+
p = h;
|
|
2006
|
+
continue;
|
|
2007
|
+
}
|
|
2008
|
+
} else if (!f && (y == y.toUpperCase() && (y = y.toLowerCase()) || y == y.toLowerCase() && (y = y.toUpperCase()))) {
|
|
2009
|
+
f = !0, x = -1, p = 0;
|
|
2010
|
+
continue;
|
|
2011
|
+
}
|
|
2012
|
+
return r(g, String(i), u, o);
|
|
2013
|
+
}
|
|
2014
|
+
u = !1, y = n(y, o, 10, g.s), (p = y.indexOf(".")) > -1 ? y = y.replace(".", "") : p = y.length;
|
|
2015
|
+
}
|
|
2016
|
+
for (x = 0; y.charCodeAt(x) === 48; x++) ;
|
|
2017
|
+
for (h = y.length; y.charCodeAt(--h) === 48; ) ;
|
|
2018
|
+
if (y = y.slice(x, ++h)) {
|
|
2019
|
+
if (h -= x, u && v.DEBUG && h > 15 && (i > ct || i !== se(i)))
|
|
2020
|
+
throw Error(Ct + g.s * i);
|
|
2021
|
+
if ((p = p - x - 1) > B)
|
|
2022
|
+
g.c = g.e = null;
|
|
2023
|
+
else if (p < A)
|
|
2024
|
+
g.c = [g.e = 0];
|
|
2025
|
+
else {
|
|
2026
|
+
if (g.e = p, g.c = [], x = (p + 1) % U, p < 0 && (x += U), x < h) {
|
|
2027
|
+
for (x && g.c.push(+y.slice(0, x)), h -= U; x < h; )
|
|
2028
|
+
g.c.push(+y.slice(x, x += U));
|
|
2029
|
+
x = U - (y = y.slice(x)).length;
|
|
2030
|
+
} else
|
|
2031
|
+
x -= h;
|
|
2032
|
+
for (; x--; y += "0") ;
|
|
2033
|
+
g.c.push(+y);
|
|
2034
|
+
}
|
|
2035
|
+
} else
|
|
2036
|
+
g.c = [g.e = 0];
|
|
2037
|
+
}
|
|
2038
|
+
v.clone = fn, v.ROUND_UP = 0, v.ROUND_DOWN = 1, v.ROUND_CEIL = 2, v.ROUND_FLOOR = 3, v.ROUND_HALF_UP = 4, v.ROUND_HALF_DOWN = 5, v.ROUND_HALF_EVEN = 6, v.ROUND_HALF_CEIL = 7, v.ROUND_HALF_FLOOR = 8, v.EUCLID = 9, v.config = v.set = function(i) {
|
|
2039
|
+
var o, a;
|
|
2040
|
+
if (i != null)
|
|
2041
|
+
if (typeof i == "object") {
|
|
2042
|
+
if (i.hasOwnProperty(o = "DECIMAL_PLACES") && (a = i[o], G(a, 0, q, o), l = a), i.hasOwnProperty(o = "ROUNDING_MODE") && (a = i[o], G(a, 0, 8, o), b = a), i.hasOwnProperty(o = "EXPONENTIAL_AT") && (a = i[o], a && a.pop ? (G(a[0], -q, 0, o), G(a[1], 0, q, o), w = a[0], E = a[1]) : (G(a, -q, q, o), w = -(E = a < 0 ? -a : a))), i.hasOwnProperty(o = "RANGE"))
|
|
2043
|
+
if (a = i[o], a && a.pop)
|
|
2044
|
+
G(a[0], -q, -1, o), G(a[1], 1, q, o), A = a[0], B = a[1];
|
|
2045
|
+
else if (G(a, -q, q, o), a)
|
|
2046
|
+
A = -(B = a < 0 ? -a : a);
|
|
2047
|
+
else
|
|
2048
|
+
throw Error(W + o + " cannot be zero: " + a);
|
|
2049
|
+
if (i.hasOwnProperty(o = "CRYPTO"))
|
|
2050
|
+
if (a = i[o], a === !!a)
|
|
2051
|
+
if (a)
|
|
2052
|
+
if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
|
|
2053
|
+
C = a;
|
|
2054
|
+
else
|
|
2055
|
+
throw C = !a, Error(W + "crypto unavailable");
|
|
2056
|
+
else
|
|
2057
|
+
C = a;
|
|
2058
|
+
else
|
|
2059
|
+
throw Error(W + o + " not true or false: " + a);
|
|
2060
|
+
if (i.hasOwnProperty(o = "MODULO_MODE") && (a = i[o], G(a, 0, 9, o), O = a), i.hasOwnProperty(o = "POW_PRECISION") && (a = i[o], G(a, 0, q, o), F = a), i.hasOwnProperty(o = "FORMAT"))
|
|
2061
|
+
if (a = i[o], typeof a == "object") H = a;
|
|
2062
|
+
else throw Error(W + o + " not an object: " + a);
|
|
2063
|
+
if (i.hasOwnProperty(o = "ALPHABET"))
|
|
2064
|
+
if (a = i[o], typeof a == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(a))
|
|
2065
|
+
oe = a.slice(0, 10) == "0123456789", j = a;
|
|
2066
|
+
else
|
|
2067
|
+
throw Error(W + o + " invalid: " + a);
|
|
2068
|
+
} else
|
|
2069
|
+
throw Error(W + "Object expected: " + i);
|
|
2070
|
+
return {
|
|
2071
|
+
DECIMAL_PLACES: l,
|
|
2072
|
+
ROUNDING_MODE: b,
|
|
2073
|
+
EXPONENTIAL_AT: [w, E],
|
|
2074
|
+
RANGE: [A, B],
|
|
2075
|
+
CRYPTO: C,
|
|
2076
|
+
MODULO_MODE: O,
|
|
2077
|
+
POW_PRECISION: F,
|
|
2078
|
+
FORMAT: H,
|
|
2079
|
+
ALPHABET: j
|
|
2080
|
+
};
|
|
2081
|
+
}, v.isBigNumber = function(i) {
|
|
2082
|
+
if (!i || i._isBigNumber !== !0) return !1;
|
|
2083
|
+
if (!v.DEBUG) return !0;
|
|
2084
|
+
var o, a, m = i.c, f = i.e, p = i.s;
|
|
2085
|
+
e: if ({}.toString.call(m) == "[object Array]") {
|
|
2086
|
+
if ((p === 1 || p === -1) && f >= -q && f <= q && f === se(f)) {
|
|
2087
|
+
if (m[0] === 0) {
|
|
2088
|
+
if (f === 0 && m.length === 1) return !0;
|
|
2089
|
+
break e;
|
|
2090
|
+
}
|
|
2091
|
+
if (o = (f + 1) % U, o < 1 && (o += U), String(m[0]).length == o) {
|
|
2092
|
+
for (o = 0; o < m.length; o++)
|
|
2093
|
+
if (a = m[o], a < 0 || a >= ie || a !== se(a)) break e;
|
|
2094
|
+
if (a !== 0) return !0;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
} else if (m === null && f === null && (p === null || p === 1 || p === -1))
|
|
2098
|
+
return !0;
|
|
2099
|
+
throw Error(W + "Invalid BigNumber: " + i);
|
|
2100
|
+
}, v.maximum = v.max = function() {
|
|
2101
|
+
return X(arguments, -1);
|
|
2102
|
+
}, v.minimum = v.min = function() {
|
|
2103
|
+
return X(arguments, 1);
|
|
2104
|
+
}, v.random = (function() {
|
|
2105
|
+
var i = 9007199254740992, o = Math.random() * i & 2097151 ? function() {
|
|
2106
|
+
return se(Math.random() * i);
|
|
2107
|
+
} : function() {
|
|
2108
|
+
return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
|
|
2109
|
+
};
|
|
2110
|
+
return function(a) {
|
|
2111
|
+
var m, f, p, x, u, h = 0, y = [], g = new v(c);
|
|
2112
|
+
if (a == null ? a = l : G(a, 0, q), x = at(a / U), C)
|
|
2113
|
+
if (crypto.getRandomValues) {
|
|
2114
|
+
for (m = crypto.getRandomValues(new Uint32Array(x *= 2)); h < x; )
|
|
2115
|
+
u = m[h] * 131072 + (m[h + 1] >>> 11), u >= 9e15 ? (f = crypto.getRandomValues(new Uint32Array(2)), m[h] = f[0], m[h + 1] = f[1]) : (y.push(u % 1e14), h += 2);
|
|
2116
|
+
h = x / 2;
|
|
2117
|
+
} else if (crypto.randomBytes) {
|
|
2118
|
+
for (m = crypto.randomBytes(x *= 7); h < x; )
|
|
2119
|
+
u = (m[h] & 31) * 281474976710656 + m[h + 1] * 1099511627776 + m[h + 2] * 4294967296 + m[h + 3] * 16777216 + (m[h + 4] << 16) + (m[h + 5] << 8) + m[h + 6], u >= 9e15 ? crypto.randomBytes(7).copy(m, h) : (y.push(u % 1e14), h += 7);
|
|
2120
|
+
h = x / 7;
|
|
2121
|
+
} else
|
|
2122
|
+
throw C = !1, Error(W + "crypto unavailable");
|
|
2123
|
+
if (!C)
|
|
2124
|
+
for (; h < x; )
|
|
2125
|
+
u = o(), u < 9e15 && (y[h++] = u % 1e14);
|
|
2126
|
+
for (x = y[--h], a %= U, x && a && (u = lt[U - a], y[h] = se(x / u) * u); y[h] === 0; y.pop(), h--) ;
|
|
2127
|
+
if (h < 0)
|
|
2128
|
+
y = [p = 0];
|
|
2129
|
+
else {
|
|
2130
|
+
for (p = -1; y[0] === 0; y.splice(0, 1), p -= U) ;
|
|
2131
|
+
for (h = 1, u = y[0]; u >= 10; u /= 10, h++) ;
|
|
2132
|
+
h < U && (p -= U - h);
|
|
2133
|
+
}
|
|
2134
|
+
return g.e = p, g.c = y, g;
|
|
2135
|
+
};
|
|
2136
|
+
})(), v.sum = function() {
|
|
2137
|
+
for (var i = 1, o = arguments, a = new v(o[0]); i < o.length; ) a = a.plus(o[i++]);
|
|
2138
|
+
return a;
|
|
2139
|
+
}, n = /* @__PURE__ */ (function() {
|
|
2140
|
+
var i = "0123456789";
|
|
2141
|
+
function o(a, m, f, p) {
|
|
2142
|
+
for (var x, u = [0], h, y = 0, g = a.length; y < g; ) {
|
|
2143
|
+
for (h = u.length; h--; u[h] *= m) ;
|
|
2144
|
+
for (u[0] += p.indexOf(a.charAt(y++)), x = 0; x < u.length; x++)
|
|
2145
|
+
u[x] > f - 1 && (u[x + 1] == null && (u[x + 1] = 0), u[x + 1] += u[x] / f | 0, u[x] %= f);
|
|
2146
|
+
}
|
|
2147
|
+
return u.reverse();
|
|
2148
|
+
}
|
|
2149
|
+
return function(a, m, f, p, x) {
|
|
2150
|
+
var u, h, y, g, d, T, I, N, M = a.indexOf("."), S = l, P = b;
|
|
2151
|
+
for (M >= 0 && (g = F, F = 0, a = a.replace(".", ""), N = new v(m), T = N.pow(a.length - M), F = g, N.c = o(
|
|
2152
|
+
ue(ne(T.c), T.e, "0"),
|
|
2153
|
+
10,
|
|
2154
|
+
f,
|
|
2155
|
+
i
|
|
2156
|
+
), N.e = N.c.length), I = o(a, m, f, x ? (u = j, i) : (u = i, j)), y = g = I.length; I[--g] == 0; I.pop()) ;
|
|
2157
|
+
if (!I[0]) return u.charAt(0);
|
|
2158
|
+
if (M < 0 ? --y : (T.c = I, T.e = y, T.s = p, T = t(T, N, S, P, f), I = T.c, d = T.r, y = T.e), h = y + S + 1, M = I[h], g = f / 2, d = d || h < 0 || I[h + 1] != null, d = P < 4 ? (M != null || d) && (P == 0 || P == (T.s < 0 ? 3 : 2)) : M > g || M == g && (P == 4 || d || P == 6 && I[h - 1] & 1 || P == (T.s < 0 ? 8 : 7)), h < 1 || !I[0])
|
|
2159
|
+
a = d ? ue(u.charAt(1), -S, u.charAt(0)) : u.charAt(0);
|
|
2160
|
+
else {
|
|
2161
|
+
if (I.length = h, d)
|
|
2162
|
+
for (--f; ++I[--h] > f; )
|
|
2163
|
+
I[h] = 0, h || (++y, I = [1].concat(I));
|
|
2164
|
+
for (g = I.length; !I[--g]; ) ;
|
|
2165
|
+
for (M = 0, a = ""; M <= g; a += u.charAt(I[M++])) ;
|
|
2166
|
+
a = ue(a, y, u.charAt(0));
|
|
2167
|
+
}
|
|
2168
|
+
return a;
|
|
2169
|
+
};
|
|
2170
|
+
})(), t = /* @__PURE__ */ (function() {
|
|
2171
|
+
function i(m, f, p) {
|
|
2172
|
+
var x, u, h, y, g = 0, d = m.length, T = f % pe, I = f / pe | 0;
|
|
2173
|
+
for (m = m.slice(); d--; )
|
|
2174
|
+
h = m[d] % pe, y = m[d] / pe | 0, x = I * h + y * T, u = T * h + x % pe * pe + g, g = (u / p | 0) + (x / pe | 0) + I * y, m[d] = u % p;
|
|
2175
|
+
return g && (m = [g].concat(m)), m;
|
|
2176
|
+
}
|
|
2177
|
+
function o(m, f, p, x) {
|
|
2178
|
+
var u, h;
|
|
2179
|
+
if (p != x)
|
|
2180
|
+
h = p > x ? 1 : -1;
|
|
2181
|
+
else
|
|
2182
|
+
for (u = h = 0; u < p; u++)
|
|
2183
|
+
if (m[u] != f[u]) {
|
|
2184
|
+
h = m[u] > f[u] ? 1 : -1;
|
|
2185
|
+
break;
|
|
2186
|
+
}
|
|
2187
|
+
return h;
|
|
2188
|
+
}
|
|
2189
|
+
function a(m, f, p, x) {
|
|
2190
|
+
for (var u = 0; p--; )
|
|
2191
|
+
m[p] -= u, u = m[p] < f[p] ? 1 : 0, m[p] = u * x + m[p] - f[p];
|
|
2192
|
+
for (; !m[0] && m.length > 1; m.splice(0, 1)) ;
|
|
2193
|
+
}
|
|
2194
|
+
return function(m, f, p, x, u) {
|
|
2195
|
+
var h, y, g, d, T, I, N, M, S, P, L, R, fe, Ne, Se, ae, Ue, te = m.s == f.s ? 1 : -1, Z = m.c, _ = f.c;
|
|
2196
|
+
if (!Z || !Z[0] || !_ || !_[0])
|
|
2197
|
+
return new v(
|
|
2198
|
+
// Return NaN if either NaN, or both Infinity or 0.
|
|
2199
|
+
!m.s || !f.s || (Z ? _ && Z[0] == _[0] : !_) ? NaN : (
|
|
2200
|
+
// Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
|
|
2201
|
+
Z && Z[0] == 0 || !_ ? te * 0 : te / 0
|
|
2202
|
+
)
|
|
2203
|
+
);
|
|
2204
|
+
for (M = new v(te), S = M.c = [], y = m.e - f.e, te = p + y + 1, u || (u = ie, y = re(m.e / U) - re(f.e / U), te = te / U | 0), g = 0; _[g] == (Z[g] || 0); g++) ;
|
|
2205
|
+
if (_[g] > (Z[g] || 0) && y--, te < 0)
|
|
2206
|
+
S.push(1), d = !0;
|
|
2207
|
+
else {
|
|
2208
|
+
for (Ne = Z.length, ae = _.length, g = 0, te += 2, T = se(u / (_[0] + 1)), T > 1 && (_ = i(_, T, u), Z = i(Z, T, u), ae = _.length, Ne = Z.length), fe = ae, P = Z.slice(0, ae), L = P.length; L < ae; P[L++] = 0) ;
|
|
2209
|
+
Ue = _.slice(), Ue = [0].concat(Ue), Se = _[0], _[1] >= u / 2 && Se++;
|
|
2210
|
+
do {
|
|
2211
|
+
if (T = 0, h = o(_, P, ae, L), h < 0) {
|
|
2212
|
+
if (R = P[0], ae != L && (R = R * u + (P[1] || 0)), T = se(R / Se), T > 1)
|
|
2213
|
+
for (T >= u && (T = u - 1), I = i(_, T, u), N = I.length, L = P.length; o(I, P, N, L) == 1; )
|
|
2214
|
+
T--, a(I, ae < N ? Ue : _, N, u), N = I.length, h = 1;
|
|
2215
|
+
else
|
|
2216
|
+
T == 0 && (h = T = 1), I = _.slice(), N = I.length;
|
|
2217
|
+
if (N < L && (I = [0].concat(I)), a(P, I, L, u), L = P.length, h == -1)
|
|
2218
|
+
for (; o(_, P, ae, L) < 1; )
|
|
2219
|
+
T++, a(P, ae < L ? Ue : _, L, u), L = P.length;
|
|
2220
|
+
} else h === 0 && (T++, P = [0]);
|
|
2221
|
+
S[g++] = T, P[0] ? P[L++] = Z[fe] || 0 : (P = [Z[fe]], L = 1);
|
|
2222
|
+
} while ((fe++ < Ne || P[0] != null) && te--);
|
|
2223
|
+
d = P[0] != null, S[0] || S.splice(0, 1);
|
|
2224
|
+
}
|
|
2225
|
+
if (u == ie) {
|
|
2226
|
+
for (g = 1, te = S[0]; te >= 10; te /= 10, g++) ;
|
|
2227
|
+
$(M, p + (M.e = g + y * U - 1) + 1, x, d);
|
|
2228
|
+
} else
|
|
2229
|
+
M.e = y, M.r = +d;
|
|
2230
|
+
return M;
|
|
2231
|
+
};
|
|
2232
|
+
})();
|
|
2233
|
+
function K(i, o, a, m) {
|
|
2234
|
+
var f, p, x, u, h;
|
|
2235
|
+
if (a == null ? a = b : G(a, 0, 8), !i.c) return i.toString();
|
|
2236
|
+
if (f = i.c[0], x = i.e, o == null)
|
|
2237
|
+
h = ne(i.c), h = m == 1 || m == 2 && (x <= w || x >= E) ? je(h, x) : ue(h, x, "0");
|
|
2238
|
+
else if (i = $(new v(i), o, a), p = i.e, h = ne(i.c), u = h.length, m == 1 || m == 2 && (o <= p || p <= w)) {
|
|
2239
|
+
for (; u < o; h += "0", u++) ;
|
|
2240
|
+
h = je(h, p);
|
|
2241
|
+
} else if (o -= x + (m === 2 && p > x), h = ue(h, p, "0"), p + 1 > u) {
|
|
2242
|
+
if (--o > 0) for (h += "."; o--; h += "0") ;
|
|
2243
|
+
} else if (o += p - u, o > 0)
|
|
2244
|
+
for (p + 1 == u && (h += "."); o--; h += "0") ;
|
|
2245
|
+
return i.s < 0 && f ? "-" + h : h;
|
|
2246
|
+
}
|
|
2247
|
+
function X(i, o) {
|
|
2248
|
+
for (var a, m, f = 1, p = new v(i[0]); f < i.length; f++)
|
|
2249
|
+
m = new v(i[f]), (!m.s || (a = be(p, m)) === o || a === 0 && p.s === o) && (p = m);
|
|
2250
|
+
return p;
|
|
2251
|
+
}
|
|
2252
|
+
function ee(i, o, a) {
|
|
2253
|
+
for (var m = 1, f = o.length; !o[--f]; o.pop()) ;
|
|
2254
|
+
for (f = o[0]; f >= 10; f /= 10, m++) ;
|
|
2255
|
+
return (a = m + a * U - 1) > B ? i.c = i.e = null : a < A ? i.c = [i.e = 0] : (i.e = a, i.c = o), i;
|
|
2256
|
+
}
|
|
2257
|
+
r = /* @__PURE__ */ (function() {
|
|
2258
|
+
var i = /^(-?)0([xbo])(?=\w[\w.]*$)/i, o = /^([^.]+)\.$/, a = /^\.([^.]+)$/, m = /^-?(Infinity|NaN)$/, f = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
|
|
2259
|
+
return function(p, x, u, h) {
|
|
2260
|
+
var y, g = u ? x : x.replace(f, "");
|
|
2261
|
+
if (m.test(g))
|
|
2262
|
+
p.s = isNaN(g) ? null : g < 0 ? -1 : 1;
|
|
2263
|
+
else {
|
|
2264
|
+
if (!u && (g = g.replace(i, function(d, T, I) {
|
|
2265
|
+
return y = (I = I.toLowerCase()) == "x" ? 16 : I == "b" ? 2 : 8, !h || h == y ? T : d;
|
|
2266
|
+
}), h && (y = h, g = g.replace(o, "$1").replace(a, "0.$1")), x != g))
|
|
2267
|
+
return new v(g, y);
|
|
2268
|
+
if (v.DEBUG)
|
|
2269
|
+
throw Error(W + "Not a" + (h ? " base " + h : "") + " number: " + x);
|
|
2270
|
+
p.s = null;
|
|
2271
|
+
}
|
|
2272
|
+
p.c = p.e = null;
|
|
2273
|
+
};
|
|
2274
|
+
})();
|
|
2275
|
+
function $(i, o, a, m) {
|
|
2276
|
+
var f, p, x, u, h, y, g, d = i.c, T = lt;
|
|
2277
|
+
if (d) {
|
|
2278
|
+
e: {
|
|
2279
|
+
for (f = 1, u = d[0]; u >= 10; u /= 10, f++) ;
|
|
2280
|
+
if (p = o - f, p < 0)
|
|
2281
|
+
p += U, x = o, h = d[y = 0], g = se(h / T[f - x - 1] % 10);
|
|
2282
|
+
else if (y = at((p + 1) / U), y >= d.length)
|
|
2283
|
+
if (m) {
|
|
2284
|
+
for (; d.length <= y; d.push(0)) ;
|
|
2285
|
+
h = g = 0, f = 1, p %= U, x = p - U + 1;
|
|
2286
|
+
} else
|
|
2287
|
+
break e;
|
|
2288
|
+
else {
|
|
2289
|
+
for (h = u = d[y], f = 1; u >= 10; u /= 10, f++) ;
|
|
2290
|
+
p %= U, x = p - U + f, g = x < 0 ? 0 : se(h / T[f - x - 1] % 10);
|
|
2291
|
+
}
|
|
2292
|
+
if (m = m || o < 0 || // Are there any non-zero digits after the rounding digit?
|
|
2293
|
+
// The expression n % pows10[d - j - 1] returns all digits of n to the right
|
|
2294
|
+
// of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
|
|
2295
|
+
d[y + 1] != null || (x < 0 ? h : h % T[f - x - 1]), m = a < 4 ? (g || m) && (a == 0 || a == (i.s < 0 ? 3 : 2)) : g > 5 || g == 5 && (a == 4 || m || a == 6 && // Check whether the digit to the left of the rounding digit is odd.
|
|
2296
|
+
(p > 0 ? x > 0 ? h / T[f - x] : 0 : d[y - 1]) % 10 & 1 || a == (i.s < 0 ? 8 : 7)), o < 1 || !d[0])
|
|
2297
|
+
return d.length = 0, m ? (o -= i.e + 1, d[0] = T[(U - o % U) % U], i.e = -o || 0) : d[0] = i.e = 0, i;
|
|
2298
|
+
if (p == 0 ? (d.length = y, u = 1, y--) : (d.length = y + 1, u = T[U - p], d[y] = x > 0 ? se(h / T[f - x] % T[x]) * u : 0), m)
|
|
2299
|
+
for (; ; )
|
|
2300
|
+
if (y == 0) {
|
|
2301
|
+
for (p = 1, x = d[0]; x >= 10; x /= 10, p++) ;
|
|
2302
|
+
for (x = d[0] += u, u = 1; x >= 10; x /= 10, u++) ;
|
|
2303
|
+
p != u && (i.e++, d[0] == ie && (d[0] = 1));
|
|
2304
|
+
break;
|
|
2305
|
+
} else {
|
|
2306
|
+
if (d[y] += u, d[y] != ie) break;
|
|
2307
|
+
d[y--] = 0, u = 1;
|
|
2308
|
+
}
|
|
2309
|
+
for (p = d.length; d[--p] === 0; d.pop()) ;
|
|
2310
|
+
}
|
|
2311
|
+
i.e > B ? i.c = i.e = null : i.e < A && (i.c = [i.e = 0]);
|
|
2312
|
+
}
|
|
2313
|
+
return i;
|
|
2314
|
+
}
|
|
2315
|
+
function J(i) {
|
|
2316
|
+
var o, a = i.e;
|
|
2317
|
+
return a === null ? i.toString() : (o = ne(i.c), o = a <= w || a >= E ? je(o, a) : ue(o, a, "0"), i.s < 0 ? "-" + o : o);
|
|
2318
|
+
}
|
|
2319
|
+
return s.absoluteValue = s.abs = function() {
|
|
2320
|
+
var i = new v(this);
|
|
2321
|
+
return i.s < 0 && (i.s = 1), i;
|
|
2322
|
+
}, s.comparedTo = function(i, o) {
|
|
2323
|
+
return be(this, new v(i, o));
|
|
2324
|
+
}, s.decimalPlaces = s.dp = function(i, o) {
|
|
2325
|
+
var a, m, f, p = this;
|
|
2326
|
+
if (i != null)
|
|
2327
|
+
return G(i, 0, q), o == null ? o = b : G(o, 0, 8), $(new v(p), i + p.e + 1, o);
|
|
2328
|
+
if (!(a = p.c)) return null;
|
|
2329
|
+
if (m = ((f = a.length - 1) - re(this.e / U)) * U, f = a[f]) for (; f % 10 == 0; f /= 10, m--) ;
|
|
2330
|
+
return m < 0 && (m = 0), m;
|
|
2331
|
+
}, s.dividedBy = s.div = function(i, o) {
|
|
2332
|
+
return t(this, new v(i, o), l, b);
|
|
2333
|
+
}, s.dividedToIntegerBy = s.idiv = function(i, o) {
|
|
2334
|
+
return t(this, new v(i, o), 0, 1);
|
|
2335
|
+
}, s.exponentiatedBy = s.pow = function(i, o) {
|
|
2336
|
+
var a, m, f, p, x, u, h, y, g, d = this;
|
|
2337
|
+
if (i = new v(i), i.c && !i.isInteger())
|
|
2338
|
+
throw Error(W + "Exponent not an integer: " + J(i));
|
|
2339
|
+
if (o != null && (o = new v(o)), u = i.e > 14, !d.c || !d.c[0] || d.c[0] == 1 && !d.e && d.c.length == 1 || !i.c || !i.c[0])
|
|
2340
|
+
return g = new v(Math.pow(+J(d), u ? i.s * (2 - Ve(i)) : +J(i))), o ? g.mod(o) : g;
|
|
2341
|
+
if (h = i.s < 0, o) {
|
|
2342
|
+
if (o.c ? !o.c[0] : !o.s) return new v(NaN);
|
|
2343
|
+
m = !h && d.isInteger() && o.isInteger(), m && (d = d.mod(o));
|
|
2344
|
+
} else {
|
|
2345
|
+
if (i.e > 9 && (d.e > 0 || d.e < -1 || (d.e == 0 ? d.c[0] > 1 || u && d.c[1] >= 24e7 : d.c[0] < 8e13 || u && d.c[0] <= 9999975e7)))
|
|
2346
|
+
return p = d.s < 0 && Ve(i) ? -0 : 0, d.e > -1 && (p = 1 / p), new v(h ? 1 / p : p);
|
|
2347
|
+
F && (p = at(F / U + 2));
|
|
2348
|
+
}
|
|
2349
|
+
for (u ? (a = new v(0.5), h && (i.s = 1), y = Ve(i)) : (f = Math.abs(+J(i)), y = f % 2), g = new v(c); ; ) {
|
|
2350
|
+
if (y) {
|
|
2351
|
+
if (g = g.times(d), !g.c) break;
|
|
2352
|
+
p ? g.c.length > p && (g.c.length = p) : m && (g = g.mod(o));
|
|
2353
|
+
}
|
|
2354
|
+
if (f) {
|
|
2355
|
+
if (f = se(f / 2), f === 0) break;
|
|
2356
|
+
y = f % 2;
|
|
2357
|
+
} else if (i = i.times(a), $(i, i.e + 1, 1), i.e > 14)
|
|
2358
|
+
y = Ve(i);
|
|
2359
|
+
else {
|
|
2360
|
+
if (f = +J(i), f === 0) break;
|
|
2361
|
+
y = f % 2;
|
|
2362
|
+
}
|
|
2363
|
+
d = d.times(d), p ? d.c && d.c.length > p && (d.c.length = p) : m && (d = d.mod(o));
|
|
2364
|
+
}
|
|
2365
|
+
return m ? g : (h && (g = c.div(g)), o ? g.mod(o) : p ? $(g, F, b, x) : g);
|
|
2366
|
+
}, s.integerValue = function(i) {
|
|
2367
|
+
var o = new v(this);
|
|
2368
|
+
return i == null ? i = b : G(i, 0, 8), $(o, o.e + 1, i);
|
|
2369
|
+
}, s.isEqualTo = s.eq = function(i, o) {
|
|
2370
|
+
return be(this, new v(i, o)) === 0;
|
|
2371
|
+
}, s.isFinite = function() {
|
|
2372
|
+
return !!this.c;
|
|
2373
|
+
}, s.isGreaterThan = s.gt = function(i, o) {
|
|
2374
|
+
return be(this, new v(i, o)) > 0;
|
|
2375
|
+
}, s.isGreaterThanOrEqualTo = s.gte = function(i, o) {
|
|
2376
|
+
return (o = be(this, new v(i, o))) === 1 || o === 0;
|
|
2377
|
+
}, s.isInteger = function() {
|
|
2378
|
+
return !!this.c && re(this.e / U) > this.c.length - 2;
|
|
2379
|
+
}, s.isLessThan = s.lt = function(i, o) {
|
|
2380
|
+
return be(this, new v(i, o)) < 0;
|
|
2381
|
+
}, s.isLessThanOrEqualTo = s.lte = function(i, o) {
|
|
2382
|
+
return (o = be(this, new v(i, o))) === -1 || o === 0;
|
|
2383
|
+
}, s.isNaN = function() {
|
|
2384
|
+
return !this.s;
|
|
2385
|
+
}, s.isNegative = function() {
|
|
2386
|
+
return this.s < 0;
|
|
2387
|
+
}, s.isPositive = function() {
|
|
2388
|
+
return this.s > 0;
|
|
2389
|
+
}, s.isZero = function() {
|
|
2390
|
+
return !!this.c && this.c[0] == 0;
|
|
2391
|
+
}, s.minus = function(i, o) {
|
|
2392
|
+
var a, m, f, p, x = this, u = x.s;
|
|
2393
|
+
if (i = new v(i, o), o = i.s, !u || !o) return new v(NaN);
|
|
2394
|
+
if (u != o)
|
|
2395
|
+
return i.s = -o, x.plus(i);
|
|
2396
|
+
var h = x.e / U, y = i.e / U, g = x.c, d = i.c;
|
|
2397
|
+
if (!h || !y) {
|
|
2398
|
+
if (!g || !d) return g ? (i.s = -o, i) : new v(d ? x : NaN);
|
|
2399
|
+
if (!g[0] || !d[0])
|
|
2400
|
+
return d[0] ? (i.s = -o, i) : new v(g[0] ? x : (
|
|
2401
|
+
// IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
|
|
2402
|
+
b == 3 ? -0 : 0
|
|
2403
|
+
));
|
|
2404
|
+
}
|
|
2405
|
+
if (h = re(h), y = re(y), g = g.slice(), u = h - y) {
|
|
2406
|
+
for ((p = u < 0) ? (u = -u, f = g) : (y = h, f = d), f.reverse(), o = u; o--; f.push(0)) ;
|
|
2407
|
+
f.reverse();
|
|
2408
|
+
} else
|
|
2409
|
+
for (m = (p = (u = g.length) < (o = d.length)) ? u : o, u = o = 0; o < m; o++)
|
|
2410
|
+
if (g[o] != d[o]) {
|
|
2411
|
+
p = g[o] < d[o];
|
|
2412
|
+
break;
|
|
2413
|
+
}
|
|
2414
|
+
if (p && (f = g, g = d, d = f, i.s = -i.s), o = (m = d.length) - (a = g.length), o > 0) for (; o--; g[a++] = 0) ;
|
|
2415
|
+
for (o = ie - 1; m > u; ) {
|
|
2416
|
+
if (g[--m] < d[m]) {
|
|
2417
|
+
for (a = m; a && !g[--a]; g[a] = o) ;
|
|
2418
|
+
--g[a], g[m] += ie;
|
|
2419
|
+
}
|
|
2420
|
+
g[m] -= d[m];
|
|
2421
|
+
}
|
|
2422
|
+
for (; g[0] == 0; g.splice(0, 1), --y) ;
|
|
2423
|
+
return g[0] ? ee(i, g, y) : (i.s = b == 3 ? -1 : 1, i.c = [i.e = 0], i);
|
|
2424
|
+
}, s.modulo = s.mod = function(i, o) {
|
|
2425
|
+
var a, m, f = this;
|
|
2426
|
+
return i = new v(i, o), !f.c || !i.s || i.c && !i.c[0] ? new v(NaN) : !i.c || f.c && !f.c[0] ? new v(f) : (O == 9 ? (m = i.s, i.s = 1, a = t(f, i, 0, 3), i.s = m, a.s *= m) : a = t(f, i, 0, O), i = f.minus(a.times(i)), !i.c[0] && O == 1 && (i.s = f.s), i);
|
|
2427
|
+
}, s.multipliedBy = s.times = function(i, o) {
|
|
2428
|
+
var a, m, f, p, x, u, h, y, g, d, T, I, N, M, S, P = this, L = P.c, R = (i = new v(i, o)).c;
|
|
2429
|
+
if (!L || !R || !L[0] || !R[0])
|
|
2430
|
+
return !P.s || !i.s || L && !L[0] && !R || R && !R[0] && !L ? i.c = i.e = i.s = null : (i.s *= P.s, !L || !R ? i.c = i.e = null : (i.c = [0], i.e = 0)), i;
|
|
2431
|
+
for (m = re(P.e / U) + re(i.e / U), i.s *= P.s, h = L.length, d = R.length, h < d && (N = L, L = R, R = N, f = h, h = d, d = f), f = h + d, N = []; f--; N.push(0)) ;
|
|
2432
|
+
for (M = ie, S = pe, f = d; --f >= 0; ) {
|
|
2433
|
+
for (a = 0, T = R[f] % S, I = R[f] / S | 0, x = h, p = f + x; p > f; )
|
|
2434
|
+
y = L[--x] % S, g = L[x] / S | 0, u = I * y + g * T, y = T * y + u % S * S + N[p] + a, a = (y / M | 0) + (u / S | 0) + I * g, N[p--] = y % M;
|
|
2435
|
+
N[p] = a;
|
|
2436
|
+
}
|
|
2437
|
+
return a ? ++m : N.splice(0, 1), ee(i, N, m);
|
|
2438
|
+
}, s.negated = function() {
|
|
2439
|
+
var i = new v(this);
|
|
2440
|
+
return i.s = -i.s || null, i;
|
|
2441
|
+
}, s.plus = function(i, o) {
|
|
2442
|
+
var a, m = this, f = m.s;
|
|
2443
|
+
if (i = new v(i, o), o = i.s, !f || !o) return new v(NaN);
|
|
2444
|
+
if (f != o)
|
|
2445
|
+
return i.s = -o, m.minus(i);
|
|
2446
|
+
var p = m.e / U, x = i.e / U, u = m.c, h = i.c;
|
|
2447
|
+
if (!p || !x) {
|
|
2448
|
+
if (!u || !h) return new v(f / 0);
|
|
2449
|
+
if (!u[0] || !h[0]) return h[0] ? i : new v(u[0] ? m : f * 0);
|
|
2450
|
+
}
|
|
2451
|
+
if (p = re(p), x = re(x), u = u.slice(), f = p - x) {
|
|
2452
|
+
for (f > 0 ? (x = p, a = h) : (f = -f, a = u), a.reverse(); f--; a.push(0)) ;
|
|
2453
|
+
a.reverse();
|
|
2454
|
+
}
|
|
2455
|
+
for (f = u.length, o = h.length, f - o < 0 && (a = h, h = u, u = a, o = f), f = 0; o; )
|
|
2456
|
+
f = (u[--o] = u[o] + h[o] + f) / ie | 0, u[o] = ie === u[o] ? 0 : u[o] % ie;
|
|
2457
|
+
return f && (u = [f].concat(u), ++x), ee(i, u, x);
|
|
2458
|
+
}, s.precision = s.sd = function(i, o) {
|
|
2459
|
+
var a, m, f, p = this;
|
|
2460
|
+
if (i != null && i !== !!i)
|
|
2461
|
+
return G(i, 1, q), o == null ? o = b : G(o, 0, 8), $(new v(p), i, o);
|
|
2462
|
+
if (!(a = p.c)) return null;
|
|
2463
|
+
if (f = a.length - 1, m = f * U + 1, f = a[f]) {
|
|
2464
|
+
for (; f % 10 == 0; f /= 10, m--) ;
|
|
2465
|
+
for (f = a[0]; f >= 10; f /= 10, m++) ;
|
|
2466
|
+
}
|
|
2467
|
+
return i && p.e + 1 > m && (m = p.e + 1), m;
|
|
2468
|
+
}, s.shiftedBy = function(i) {
|
|
2469
|
+
return G(i, -ct, ct), this.times("1e" + i);
|
|
2470
|
+
}, s.squareRoot = s.sqrt = function() {
|
|
2471
|
+
var i, o, a, m, f, p = this, x = p.c, u = p.s, h = p.e, y = l + 4, g = new v("0.5");
|
|
2472
|
+
if (u !== 1 || !x || !x[0])
|
|
2473
|
+
return new v(!u || u < 0 && (!x || x[0]) ? NaN : x ? p : 1 / 0);
|
|
2474
|
+
if (u = Math.sqrt(+J(p)), u == 0 || u == 1 / 0 ? (o = ne(x), (o.length + h) % 2 == 0 && (o += "0"), u = Math.sqrt(+o), h = re((h + 1) / 2) - (h < 0 || h % 2), u == 1 / 0 ? o = "5e" + h : (o = u.toExponential(), o = o.slice(0, o.indexOf("e") + 1) + h), a = new v(o)) : a = new v(u + ""), a.c[0]) {
|
|
2475
|
+
for (h = a.e, u = h + y, u < 3 && (u = 0); ; )
|
|
2476
|
+
if (f = a, a = g.times(f.plus(t(p, f, y, 1))), ne(f.c).slice(0, u) === (o = ne(a.c)).slice(0, u))
|
|
2477
|
+
if (a.e < h && --u, o = o.slice(u - 3, u + 1), o == "9999" || !m && o == "4999") {
|
|
2478
|
+
if (!m && ($(f, f.e + l + 2, 0), f.times(f).eq(p))) {
|
|
2479
|
+
a = f;
|
|
2480
|
+
break;
|
|
2481
|
+
}
|
|
2482
|
+
y += 4, u += 4, m = 1;
|
|
2483
|
+
} else {
|
|
2484
|
+
(!+o || !+o.slice(1) && o.charAt(0) == "5") && ($(a, a.e + l + 2, 1), i = !a.times(a).eq(p));
|
|
2485
|
+
break;
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
return $(a, a.e + l + 1, b, i);
|
|
2489
|
+
}, s.toExponential = function(i, o) {
|
|
2490
|
+
return i != null && (G(i, 0, q), i++), K(this, i, o, 1);
|
|
2491
|
+
}, s.toFixed = function(i, o) {
|
|
2492
|
+
return i != null && (G(i, 0, q), i = i + this.e + 1), K(this, i, o);
|
|
2493
|
+
}, s.toFormat = function(i, o, a) {
|
|
2494
|
+
var m, f = this;
|
|
2495
|
+
if (a == null)
|
|
2496
|
+
i != null && o && typeof o == "object" ? (a = o, o = null) : i && typeof i == "object" ? (a = i, i = o = null) : a = H;
|
|
2497
|
+
else if (typeof a != "object")
|
|
2498
|
+
throw Error(W + "Argument not an object: " + a);
|
|
2499
|
+
if (m = f.toFixed(i, o), f.c) {
|
|
2500
|
+
var p, x = m.split("."), u = +a.groupSize, h = +a.secondaryGroupSize, y = a.groupSeparator || "", g = x[0], d = x[1], T = f.s < 0, I = T ? g.slice(1) : g, N = I.length;
|
|
2501
|
+
if (h && (p = u, u = h, h = p, N -= p), u > 0 && N > 0) {
|
|
2502
|
+
for (p = N % u || u, g = I.substr(0, p); p < N; p += u) g += y + I.substr(p, u);
|
|
2503
|
+
h > 0 && (g += y + I.slice(p)), T && (g = "-" + g);
|
|
2504
|
+
}
|
|
2505
|
+
m = d ? g + (a.decimalSeparator || "") + ((h = +a.fractionGroupSize) ? d.replace(
|
|
2506
|
+
new RegExp("\\d{" + h + "}\\B", "g"),
|
|
2507
|
+
"$&" + (a.fractionGroupSeparator || "")
|
|
2508
|
+
) : d) : g;
|
|
2509
|
+
}
|
|
2510
|
+
return (a.prefix || "") + m + (a.suffix || "");
|
|
2511
|
+
}, s.toFraction = function(i) {
|
|
2512
|
+
var o, a, m, f, p, x, u, h, y, g, d, T, I = this, N = I.c;
|
|
2513
|
+
if (i != null && (u = new v(i), !u.isInteger() && (u.c || u.s !== 1) || u.lt(c)))
|
|
2514
|
+
throw Error(W + "Argument " + (u.isInteger() ? "out of range: " : "not an integer: ") + J(u));
|
|
2515
|
+
if (!N) return new v(I);
|
|
2516
|
+
for (o = new v(c), y = a = new v(c), m = h = new v(c), T = ne(N), p = o.e = T.length - I.e - 1, o.c[0] = lt[(x = p % U) < 0 ? U + x : x], i = !i || u.comparedTo(o) > 0 ? p > 0 ? o : y : u, x = B, B = 1 / 0, u = new v(T), h.c[0] = 0; g = t(u, o, 0, 1), f = a.plus(g.times(m)), f.comparedTo(i) != 1; )
|
|
2517
|
+
a = m, m = f, y = h.plus(g.times(f = y)), h = f, o = u.minus(g.times(f = o)), u = f;
|
|
2518
|
+
return f = t(i.minus(a), m, 0, 1), h = h.plus(f.times(y)), a = a.plus(f.times(m)), h.s = y.s = I.s, p = p * 2, d = t(y, m, p, b).minus(I).abs().comparedTo(
|
|
2519
|
+
t(h, a, p, b).minus(I).abs()
|
|
2520
|
+
) < 1 ? [y, m] : [h, a], B = x, d;
|
|
2521
|
+
}, s.toNumber = function() {
|
|
2522
|
+
return +J(this);
|
|
2523
|
+
}, s.toPrecision = function(i, o) {
|
|
2524
|
+
return i != null && G(i, 1, q), K(this, i, o, 2);
|
|
2525
|
+
}, s.toString = function(i) {
|
|
2526
|
+
var o, a = this, m = a.s, f = a.e;
|
|
2527
|
+
return f === null ? m ? (o = "Infinity", m < 0 && (o = "-" + o)) : o = "NaN" : (i == null ? o = f <= w || f >= E ? je(ne(a.c), f) : ue(ne(a.c), f, "0") : i === 10 && oe ? (a = $(new v(a), l + f + 1, b), o = ue(ne(a.c), a.e, "0")) : (G(i, 2, j.length, "Base"), o = n(ue(ne(a.c), f, "0"), 10, i, m, !0)), m < 0 && a.c[0] && (o = "-" + o)), o;
|
|
2528
|
+
}, s.valueOf = s.toJSON = function() {
|
|
2529
|
+
return J(this);
|
|
2530
|
+
}, s._isBigNumber = !0, s[Symbol.toStringTag] = "BigNumber", s[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = s.valueOf, e != null && v.set(e), v;
|
|
2531
|
+
}
|
|
2532
|
+
function re(e) {
|
|
2533
|
+
var t = e | 0;
|
|
2534
|
+
return e > 0 || e === t ? t : t - 1;
|
|
2535
|
+
}
|
|
2536
|
+
function ne(e) {
|
|
2537
|
+
for (var t, n, r = 1, s = e.length, c = e[0] + ""; r < s; ) {
|
|
2538
|
+
for (t = e[r++] + "", n = U - t.length; n--; t = "0" + t) ;
|
|
2539
|
+
c += t;
|
|
2540
|
+
}
|
|
2541
|
+
for (s = c.length; c.charCodeAt(--s) === 48; ) ;
|
|
2542
|
+
return c.slice(0, s + 1 || 1);
|
|
2543
|
+
}
|
|
2544
|
+
function be(e, t) {
|
|
2545
|
+
var n, r, s = e.c, c = t.c, l = e.s, b = t.s, w = e.e, E = t.e;
|
|
2546
|
+
if (!l || !b) return null;
|
|
2547
|
+
if (n = s && !s[0], r = c && !c[0], n || r) return n ? r ? 0 : -b : l;
|
|
2548
|
+
if (l != b) return l;
|
|
2549
|
+
if (n = l < 0, r = w == E, !s || !c) return r ? 0 : !s ^ n ? 1 : -1;
|
|
2550
|
+
if (!r) return w > E ^ n ? 1 : -1;
|
|
2551
|
+
for (b = (w = s.length) < (E = c.length) ? w : E, l = 0; l < b; l++) if (s[l] != c[l]) return s[l] > c[l] ^ n ? 1 : -1;
|
|
2552
|
+
return w == E ? 0 : w > E ^ n ? 1 : -1;
|
|
2553
|
+
}
|
|
2554
|
+
function G(e, t, n, r) {
|
|
2555
|
+
if (e < t || e > n || e !== se(e))
|
|
2556
|
+
throw Error(W + (r || "Argument") + (typeof e == "number" ? e < t || e > n ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(e));
|
|
2557
|
+
}
|
|
2558
|
+
function Ve(e) {
|
|
2559
|
+
var t = e.c.length - 1;
|
|
2560
|
+
return re(e.e / U) == t && e.c[t] % 2 != 0;
|
|
2561
|
+
}
|
|
2562
|
+
function je(e, t) {
|
|
2563
|
+
return (e.length > 1 ? e.charAt(0) + "." + e.slice(1) : e) + (t < 0 ? "e" : "e+") + t;
|
|
2564
|
+
}
|
|
2565
|
+
function ue(e, t, n) {
|
|
2566
|
+
var r, s;
|
|
2567
|
+
if (t < 0) {
|
|
2568
|
+
for (s = n + "."; ++t; s += n) ;
|
|
2569
|
+
e = s + e;
|
|
2570
|
+
} else if (r = e.length, ++t > r) {
|
|
2571
|
+
for (s = n, t -= r; --t; s += n) ;
|
|
2572
|
+
e += s;
|
|
2573
|
+
} else t < r && (e = e.slice(0, t) + "." + e.slice(t));
|
|
2574
|
+
return e;
|
|
2575
|
+
}
|
|
2576
|
+
var ft = fn();
|
|
2577
|
+
class et {
|
|
2578
|
+
baseUrl;
|
|
2579
|
+
constructor(t) {
|
|
2580
|
+
this.baseUrl = t;
|
|
2581
|
+
}
|
|
2582
|
+
buildUrl(t, n) {
|
|
2583
|
+
const r = new URL(t, this.baseUrl);
|
|
2584
|
+
return n && Object.entries(n).forEach(([s, c]) => {
|
|
2585
|
+
c != null && r.searchParams.append(s, String(c));
|
|
2586
|
+
}), r.toString();
|
|
2587
|
+
}
|
|
2588
|
+
async get(t, n = {}) {
|
|
2589
|
+
const r = this.buildUrl(t, n.query), s = await fetch(r, {
|
|
2590
|
+
method: "GET",
|
|
2591
|
+
headers: n.headers || {}
|
|
2592
|
+
});
|
|
2593
|
+
if (!s.ok)
|
|
2594
|
+
throw new Error(`HTTP ${s.status}: ${s.statusText}`);
|
|
2595
|
+
return { data: await s.json(), status: s.status };
|
|
2596
|
+
}
|
|
2597
|
+
async post(t, n, r = {}) {
|
|
2598
|
+
const s = this.buildUrl(t, r.query), c = await fetch(s, {
|
|
2599
|
+
method: "POST",
|
|
2600
|
+
headers: {
|
|
2601
|
+
"Content-Type": "application/json",
|
|
2602
|
+
...r.headers
|
|
2603
|
+
},
|
|
2604
|
+
body: JSON.stringify(n)
|
|
2605
|
+
});
|
|
2606
|
+
if (!c.ok)
|
|
2607
|
+
throw new Error(`HTTP ${c.status}: ${c.statusText}`);
|
|
2608
|
+
return { data: await c.json(), status: c.status };
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
class Ir extends D {
|
|
2612
|
+
constructor({ value: t }) {
|
|
2613
|
+
super(`Number \`${t}\` is not a valid decimal number.`, {
|
|
2614
|
+
name: "InvalidDecimalNumberError"
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
function vr(e, t) {
|
|
2619
|
+
if (!/^(-?)([0-9]*)\.?([0-9]*)$/.test(e))
|
|
2620
|
+
throw new Ir({ value: e });
|
|
2621
|
+
let [n, r = "0"] = e.split(".");
|
|
2622
|
+
const s = n.startsWith("-");
|
|
2623
|
+
if (s && (n = n.slice(1)), r = r.replace(/(0+)$/, ""), t === 0)
|
|
2624
|
+
Math.round(+`.${r}`) === 1 && (n = `${BigInt(n) + 1n}`), r = "";
|
|
2625
|
+
else if (r.length > t) {
|
|
2626
|
+
const [c, l, b] = [
|
|
2627
|
+
r.slice(0, t - 1),
|
|
2628
|
+
r.slice(t - 1, t),
|
|
2629
|
+
r.slice(t)
|
|
2630
|
+
], w = Math.round(+`${l}.${b}`);
|
|
2631
|
+
w > 9 ? r = `${BigInt(c) + BigInt(1)}0`.padStart(c.length + 1, "0") : r = `${c}${w}`, r.length > t && (r = r.slice(1), n = `${BigInt(n) + 1n}`), r = r.slice(0, t);
|
|
2632
|
+
} else
|
|
2633
|
+
r = r.padEnd(t, "0");
|
|
2634
|
+
return BigInt(`${s ? "-" : ""}${n}${r}`);
|
|
2635
|
+
}
|
|
2636
|
+
const Er = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", Ar = "0x0000000000000000000000000000000000000000", Tr = 0.01, Br = "https://deep-index.moralis.io";
|
|
2637
|
+
function dn() {
|
|
2638
|
+
return "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6ImY4NmY0Yzc2LTA3MDQtNGEwZS04YTA0LWUwODllOGQxMGZjZCIsIm9yZ0lkIjoiMzk0MDAyIiwidXNlcklkIjoiNDA0ODUzIiwidHlwZUlkIjoiYjQyODExOTQtOGQ0Yi00NjkxLTlhZjItNjU4ODE2NzExYmRjIiwidHlwZSI6IlBST0pFQ1QiLCJpYXQiOjE3MTY4NjQyNTYsImV4cCI6NDg3MjYyNDI1Nn0.V8crfBIBardAnZkc05FD0hQIJBeZxMqvzRnYExVtnF8";
|
|
2639
|
+
}
|
|
2640
|
+
function kr(e) {
|
|
2641
|
+
return {
|
|
2642
|
+
"X-API-Key": e,
|
|
2643
|
+
Accept: "application/json"
|
|
2644
|
+
};
|
|
2645
|
+
}
|
|
2646
|
+
const Pr = new et(Br);
|
|
2647
|
+
async function Nr(e) {
|
|
2648
|
+
const {
|
|
2649
|
+
address: t,
|
|
2650
|
+
chain: n = "base",
|
|
2651
|
+
token_addresses: r,
|
|
2652
|
+
exclude_spam: s,
|
|
2653
|
+
exclude_unverified_contracts: c
|
|
2654
|
+
} = e;
|
|
2655
|
+
if (!t)
|
|
2656
|
+
throw new Error("Address is required");
|
|
2657
|
+
try {
|
|
2658
|
+
const l = dn(), b = {
|
|
2659
|
+
chain: n,
|
|
2660
|
+
exclude_spam: s ?? !1,
|
|
2661
|
+
exclude_unverified_contracts: c ?? !1
|
|
2662
|
+
};
|
|
2663
|
+
r && (b.token_addresses = r);
|
|
2664
|
+
const E = (await Pr.get(
|
|
2665
|
+
`/api/v2.2/wallets/${encodeURIComponent(t)}/tokens`,
|
|
2666
|
+
{
|
|
2667
|
+
query: b,
|
|
2668
|
+
headers: kr(l)
|
|
2669
|
+
}
|
|
2670
|
+
)).data;
|
|
2671
|
+
return E?.result?.length > 0 && (E.result = E.result.filter((A) => {
|
|
2672
|
+
const B = new ft(A?.balance || 0), C = new ft(A?.usd_value || 0);
|
|
2673
|
+
return B.gt(0) && C.gte(Tr);
|
|
2674
|
+
}), E.result = E.result.map((A) => ({
|
|
2675
|
+
...A,
|
|
2676
|
+
token_address: A.token_address === Er ? Ar : A.token_address
|
|
2677
|
+
}))), {
|
|
2678
|
+
success: !0,
|
|
2679
|
+
data: E
|
|
2680
|
+
};
|
|
2681
|
+
} catch (l) {
|
|
2682
|
+
const b = l instanceof Error ? l.message : "Unknown error";
|
|
2683
|
+
return console.error("❌ Error fetching token balances:", b), {
|
|
2684
|
+
success: !1,
|
|
2685
|
+
error: b
|
|
2686
|
+
};
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
async function Sr(e) {
|
|
2690
|
+
const { prompt: t, model: n = "gpt-4.1-mini", stream: r = !1 } = e;
|
|
2691
|
+
if (!t)
|
|
2692
|
+
throw new Error("Prompt is required");
|
|
2693
|
+
try {
|
|
2694
|
+
const s = dn();
|
|
2695
|
+
return {
|
|
2696
|
+
success: !0,
|
|
2697
|
+
data: (await new et("https://cortex-api.moralis.io").post(
|
|
2698
|
+
"/chat",
|
|
2699
|
+
{
|
|
2700
|
+
prompt: t,
|
|
2701
|
+
model: n,
|
|
2702
|
+
stream: r
|
|
2703
|
+
},
|
|
2704
|
+
{
|
|
2705
|
+
headers: {
|
|
2706
|
+
"X-API-Key": s,
|
|
2707
|
+
Accept: "application/json",
|
|
2708
|
+
"Content-Type": "application/json"
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
)).data
|
|
2712
|
+
};
|
|
2713
|
+
} catch (s) {
|
|
2714
|
+
const c = s instanceof Error ? s.message : "Unknown error";
|
|
2715
|
+
return console.error("❌ Error chatting with Cortex AI:", c), {
|
|
2716
|
+
success: !1,
|
|
2717
|
+
error: c
|
|
2718
|
+
};
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
const Ur = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAx8SURBVHgB7VprbFzFFT5n9kmoil0JiUqVsuYX/7BRSeL+aOyKivKjxYYEmpbWNlQpUYvsQAtBVPHdoBYFodgWIiAK8ppWysOVbFrRh0qxUyE5BlQ7/VEqVYo3P6qq6iMbpYTEu3dOz7zuY72Jr51NIrU59u597NyZ+ea8zx2A63Sd/qcI4QoQTfW0QC3fDrLWpS4BUxUAeQwfmFyEa0xNB0xHtw9yrx7DbAlH4WGI1FkZBHq47egEXCNqGmCa3NbF3Q0z0K7IXbLD1I+zBCh24/Yjb8JVpssGTIe+WoCUP8TYbufemKvYzkdSghwcTUsKgQfnJfCrRdwxXYarRM0X6XHW3w3Ze1ln+xlTV4MWFMo4mkUBKkK6NoG9Vx74ugHfNjNXyJ/nk/P5ymJvR6VRGzpyfw+AGOFRCoF4o8BA0s0MrBQg6zdccf1eE+CWhYWWDedrg7mqP5StYUtOAuVqgHy+mPFpOi/lxK97O8v1z7Eh6+fDMH8KcdFuOCV+nnqvlEVPDLhlbq6QQpzJ+lhgkMBgQR2zPlBegfYB8vzJkvBguTYxvSMOnA71FECkPcbal0C3FZUgw/rdZDFPDPjG9+eXGGQhr0DWCHI+8keB5nMpiO9hzoGuQZnPvTce2rxCPDXwVHaEdfzeOKcvwnlkN7b9aBGaRIkAZxbm+pmz43kGmVXcVUB9ZHE2INUnq6/1Aqh7xB8+4lLmAtx3cOemFeJJh1jMBYu51m9YiTcqBUSzPPBAM7idCHBu4b2ZtISteQaTrTmuohZpw2Ut2vqYl0YC1OJkagZ43qdS2qfi/l0N9Hty2zBIZItOGxtwmMI5sm77y92X68JEkkYSZTsShZPRXoX/lb0NLC5pruhLFGQYph/hU+wTIE7ufXF+uL5v3P6zIshqN59FxZ+Mu4oyhFgVMu9w2FqAy6DVObwwV8iAWDJia0RZc5qPWZ85qa20E/PQgLnrXPx3pePlrEx5jz/+2Qb6HRHzMByNtlDLeAo+qnbgwHQF1kEJOJxWg+uRLb/MBTNAAJ1hLntIsnvPhd9M3+X/GW6ms6DbE0Cgg+Z50lEGMRjplw4+P7/wsjdXiI6EOyZLmtvEMTdJCjDGQW+EDekpWCclAFzTINWkyeiUA4TLgAMf3L25+O6XO2e/6P+psrv6Wyhe+AV8vvoXLfNBe6sO+iHDOCIJt2czqZMT++JirnVUpljExSmjDVEhVJGZilGwiw4/MATroEQ67CaNNj7W+ow0++Fdm6ejs1Hwbqb/wM7qu7D//M/pM/K0XijLYQva2SDugfSVd8SbH4EY6MNsoEQIOkZ2BQSNcEDTDlcEsOaukVIbBoIEjLkaGUzGtPqUPId7Pn6HUfkPs3ieskbIMc2KupEVATg49czxcagHzREXtzgT3lSTiIWlI7BGSgZYcRcwIl0KtTwT6yiMkK3/NJcvPtJZOvDtLW1Qk/sadm04jQy671d76kCr8JI4t44Oq39wiwdddEilpclpDRx2+uuAiZioSQMSjJ5RnUsBeO6xTo9Bt3FXJQqEhRtR4ILUVf/vnnw/rtMPTI7xYSa8Q3EuC1jh6i5FSay0HdkurlllUt75Yk8ogcAGHs/b3VneM7RlQBDewY3KtiMFF8kuEErp/f6J+Z7Yg37qYf61YhamLjhRBuzo9q2QkJJbaTM5t7Qo6zisOkK3FhBofEPa/eSmxe/s2dLGKD3UeonhA9yFkDS+MLQQlIi0PksajVi8wPIZoxAR+1UoGYetZVZ8Iyt+ogGHnfKaiawe0zzyg81FIeXDZFx0AJ1Pb/LpQtwgZWtjmstGGay7ChZ1qy48JKBkHLZdK+MCgUjXParWAiEwwUnTsK97naUU4JBxr0Zm9YpJ7PvjrvcCUeXEgSMr5rIR/EgRwXL7hnR/kvGS+2EAF2I1JGW0iMCFWGSCDKIkHW/bt2mMHxw1AbhTZv4T0os1TNfG7FQihg6M9RZ4OySgRICtycVgMpdioIlPgpYfjzxVgATkZ84VeZHOxFSfsOvDR+e63KXmskoVYxwOKJHhSgQYyfxT6Ak5MoxbJYH1VoqM+1axeALq9borKcJRhCBU1y5akBis6/ZNMxLGfTJAWxI9Tu6WzOwxKMU14DKC019yXkZN615ISNnl7BjFNEclKLB1oT+02Jx0l2Ijk3Vs6iQPzQBcKwenNuvR51KuaEmBO8IgWeDT/tMjXiIL2j3aURGIs0gmXTF9QGtLdjlYNCPWnE2FwQoG1ZJUZuNqYyQAnK9o3VXDS7qEAcYTYJ2SgaxFQn21ZCUmzmxIyhPOVpAr9BB11bU6FhT6zdjGe/i0qnNYHXBHRwXVikJgj6jhk0SLzjMqsGSttjEuYjAplzmeUUmJS69MYirrCvpCnDZjRhYfIZFHSGS0ONGfDS6CqAtjADgamuURy2jZqg4CXZxMLJU3jEMS8m1/EEQw6ruwFNVjKeMZlJ2QMzeXxpKA2CSfUGyzdS0bacEKvyelqUu5gE+n0BToYs/ZHx0YhnWQkt0MVAvhDSzHgJoTsjHSJSkR4Avi45Iu7RjdshYJu9pnFmJcznzjDY9/KJvChLPSrpCnhcM7u++lS4NOuembMFUbMB3EyNAgERZcj3DxN5QNKVmk1dHNlpGtJ7jUALQo1eTyYH1TkmKAgsmYqTtLp/wqR2ReZe9rJ09744WGYzmRtmEmOGtN1Bo2kgC21hPzx80SaUVp8IvBWpqP8sX97VN1XB54bZYXZ0hH1mBFO5Bycvfa6EJq6V/fPzx+emiqEBvIchgiObMZVMSS4BWkJtcskVZUubNzlqsSs3YShocSNqY3rORy9lsHx/i3op5naD0DmUMIE35f4B/+8d236sWcbIElEoNEsjMhG1hkbp7CVS31WpIHHtQvhr3b+Jpg+HNvvbeimJbbNer5EnqZqaccVONqMHhBbJeula+G/77r7aW/7TzW12BQwPq0RULYYdiueW7J0T87Ay6T02OTKdBU11S8xqzoxseen75h8Nk2Dlg8dOUrI+suL6IwdON6NWHplo/EXgiDG+PUsD6gsNPG0E7Y0lITAo96StOQmYmdjwFdEELMfKkBaEU3fm9vcVnKW3lWE7Ye4lyJM+LBRBlDGwRBloJhdVekIrN2Rfq61xPN1GFHf928+YTw6XErj5GMEQqc2yz1TM43dDutTz9d/uQzQ2zBBQMSZXefopmC+XZcs8GHju8oRZGWLowPtMPqTDOtdJROdm8Z5bGOOadvyz5ka5Deg4fml7750/m+Rs+2ervKrc8+0sYZez+ztxykgxYkRAomzkwrXfAx/grCHhL53iitC7CiPOa4SG5ibDsDF2moebI+QmlnaX7h0fHGYt763EMTHEx0M+Mi9epg/jpLdJZRg5Z+ua6L6EKZ81qtDKvQugEvdnMqV5XdqDabheEd2Hk75rSnpVh64tXj40+9vBJ46/4d5ZtHez2/Ktp4yhM6MHF5A5KLPAihPjEQZpRotsSeM8m743UDVrR4T2dZ8JtDVWO2t3TmEE/dQMlkP78fntn7UmP9/vQr95RveeWuAUrVbj2b47hdP+NKoLaQGZu1jMTRlrtEiTbBXBZgRccZdKZG3axis6YYhOFkbHJoiyQbhQTvudH5pQMHPmio34s35eFcBlrI1nf0UxGbFJCM5uQ2iANRggR02YAVzfZ2lt/+yiYFumhDZ8PnoKQL0UOBfH/8pf3zUz9+NizQTXkLLYipcfX+OBpoUFgKDQmjmZrWgDI+mGx/V1MAO/pl751F8Pn9Eck3LHtMgmXfJwcv1o3A96BIvfOTfcf/fWT4+JKoLZ9mdFstIFcjiufFjgjbQ1HmSM6vfgESUlMBK1L7sw5/rbNfVPEOdl2nzKSsDkoKQIf6ia18swDubbmlSAhlDVdKb3HQm1j1zh/deAzOVTvWstFlzX5srfTYq3P9WRLDWR826p0/1XCrU66m94lg3uwAIrUXxGyNUruEACO7g8qF1zerCEzt6hvXgFNiCO87cmKN02k+h+vpxZ2dJV8qSy73IdUvMOk6ClC4Syt4z2QbmIPN0o7c38eFugncPtm9HrC6J7iK5I3MFfKcGWVr2J9zXNX7uMDu+TIc15ytBbt+IIOyrXD3/gq/SoP17t5xdFUBO3rhhfmeDTUYYbCFnNmqqEQ5AGu3O2mxzlRp922vbhmFJtE1Aezo9R+qLY1imAEWAo5arud8qqRqtLvjYGcJmkjXFLCjo9677bnl9Nasj60swpSuyWOfgPxix2jHZYnvdbpO/wf0X652D+/dGV80AAAAAElFTkSuQmCC";
|
|
2722
|
+
class Cr extends et {
|
|
2723
|
+
constructor() {
|
|
2724
|
+
super("https://wallet-api.pantograph.app");
|
|
2725
|
+
}
|
|
2726
|
+
/**
|
|
2727
|
+
* Lấy thông tin chi tiết của các tokens theo địa chỉ contract
|
|
2728
|
+
* @param addresses - Mảng địa chỉ contract của tokens
|
|
2729
|
+
* @param chain - Chain name (default: 'base')
|
|
2730
|
+
* @returns Response chứa thông tin tokens
|
|
2731
|
+
*/
|
|
2732
|
+
async getTokensDetails(t, n = "base") {
|
|
2733
|
+
try {
|
|
2734
|
+
if (!t || !Array.isArray(t) || t.length === 0)
|
|
2735
|
+
throw new Error("Addresses must be a non-empty array");
|
|
2736
|
+
const r = t.join(","), s = await this.get(`/keyrings/tokens/${n}/v2`, {
|
|
2737
|
+
query: {
|
|
2738
|
+
addresses: r
|
|
2739
|
+
}
|
|
2740
|
+
});
|
|
2741
|
+
return Array.isArray(s.data) && (s.data = s.data.filter(
|
|
2742
|
+
(c, l, b) => l === b.findIndex(
|
|
2743
|
+
(w) => w.address.toLowerCase() === c.address.toLowerCase()
|
|
2744
|
+
)
|
|
2745
|
+
), Array.isArray(t) && t.length > 0 && (s.data = s.data.filter(
|
|
2746
|
+
(c) => t.some(
|
|
2747
|
+
(l) => l.toLowerCase() === c.address.toLowerCase()
|
|
2748
|
+
)
|
|
2749
|
+
), s.data.sort((c, l) => t.findIndex(
|
|
2750
|
+
(b) => b.toLowerCase() === c.address.toLowerCase()
|
|
2751
|
+
) - t.findIndex(
|
|
2752
|
+
(b) => b.toLowerCase() === l.address.toLowerCase()
|
|
2753
|
+
)))), s;
|
|
2754
|
+
} catch (r) {
|
|
2755
|
+
throw console.error(
|
|
2756
|
+
"❌ Error getting tokens details:",
|
|
2757
|
+
r instanceof Error ? r.message : r
|
|
2758
|
+
), r;
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
/**
|
|
2762
|
+
* Lấy thông tin chi tiết của một token theo địa chỉ contract
|
|
2763
|
+
* @param address - Địa chỉ contract của token
|
|
2764
|
+
* @param chain - Chain name (default: 'base')
|
|
2765
|
+
* @returns Response chứa thông tin token
|
|
2766
|
+
*/
|
|
2767
|
+
async getTokenDetail(t, n = "base") {
|
|
2768
|
+
try {
|
|
2769
|
+
if (!t)
|
|
2770
|
+
throw new Error("Address is required");
|
|
2771
|
+
const r = await this.getTokensDetails([t], n);
|
|
2772
|
+
return {
|
|
2773
|
+
data: r.data[0] || null,
|
|
2774
|
+
status: r.status
|
|
2775
|
+
};
|
|
2776
|
+
} catch (r) {
|
|
2777
|
+
throw console.error(
|
|
2778
|
+
`❌ Error getting token detail for ${t}:`,
|
|
2779
|
+
r instanceof Error ? r.message : r
|
|
2780
|
+
), r;
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
/**
|
|
2784
|
+
* Lấy danh sách top gainers tokens
|
|
2785
|
+
* @param chainName - Chain name (default: 'base')
|
|
2786
|
+
* @param duration - Duration (default: '24h')
|
|
2787
|
+
* @param limit - Số lượng tokens (default: 3)
|
|
2788
|
+
* @returns Response chứa danh sách top gainers
|
|
2789
|
+
*/
|
|
2790
|
+
async getTopGainers(t = "base", n = "24h", r = 3) {
|
|
2791
|
+
try {
|
|
2792
|
+
return await this.get(`/token-list/top-gainers/${t}`, {
|
|
2793
|
+
query: {
|
|
2794
|
+
duration: n,
|
|
2795
|
+
limit: r
|
|
2796
|
+
}
|
|
2797
|
+
});
|
|
2798
|
+
} catch (s) {
|
|
2799
|
+
throw console.error(
|
|
2800
|
+
"❌ Error getting top gainers:",
|
|
2801
|
+
s instanceof Error ? s.message : s
|
|
2802
|
+
), s;
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
const Mt = new Cr(), Mr = "https://dln.debridge.finance", Or = new et(Mr);
|
|
2807
|
+
async function Lr(e) {
|
|
2808
|
+
const {
|
|
2809
|
+
chainId: t,
|
|
2810
|
+
tokenIn: n,
|
|
2811
|
+
tokenInAmount: r,
|
|
2812
|
+
tokenOut: s,
|
|
2813
|
+
accesstoken: c,
|
|
2814
|
+
slippage: l = "auto",
|
|
2815
|
+
tokenOutRecipient: b
|
|
2816
|
+
} = e;
|
|
2817
|
+
if (!t || !n || !r || !s)
|
|
2818
|
+
throw new Error(
|
|
2819
|
+
"Missing required parameters: chainId, tokenIn, tokenInAmount, tokenOut"
|
|
2820
|
+
);
|
|
2821
|
+
try {
|
|
2822
|
+
const w = await Or.get("/v1.0/chain/transaction", {
|
|
2823
|
+
query: {
|
|
2824
|
+
chainId: String(t),
|
|
2825
|
+
tokenIn: n,
|
|
2826
|
+
tokenInAmount: r,
|
|
2827
|
+
tokenOut: s,
|
|
2828
|
+
slippage: String(l),
|
|
2829
|
+
tokenOutRecipient: b,
|
|
2830
|
+
accesstoken: c
|
|
2831
|
+
}
|
|
2832
|
+
});
|
|
2833
|
+
if (w.data?.error)
|
|
2834
|
+
throw new Error(`DeBridge API Error: ${w.data.error}`);
|
|
2835
|
+
return console.log("✅ Quote retrieved successfully"), {
|
|
2836
|
+
success: !0,
|
|
2837
|
+
data: w.data
|
|
2838
|
+
};
|
|
2839
|
+
} catch (w) {
|
|
2840
|
+
let E = w instanceof Error ? w.message : "Unknown error";
|
|
2841
|
+
const A = w;
|
|
2842
|
+
A.data?.errorMessage ? E = A.data.errorMessage : A.response?.data?.errorMessage ? E = A.response.data.errorMessage : A.data?.message ? E = A.data.message : A.response?.data?.message && (E = A.response.data.message);
|
|
2843
|
+
const B = A.status || A.response?.status || A.statusCode || A.data?.status;
|
|
2844
|
+
return console.error("📋 Error details:", {
|
|
2845
|
+
errorMessage: E,
|
|
2846
|
+
errorCode: A.data?.errorCode,
|
|
2847
|
+
errorId: A.data?.errorId,
|
|
2848
|
+
status: B,
|
|
2849
|
+
reqId: A.data?.reqId,
|
|
2850
|
+
fullError: {
|
|
2851
|
+
message: A.message,
|
|
2852
|
+
status: A.status,
|
|
2853
|
+
statusCode: A.statusCode
|
|
2854
|
+
}
|
|
2855
|
+
}), {
|
|
2856
|
+
success: !1,
|
|
2857
|
+
error: w instanceof Error ? w.message : "Unknown error",
|
|
2858
|
+
status: B,
|
|
2859
|
+
errorMessage: E,
|
|
2860
|
+
errorCode: A.data?.errorCode,
|
|
2861
|
+
errorId: A.data?.errorId
|
|
2862
|
+
};
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
function me(e) {
|
|
2866
|
+
const t = [], n = /!\[([^\]]*)\]\(([^)]+)\)|\[([^\]]*)\]\(([^)]+)\)|(https?:\/\/[^\s<>]+)|\*\*(.+?)\*\*|__(.+?)__|\*(.+?)\*|_(.+?)_|~~(.+?)~~|`([^`]+)`/g;
|
|
2867
|
+
let r = 0, s;
|
|
2868
|
+
for (; (s = n.exec(e)) !== null; )
|
|
2869
|
+
s.index > r && t.push(e.slice(r, s.index)), s[1] !== void 0 || s[2] !== void 0 ? t.push(
|
|
2870
|
+
/* @__PURE__ */ k(
|
|
2871
|
+
"img",
|
|
2872
|
+
{
|
|
2873
|
+
src: s[2],
|
|
2874
|
+
alt: s[1],
|
|
2875
|
+
className: "mc-image"
|
|
2876
|
+
},
|
|
2877
|
+
s.index
|
|
2878
|
+
)
|
|
2879
|
+
) : s[3] !== void 0 ? t.push(
|
|
2880
|
+
/* @__PURE__ */ k(
|
|
2881
|
+
"a",
|
|
2882
|
+
{
|
|
2883
|
+
href: s[4],
|
|
2884
|
+
target: "_blank",
|
|
2885
|
+
rel: "noopener noreferrer",
|
|
2886
|
+
className: "mc-link",
|
|
2887
|
+
children: s[3]
|
|
2888
|
+
},
|
|
2889
|
+
s.index
|
|
2890
|
+
)
|
|
2891
|
+
) : s[5] !== void 0 ? t.push(
|
|
2892
|
+
/* @__PURE__ */ k(
|
|
2893
|
+
"a",
|
|
2894
|
+
{
|
|
2895
|
+
href: s[5],
|
|
2896
|
+
target: "_blank",
|
|
2897
|
+
rel: "noopener noreferrer",
|
|
2898
|
+
className: "mc-link",
|
|
2899
|
+
children: s[5]
|
|
2900
|
+
},
|
|
2901
|
+
s.index
|
|
2902
|
+
)
|
|
2903
|
+
) : s[6] !== void 0 ? t.push(/* @__PURE__ */ k("strong", { children: me(s[6]) }, s.index)) : s[7] !== void 0 ? t.push(/* @__PURE__ */ k("strong", { children: me(s[7]) }, s.index)) : s[8] !== void 0 ? t.push(/* @__PURE__ */ k("em", { children: me(s[8]) }, s.index)) : s[9] !== void 0 ? t.push(/* @__PURE__ */ k("em", { children: me(s[9]) }, s.index)) : s[10] !== void 0 ? t.push(/* @__PURE__ */ k("del", { children: me(s[10]) }, s.index)) : s[11] !== void 0 && t.push(
|
|
2904
|
+
/* @__PURE__ */ k("code", { className: "mc-inline-code", children: s[11] }, s.index)
|
|
2905
|
+
), r = s.index + s[0].length;
|
|
2906
|
+
return r < e.length && t.push(e.slice(r)), t.length > 0 ? t : [e];
|
|
2907
|
+
}
|
|
2908
|
+
const zr = ({ content: e }) => {
|
|
2909
|
+
const t = e.split(`
|
|
2910
|
+
`), n = [];
|
|
2911
|
+
let r = 0;
|
|
2912
|
+
for (; r < t.length; ) {
|
|
2913
|
+
const s = t[r];
|
|
2914
|
+
if (s.trimStart().startsWith("```")) {
|
|
2915
|
+
const l = s.trimStart().slice(3).trim(), b = [];
|
|
2916
|
+
for (r++; r < t.length && !t[r].trimStart().startsWith("```"); )
|
|
2917
|
+
b.push(t[r]), r++;
|
|
2918
|
+
n.push(
|
|
2919
|
+
/* @__PURE__ */ V("div", { className: "mc-codeblock", children: [
|
|
2920
|
+
l && /* @__PURE__ */ k("div", { className: "mc-codeblock-lang", children: l }),
|
|
2921
|
+
/* @__PURE__ */ k("pre", { children: /* @__PURE__ */ k("code", { children: b.join(`
|
|
2922
|
+
`) }) })
|
|
2923
|
+
] }, `code-${r}`)
|
|
2924
|
+
), r++;
|
|
2925
|
+
continue;
|
|
2926
|
+
}
|
|
2927
|
+
if (/^(\s*[-*_]\s*){3,}$/.test(s)) {
|
|
2928
|
+
n.push(/* @__PURE__ */ k("hr", { className: "mc-hr" }, `hr-${r}`)), r++;
|
|
2929
|
+
continue;
|
|
2930
|
+
}
|
|
2931
|
+
const c = s.match(/^(#{1,3})\s+(.+)/);
|
|
2932
|
+
if (c) {
|
|
2933
|
+
const l = c[1].length, b = c[2];
|
|
2934
|
+
n.push(
|
|
2935
|
+
/* @__PURE__ */ k("div", { className: `mc-heading mc-h${l}`, children: me(b) }, `h-${r}`)
|
|
2936
|
+
), r++;
|
|
2937
|
+
continue;
|
|
2938
|
+
}
|
|
2939
|
+
if (s.trimStart().startsWith("> ")) {
|
|
2940
|
+
const l = [];
|
|
2941
|
+
for (; r < t.length && t[r].trimStart().startsWith("> "); )
|
|
2942
|
+
l.push(t[r].replace(/^\s*>\s?/, "")), r++;
|
|
2943
|
+
n.push(
|
|
2944
|
+
/* @__PURE__ */ k("div", { className: "mc-blockquote", children: l.map((b, w) => /* @__PURE__ */ k("div", { children: me(b) }, w)) }, `bq-${r}`)
|
|
2945
|
+
);
|
|
2946
|
+
continue;
|
|
2947
|
+
}
|
|
2948
|
+
if (s.trim() === "") {
|
|
2949
|
+
n.push(/* @__PURE__ */ k("div", { className: "mc-empty-line" }, `empty-${r}`)), r++;
|
|
2950
|
+
continue;
|
|
2951
|
+
}
|
|
2952
|
+
n.push(
|
|
2953
|
+
/* @__PURE__ */ k("div", { className: "mc-line", children: me(s) }, `line-${r}`)
|
|
2954
|
+
), r++;
|
|
2955
|
+
}
|
|
2956
|
+
return /* @__PURE__ */ k("div", { className: "message-content", children: n });
|
|
2957
|
+
}, Fr = ({
|
|
2958
|
+
isOpen: e,
|
|
2959
|
+
onClose: t,
|
|
2960
|
+
onTransaction: n
|
|
2961
|
+
}) => {
|
|
2962
|
+
const { messages: r, addMessage: s } = xr(), [c, l] = Ae(""), [b, w] = Ae(!1), [E, A] = Ae(!0), [B, C] = Ae(null), O = It(null), F = It(null), { account: H, chainData: j, chainType: oe, chainTypeMoralis: v, chainId: K } = wt(), X = Q(() => {
|
|
2963
|
+
const d = localStorage.getItem("dataBuyToken");
|
|
2964
|
+
if (d)
|
|
2965
|
+
try {
|
|
2966
|
+
return JSON.parse(d);
|
|
2967
|
+
} catch {
|
|
2968
|
+
return {
|
|
2969
|
+
srcTokenAddress: "",
|
|
2970
|
+
descTokenAddress: "",
|
|
2971
|
+
amount: "",
|
|
2972
|
+
srcTokenDecimals: 18,
|
|
2973
|
+
descTokenDecimals: 18
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
return {
|
|
2977
|
+
srcTokenAddress: "",
|
|
2978
|
+
descTokenAddress: "",
|
|
2979
|
+
amount: "",
|
|
2980
|
+
srcTokenDecimals: 18,
|
|
2981
|
+
descTokenDecimals: 18
|
|
2982
|
+
};
|
|
2983
|
+
}, []), ee = Q(
|
|
2984
|
+
(d) => {
|
|
2985
|
+
localStorage.setItem("dataBuyToken", JSON.stringify(d));
|
|
2986
|
+
},
|
|
2987
|
+
[]
|
|
2988
|
+
), $ = Q(
|
|
2989
|
+
(d) => {
|
|
2990
|
+
const I = { ...X(), ...d };
|
|
2991
|
+
ee(I);
|
|
2992
|
+
},
|
|
2993
|
+
[X, ee]
|
|
2994
|
+
), J = Q((d) => {
|
|
2995
|
+
l(d), A(!1), F.current?.focus();
|
|
2996
|
+
}, []), i = Q((d) => {
|
|
2997
|
+
C(d), F.current?.focus();
|
|
2998
|
+
}, []), o = Q(
|
|
2999
|
+
async (d, T) => {
|
|
3000
|
+
$({
|
|
3001
|
+
descTokenAddress: d,
|
|
3002
|
+
descTokenDecimals: T || 18
|
|
3003
|
+
});
|
|
3004
|
+
try {
|
|
3005
|
+
w(!0);
|
|
3006
|
+
const I = await Nr({
|
|
3007
|
+
address: H?.address || "",
|
|
3008
|
+
chain: v
|
|
3009
|
+
});
|
|
3010
|
+
if (I?.success && I?.data?.result) {
|
|
3011
|
+
const M = I.data.result.map((S) => ({
|
|
3012
|
+
id: S.token_address,
|
|
3013
|
+
text: `${S.name}: ${S.balance_formatted} ${S.symbol} ($${S.usd_value?.toFixed(4) || "0"})`,
|
|
3014
|
+
value: `Buy with ${S.symbol}`,
|
|
3015
|
+
action: "click_balance_item_user_to_buy_button",
|
|
3016
|
+
fullWidth: !0,
|
|
3017
|
+
extraData: {
|
|
3018
|
+
tokenAddress: S.token_address,
|
|
3019
|
+
symbol: S.symbol,
|
|
3020
|
+
balance: S.balance_formatted,
|
|
3021
|
+
usdValue: S.usd_value,
|
|
3022
|
+
decimals: S.decimals
|
|
3023
|
+
}
|
|
3024
|
+
}));
|
|
3025
|
+
s(
|
|
3026
|
+
"This is the spendable balance of your wallet on OPTIMISM chain. Please choose the coins you want to use for this trade.",
|
|
3027
|
+
"bot",
|
|
3028
|
+
void 0,
|
|
3029
|
+
M
|
|
3030
|
+
);
|
|
3031
|
+
} else
|
|
3032
|
+
s(
|
|
3033
|
+
"Sorry, I could not fetch your wallet balance. Please try again.",
|
|
3034
|
+
"bot"
|
|
3035
|
+
);
|
|
3036
|
+
} catch (I) {
|
|
3037
|
+
console.error("Error fetching wallet balance:", I), s(
|
|
3038
|
+
"Sorry, I encountered an error fetching your wallet balance.",
|
|
3039
|
+
"bot"
|
|
3040
|
+
);
|
|
3041
|
+
} finally {
|
|
3042
|
+
w(!1);
|
|
3043
|
+
}
|
|
3044
|
+
},
|
|
3045
|
+
[H?.address, v, s, $]
|
|
3046
|
+
), a = Q(
|
|
3047
|
+
async (d, T, I, N) => {
|
|
3048
|
+
const M = [25, 50, 75, 100];
|
|
3049
|
+
$({
|
|
3050
|
+
srcTokenAddress: d,
|
|
3051
|
+
srcTokenDecimals: N || 18
|
|
3052
|
+
});
|
|
3053
|
+
const S = M.map(
|
|
3054
|
+
(P) => ({
|
|
3055
|
+
id: `percent-${P}`,
|
|
3056
|
+
text: `${P}%`,
|
|
3057
|
+
value: `Use ${P}% of ${T}`,
|
|
3058
|
+
action: "select_percent",
|
|
3059
|
+
extraData: {
|
|
3060
|
+
percent: P,
|
|
3061
|
+
tokenAddress: d,
|
|
3062
|
+
tokenSymbol: T,
|
|
3063
|
+
tokenBalance: I
|
|
3064
|
+
}
|
|
3065
|
+
})
|
|
3066
|
+
);
|
|
3067
|
+
s(
|
|
3068
|
+
`📊 Select the amount of ${T} to use:
|
|
3069
|
+
|
|
3070
|
+
Available: ${I} ${T}`,
|
|
3071
|
+
"bot",
|
|
3072
|
+
void 0,
|
|
3073
|
+
S
|
|
3074
|
+
);
|
|
3075
|
+
},
|
|
3076
|
+
[s, $]
|
|
3077
|
+
), m = Q(
|
|
3078
|
+
async (d, T) => {
|
|
3079
|
+
$({
|
|
3080
|
+
amount: (parseFloat(T) * (d / 100)).toFixed(6)
|
|
3081
|
+
});
|
|
3082
|
+
const I = X(), N = vr(
|
|
3083
|
+
I.amount,
|
|
3084
|
+
I.srcTokenDecimals || 18
|
|
3085
|
+
).toString(), M = await Lr({
|
|
3086
|
+
chainId: K,
|
|
3087
|
+
tokenIn: I.srcTokenAddress,
|
|
3088
|
+
tokenInAmount: N,
|
|
3089
|
+
tokenOut: I.descTokenAddress,
|
|
3090
|
+
tokenOutRecipient: H?.address || "",
|
|
3091
|
+
slippage: "auto",
|
|
3092
|
+
accesstoken: "d6c45897b8f6"
|
|
3093
|
+
});
|
|
3094
|
+
if (M.success && M.data) {
|
|
3095
|
+
const S = M.data, P = S.tokenIn, L = S.tokenOut, R = (parseFloat(P.amount) / Math.pow(10, P.decimals)).toFixed(6), fe = (parseFloat(L.amount) / Math.pow(10, L.decimals)).toFixed(6), Ne = `📋 Swap Preview
|
|
3096
|
+
|
|
3097
|
+
From: ${R} ${P.symbol}
|
|
3098
|
+
To: ${fe} ${L.symbol}
|
|
3099
|
+
|
|
3100
|
+
💰 Value: ~$${P.approximateUsdValue?.toFixed(4) || "0"}
|
|
3101
|
+
📊 Slippage: ${S.slippage}%
|
|
3102
|
+
⛽ Gas Fee: ~$${S.estimatedTransactionFee?.approximateUsdValue?.toFixed(6) || "0"}
|
|
3103
|
+
💵 Protocol Fee: ~$${S.protocolFeeApproximateUsdValue?.toFixed(6) || "0"}
|
|
3104
|
+
|
|
3105
|
+
Ready to proceed with the swap?`, Se = [
|
|
3106
|
+
{
|
|
3107
|
+
id: "confirm-swap",
|
|
3108
|
+
text: "✅ Yes",
|
|
3109
|
+
value: "Confirm swap",
|
|
3110
|
+
action: "confirm_swap",
|
|
3111
|
+
extraData: {
|
|
3112
|
+
tx: S.tx
|
|
3113
|
+
}
|
|
3114
|
+
},
|
|
3115
|
+
{
|
|
3116
|
+
id: "cancel-swap",
|
|
3117
|
+
text: "❌ No",
|
|
3118
|
+
value: "Cancel swap",
|
|
3119
|
+
action: "cancel_swap"
|
|
3120
|
+
}
|
|
3121
|
+
];
|
|
3122
|
+
s(Ne, "bot", void 0, Se);
|
|
3123
|
+
} else
|
|
3124
|
+
s(
|
|
3125
|
+
`⚠️ Unable to get swap estimation. Error: ${M.errorMessage || M.error || "Unknown error"}`,
|
|
3126
|
+
"bot"
|
|
3127
|
+
);
|
|
3128
|
+
},
|
|
3129
|
+
[X, $, s, K, H?.address]
|
|
3130
|
+
), f = Q(
|
|
3131
|
+
async (d, T, I) => {
|
|
3132
|
+
try {
|
|
3133
|
+
if (s(d, "user"), A(!1), w(!0), T)
|
|
3134
|
+
switch (await He(500), T) {
|
|
3135
|
+
case "click_buy_item_token_button":
|
|
3136
|
+
await o(
|
|
3137
|
+
I?.tokenAddress || "",
|
|
3138
|
+
I?.decimals || 18
|
|
3139
|
+
);
|
|
3140
|
+
break;
|
|
3141
|
+
case "click_balance_item_user_to_buy_button":
|
|
3142
|
+
await a(
|
|
3143
|
+
I?.tokenAddress || "",
|
|
3144
|
+
I?.symbol || "",
|
|
3145
|
+
I?.balance || "",
|
|
3146
|
+
I?.decimals || 18
|
|
3147
|
+
);
|
|
3148
|
+
break;
|
|
3149
|
+
case "select_percent":
|
|
3150
|
+
await m(
|
|
3151
|
+
I?.percent || 0,
|
|
3152
|
+
I?.tokenBalance || ""
|
|
3153
|
+
);
|
|
3154
|
+
break;
|
|
3155
|
+
case "confirm_swap":
|
|
3156
|
+
if (I?.tx && n) {
|
|
3157
|
+
const N = I.tx, M = {
|
|
3158
|
+
from: H?.address || "",
|
|
3159
|
+
to: N.to,
|
|
3160
|
+
data: N.data,
|
|
3161
|
+
value: N.value,
|
|
3162
|
+
chainId: K
|
|
3163
|
+
};
|
|
3164
|
+
s("⚙️ Transaction processing... Please wait.", "bot");
|
|
3165
|
+
try {
|
|
3166
|
+
const S = await n(M);
|
|
3167
|
+
s(
|
|
3168
|
+
S === "success" ? "✅ Transaction successful! Your swap has been completed." : "❌ Transaction failed. Please try again.",
|
|
3169
|
+
"bot"
|
|
3170
|
+
);
|
|
3171
|
+
} catch (S) {
|
|
3172
|
+
console.error("Transaction error:", S), s("❌ Transaction failed. Please try again.", "bot");
|
|
3173
|
+
}
|
|
3174
|
+
} else
|
|
3175
|
+
s("⚠️ Transaction data not available.", "bot");
|
|
3176
|
+
break;
|
|
3177
|
+
case "cancel_swap":
|
|
3178
|
+
s("❌ Swap cancelled.", "bot");
|
|
3179
|
+
break;
|
|
3180
|
+
default:
|
|
3181
|
+
s(
|
|
3182
|
+
`Action "${T}" executed for: ${d}`,
|
|
3183
|
+
"bot"
|
|
3184
|
+
);
|
|
3185
|
+
}
|
|
3186
|
+
else
|
|
3187
|
+
await He(500), s(`Received: ${d}`, "bot");
|
|
3188
|
+
w(!1), F.current?.focus();
|
|
3189
|
+
} catch (N) {
|
|
3190
|
+
s(
|
|
3191
|
+
"Sorry, I encountered an error processing your request.",
|
|
3192
|
+
"bot"
|
|
3193
|
+
), w(!1), console.error("Error handling button click:", N);
|
|
3194
|
+
}
|
|
3195
|
+
},
|
|
3196
|
+
[
|
|
3197
|
+
H?.address,
|
|
3198
|
+
s,
|
|
3199
|
+
K,
|
|
3200
|
+
o,
|
|
3201
|
+
a,
|
|
3202
|
+
n,
|
|
3203
|
+
m
|
|
3204
|
+
]
|
|
3205
|
+
), p = Q(async () => {
|
|
3206
|
+
try {
|
|
3207
|
+
w(!0);
|
|
3208
|
+
const d = j.tokenTrendingDefault || [], [T, I] = await Promise.allSettled([
|
|
3209
|
+
Mt.getTopGainers(oe, "24h", 5),
|
|
3210
|
+
Mt.getTokensDetails(d, oe)
|
|
3211
|
+
]);
|
|
3212
|
+
let N = [];
|
|
3213
|
+
T.status === "fulfilled" && T.value?.data ? N = [...T.value.data] : console.warn("⚠️ Top gainers failed:"), I.status === "fulfilled" && I.value?.data ? N = [...I.value.data, ...N] : console.warn("⚠️ Default tokens failed:"), N = N.filter(
|
|
3214
|
+
(P, L, R) => L === R.findIndex(
|
|
3215
|
+
(fe) => fe.address.toLowerCase() === P.address.toLowerCase()
|
|
3216
|
+
)
|
|
3217
|
+
);
|
|
3218
|
+
const M = N.map((P) => ({
|
|
3219
|
+
id: P?.symbol,
|
|
3220
|
+
text: P?.symbol,
|
|
3221
|
+
value: `Buy ${P.name} (${P?.symbol})`,
|
|
3222
|
+
action: "click_buy_item_token_button",
|
|
3223
|
+
extraData: {
|
|
3224
|
+
tokenAddress: P?.address || "",
|
|
3225
|
+
symbol: P?.symbol || "",
|
|
3226
|
+
decimals: P?.decimals || 18
|
|
3227
|
+
}
|
|
3228
|
+
}));
|
|
3229
|
+
await He(1e3), w(!1), s(
|
|
3230
|
+
`📈 Here is the list of tokens that are currently trending upwards on ${j?.name || "Unknown"} chain`,
|
|
3231
|
+
"bot"
|
|
3232
|
+
);
|
|
3233
|
+
const S = N.map(
|
|
3234
|
+
(P, L) => `${L + 1}. ${P.name} (${P?.auditGoplus?.token_symbol || P.symbol || "Unknown"})
|
|
3235
|
+
$${ft(
|
|
3236
|
+
P?.price || 0
|
|
3237
|
+
).decimalPlaces(4).toFormat()} (${P.price_change_percentage_24h || P.priceChange}%)
|
|
3238
|
+
|
|
3239
|
+
---
|
|
3240
|
+
`
|
|
3241
|
+
).join(`
|
|
3242
|
+
`);
|
|
3243
|
+
s(
|
|
3244
|
+
`${S}
|
|
3245
|
+
Is there any token you want to buy?`,
|
|
3246
|
+
"bot",
|
|
3247
|
+
void 0,
|
|
3248
|
+
M
|
|
3249
|
+
);
|
|
3250
|
+
} catch (d) {
|
|
3251
|
+
console.error("Error fetching trending tokens:", d), s(
|
|
3252
|
+
"Sorry, I encountered an error fetching trending tokens.",
|
|
3253
|
+
"bot"
|
|
3254
|
+
);
|
|
3255
|
+
} finally {
|
|
3256
|
+
w(!1);
|
|
3257
|
+
}
|
|
3258
|
+
}, [s, j?.name, j.tokenTrendingDefault, oe]), x = gn(
|
|
3259
|
+
() => [
|
|
3260
|
+
{
|
|
3261
|
+
id: "ask",
|
|
3262
|
+
icon: "❓",
|
|
3263
|
+
text: "Ask a question",
|
|
3264
|
+
action: () => J("I have a question")
|
|
3265
|
+
},
|
|
3266
|
+
{
|
|
3267
|
+
id: "buy",
|
|
3268
|
+
icon: "💰",
|
|
3269
|
+
text: "Buy trending token",
|
|
3270
|
+
action: () => J("Show me trending tokens")
|
|
3271
|
+
},
|
|
3272
|
+
{
|
|
3273
|
+
id: "test-buttons",
|
|
3274
|
+
icon: "🧪",
|
|
3275
|
+
text: "Test Buttons (Demo)",
|
|
3276
|
+
action: async () => {
|
|
3277
|
+
await p();
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
],
|
|
3281
|
+
[J, p]
|
|
3282
|
+
), u = (d) => {
|
|
3283
|
+
if (d === 0) return !0;
|
|
3284
|
+
const T = r[d], I = r[d - 1], N = new Date(T.timestamp), M = new Date(I.timestamp);
|
|
3285
|
+
return N.setHours(0, 0, 0, 0), M.setHours(0, 0, 0, 0), N.getTime() !== M.getTime();
|
|
3286
|
+
};
|
|
3287
|
+
Te(() => {
|
|
3288
|
+
O.current?.scrollIntoView({ behavior: "smooth" });
|
|
3289
|
+
}, [r]), Te(() => {
|
|
3290
|
+
e && (F.current && F.current.focus(), O.current?.scrollIntoView({ behavior: "instant" }));
|
|
3291
|
+
}, [e]), Te(() => {
|
|
3292
|
+
const d = (T) => {
|
|
3293
|
+
T.key === "Escape" && e && t();
|
|
3294
|
+
};
|
|
3295
|
+
return document.addEventListener("keydown", d), () => document.removeEventListener("keydown", d);
|
|
3296
|
+
}, [e, t]);
|
|
3297
|
+
const h = Q(async () => {
|
|
3298
|
+
if (c.trim() === "" || b) return;
|
|
3299
|
+
const d = B, T = s(c.trim(), "user", B?.id);
|
|
3300
|
+
l(""), C(null), w(!0), A(!1), w(!0);
|
|
3301
|
+
try {
|
|
3302
|
+
let I = `User wallet: ${H?.address || "Not connected"}
|
|
3303
|
+
Chain: ${j?.name || "Unknown"}`;
|
|
3304
|
+
d && (I += `
|
|
3305
|
+
|
|
3306
|
+
User is replying to this ${d.sender === "user" ? "their previous" : "your"} message:
|
|
3307
|
+
"${d.text}"`), I += `
|
|
3308
|
+
|
|
3309
|
+
User question: ${c.trim()}`;
|
|
3310
|
+
const N = await Sr({
|
|
3311
|
+
prompt: I,
|
|
3312
|
+
model: "gpt-4.1-mini",
|
|
3313
|
+
stream: !1
|
|
3314
|
+
});
|
|
3315
|
+
N.success && N.data ? s(N.data.text, "bot", T.id) : s(
|
|
3316
|
+
"Sorry, I encountered an error processing your request.",
|
|
3317
|
+
"bot",
|
|
3318
|
+
T.id
|
|
3319
|
+
);
|
|
3320
|
+
} catch (I) {
|
|
3321
|
+
console.error("Error getting AI response:", I), s(
|
|
3322
|
+
"Sorry, I encountered an error processing your request.",
|
|
3323
|
+
"bot",
|
|
3324
|
+
T.id
|
|
3325
|
+
);
|
|
3326
|
+
}
|
|
3327
|
+
w(!1), await He(50), F.current?.focus();
|
|
3328
|
+
}, [
|
|
3329
|
+
c,
|
|
3330
|
+
b,
|
|
3331
|
+
s,
|
|
3332
|
+
B,
|
|
3333
|
+
H?.address,
|
|
3334
|
+
j?.name
|
|
3335
|
+
]), y = Q(
|
|
3336
|
+
(d) => {
|
|
3337
|
+
d.key === "Enter" && !d.shiftKey && (d.preventDefault(), h());
|
|
3338
|
+
},
|
|
3339
|
+
[h]
|
|
3340
|
+
), g = Q(() => {
|
|
3341
|
+
const d = window.getSelection();
|
|
3342
|
+
d && d.toString().length > 0 || t();
|
|
3343
|
+
}, [t]);
|
|
3344
|
+
return e ? /* @__PURE__ */ k(
|
|
3345
|
+
"div",
|
|
3346
|
+
{
|
|
3347
|
+
className: "chat-modal-overlay",
|
|
3348
|
+
onClick: g,
|
|
3349
|
+
role: "dialog",
|
|
3350
|
+
"aria-modal": "true",
|
|
3351
|
+
"aria-labelledby": "chat-modal-title",
|
|
3352
|
+
children: /* @__PURE__ */ V("div", { className: "chat-modal", onClick: (d) => d.stopPropagation(), children: [
|
|
3353
|
+
/* @__PURE__ */ V("div", { className: "chat-modal-header", children: [
|
|
3354
|
+
/* @__PURE__ */ V("div", { className: "chat-modal-header-left", children: [
|
|
3355
|
+
/* @__PURE__ */ k("div", { className: "keyring-logo", children: /* @__PURE__ */ k(
|
|
3356
|
+
"img",
|
|
3357
|
+
{
|
|
3358
|
+
src: Ur,
|
|
3359
|
+
alt: "Keyring Logo",
|
|
3360
|
+
width: 40,
|
|
3361
|
+
height: 40
|
|
3362
|
+
}
|
|
3363
|
+
) }),
|
|
3364
|
+
/* @__PURE__ */ k("h3", { id: "chat-modal-title", children: "Keyring Agent" })
|
|
3365
|
+
] }),
|
|
3366
|
+
/* @__PURE__ */ k(
|
|
3367
|
+
"button",
|
|
3368
|
+
{
|
|
3369
|
+
className: "close-button",
|
|
3370
|
+
onClick: t,
|
|
3371
|
+
"aria-label": "Close chat",
|
|
3372
|
+
type: "button",
|
|
3373
|
+
children: /* @__PURE__ */ k("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ k(
|
|
3374
|
+
"path",
|
|
3375
|
+
{
|
|
3376
|
+
d: "M15 5L5 15M5 5L15 15",
|
|
3377
|
+
stroke: "currentColor",
|
|
3378
|
+
strokeWidth: "2",
|
|
3379
|
+
strokeLinecap: "round"
|
|
3380
|
+
}
|
|
3381
|
+
) })
|
|
3382
|
+
}
|
|
3383
|
+
)
|
|
3384
|
+
] }),
|
|
3385
|
+
/* @__PURE__ */ V("div", { className: "chat-user-info", children: [
|
|
3386
|
+
/* @__PURE__ */ k("div", { className: "user-avatar", children: /* @__PURE__ */ k(
|
|
3387
|
+
"img",
|
|
3388
|
+
{
|
|
3389
|
+
src: j?.logo || "",
|
|
3390
|
+
alt: "User Avatar",
|
|
3391
|
+
width: 20,
|
|
3392
|
+
height: 20
|
|
3393
|
+
}
|
|
3394
|
+
) }),
|
|
3395
|
+
/* @__PURE__ */ k("span", { className: "user-wallet", children: mr(H?.address) || "Not connected" })
|
|
3396
|
+
] }),
|
|
3397
|
+
/* @__PURE__ */ V("div", { className: "chat-modal-messages", role: "log", "aria-live": "polite", children: [
|
|
3398
|
+
r.map((d, T) => /* @__PURE__ */ V("div", { children: [
|
|
3399
|
+
u(T) && /* @__PURE__ */ k("div", { className: "date-separator", children: pr(d.timestamp) }),
|
|
3400
|
+
/* @__PURE__ */ V(
|
|
3401
|
+
"div",
|
|
3402
|
+
{
|
|
3403
|
+
className: `message ${d.sender === "user" ? "message-user" : "message-bot"}`,
|
|
3404
|
+
role: "article",
|
|
3405
|
+
children: [
|
|
3406
|
+
/* @__PURE__ */ k(
|
|
3407
|
+
"button",
|
|
3408
|
+
{
|
|
3409
|
+
className: "message-reply-button",
|
|
3410
|
+
onClick: () => i(d),
|
|
3411
|
+
"aria-label": "Reply to message",
|
|
3412
|
+
type: "button",
|
|
3413
|
+
children: /* @__PURE__ */ k("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ k(
|
|
3414
|
+
"path",
|
|
3415
|
+
{
|
|
3416
|
+
d: "M3.5 8.5L1 6L3.5 3.5M1.5 6H10C12.2091 6 14 7.79086 14 10V13",
|
|
3417
|
+
stroke: "currentColor",
|
|
3418
|
+
strokeWidth: "1.5",
|
|
3419
|
+
strokeLinecap: "round",
|
|
3420
|
+
strokeLinejoin: "round"
|
|
3421
|
+
}
|
|
3422
|
+
) })
|
|
3423
|
+
}
|
|
3424
|
+
),
|
|
3425
|
+
/* @__PURE__ */ V("div", { className: "message-bubble", children: [
|
|
3426
|
+
d.replyTo && /* @__PURE__ */ V("div", { className: "message-reply-to", children: [
|
|
3427
|
+
/* @__PURE__ */ V("div", { className: "message-reply-to-label", children: [
|
|
3428
|
+
"Replying to",
|
|
3429
|
+
" ",
|
|
3430
|
+
d.replyTo.sender === "user" ? "You" : "Keyring Agent"
|
|
3431
|
+
] }),
|
|
3432
|
+
/* @__PURE__ */ k("div", { className: "message-reply-to-text", children: d.replyTo.text })
|
|
3433
|
+
] }),
|
|
3434
|
+
/* @__PURE__ */ k("div", { className: "message-text", children: /* @__PURE__ */ k(zr, { content: d.text }) }),
|
|
3435
|
+
d.buttons && d.buttons.length > 0 && /* @__PURE__ */ k("div", { className: "message-buttons", children: d.buttons.map((I) => /* @__PURE__ */ k(
|
|
3436
|
+
"button",
|
|
3437
|
+
{
|
|
3438
|
+
className: `message-button ${I.fullWidth ? "full-width" : ""}`,
|
|
3439
|
+
onClick: () => f(
|
|
3440
|
+
I.value,
|
|
3441
|
+
I.action,
|
|
3442
|
+
I?.extraData
|
|
3443
|
+
),
|
|
3444
|
+
type: "button",
|
|
3445
|
+
children: I.text
|
|
3446
|
+
},
|
|
3447
|
+
I.id
|
|
3448
|
+
)) }),
|
|
3449
|
+
/* @__PURE__ */ V("div", { className: "message-timestamp", children: [
|
|
3450
|
+
d.timestamp.toLocaleTimeString("en-US", {
|
|
3451
|
+
hour: "2-digit",
|
|
3452
|
+
minute: "2-digit",
|
|
3453
|
+
hour12: !1
|
|
3454
|
+
}),
|
|
3455
|
+
d.sender === "user" && /* @__PURE__ */ k(
|
|
3456
|
+
"svg",
|
|
3457
|
+
{
|
|
3458
|
+
width: "16",
|
|
3459
|
+
height: "16",
|
|
3460
|
+
viewBox: "0 0 16 16",
|
|
3461
|
+
fill: "none",
|
|
3462
|
+
className: "check-icon",
|
|
3463
|
+
children: /* @__PURE__ */ k(
|
|
3464
|
+
"path",
|
|
3465
|
+
{
|
|
3466
|
+
d: "M13.3333 4L6 11.3333L2.66667 8",
|
|
3467
|
+
stroke: "currentColor",
|
|
3468
|
+
strokeWidth: "2",
|
|
3469
|
+
strokeLinecap: "round",
|
|
3470
|
+
strokeLinejoin: "round"
|
|
3471
|
+
}
|
|
3472
|
+
)
|
|
3473
|
+
}
|
|
3474
|
+
)
|
|
3475
|
+
] })
|
|
3476
|
+
] })
|
|
3477
|
+
]
|
|
3478
|
+
}
|
|
3479
|
+
)
|
|
3480
|
+
] }, d.id)),
|
|
3481
|
+
b && /* @__PURE__ */ k(
|
|
3482
|
+
"div",
|
|
3483
|
+
{
|
|
3484
|
+
className: "message message-bot typing-indicator",
|
|
3485
|
+
role: "status",
|
|
3486
|
+
"aria-label": "Bot is typing",
|
|
3487
|
+
children: /* @__PURE__ */ V("div", { className: "message-bubble", children: [
|
|
3488
|
+
/* @__PURE__ */ k("span", { className: "typing-dot" }),
|
|
3489
|
+
/* @__PURE__ */ k("span", { className: "typing-dot" }),
|
|
3490
|
+
/* @__PURE__ */ k("span", { className: "typing-dot" })
|
|
3491
|
+
] })
|
|
3492
|
+
}
|
|
3493
|
+
),
|
|
3494
|
+
E && /* @__PURE__ */ k("div", { className: "suggestions-container", children: x.map((d) => /* @__PURE__ */ V(
|
|
3495
|
+
"button",
|
|
3496
|
+
{
|
|
3497
|
+
className: "suggestion-button",
|
|
3498
|
+
onClick: d.action,
|
|
3499
|
+
type: "button",
|
|
3500
|
+
children: [
|
|
3501
|
+
/* @__PURE__ */ k("span", { className: "suggestion-icon", children: d.icon }),
|
|
3502
|
+
/* @__PURE__ */ k("span", { className: "suggestion-text", children: d.text })
|
|
3503
|
+
]
|
|
3504
|
+
},
|
|
3505
|
+
d.id
|
|
3506
|
+
)) }),
|
|
3507
|
+
/* @__PURE__ */ k("div", { ref: O })
|
|
3508
|
+
] }),
|
|
3509
|
+
/* @__PURE__ */ V("div", { className: "chat-modal-input", children: [
|
|
3510
|
+
B && /* @__PURE__ */ V("div", { className: "reply-preview", children: [
|
|
3511
|
+
/* @__PURE__ */ V("div", { className: "reply-preview-content", children: [
|
|
3512
|
+
/* @__PURE__ */ V("div", { className: "reply-preview-label", children: [
|
|
3513
|
+
"Replying to",
|
|
3514
|
+
" ",
|
|
3515
|
+
B.sender === "user" ? "You" : "Keyring Agent"
|
|
3516
|
+
] }),
|
|
3517
|
+
/* @__PURE__ */ k("div", { className: "reply-preview-text", children: B.text })
|
|
3518
|
+
] }),
|
|
3519
|
+
/* @__PURE__ */ k(
|
|
3520
|
+
"button",
|
|
3521
|
+
{
|
|
3522
|
+
className: "reply-preview-close",
|
|
3523
|
+
onClick: () => C(null),
|
|
3524
|
+
"aria-label": "Cancel reply",
|
|
3525
|
+
type: "button",
|
|
3526
|
+
children: /* @__PURE__ */ k("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ k(
|
|
3527
|
+
"path",
|
|
3528
|
+
{
|
|
3529
|
+
d: "M12 4L4 12M4 4L12 12",
|
|
3530
|
+
stroke: "currentColor",
|
|
3531
|
+
strokeWidth: "1.5",
|
|
3532
|
+
strokeLinecap: "round"
|
|
3533
|
+
}
|
|
3534
|
+
) })
|
|
3535
|
+
}
|
|
3536
|
+
)
|
|
3537
|
+
] }),
|
|
3538
|
+
/* @__PURE__ */ V("div", { className: "chat-modal-input-row", children: [
|
|
3539
|
+
/* @__PURE__ */ k(
|
|
3540
|
+
"input",
|
|
3541
|
+
{
|
|
3542
|
+
ref: F,
|
|
3543
|
+
type: "text",
|
|
3544
|
+
placeholder: "Message ....",
|
|
3545
|
+
value: c,
|
|
3546
|
+
onChange: (d) => l(d.target.value),
|
|
3547
|
+
onKeyPress: y,
|
|
3548
|
+
disabled: b,
|
|
3549
|
+
"aria-label": "Message input"
|
|
3550
|
+
}
|
|
3551
|
+
),
|
|
3552
|
+
/* @__PURE__ */ k(
|
|
3553
|
+
"button",
|
|
3554
|
+
{
|
|
3555
|
+
className: "send-button",
|
|
3556
|
+
onClick: h,
|
|
3557
|
+
"aria-label": "Send message",
|
|
3558
|
+
disabled: b || c.trim() === "",
|
|
3559
|
+
type: "button",
|
|
3560
|
+
children: /* @__PURE__ */ k("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ k(
|
|
3561
|
+
"path",
|
|
3562
|
+
{
|
|
3563
|
+
d: "M18 2L9 11M18 2L12 18L9 11M18 2L2 8L9 11",
|
|
3564
|
+
stroke: "white",
|
|
3565
|
+
strokeWidth: "2",
|
|
3566
|
+
strokeLinecap: "round",
|
|
3567
|
+
strokeLinejoin: "round"
|
|
3568
|
+
}
|
|
3569
|
+
) })
|
|
3570
|
+
}
|
|
3571
|
+
)
|
|
3572
|
+
] })
|
|
3573
|
+
] })
|
|
3574
|
+
] })
|
|
3575
|
+
}
|
|
3576
|
+
) : null;
|
|
3577
|
+
}, hn = Ot(void 0), Hr = () => {
|
|
3578
|
+
const e = Lt(hn);
|
|
3579
|
+
if (!e)
|
|
3580
|
+
throw new Error("useConfig must be used within ConfigProvider");
|
|
3581
|
+
return e;
|
|
3582
|
+
}, Dr = ({
|
|
3583
|
+
children: e,
|
|
3584
|
+
initialConfig: t
|
|
3585
|
+
}) => /* @__PURE__ */ k(hn.Provider, { value: { config: t || null }, children: e }), $r = ({
|
|
3586
|
+
position: e,
|
|
3587
|
+
theme: t,
|
|
3588
|
+
defaultOpen: n,
|
|
3589
|
+
onOpen: r,
|
|
3590
|
+
onClose: s,
|
|
3591
|
+
onTransaction: c
|
|
3592
|
+
}) => {
|
|
3593
|
+
const { account: l } = wt(), [b, w] = Ae(n);
|
|
3594
|
+
Te(() => {
|
|
3595
|
+
n && r && r();
|
|
3596
|
+
}, []);
|
|
3597
|
+
const E = Q(() => {
|
|
3598
|
+
w(!0), r?.();
|
|
3599
|
+
}, [r]), A = Q(() => {
|
|
3600
|
+
w(!1), s?.();
|
|
3601
|
+
}, [s]), B = Q(() => {
|
|
3602
|
+
b ? A() : E();
|
|
3603
|
+
}, [b, E, A]), C = {
|
|
3604
|
+
position: "fixed",
|
|
3605
|
+
[e === "bottom-right" ? "right" : "left"]: "20px",
|
|
3606
|
+
bottom: "20px",
|
|
3607
|
+
zIndex: t.zIndex ?? 9999
|
|
3608
|
+
};
|
|
3609
|
+
return /* @__PURE__ */ k("div", { style: C, role: "complementary", "aria-label": "Chat widget", children: l?.address && l?.chainId && /* @__PURE__ */ V(pn, { children: [
|
|
3610
|
+
/* @__PURE__ */ k(bn, { onClick: B }),
|
|
3611
|
+
/* @__PURE__ */ k(
|
|
3612
|
+
Fr,
|
|
3613
|
+
{
|
|
3614
|
+
isOpen: b,
|
|
3615
|
+
onClose: A,
|
|
3616
|
+
onTransaction: c
|
|
3617
|
+
}
|
|
3618
|
+
)
|
|
3619
|
+
] }) });
|
|
3620
|
+
}, Rr = ({
|
|
3621
|
+
position: e = "bottom-right",
|
|
3622
|
+
theme: t = {},
|
|
3623
|
+
defaultOpen: n = !1,
|
|
3624
|
+
onOpen: r,
|
|
3625
|
+
onClose: s,
|
|
3626
|
+
account: c,
|
|
3627
|
+
onTransaction: l
|
|
3628
|
+
}) => /* @__PURE__ */ k(Dr, { initialConfig: {
|
|
3629
|
+
position: e,
|
|
3630
|
+
theme: t
|
|
3631
|
+
}, children: /* @__PURE__ */ k(yr, { initialAccount: c, children: /* @__PURE__ */ k(
|
|
3632
|
+
$r,
|
|
3633
|
+
{
|
|
3634
|
+
position: e,
|
|
3635
|
+
theme: t,
|
|
3636
|
+
defaultOpen: n,
|
|
3637
|
+
onOpen: r,
|
|
3638
|
+
onClose: s,
|
|
3639
|
+
onTransaction: l
|
|
3640
|
+
}
|
|
3641
|
+
) }) });
|
|
3642
|
+
export {
|
|
3643
|
+
Rr as ChatWidget,
|
|
3644
|
+
Dr as ConfigProvider,
|
|
3645
|
+
yr as ConnectProvider,
|
|
3646
|
+
Hr as useConfig,
|
|
3647
|
+
wt as useConnect
|
|
3648
|
+
};
|