@shogun-sdk/swap 0.0.2-test
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 +274 -0
- package/dist/core.cjs +619 -0
- package/dist/core.d.cts +137 -0
- package/dist/core.d.ts +137 -0
- package/dist/core.js +590 -0
- package/dist/execute-FaLLPp1i.d.cts +147 -0
- package/dist/execute-HX1fQ7wG.d.ts +147 -0
- package/dist/index.cjs +2477 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +2458 -0
- package/dist/react.cjs +2364 -0
- package/dist/react.d.cts +158 -0
- package/dist/react.d.ts +158 -0
- package/dist/react.js +2355 -0
- package/dist/wallet-MmUIz8GE.d.cts +29 -0
- package/dist/wallet-MmUIz8GE.d.ts +29 -0
- package/dist/wallet-adapter.cjs +175 -0
- package/dist/wallet-adapter.d.cts +34 -0
- package/dist/wallet-adapter.d.ts +34 -0
- package/dist/wallet-adapter.js +150 -0
- package/package.json +68 -0
package/dist/react.js
ADDED
|
@@ -0,0 +1,2355 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react.production.js
|
|
28
|
+
var require_react_production = __commonJS({
|
|
29
|
+
"../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react.production.js"(exports) {
|
|
30
|
+
"use strict";
|
|
31
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element");
|
|
32
|
+
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
|
33
|
+
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
34
|
+
var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
|
|
35
|
+
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
36
|
+
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer");
|
|
37
|
+
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
|
|
38
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
|
|
39
|
+
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
40
|
+
var REACT_MEMO_TYPE = Symbol.for("react.memo");
|
|
41
|
+
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
42
|
+
var REACT_ACTIVITY_TYPE = Symbol.for("react.activity");
|
|
43
|
+
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
|
44
|
+
function getIteratorFn(maybeIterable) {
|
|
45
|
+
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
|
|
46
|
+
maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
|
|
47
|
+
return "function" === typeof maybeIterable ? maybeIterable : null;
|
|
48
|
+
}
|
|
49
|
+
var ReactNoopUpdateQueue = {
|
|
50
|
+
isMounted: function() {
|
|
51
|
+
return false;
|
|
52
|
+
},
|
|
53
|
+
enqueueForceUpdate: function() {
|
|
54
|
+
},
|
|
55
|
+
enqueueReplaceState: function() {
|
|
56
|
+
},
|
|
57
|
+
enqueueSetState: function() {
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var assign = Object.assign;
|
|
61
|
+
var emptyObject = {};
|
|
62
|
+
function Component(props, context, updater) {
|
|
63
|
+
this.props = props;
|
|
64
|
+
this.context = context;
|
|
65
|
+
this.refs = emptyObject;
|
|
66
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
67
|
+
}
|
|
68
|
+
Component.prototype.isReactComponent = {};
|
|
69
|
+
Component.prototype.setState = function(partialState, callback) {
|
|
70
|
+
if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
|
|
71
|
+
throw Error(
|
|
72
|
+
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
73
|
+
);
|
|
74
|
+
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
|
75
|
+
};
|
|
76
|
+
Component.prototype.forceUpdate = function(callback) {
|
|
77
|
+
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
|
78
|
+
};
|
|
79
|
+
function ComponentDummy() {
|
|
80
|
+
}
|
|
81
|
+
ComponentDummy.prototype = Component.prototype;
|
|
82
|
+
function PureComponent(props, context, updater) {
|
|
83
|
+
this.props = props;
|
|
84
|
+
this.context = context;
|
|
85
|
+
this.refs = emptyObject;
|
|
86
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
87
|
+
}
|
|
88
|
+
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
|
89
|
+
pureComponentPrototype.constructor = PureComponent;
|
|
90
|
+
assign(pureComponentPrototype, Component.prototype);
|
|
91
|
+
pureComponentPrototype.isPureReactComponent = true;
|
|
92
|
+
var isArrayImpl = Array.isArray;
|
|
93
|
+
function noop() {
|
|
94
|
+
}
|
|
95
|
+
var ReactSharedInternals = { H: null, A: null, T: null, S: null };
|
|
96
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
97
|
+
function ReactElement(type, key, props) {
|
|
98
|
+
var refProp = props.ref;
|
|
99
|
+
return {
|
|
100
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
101
|
+
type,
|
|
102
|
+
key,
|
|
103
|
+
ref: void 0 !== refProp ? refProp : null,
|
|
104
|
+
props
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function cloneAndReplaceKey(oldElement, newKey) {
|
|
108
|
+
return ReactElement(oldElement.type, newKey, oldElement.props);
|
|
109
|
+
}
|
|
110
|
+
function isValidElement(object) {
|
|
111
|
+
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
112
|
+
}
|
|
113
|
+
function escape(key) {
|
|
114
|
+
var escaperLookup = { "=": "=0", ":": "=2" };
|
|
115
|
+
return "$" + key.replace(/[=:]/g, function(match) {
|
|
116
|
+
return escaperLookup[match];
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
var userProvidedKeyEscapeRegex = /\/+/g;
|
|
120
|
+
function getElementKey(element, index) {
|
|
121
|
+
return "object" === typeof element && null !== element && null != element.key ? escape("" + element.key) : index.toString(36);
|
|
122
|
+
}
|
|
123
|
+
function resolveThenable(thenable) {
|
|
124
|
+
switch (thenable.status) {
|
|
125
|
+
case "fulfilled":
|
|
126
|
+
return thenable.value;
|
|
127
|
+
case "rejected":
|
|
128
|
+
throw thenable.reason;
|
|
129
|
+
default:
|
|
130
|
+
switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
|
|
131
|
+
function(fulfilledValue) {
|
|
132
|
+
"pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
|
|
133
|
+
},
|
|
134
|
+
function(error) {
|
|
135
|
+
"pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
136
|
+
}
|
|
137
|
+
)), thenable.status) {
|
|
138
|
+
case "fulfilled":
|
|
139
|
+
return thenable.value;
|
|
140
|
+
case "rejected":
|
|
141
|
+
throw thenable.reason;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
throw thenable;
|
|
145
|
+
}
|
|
146
|
+
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
|
147
|
+
var type = typeof children;
|
|
148
|
+
if ("undefined" === type || "boolean" === type) children = null;
|
|
149
|
+
var invokeCallback = false;
|
|
150
|
+
if (null === children) invokeCallback = true;
|
|
151
|
+
else
|
|
152
|
+
switch (type) {
|
|
153
|
+
case "bigint":
|
|
154
|
+
case "string":
|
|
155
|
+
case "number":
|
|
156
|
+
invokeCallback = true;
|
|
157
|
+
break;
|
|
158
|
+
case "object":
|
|
159
|
+
switch (children.$$typeof) {
|
|
160
|
+
case REACT_ELEMENT_TYPE:
|
|
161
|
+
case REACT_PORTAL_TYPE:
|
|
162
|
+
invokeCallback = true;
|
|
163
|
+
break;
|
|
164
|
+
case REACT_LAZY_TYPE:
|
|
165
|
+
return invokeCallback = children._init, mapIntoArray(
|
|
166
|
+
invokeCallback(children._payload),
|
|
167
|
+
array,
|
|
168
|
+
escapedPrefix,
|
|
169
|
+
nameSoFar,
|
|
170
|
+
callback
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (invokeCallback)
|
|
175
|
+
return callback = callback(children), invokeCallback = "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar, isArrayImpl(callback) ? (escapedPrefix = "", null != invokeCallback && (escapedPrefix = invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
|
|
176
|
+
return c;
|
|
177
|
+
})) : null != callback && (isValidElement(callback) && (callback = cloneAndReplaceKey(
|
|
178
|
+
callback,
|
|
179
|
+
escapedPrefix + (null == callback.key || children && children.key === callback.key ? "" : ("" + callback.key).replace(
|
|
180
|
+
userProvidedKeyEscapeRegex,
|
|
181
|
+
"$&/"
|
|
182
|
+
) + "/") + invokeCallback
|
|
183
|
+
)), array.push(callback)), 1;
|
|
184
|
+
invokeCallback = 0;
|
|
185
|
+
var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
|
|
186
|
+
if (isArrayImpl(children))
|
|
187
|
+
for (var i = 0; i < children.length; i++)
|
|
188
|
+
nameSoFar = children[i], type = nextNamePrefix + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
|
|
189
|
+
nameSoFar,
|
|
190
|
+
array,
|
|
191
|
+
escapedPrefix,
|
|
192
|
+
type,
|
|
193
|
+
callback
|
|
194
|
+
);
|
|
195
|
+
else if (i = getIteratorFn(children), "function" === typeof i)
|
|
196
|
+
for (children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
|
|
197
|
+
nameSoFar = nameSoFar.value, type = nextNamePrefix + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
|
|
198
|
+
nameSoFar,
|
|
199
|
+
array,
|
|
200
|
+
escapedPrefix,
|
|
201
|
+
type,
|
|
202
|
+
callback
|
|
203
|
+
);
|
|
204
|
+
else if ("object" === type) {
|
|
205
|
+
if ("function" === typeof children.then)
|
|
206
|
+
return mapIntoArray(
|
|
207
|
+
resolveThenable(children),
|
|
208
|
+
array,
|
|
209
|
+
escapedPrefix,
|
|
210
|
+
nameSoFar,
|
|
211
|
+
callback
|
|
212
|
+
);
|
|
213
|
+
array = String(children);
|
|
214
|
+
throw Error(
|
|
215
|
+
"Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead."
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
return invokeCallback;
|
|
219
|
+
}
|
|
220
|
+
function mapChildren(children, func, context) {
|
|
221
|
+
if (null == children) return children;
|
|
222
|
+
var result = [], count = 0;
|
|
223
|
+
mapIntoArray(children, result, "", "", function(child) {
|
|
224
|
+
return func.call(context, child, count++);
|
|
225
|
+
});
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
function lazyInitializer(payload) {
|
|
229
|
+
if (-1 === payload._status) {
|
|
230
|
+
var ctor = payload._result;
|
|
231
|
+
ctor = ctor();
|
|
232
|
+
ctor.then(
|
|
233
|
+
function(moduleObject) {
|
|
234
|
+
if (0 === payload._status || -1 === payload._status)
|
|
235
|
+
payload._status = 1, payload._result = moduleObject;
|
|
236
|
+
},
|
|
237
|
+
function(error) {
|
|
238
|
+
if (0 === payload._status || -1 === payload._status)
|
|
239
|
+
payload._status = 2, payload._result = error;
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
-1 === payload._status && (payload._status = 0, payload._result = ctor);
|
|
243
|
+
}
|
|
244
|
+
if (1 === payload._status) return payload._result.default;
|
|
245
|
+
throw payload._result;
|
|
246
|
+
}
|
|
247
|
+
var reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
|
|
248
|
+
if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
|
|
249
|
+
var event = new window.ErrorEvent("error", {
|
|
250
|
+
bubbles: true,
|
|
251
|
+
cancelable: true,
|
|
252
|
+
message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
|
|
253
|
+
error
|
|
254
|
+
});
|
|
255
|
+
if (!window.dispatchEvent(event)) return;
|
|
256
|
+
} else if ("object" === typeof process && "function" === typeof process.emit) {
|
|
257
|
+
process.emit("uncaughtException", error);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
console.error(error);
|
|
261
|
+
};
|
|
262
|
+
var Children = {
|
|
263
|
+
map: mapChildren,
|
|
264
|
+
forEach: function(children, forEachFunc, forEachContext) {
|
|
265
|
+
mapChildren(
|
|
266
|
+
children,
|
|
267
|
+
function() {
|
|
268
|
+
forEachFunc.apply(this, arguments);
|
|
269
|
+
},
|
|
270
|
+
forEachContext
|
|
271
|
+
);
|
|
272
|
+
},
|
|
273
|
+
count: function(children) {
|
|
274
|
+
var n = 0;
|
|
275
|
+
mapChildren(children, function() {
|
|
276
|
+
n++;
|
|
277
|
+
});
|
|
278
|
+
return n;
|
|
279
|
+
},
|
|
280
|
+
toArray: function(children) {
|
|
281
|
+
return mapChildren(children, function(child) {
|
|
282
|
+
return child;
|
|
283
|
+
}) || [];
|
|
284
|
+
},
|
|
285
|
+
only: function(children) {
|
|
286
|
+
if (!isValidElement(children))
|
|
287
|
+
throw Error(
|
|
288
|
+
"React.Children.only expected to receive a single React element child."
|
|
289
|
+
);
|
|
290
|
+
return children;
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
exports.Activity = REACT_ACTIVITY_TYPE;
|
|
294
|
+
exports.Children = Children;
|
|
295
|
+
exports.Component = Component;
|
|
296
|
+
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
297
|
+
exports.Profiler = REACT_PROFILER_TYPE;
|
|
298
|
+
exports.PureComponent = PureComponent;
|
|
299
|
+
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
300
|
+
exports.Suspense = REACT_SUSPENSE_TYPE;
|
|
301
|
+
exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
|
|
302
|
+
exports.__COMPILER_RUNTIME = {
|
|
303
|
+
__proto__: null,
|
|
304
|
+
c: function(size) {
|
|
305
|
+
return ReactSharedInternals.H.useMemoCache(size);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
exports.cache = function(fn) {
|
|
309
|
+
return function() {
|
|
310
|
+
return fn.apply(null, arguments);
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
exports.cacheSignal = function() {
|
|
314
|
+
return null;
|
|
315
|
+
};
|
|
316
|
+
exports.cloneElement = function(element, config, children) {
|
|
317
|
+
if (null === element || void 0 === element)
|
|
318
|
+
throw Error(
|
|
319
|
+
"The argument must be a React element, but you passed " + element + "."
|
|
320
|
+
);
|
|
321
|
+
var props = assign({}, element.props), key = element.key;
|
|
322
|
+
if (null != config)
|
|
323
|
+
for (propName in void 0 !== config.key && (key = "" + config.key), config)
|
|
324
|
+
!hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
|
|
325
|
+
var propName = arguments.length - 2;
|
|
326
|
+
if (1 === propName) props.children = children;
|
|
327
|
+
else if (1 < propName) {
|
|
328
|
+
for (var childArray = Array(propName), i = 0; i < propName; i++)
|
|
329
|
+
childArray[i] = arguments[i + 2];
|
|
330
|
+
props.children = childArray;
|
|
331
|
+
}
|
|
332
|
+
return ReactElement(element.type, key, props);
|
|
333
|
+
};
|
|
334
|
+
exports.createContext = function(defaultValue) {
|
|
335
|
+
defaultValue = {
|
|
336
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
337
|
+
_currentValue: defaultValue,
|
|
338
|
+
_currentValue2: defaultValue,
|
|
339
|
+
_threadCount: 0,
|
|
340
|
+
Provider: null,
|
|
341
|
+
Consumer: null
|
|
342
|
+
};
|
|
343
|
+
defaultValue.Provider = defaultValue;
|
|
344
|
+
defaultValue.Consumer = {
|
|
345
|
+
$$typeof: REACT_CONSUMER_TYPE,
|
|
346
|
+
_context: defaultValue
|
|
347
|
+
};
|
|
348
|
+
return defaultValue;
|
|
349
|
+
};
|
|
350
|
+
exports.createElement = function(type, config, children) {
|
|
351
|
+
var propName, props = {}, key = null;
|
|
352
|
+
if (null != config)
|
|
353
|
+
for (propName in void 0 !== config.key && (key = "" + config.key), config)
|
|
354
|
+
hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (props[propName] = config[propName]);
|
|
355
|
+
var childrenLength = arguments.length - 2;
|
|
356
|
+
if (1 === childrenLength) props.children = children;
|
|
357
|
+
else if (1 < childrenLength) {
|
|
358
|
+
for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
|
|
359
|
+
childArray[i] = arguments[i + 2];
|
|
360
|
+
props.children = childArray;
|
|
361
|
+
}
|
|
362
|
+
if (type && type.defaultProps)
|
|
363
|
+
for (propName in childrenLength = type.defaultProps, childrenLength)
|
|
364
|
+
void 0 === props[propName] && (props[propName] = childrenLength[propName]);
|
|
365
|
+
return ReactElement(type, key, props);
|
|
366
|
+
};
|
|
367
|
+
exports.createRef = function() {
|
|
368
|
+
return { current: null };
|
|
369
|
+
};
|
|
370
|
+
exports.forwardRef = function(render) {
|
|
371
|
+
return { $$typeof: REACT_FORWARD_REF_TYPE, render };
|
|
372
|
+
};
|
|
373
|
+
exports.isValidElement = isValidElement;
|
|
374
|
+
exports.lazy = function(ctor) {
|
|
375
|
+
return {
|
|
376
|
+
$$typeof: REACT_LAZY_TYPE,
|
|
377
|
+
_payload: { _status: -1, _result: ctor },
|
|
378
|
+
_init: lazyInitializer
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
exports.memo = function(type, compare) {
|
|
382
|
+
return {
|
|
383
|
+
$$typeof: REACT_MEMO_TYPE,
|
|
384
|
+
type,
|
|
385
|
+
compare: void 0 === compare ? null : compare
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
exports.startTransition = function(scope) {
|
|
389
|
+
var prevTransition = ReactSharedInternals.T, currentTransition = {};
|
|
390
|
+
ReactSharedInternals.T = currentTransition;
|
|
391
|
+
try {
|
|
392
|
+
var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
|
|
393
|
+
null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
|
|
394
|
+
"object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && returnValue.then(noop, reportGlobalError);
|
|
395
|
+
} catch (error) {
|
|
396
|
+
reportGlobalError(error);
|
|
397
|
+
} finally {
|
|
398
|
+
null !== prevTransition && null !== currentTransition.types && (prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
exports.unstable_useCacheRefresh = function() {
|
|
402
|
+
return ReactSharedInternals.H.useCacheRefresh();
|
|
403
|
+
};
|
|
404
|
+
exports.use = function(usable) {
|
|
405
|
+
return ReactSharedInternals.H.use(usable);
|
|
406
|
+
};
|
|
407
|
+
exports.useActionState = function(action, initialState, permalink) {
|
|
408
|
+
return ReactSharedInternals.H.useActionState(action, initialState, permalink);
|
|
409
|
+
};
|
|
410
|
+
exports.useCallback = function(callback, deps) {
|
|
411
|
+
return ReactSharedInternals.H.useCallback(callback, deps);
|
|
412
|
+
};
|
|
413
|
+
exports.useContext = function(Context) {
|
|
414
|
+
return ReactSharedInternals.H.useContext(Context);
|
|
415
|
+
};
|
|
416
|
+
exports.useDebugValue = function() {
|
|
417
|
+
};
|
|
418
|
+
exports.useDeferredValue = function(value, initialValue) {
|
|
419
|
+
return ReactSharedInternals.H.useDeferredValue(value, initialValue);
|
|
420
|
+
};
|
|
421
|
+
exports.useEffect = function(create, deps) {
|
|
422
|
+
return ReactSharedInternals.H.useEffect(create, deps);
|
|
423
|
+
};
|
|
424
|
+
exports.useEffectEvent = function(callback) {
|
|
425
|
+
return ReactSharedInternals.H.useEffectEvent(callback);
|
|
426
|
+
};
|
|
427
|
+
exports.useId = function() {
|
|
428
|
+
return ReactSharedInternals.H.useId();
|
|
429
|
+
};
|
|
430
|
+
exports.useImperativeHandle = function(ref, create, deps) {
|
|
431
|
+
return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
|
|
432
|
+
};
|
|
433
|
+
exports.useInsertionEffect = function(create, deps) {
|
|
434
|
+
return ReactSharedInternals.H.useInsertionEffect(create, deps);
|
|
435
|
+
};
|
|
436
|
+
exports.useLayoutEffect = function(create, deps) {
|
|
437
|
+
return ReactSharedInternals.H.useLayoutEffect(create, deps);
|
|
438
|
+
};
|
|
439
|
+
exports.useMemo = function(create, deps) {
|
|
440
|
+
return ReactSharedInternals.H.useMemo(create, deps);
|
|
441
|
+
};
|
|
442
|
+
exports.useOptimistic = function(passthrough, reducer) {
|
|
443
|
+
return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
|
|
444
|
+
};
|
|
445
|
+
exports.useReducer = function(reducer, initialArg, init) {
|
|
446
|
+
return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
|
|
447
|
+
};
|
|
448
|
+
exports.useRef = function(initialValue) {
|
|
449
|
+
return ReactSharedInternals.H.useRef(initialValue);
|
|
450
|
+
};
|
|
451
|
+
exports.useState = function(initialState) {
|
|
452
|
+
return ReactSharedInternals.H.useState(initialState);
|
|
453
|
+
};
|
|
454
|
+
exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
|
|
455
|
+
return ReactSharedInternals.H.useSyncExternalStore(
|
|
456
|
+
subscribe,
|
|
457
|
+
getSnapshot,
|
|
458
|
+
getServerSnapshot
|
|
459
|
+
);
|
|
460
|
+
};
|
|
461
|
+
exports.useTransition = function() {
|
|
462
|
+
return ReactSharedInternals.H.useTransition();
|
|
463
|
+
};
|
|
464
|
+
exports.version = "19.2.0";
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// ../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react.development.js
|
|
469
|
+
var require_react_development = __commonJS({
|
|
470
|
+
"../../node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react.development.js"(exports, module) {
|
|
471
|
+
"use strict";
|
|
472
|
+
"production" !== process.env.NODE_ENV && function() {
|
|
473
|
+
function defineDeprecationWarning(methodName, info) {
|
|
474
|
+
Object.defineProperty(Component.prototype, methodName, {
|
|
475
|
+
get: function() {
|
|
476
|
+
console.warn(
|
|
477
|
+
"%s(...) is deprecated in plain JavaScript React classes. %s",
|
|
478
|
+
info[0],
|
|
479
|
+
info[1]
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
function getIteratorFn(maybeIterable) {
|
|
485
|
+
if (null === maybeIterable || "object" !== typeof maybeIterable)
|
|
486
|
+
return null;
|
|
487
|
+
maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
|
|
488
|
+
return "function" === typeof maybeIterable ? maybeIterable : null;
|
|
489
|
+
}
|
|
490
|
+
function warnNoop(publicInstance, callerName) {
|
|
491
|
+
publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
|
|
492
|
+
var warningKey = publicInstance + "." + callerName;
|
|
493
|
+
didWarnStateUpdateForUnmountedComponent[warningKey] || (console.error(
|
|
494
|
+
"Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
|
|
495
|
+
callerName,
|
|
496
|
+
publicInstance
|
|
497
|
+
), didWarnStateUpdateForUnmountedComponent[warningKey] = true);
|
|
498
|
+
}
|
|
499
|
+
function Component(props, context, updater) {
|
|
500
|
+
this.props = props;
|
|
501
|
+
this.context = context;
|
|
502
|
+
this.refs = emptyObject;
|
|
503
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
504
|
+
}
|
|
505
|
+
function ComponentDummy() {
|
|
506
|
+
}
|
|
507
|
+
function PureComponent(props, context, updater) {
|
|
508
|
+
this.props = props;
|
|
509
|
+
this.context = context;
|
|
510
|
+
this.refs = emptyObject;
|
|
511
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
512
|
+
}
|
|
513
|
+
function noop() {
|
|
514
|
+
}
|
|
515
|
+
function testStringCoercion(value) {
|
|
516
|
+
return "" + value;
|
|
517
|
+
}
|
|
518
|
+
function checkKeyStringCoercion(value) {
|
|
519
|
+
try {
|
|
520
|
+
testStringCoercion(value);
|
|
521
|
+
var JSCompiler_inline_result = false;
|
|
522
|
+
} catch (e) {
|
|
523
|
+
JSCompiler_inline_result = true;
|
|
524
|
+
}
|
|
525
|
+
if (JSCompiler_inline_result) {
|
|
526
|
+
JSCompiler_inline_result = console;
|
|
527
|
+
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
528
|
+
var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
529
|
+
JSCompiler_temp_const.call(
|
|
530
|
+
JSCompiler_inline_result,
|
|
531
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
532
|
+
JSCompiler_inline_result$jscomp$0
|
|
533
|
+
);
|
|
534
|
+
return testStringCoercion(value);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
function getComponentNameFromType(type) {
|
|
538
|
+
if (null == type) return null;
|
|
539
|
+
if ("function" === typeof type)
|
|
540
|
+
return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
|
|
541
|
+
if ("string" === typeof type) return type;
|
|
542
|
+
switch (type) {
|
|
543
|
+
case REACT_FRAGMENT_TYPE:
|
|
544
|
+
return "Fragment";
|
|
545
|
+
case REACT_PROFILER_TYPE:
|
|
546
|
+
return "Profiler";
|
|
547
|
+
case REACT_STRICT_MODE_TYPE:
|
|
548
|
+
return "StrictMode";
|
|
549
|
+
case REACT_SUSPENSE_TYPE:
|
|
550
|
+
return "Suspense";
|
|
551
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
552
|
+
return "SuspenseList";
|
|
553
|
+
case REACT_ACTIVITY_TYPE:
|
|
554
|
+
return "Activity";
|
|
555
|
+
}
|
|
556
|
+
if ("object" === typeof type)
|
|
557
|
+
switch ("number" === typeof type.tag && console.error(
|
|
558
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
559
|
+
), type.$$typeof) {
|
|
560
|
+
case REACT_PORTAL_TYPE:
|
|
561
|
+
return "Portal";
|
|
562
|
+
case REACT_CONTEXT_TYPE:
|
|
563
|
+
return type.displayName || "Context";
|
|
564
|
+
case REACT_CONSUMER_TYPE:
|
|
565
|
+
return (type._context.displayName || "Context") + ".Consumer";
|
|
566
|
+
case REACT_FORWARD_REF_TYPE:
|
|
567
|
+
var innerType = type.render;
|
|
568
|
+
type = type.displayName;
|
|
569
|
+
type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
|
|
570
|
+
return type;
|
|
571
|
+
case REACT_MEMO_TYPE:
|
|
572
|
+
return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
|
|
573
|
+
case REACT_LAZY_TYPE:
|
|
574
|
+
innerType = type._payload;
|
|
575
|
+
type = type._init;
|
|
576
|
+
try {
|
|
577
|
+
return getComponentNameFromType(type(innerType));
|
|
578
|
+
} catch (x) {
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return null;
|
|
582
|
+
}
|
|
583
|
+
function getTaskName(type) {
|
|
584
|
+
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
585
|
+
if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
|
|
586
|
+
return "<...>";
|
|
587
|
+
try {
|
|
588
|
+
var name = getComponentNameFromType(type);
|
|
589
|
+
return name ? "<" + name + ">" : "<...>";
|
|
590
|
+
} catch (x) {
|
|
591
|
+
return "<...>";
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
function getOwner() {
|
|
595
|
+
var dispatcher = ReactSharedInternals.A;
|
|
596
|
+
return null === dispatcher ? null : dispatcher.getOwner();
|
|
597
|
+
}
|
|
598
|
+
function UnknownOwner() {
|
|
599
|
+
return Error("react-stack-top-frame");
|
|
600
|
+
}
|
|
601
|
+
function hasValidKey(config) {
|
|
602
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
603
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
604
|
+
if (getter && getter.isReactWarning) return false;
|
|
605
|
+
}
|
|
606
|
+
return void 0 !== config.key;
|
|
607
|
+
}
|
|
608
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
609
|
+
function warnAboutAccessingKey() {
|
|
610
|
+
specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
|
|
611
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
612
|
+
displayName
|
|
613
|
+
));
|
|
614
|
+
}
|
|
615
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
616
|
+
Object.defineProperty(props, "key", {
|
|
617
|
+
get: warnAboutAccessingKey,
|
|
618
|
+
configurable: true
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
622
|
+
var componentName = getComponentNameFromType(this.type);
|
|
623
|
+
didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
|
|
624
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
625
|
+
));
|
|
626
|
+
componentName = this.props.ref;
|
|
627
|
+
return void 0 !== componentName ? componentName : null;
|
|
628
|
+
}
|
|
629
|
+
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
630
|
+
var refProp = props.ref;
|
|
631
|
+
type = {
|
|
632
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
633
|
+
type,
|
|
634
|
+
key,
|
|
635
|
+
props,
|
|
636
|
+
_owner: owner
|
|
637
|
+
};
|
|
638
|
+
null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
|
|
639
|
+
enumerable: false,
|
|
640
|
+
get: elementRefGetterWithDeprecationWarning
|
|
641
|
+
}) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
642
|
+
type._store = {};
|
|
643
|
+
Object.defineProperty(type._store, "validated", {
|
|
644
|
+
configurable: false,
|
|
645
|
+
enumerable: false,
|
|
646
|
+
writable: true,
|
|
647
|
+
value: 0
|
|
648
|
+
});
|
|
649
|
+
Object.defineProperty(type, "_debugInfo", {
|
|
650
|
+
configurable: false,
|
|
651
|
+
enumerable: false,
|
|
652
|
+
writable: true,
|
|
653
|
+
value: null
|
|
654
|
+
});
|
|
655
|
+
Object.defineProperty(type, "_debugStack", {
|
|
656
|
+
configurable: false,
|
|
657
|
+
enumerable: false,
|
|
658
|
+
writable: true,
|
|
659
|
+
value: debugStack
|
|
660
|
+
});
|
|
661
|
+
Object.defineProperty(type, "_debugTask", {
|
|
662
|
+
configurable: false,
|
|
663
|
+
enumerable: false,
|
|
664
|
+
writable: true,
|
|
665
|
+
value: debugTask
|
|
666
|
+
});
|
|
667
|
+
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
668
|
+
return type;
|
|
669
|
+
}
|
|
670
|
+
function cloneAndReplaceKey(oldElement, newKey) {
|
|
671
|
+
newKey = ReactElement(
|
|
672
|
+
oldElement.type,
|
|
673
|
+
newKey,
|
|
674
|
+
oldElement.props,
|
|
675
|
+
oldElement._owner,
|
|
676
|
+
oldElement._debugStack,
|
|
677
|
+
oldElement._debugTask
|
|
678
|
+
);
|
|
679
|
+
oldElement._store && (newKey._store.validated = oldElement._store.validated);
|
|
680
|
+
return newKey;
|
|
681
|
+
}
|
|
682
|
+
function validateChildKeys(node) {
|
|
683
|
+
isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
|
|
684
|
+
}
|
|
685
|
+
function isValidElement(object) {
|
|
686
|
+
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
687
|
+
}
|
|
688
|
+
function escape(key) {
|
|
689
|
+
var escaperLookup = { "=": "=0", ":": "=2" };
|
|
690
|
+
return "$" + key.replace(/[=:]/g, function(match) {
|
|
691
|
+
return escaperLookup[match];
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
function getElementKey(element, index) {
|
|
695
|
+
return "object" === typeof element && null !== element && null != element.key ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
|
|
696
|
+
}
|
|
697
|
+
function resolveThenable(thenable) {
|
|
698
|
+
switch (thenable.status) {
|
|
699
|
+
case "fulfilled":
|
|
700
|
+
return thenable.value;
|
|
701
|
+
case "rejected":
|
|
702
|
+
throw thenable.reason;
|
|
703
|
+
default:
|
|
704
|
+
switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
|
|
705
|
+
function(fulfilledValue) {
|
|
706
|
+
"pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
|
|
707
|
+
},
|
|
708
|
+
function(error) {
|
|
709
|
+
"pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
710
|
+
}
|
|
711
|
+
)), thenable.status) {
|
|
712
|
+
case "fulfilled":
|
|
713
|
+
return thenable.value;
|
|
714
|
+
case "rejected":
|
|
715
|
+
throw thenable.reason;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
throw thenable;
|
|
719
|
+
}
|
|
720
|
+
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
|
721
|
+
var type = typeof children;
|
|
722
|
+
if ("undefined" === type || "boolean" === type) children = null;
|
|
723
|
+
var invokeCallback = false;
|
|
724
|
+
if (null === children) invokeCallback = true;
|
|
725
|
+
else
|
|
726
|
+
switch (type) {
|
|
727
|
+
case "bigint":
|
|
728
|
+
case "string":
|
|
729
|
+
case "number":
|
|
730
|
+
invokeCallback = true;
|
|
731
|
+
break;
|
|
732
|
+
case "object":
|
|
733
|
+
switch (children.$$typeof) {
|
|
734
|
+
case REACT_ELEMENT_TYPE:
|
|
735
|
+
case REACT_PORTAL_TYPE:
|
|
736
|
+
invokeCallback = true;
|
|
737
|
+
break;
|
|
738
|
+
case REACT_LAZY_TYPE:
|
|
739
|
+
return invokeCallback = children._init, mapIntoArray(
|
|
740
|
+
invokeCallback(children._payload),
|
|
741
|
+
array,
|
|
742
|
+
escapedPrefix,
|
|
743
|
+
nameSoFar,
|
|
744
|
+
callback
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (invokeCallback) {
|
|
749
|
+
invokeCallback = children;
|
|
750
|
+
callback = callback(invokeCallback);
|
|
751
|
+
var childKey = "" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
|
|
752
|
+
isArrayImpl(callback) ? (escapedPrefix = "", null != childKey && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
|
|
753
|
+
return c;
|
|
754
|
+
})) : null != callback && (isValidElement(callback) && (null != callback.key && (invokeCallback && invokeCallback.key === callback.key || checkKeyStringCoercion(callback.key)), escapedPrefix = cloneAndReplaceKey(
|
|
755
|
+
callback,
|
|
756
|
+
escapedPrefix + (null == callback.key || invokeCallback && invokeCallback.key === callback.key ? "" : ("" + callback.key).replace(
|
|
757
|
+
userProvidedKeyEscapeRegex,
|
|
758
|
+
"$&/"
|
|
759
|
+
) + "/") + childKey
|
|
760
|
+
), "" !== nameSoFar && null != invokeCallback && isValidElement(invokeCallback) && null == invokeCallback.key && invokeCallback._store && !invokeCallback._store.validated && (escapedPrefix._store.validated = 2), callback = escapedPrefix), array.push(callback));
|
|
761
|
+
return 1;
|
|
762
|
+
}
|
|
763
|
+
invokeCallback = 0;
|
|
764
|
+
childKey = "" === nameSoFar ? "." : nameSoFar + ":";
|
|
765
|
+
if (isArrayImpl(children))
|
|
766
|
+
for (var i = 0; i < children.length; i++)
|
|
767
|
+
nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
|
|
768
|
+
nameSoFar,
|
|
769
|
+
array,
|
|
770
|
+
escapedPrefix,
|
|
771
|
+
type,
|
|
772
|
+
callback
|
|
773
|
+
);
|
|
774
|
+
else if (i = getIteratorFn(children), "function" === typeof i)
|
|
775
|
+
for (i === children.entries && (didWarnAboutMaps || console.warn(
|
|
776
|
+
"Using Maps as children is not supported. Use an array of keyed ReactElements instead."
|
|
777
|
+
), didWarnAboutMaps = true), children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
|
|
778
|
+
nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
|
|
779
|
+
nameSoFar,
|
|
780
|
+
array,
|
|
781
|
+
escapedPrefix,
|
|
782
|
+
type,
|
|
783
|
+
callback
|
|
784
|
+
);
|
|
785
|
+
else if ("object" === type) {
|
|
786
|
+
if ("function" === typeof children.then)
|
|
787
|
+
return mapIntoArray(
|
|
788
|
+
resolveThenable(children),
|
|
789
|
+
array,
|
|
790
|
+
escapedPrefix,
|
|
791
|
+
nameSoFar,
|
|
792
|
+
callback
|
|
793
|
+
);
|
|
794
|
+
array = String(children);
|
|
795
|
+
throw Error(
|
|
796
|
+
"Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead."
|
|
797
|
+
);
|
|
798
|
+
}
|
|
799
|
+
return invokeCallback;
|
|
800
|
+
}
|
|
801
|
+
function mapChildren(children, func, context) {
|
|
802
|
+
if (null == children) return children;
|
|
803
|
+
var result = [], count = 0;
|
|
804
|
+
mapIntoArray(children, result, "", "", function(child) {
|
|
805
|
+
return func.call(context, child, count++);
|
|
806
|
+
});
|
|
807
|
+
return result;
|
|
808
|
+
}
|
|
809
|
+
function lazyInitializer(payload) {
|
|
810
|
+
if (-1 === payload._status) {
|
|
811
|
+
var ioInfo = payload._ioInfo;
|
|
812
|
+
null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
|
|
813
|
+
ioInfo = payload._result;
|
|
814
|
+
var thenable = ioInfo();
|
|
815
|
+
thenable.then(
|
|
816
|
+
function(moduleObject) {
|
|
817
|
+
if (0 === payload._status || -1 === payload._status) {
|
|
818
|
+
payload._status = 1;
|
|
819
|
+
payload._result = moduleObject;
|
|
820
|
+
var _ioInfo = payload._ioInfo;
|
|
821
|
+
null != _ioInfo && (_ioInfo.end = performance.now());
|
|
822
|
+
void 0 === thenable.status && (thenable.status = "fulfilled", thenable.value = moduleObject);
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
function(error) {
|
|
826
|
+
if (0 === payload._status || -1 === payload._status) {
|
|
827
|
+
payload._status = 2;
|
|
828
|
+
payload._result = error;
|
|
829
|
+
var _ioInfo2 = payload._ioInfo;
|
|
830
|
+
null != _ioInfo2 && (_ioInfo2.end = performance.now());
|
|
831
|
+
void 0 === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
);
|
|
835
|
+
ioInfo = payload._ioInfo;
|
|
836
|
+
if (null != ioInfo) {
|
|
837
|
+
ioInfo.value = thenable;
|
|
838
|
+
var displayName = thenable.displayName;
|
|
839
|
+
"string" === typeof displayName && (ioInfo.name = displayName);
|
|
840
|
+
}
|
|
841
|
+
-1 === payload._status && (payload._status = 0, payload._result = thenable);
|
|
842
|
+
}
|
|
843
|
+
if (1 === payload._status)
|
|
844
|
+
return ioInfo = payload._result, void 0 === ioInfo && console.error(
|
|
845
|
+
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
|
|
846
|
+
ioInfo
|
|
847
|
+
), "default" in ioInfo || console.error(
|
|
848
|
+
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
|
|
849
|
+
ioInfo
|
|
850
|
+
), ioInfo.default;
|
|
851
|
+
throw payload._result;
|
|
852
|
+
}
|
|
853
|
+
function resolveDispatcher() {
|
|
854
|
+
var dispatcher = ReactSharedInternals.H;
|
|
855
|
+
null === dispatcher && console.error(
|
|
856
|
+
"Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
|
|
857
|
+
);
|
|
858
|
+
return dispatcher;
|
|
859
|
+
}
|
|
860
|
+
function releaseAsyncTransition() {
|
|
861
|
+
ReactSharedInternals.asyncTransitions--;
|
|
862
|
+
}
|
|
863
|
+
function enqueueTask(task) {
|
|
864
|
+
if (null === enqueueTaskImpl)
|
|
865
|
+
try {
|
|
866
|
+
var requireString = ("require" + Math.random()).slice(0, 7);
|
|
867
|
+
enqueueTaskImpl = (module && module[requireString]).call(
|
|
868
|
+
module,
|
|
869
|
+
"timers"
|
|
870
|
+
).setImmediate;
|
|
871
|
+
} catch (_err) {
|
|
872
|
+
enqueueTaskImpl = function(callback) {
|
|
873
|
+
false === didWarnAboutMessageChannel && (didWarnAboutMessageChannel = true, "undefined" === typeof MessageChannel && console.error(
|
|
874
|
+
"This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
|
|
875
|
+
));
|
|
876
|
+
var channel = new MessageChannel();
|
|
877
|
+
channel.port1.onmessage = callback;
|
|
878
|
+
channel.port2.postMessage(void 0);
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
return enqueueTaskImpl(task);
|
|
882
|
+
}
|
|
883
|
+
function aggregateErrors(errors) {
|
|
884
|
+
return 1 < errors.length && "function" === typeof AggregateError ? new AggregateError(errors) : errors[0];
|
|
885
|
+
}
|
|
886
|
+
function popActScope(prevActQueue, prevActScopeDepth) {
|
|
887
|
+
prevActScopeDepth !== actScopeDepth - 1 && console.error(
|
|
888
|
+
"You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
|
|
889
|
+
);
|
|
890
|
+
actScopeDepth = prevActScopeDepth;
|
|
891
|
+
}
|
|
892
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
|
|
893
|
+
var queue = ReactSharedInternals.actQueue;
|
|
894
|
+
if (null !== queue)
|
|
895
|
+
if (0 !== queue.length)
|
|
896
|
+
try {
|
|
897
|
+
flushActQueue(queue);
|
|
898
|
+
enqueueTask(function() {
|
|
899
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
|
900
|
+
});
|
|
901
|
+
return;
|
|
902
|
+
} catch (error) {
|
|
903
|
+
ReactSharedInternals.thrownErrors.push(error);
|
|
904
|
+
}
|
|
905
|
+
else ReactSharedInternals.actQueue = null;
|
|
906
|
+
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
|
|
907
|
+
}
|
|
908
|
+
function flushActQueue(queue) {
|
|
909
|
+
if (!isFlushing) {
|
|
910
|
+
isFlushing = true;
|
|
911
|
+
var i = 0;
|
|
912
|
+
try {
|
|
913
|
+
for (; i < queue.length; i++) {
|
|
914
|
+
var callback = queue[i];
|
|
915
|
+
do {
|
|
916
|
+
ReactSharedInternals.didUsePromise = false;
|
|
917
|
+
var continuation = callback(false);
|
|
918
|
+
if (null !== continuation) {
|
|
919
|
+
if (ReactSharedInternals.didUsePromise) {
|
|
920
|
+
queue[i] = callback;
|
|
921
|
+
queue.splice(0, i);
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
callback = continuation;
|
|
925
|
+
} else break;
|
|
926
|
+
} while (1);
|
|
927
|
+
}
|
|
928
|
+
queue.length = 0;
|
|
929
|
+
} catch (error) {
|
|
930
|
+
queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
|
|
931
|
+
} finally {
|
|
932
|
+
isFlushing = false;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
937
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
|
|
938
|
+
isMounted: function() {
|
|
939
|
+
return false;
|
|
940
|
+
},
|
|
941
|
+
enqueueForceUpdate: function(publicInstance) {
|
|
942
|
+
warnNoop(publicInstance, "forceUpdate");
|
|
943
|
+
},
|
|
944
|
+
enqueueReplaceState: function(publicInstance) {
|
|
945
|
+
warnNoop(publicInstance, "replaceState");
|
|
946
|
+
},
|
|
947
|
+
enqueueSetState: function(publicInstance) {
|
|
948
|
+
warnNoop(publicInstance, "setState");
|
|
949
|
+
}
|
|
950
|
+
}, assign = Object.assign, emptyObject = {};
|
|
951
|
+
Object.freeze(emptyObject);
|
|
952
|
+
Component.prototype.isReactComponent = {};
|
|
953
|
+
Component.prototype.setState = function(partialState, callback) {
|
|
954
|
+
if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
|
|
955
|
+
throw Error(
|
|
956
|
+
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
957
|
+
);
|
|
958
|
+
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
|
959
|
+
};
|
|
960
|
+
Component.prototype.forceUpdate = function(callback) {
|
|
961
|
+
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
|
962
|
+
};
|
|
963
|
+
var deprecatedAPIs = {
|
|
964
|
+
isMounted: [
|
|
965
|
+
"isMounted",
|
|
966
|
+
"Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
|
|
967
|
+
],
|
|
968
|
+
replaceState: [
|
|
969
|
+
"replaceState",
|
|
970
|
+
"Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
|
|
971
|
+
]
|
|
972
|
+
};
|
|
973
|
+
for (fnName in deprecatedAPIs)
|
|
974
|
+
deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
975
|
+
ComponentDummy.prototype = Component.prototype;
|
|
976
|
+
deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
|
|
977
|
+
deprecatedAPIs.constructor = PureComponent;
|
|
978
|
+
assign(deprecatedAPIs, Component.prototype);
|
|
979
|
+
deprecatedAPIs.isPureReactComponent = true;
|
|
980
|
+
var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = {
|
|
981
|
+
H: null,
|
|
982
|
+
A: null,
|
|
983
|
+
T: null,
|
|
984
|
+
S: null,
|
|
985
|
+
actQueue: null,
|
|
986
|
+
asyncTransitions: 0,
|
|
987
|
+
isBatchingLegacy: false,
|
|
988
|
+
didScheduleLegacyUpdate: false,
|
|
989
|
+
didUsePromise: false,
|
|
990
|
+
thrownErrors: [],
|
|
991
|
+
getCurrentStack: null,
|
|
992
|
+
recentlyCreatedOwnerStacks: 0
|
|
993
|
+
}, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
|
|
994
|
+
return null;
|
|
995
|
+
};
|
|
996
|
+
deprecatedAPIs = {
|
|
997
|
+
react_stack_bottom_frame: function(callStackForError) {
|
|
998
|
+
return callStackForError();
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
|
|
1002
|
+
var didWarnAboutElementRef = {};
|
|
1003
|
+
var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(
|
|
1004
|
+
deprecatedAPIs,
|
|
1005
|
+
UnknownOwner
|
|
1006
|
+
)();
|
|
1007
|
+
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
1008
|
+
var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
|
|
1009
|
+
if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
|
|
1010
|
+
var event = new window.ErrorEvent("error", {
|
|
1011
|
+
bubbles: true,
|
|
1012
|
+
cancelable: true,
|
|
1013
|
+
message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
|
|
1014
|
+
error
|
|
1015
|
+
});
|
|
1016
|
+
if (!window.dispatchEvent(event)) return;
|
|
1017
|
+
} else if ("object" === typeof process && "function" === typeof process.emit) {
|
|
1018
|
+
process.emit("uncaughtException", error);
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
console.error(error);
|
|
1022
|
+
}, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = "function" === typeof queueMicrotask ? function(callback) {
|
|
1023
|
+
queueMicrotask(function() {
|
|
1024
|
+
return queueMicrotask(callback);
|
|
1025
|
+
});
|
|
1026
|
+
} : enqueueTask;
|
|
1027
|
+
deprecatedAPIs = Object.freeze({
|
|
1028
|
+
__proto__: null,
|
|
1029
|
+
c: function(size) {
|
|
1030
|
+
return resolveDispatcher().useMemoCache(size);
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
var fnName = {
|
|
1034
|
+
map: mapChildren,
|
|
1035
|
+
forEach: function(children, forEachFunc, forEachContext) {
|
|
1036
|
+
mapChildren(
|
|
1037
|
+
children,
|
|
1038
|
+
function() {
|
|
1039
|
+
forEachFunc.apply(this, arguments);
|
|
1040
|
+
},
|
|
1041
|
+
forEachContext
|
|
1042
|
+
);
|
|
1043
|
+
},
|
|
1044
|
+
count: function(children) {
|
|
1045
|
+
var n = 0;
|
|
1046
|
+
mapChildren(children, function() {
|
|
1047
|
+
n++;
|
|
1048
|
+
});
|
|
1049
|
+
return n;
|
|
1050
|
+
},
|
|
1051
|
+
toArray: function(children) {
|
|
1052
|
+
return mapChildren(children, function(child) {
|
|
1053
|
+
return child;
|
|
1054
|
+
}) || [];
|
|
1055
|
+
},
|
|
1056
|
+
only: function(children) {
|
|
1057
|
+
if (!isValidElement(children))
|
|
1058
|
+
throw Error(
|
|
1059
|
+
"React.Children.only expected to receive a single React element child."
|
|
1060
|
+
);
|
|
1061
|
+
return children;
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
exports.Activity = REACT_ACTIVITY_TYPE;
|
|
1065
|
+
exports.Children = fnName;
|
|
1066
|
+
exports.Component = Component;
|
|
1067
|
+
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
1068
|
+
exports.Profiler = REACT_PROFILER_TYPE;
|
|
1069
|
+
exports.PureComponent = PureComponent;
|
|
1070
|
+
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
1071
|
+
exports.Suspense = REACT_SUSPENSE_TYPE;
|
|
1072
|
+
exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
|
|
1073
|
+
exports.__COMPILER_RUNTIME = deprecatedAPIs;
|
|
1074
|
+
exports.act = function(callback) {
|
|
1075
|
+
var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
|
|
1076
|
+
actScopeDepth++;
|
|
1077
|
+
var queue = ReactSharedInternals.actQueue = null !== prevActQueue ? prevActQueue : [], didAwaitActCall = false;
|
|
1078
|
+
try {
|
|
1079
|
+
var result = callback();
|
|
1080
|
+
} catch (error) {
|
|
1081
|
+
ReactSharedInternals.thrownErrors.push(error);
|
|
1082
|
+
}
|
|
1083
|
+
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
1084
|
+
throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
1085
|
+
if (null !== result && "object" === typeof result && "function" === typeof result.then) {
|
|
1086
|
+
var thenable = result;
|
|
1087
|
+
queueSeveralMicrotasks(function() {
|
|
1088
|
+
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
|
|
1089
|
+
"You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
|
|
1090
|
+
));
|
|
1091
|
+
});
|
|
1092
|
+
return {
|
|
1093
|
+
then: function(resolve, reject) {
|
|
1094
|
+
didAwaitActCall = true;
|
|
1095
|
+
thenable.then(
|
|
1096
|
+
function(returnValue) {
|
|
1097
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
1098
|
+
if (0 === prevActScopeDepth) {
|
|
1099
|
+
try {
|
|
1100
|
+
flushActQueue(queue), enqueueTask(function() {
|
|
1101
|
+
return recursivelyFlushAsyncActWork(
|
|
1102
|
+
returnValue,
|
|
1103
|
+
resolve,
|
|
1104
|
+
reject
|
|
1105
|
+
);
|
|
1106
|
+
});
|
|
1107
|
+
} catch (error$0) {
|
|
1108
|
+
ReactSharedInternals.thrownErrors.push(error$0);
|
|
1109
|
+
}
|
|
1110
|
+
if (0 < ReactSharedInternals.thrownErrors.length) {
|
|
1111
|
+
var _thrownError = aggregateErrors(
|
|
1112
|
+
ReactSharedInternals.thrownErrors
|
|
1113
|
+
);
|
|
1114
|
+
ReactSharedInternals.thrownErrors.length = 0;
|
|
1115
|
+
reject(_thrownError);
|
|
1116
|
+
}
|
|
1117
|
+
} else resolve(returnValue);
|
|
1118
|
+
},
|
|
1119
|
+
function(error) {
|
|
1120
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
1121
|
+
0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(
|
|
1122
|
+
ReactSharedInternals.thrownErrors
|
|
1123
|
+
), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
|
|
1124
|
+
}
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
var returnValue$jscomp$0 = result;
|
|
1130
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
1131
|
+
0 === prevActScopeDepth && (flushActQueue(queue), 0 !== queue.length && queueSeveralMicrotasks(function() {
|
|
1132
|
+
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
|
|
1133
|
+
"A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
|
|
1134
|
+
));
|
|
1135
|
+
}), ReactSharedInternals.actQueue = null);
|
|
1136
|
+
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
1137
|
+
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
1138
|
+
return {
|
|
1139
|
+
then: function(resolve, reject) {
|
|
1140
|
+
didAwaitActCall = true;
|
|
1141
|
+
0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
|
1142
|
+
return recursivelyFlushAsyncActWork(
|
|
1143
|
+
returnValue$jscomp$0,
|
|
1144
|
+
resolve,
|
|
1145
|
+
reject
|
|
1146
|
+
);
|
|
1147
|
+
})) : resolve(returnValue$jscomp$0);
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
};
|
|
1151
|
+
exports.cache = function(fn) {
|
|
1152
|
+
return function() {
|
|
1153
|
+
return fn.apply(null, arguments);
|
|
1154
|
+
};
|
|
1155
|
+
};
|
|
1156
|
+
exports.cacheSignal = function() {
|
|
1157
|
+
return null;
|
|
1158
|
+
};
|
|
1159
|
+
exports.captureOwnerStack = function() {
|
|
1160
|
+
var getCurrentStack = ReactSharedInternals.getCurrentStack;
|
|
1161
|
+
return null === getCurrentStack ? null : getCurrentStack();
|
|
1162
|
+
};
|
|
1163
|
+
exports.cloneElement = function(element, config, children) {
|
|
1164
|
+
if (null === element || void 0 === element)
|
|
1165
|
+
throw Error(
|
|
1166
|
+
"The argument must be a React element, but you passed " + element + "."
|
|
1167
|
+
);
|
|
1168
|
+
var props = assign({}, element.props), key = element.key, owner = element._owner;
|
|
1169
|
+
if (null != config) {
|
|
1170
|
+
var JSCompiler_inline_result;
|
|
1171
|
+
a: {
|
|
1172
|
+
if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
|
|
1173
|
+
config,
|
|
1174
|
+
"ref"
|
|
1175
|
+
).get) && JSCompiler_inline_result.isReactWarning) {
|
|
1176
|
+
JSCompiler_inline_result = false;
|
|
1177
|
+
break a;
|
|
1178
|
+
}
|
|
1179
|
+
JSCompiler_inline_result = void 0 !== config.ref;
|
|
1180
|
+
}
|
|
1181
|
+
JSCompiler_inline_result && (owner = getOwner());
|
|
1182
|
+
hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
|
|
1183
|
+
for (propName in config)
|
|
1184
|
+
!hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
|
|
1185
|
+
}
|
|
1186
|
+
var propName = arguments.length - 2;
|
|
1187
|
+
if (1 === propName) props.children = children;
|
|
1188
|
+
else if (1 < propName) {
|
|
1189
|
+
JSCompiler_inline_result = Array(propName);
|
|
1190
|
+
for (var i = 0; i < propName; i++)
|
|
1191
|
+
JSCompiler_inline_result[i] = arguments[i + 2];
|
|
1192
|
+
props.children = JSCompiler_inline_result;
|
|
1193
|
+
}
|
|
1194
|
+
props = ReactElement(
|
|
1195
|
+
element.type,
|
|
1196
|
+
key,
|
|
1197
|
+
props,
|
|
1198
|
+
owner,
|
|
1199
|
+
element._debugStack,
|
|
1200
|
+
element._debugTask
|
|
1201
|
+
);
|
|
1202
|
+
for (key = 2; key < arguments.length; key++)
|
|
1203
|
+
validateChildKeys(arguments[key]);
|
|
1204
|
+
return props;
|
|
1205
|
+
};
|
|
1206
|
+
exports.createContext = function(defaultValue) {
|
|
1207
|
+
defaultValue = {
|
|
1208
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
1209
|
+
_currentValue: defaultValue,
|
|
1210
|
+
_currentValue2: defaultValue,
|
|
1211
|
+
_threadCount: 0,
|
|
1212
|
+
Provider: null,
|
|
1213
|
+
Consumer: null
|
|
1214
|
+
};
|
|
1215
|
+
defaultValue.Provider = defaultValue;
|
|
1216
|
+
defaultValue.Consumer = {
|
|
1217
|
+
$$typeof: REACT_CONSUMER_TYPE,
|
|
1218
|
+
_context: defaultValue
|
|
1219
|
+
};
|
|
1220
|
+
defaultValue._currentRenderer = null;
|
|
1221
|
+
defaultValue._currentRenderer2 = null;
|
|
1222
|
+
return defaultValue;
|
|
1223
|
+
};
|
|
1224
|
+
exports.createElement = function(type, config, children) {
|
|
1225
|
+
for (var i = 2; i < arguments.length; i++)
|
|
1226
|
+
validateChildKeys(arguments[i]);
|
|
1227
|
+
i = {};
|
|
1228
|
+
var key = null;
|
|
1229
|
+
if (null != config)
|
|
1230
|
+
for (propName in didWarnAboutOldJSXRuntime || !("__self" in config) || "key" in config || (didWarnAboutOldJSXRuntime = true, console.warn(
|
|
1231
|
+
"Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
|
|
1232
|
+
)), hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key), config)
|
|
1233
|
+
hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (i[propName] = config[propName]);
|
|
1234
|
+
var childrenLength = arguments.length - 2;
|
|
1235
|
+
if (1 === childrenLength) i.children = children;
|
|
1236
|
+
else if (1 < childrenLength) {
|
|
1237
|
+
for (var childArray = Array(childrenLength), _i = 0; _i < childrenLength; _i++)
|
|
1238
|
+
childArray[_i] = arguments[_i + 2];
|
|
1239
|
+
Object.freeze && Object.freeze(childArray);
|
|
1240
|
+
i.children = childArray;
|
|
1241
|
+
}
|
|
1242
|
+
if (type && type.defaultProps)
|
|
1243
|
+
for (propName in childrenLength = type.defaultProps, childrenLength)
|
|
1244
|
+
void 0 === i[propName] && (i[propName] = childrenLength[propName]);
|
|
1245
|
+
key && defineKeyPropWarningGetter(
|
|
1246
|
+
i,
|
|
1247
|
+
"function" === typeof type ? type.displayName || type.name || "Unknown" : type
|
|
1248
|
+
);
|
|
1249
|
+
var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
1250
|
+
return ReactElement(
|
|
1251
|
+
type,
|
|
1252
|
+
key,
|
|
1253
|
+
i,
|
|
1254
|
+
getOwner(),
|
|
1255
|
+
propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
1256
|
+
propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
1257
|
+
);
|
|
1258
|
+
};
|
|
1259
|
+
exports.createRef = function() {
|
|
1260
|
+
var refObject = { current: null };
|
|
1261
|
+
Object.seal(refObject);
|
|
1262
|
+
return refObject;
|
|
1263
|
+
};
|
|
1264
|
+
exports.forwardRef = function(render) {
|
|
1265
|
+
null != render && render.$$typeof === REACT_MEMO_TYPE ? console.error(
|
|
1266
|
+
"forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
|
|
1267
|
+
) : "function" !== typeof render ? console.error(
|
|
1268
|
+
"forwardRef requires a render function but was given %s.",
|
|
1269
|
+
null === render ? "null" : typeof render
|
|
1270
|
+
) : 0 !== render.length && 2 !== render.length && console.error(
|
|
1271
|
+
"forwardRef render functions accept exactly two parameters: props and ref. %s",
|
|
1272
|
+
1 === render.length ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined."
|
|
1273
|
+
);
|
|
1274
|
+
null != render && null != render.defaultProps && console.error(
|
|
1275
|
+
"forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
|
|
1276
|
+
);
|
|
1277
|
+
var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
|
|
1278
|
+
Object.defineProperty(elementType, "displayName", {
|
|
1279
|
+
enumerable: false,
|
|
1280
|
+
configurable: true,
|
|
1281
|
+
get: function() {
|
|
1282
|
+
return ownName;
|
|
1283
|
+
},
|
|
1284
|
+
set: function(name) {
|
|
1285
|
+
ownName = name;
|
|
1286
|
+
render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1289
|
+
return elementType;
|
|
1290
|
+
};
|
|
1291
|
+
exports.isValidElement = isValidElement;
|
|
1292
|
+
exports.lazy = function(ctor) {
|
|
1293
|
+
ctor = { _status: -1, _result: ctor };
|
|
1294
|
+
var lazyType = {
|
|
1295
|
+
$$typeof: REACT_LAZY_TYPE,
|
|
1296
|
+
_payload: ctor,
|
|
1297
|
+
_init: lazyInitializer
|
|
1298
|
+
}, ioInfo = {
|
|
1299
|
+
name: "lazy",
|
|
1300
|
+
start: -1,
|
|
1301
|
+
end: -1,
|
|
1302
|
+
value: null,
|
|
1303
|
+
owner: null,
|
|
1304
|
+
debugStack: Error("react-stack-top-frame"),
|
|
1305
|
+
debugTask: console.createTask ? console.createTask("lazy()") : null
|
|
1306
|
+
};
|
|
1307
|
+
ctor._ioInfo = ioInfo;
|
|
1308
|
+
lazyType._debugInfo = [{ awaited: ioInfo }];
|
|
1309
|
+
return lazyType;
|
|
1310
|
+
};
|
|
1311
|
+
exports.memo = function(type, compare) {
|
|
1312
|
+
null == type && console.error(
|
|
1313
|
+
"memo: The first argument must be a component. Instead received: %s",
|
|
1314
|
+
null === type ? "null" : typeof type
|
|
1315
|
+
);
|
|
1316
|
+
compare = {
|
|
1317
|
+
$$typeof: REACT_MEMO_TYPE,
|
|
1318
|
+
type,
|
|
1319
|
+
compare: void 0 === compare ? null : compare
|
|
1320
|
+
};
|
|
1321
|
+
var ownName;
|
|
1322
|
+
Object.defineProperty(compare, "displayName", {
|
|
1323
|
+
enumerable: false,
|
|
1324
|
+
configurable: true,
|
|
1325
|
+
get: function() {
|
|
1326
|
+
return ownName;
|
|
1327
|
+
},
|
|
1328
|
+
set: function(name) {
|
|
1329
|
+
ownName = name;
|
|
1330
|
+
type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
return compare;
|
|
1334
|
+
};
|
|
1335
|
+
exports.startTransition = function(scope) {
|
|
1336
|
+
var prevTransition = ReactSharedInternals.T, currentTransition = {};
|
|
1337
|
+
currentTransition._updatedFibers = /* @__PURE__ */ new Set();
|
|
1338
|
+
ReactSharedInternals.T = currentTransition;
|
|
1339
|
+
try {
|
|
1340
|
+
var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
|
|
1341
|
+
null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
|
|
1342
|
+
"object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
|
|
1343
|
+
} catch (error) {
|
|
1344
|
+
reportGlobalError(error);
|
|
1345
|
+
} finally {
|
|
1346
|
+
null === prevTransition && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn(
|
|
1347
|
+
"Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
|
|
1348
|
+
)), null !== prevTransition && null !== currentTransition.types && (null !== prevTransition.types && prevTransition.types !== currentTransition.types && console.error(
|
|
1349
|
+
"We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
|
|
1350
|
+
), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
exports.unstable_useCacheRefresh = function() {
|
|
1354
|
+
return resolveDispatcher().useCacheRefresh();
|
|
1355
|
+
};
|
|
1356
|
+
exports.use = function(usable) {
|
|
1357
|
+
return resolveDispatcher().use(usable);
|
|
1358
|
+
};
|
|
1359
|
+
exports.useActionState = function(action, initialState, permalink) {
|
|
1360
|
+
return resolveDispatcher().useActionState(
|
|
1361
|
+
action,
|
|
1362
|
+
initialState,
|
|
1363
|
+
permalink
|
|
1364
|
+
);
|
|
1365
|
+
};
|
|
1366
|
+
exports.useCallback = function(callback, deps) {
|
|
1367
|
+
return resolveDispatcher().useCallback(callback, deps);
|
|
1368
|
+
};
|
|
1369
|
+
exports.useContext = function(Context) {
|
|
1370
|
+
var dispatcher = resolveDispatcher();
|
|
1371
|
+
Context.$$typeof === REACT_CONSUMER_TYPE && console.error(
|
|
1372
|
+
"Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
|
|
1373
|
+
);
|
|
1374
|
+
return dispatcher.useContext(Context);
|
|
1375
|
+
};
|
|
1376
|
+
exports.useDebugValue = function(value, formatterFn) {
|
|
1377
|
+
return resolveDispatcher().useDebugValue(value, formatterFn);
|
|
1378
|
+
};
|
|
1379
|
+
exports.useDeferredValue = function(value, initialValue) {
|
|
1380
|
+
return resolveDispatcher().useDeferredValue(value, initialValue);
|
|
1381
|
+
};
|
|
1382
|
+
exports.useEffect = function(create, deps) {
|
|
1383
|
+
null == create && console.warn(
|
|
1384
|
+
"React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1385
|
+
);
|
|
1386
|
+
return resolveDispatcher().useEffect(create, deps);
|
|
1387
|
+
};
|
|
1388
|
+
exports.useEffectEvent = function(callback) {
|
|
1389
|
+
return resolveDispatcher().useEffectEvent(callback);
|
|
1390
|
+
};
|
|
1391
|
+
exports.useId = function() {
|
|
1392
|
+
return resolveDispatcher().useId();
|
|
1393
|
+
};
|
|
1394
|
+
exports.useImperativeHandle = function(ref, create, deps) {
|
|
1395
|
+
return resolveDispatcher().useImperativeHandle(ref, create, deps);
|
|
1396
|
+
};
|
|
1397
|
+
exports.useInsertionEffect = function(create, deps) {
|
|
1398
|
+
null == create && console.warn(
|
|
1399
|
+
"React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1400
|
+
);
|
|
1401
|
+
return resolveDispatcher().useInsertionEffect(create, deps);
|
|
1402
|
+
};
|
|
1403
|
+
exports.useLayoutEffect = function(create, deps) {
|
|
1404
|
+
null == create && console.warn(
|
|
1405
|
+
"React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1406
|
+
);
|
|
1407
|
+
return resolveDispatcher().useLayoutEffect(create, deps);
|
|
1408
|
+
};
|
|
1409
|
+
exports.useMemo = function(create, deps) {
|
|
1410
|
+
return resolveDispatcher().useMemo(create, deps);
|
|
1411
|
+
};
|
|
1412
|
+
exports.useOptimistic = function(passthrough, reducer) {
|
|
1413
|
+
return resolveDispatcher().useOptimistic(passthrough, reducer);
|
|
1414
|
+
};
|
|
1415
|
+
exports.useReducer = function(reducer, initialArg, init) {
|
|
1416
|
+
return resolveDispatcher().useReducer(reducer, initialArg, init);
|
|
1417
|
+
};
|
|
1418
|
+
exports.useRef = function(initialValue) {
|
|
1419
|
+
return resolveDispatcher().useRef(initialValue);
|
|
1420
|
+
};
|
|
1421
|
+
exports.useState = function(initialState) {
|
|
1422
|
+
return resolveDispatcher().useState(initialState);
|
|
1423
|
+
};
|
|
1424
|
+
exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
|
|
1425
|
+
return resolveDispatcher().useSyncExternalStore(
|
|
1426
|
+
subscribe,
|
|
1427
|
+
getSnapshot,
|
|
1428
|
+
getServerSnapshot
|
|
1429
|
+
);
|
|
1430
|
+
};
|
|
1431
|
+
exports.useTransition = function() {
|
|
1432
|
+
return resolveDispatcher().useTransition();
|
|
1433
|
+
};
|
|
1434
|
+
exports.version = "19.2.0";
|
|
1435
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
1436
|
+
}();
|
|
1437
|
+
}
|
|
1438
|
+
});
|
|
1439
|
+
|
|
1440
|
+
// ../../node_modules/.pnpm/react@19.2.0/node_modules/react/index.js
|
|
1441
|
+
var require_react = __commonJS({
|
|
1442
|
+
"../../node_modules/.pnpm/react@19.2.0/node_modules/react/index.js"(exports, module) {
|
|
1443
|
+
"use strict";
|
|
1444
|
+
if (process.env.NODE_ENV === "production") {
|
|
1445
|
+
module.exports = require_react_production();
|
|
1446
|
+
} else {
|
|
1447
|
+
module.exports = require_react_development();
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
});
|
|
1451
|
+
|
|
1452
|
+
// src/react/useTokenList.ts
|
|
1453
|
+
var import_react = __toESM(require_react(), 1);
|
|
1454
|
+
|
|
1455
|
+
// src/core/token-list.ts
|
|
1456
|
+
import { getTokenList as intentsGetTokenList } from "@shogun-sdk/intents-sdk";
|
|
1457
|
+
async function getTokenList(params) {
|
|
1458
|
+
return intentsGetTokenList(params);
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
// src/react/useTokenList.ts
|
|
1462
|
+
var tokenCache = /* @__PURE__ */ new Map();
|
|
1463
|
+
function useTokenList(params) {
|
|
1464
|
+
const [data, setData] = (0, import_react.useState)(null);
|
|
1465
|
+
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
1466
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
1467
|
+
const controllerRef = (0, import_react.useRef)(null);
|
|
1468
|
+
const debounceRef = (0, import_react.useRef)(null);
|
|
1469
|
+
const debounceMs = params.debounceMs ?? 250;
|
|
1470
|
+
const cacheKey = (0, import_react.useMemo)(() => {
|
|
1471
|
+
return JSON.stringify({
|
|
1472
|
+
q: params.q?.trim().toLowerCase() ?? "",
|
|
1473
|
+
networkId: params.networkId ?? "all",
|
|
1474
|
+
page: params.page ?? 1,
|
|
1475
|
+
limit: params.limit ?? 50
|
|
1476
|
+
});
|
|
1477
|
+
}, [params.q, params.networkId, params.page, params.limit]);
|
|
1478
|
+
async function fetchTokens(signal) {
|
|
1479
|
+
if (tokenCache.has(cacheKey)) {
|
|
1480
|
+
setData(tokenCache.get(cacheKey));
|
|
1481
|
+
setLoading(false);
|
|
1482
|
+
setError(null);
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
try {
|
|
1486
|
+
setLoading(true);
|
|
1487
|
+
const result = await getTokenList({ ...params, signal });
|
|
1488
|
+
tokenCache.set(cacheKey, result);
|
|
1489
|
+
setData(result);
|
|
1490
|
+
setError(null);
|
|
1491
|
+
} catch (err) {
|
|
1492
|
+
if (err.name !== "AbortError") {
|
|
1493
|
+
const e = err instanceof Error ? err : new Error("Unknown error while fetching tokens");
|
|
1494
|
+
setError(e);
|
|
1495
|
+
}
|
|
1496
|
+
} finally {
|
|
1497
|
+
setLoading(false);
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
(0, import_react.useEffect)(() => {
|
|
1501
|
+
if (!params.q && !params.networkId) return;
|
|
1502
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
1503
|
+
if (controllerRef.current) controllerRef.current.abort();
|
|
1504
|
+
const controller = new AbortController();
|
|
1505
|
+
controllerRef.current = controller;
|
|
1506
|
+
debounceRef.current = setTimeout(() => {
|
|
1507
|
+
fetchTokens(controller.signal);
|
|
1508
|
+
}, debounceMs);
|
|
1509
|
+
return () => {
|
|
1510
|
+
controller.abort();
|
|
1511
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
1512
|
+
};
|
|
1513
|
+
}, [cacheKey, debounceMs]);
|
|
1514
|
+
return (0, import_react.useMemo)(
|
|
1515
|
+
() => ({
|
|
1516
|
+
/** Current fetched data (cached when possible) */
|
|
1517
|
+
data,
|
|
1518
|
+
/** Whether a request is in progress */
|
|
1519
|
+
loading,
|
|
1520
|
+
/** Error object if a request failed */
|
|
1521
|
+
error,
|
|
1522
|
+
/** Manually refetch the token list */
|
|
1523
|
+
refetch: () => fetchTokens(),
|
|
1524
|
+
/** Clear all cached token results (shared across hook instances) */
|
|
1525
|
+
clearCache: () => tokenCache.clear()
|
|
1526
|
+
}),
|
|
1527
|
+
[data, loading, error]
|
|
1528
|
+
);
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
// src/react/useExecuteOrder.ts
|
|
1532
|
+
var import_react2 = __toESM(require_react(), 1);
|
|
1533
|
+
|
|
1534
|
+
// src/core/executeOrder/execute.ts
|
|
1535
|
+
import { ChainID as ChainID4, isEvmChain as isEvmChain2 } from "@shogun-sdk/intents-sdk";
|
|
1536
|
+
import { BaseError } from "viem";
|
|
1537
|
+
|
|
1538
|
+
// src/utils/address.ts
|
|
1539
|
+
var NATIVE_TOKEN = {
|
|
1540
|
+
ETH: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
1541
|
+
SOL: "So11111111111111111111111111111111111111111",
|
|
1542
|
+
SUI: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"
|
|
1543
|
+
};
|
|
1544
|
+
var isNativeAddress = (tokenAddress) => {
|
|
1545
|
+
const NATIVE_ADDRESSES = Object.values(SupportedChains).map((chain) => chain.tokenAddress.toLowerCase());
|
|
1546
|
+
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
|
1547
|
+
return !!tokenAddress && NATIVE_ADDRESSES.includes(normalizedTokenAddress);
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
// src/utils/chain.ts
|
|
1551
|
+
import { ChainID } from "@shogun-sdk/intents-sdk";
|
|
1552
|
+
var SOLANA_CHAIN_ID = ChainID.Solana;
|
|
1553
|
+
var SupportedChains = [
|
|
1554
|
+
{
|
|
1555
|
+
id: ChainID.Arbitrum,
|
|
1556
|
+
name: "Arbitrum",
|
|
1557
|
+
isEVM: true,
|
|
1558
|
+
wrapped: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
1559
|
+
symbol: "ETH",
|
|
1560
|
+
decimals: 18,
|
|
1561
|
+
tokenAddress: NATIVE_TOKEN.ETH
|
|
1562
|
+
},
|
|
1563
|
+
{
|
|
1564
|
+
id: ChainID.Optimism,
|
|
1565
|
+
name: "Optimism",
|
|
1566
|
+
isEVM: true,
|
|
1567
|
+
wrapped: "0x4200000000000000000000000000000000000006",
|
|
1568
|
+
symbol: "ETH",
|
|
1569
|
+
decimals: 18,
|
|
1570
|
+
tokenAddress: NATIVE_TOKEN.ETH
|
|
1571
|
+
},
|
|
1572
|
+
{
|
|
1573
|
+
id: ChainID.Base,
|
|
1574
|
+
name: "Base",
|
|
1575
|
+
isEVM: true,
|
|
1576
|
+
wrapped: "0x4200000000000000000000000000000000000006",
|
|
1577
|
+
symbol: "ETH",
|
|
1578
|
+
decimals: 18,
|
|
1579
|
+
tokenAddress: NATIVE_TOKEN.ETH
|
|
1580
|
+
},
|
|
1581
|
+
{
|
|
1582
|
+
id: ChainID.Hyperliquid,
|
|
1583
|
+
name: "Hyperliquid",
|
|
1584
|
+
isEVM: true,
|
|
1585
|
+
wrapped: "0x5555555555555555555555555555555555555555",
|
|
1586
|
+
symbol: "ETH",
|
|
1587
|
+
decimals: 18,
|
|
1588
|
+
tokenAddress: NATIVE_TOKEN.ETH
|
|
1589
|
+
},
|
|
1590
|
+
{
|
|
1591
|
+
id: ChainID.BSC,
|
|
1592
|
+
name: "BSC",
|
|
1593
|
+
isEVM: true,
|
|
1594
|
+
wrapped: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
|
|
1595
|
+
symbol: "BNB",
|
|
1596
|
+
decimals: 18,
|
|
1597
|
+
tokenAddress: NATIVE_TOKEN.ETH
|
|
1598
|
+
},
|
|
1599
|
+
{
|
|
1600
|
+
id: SOLANA_CHAIN_ID,
|
|
1601
|
+
name: "Solana",
|
|
1602
|
+
isEVM: false,
|
|
1603
|
+
wrapped: "So11111111111111111111111111111111111111112",
|
|
1604
|
+
symbol: "SOL",
|
|
1605
|
+
decimals: 9,
|
|
1606
|
+
tokenAddress: NATIVE_TOKEN.SOL
|
|
1607
|
+
}
|
|
1608
|
+
];
|
|
1609
|
+
|
|
1610
|
+
// src/utils/viem.ts
|
|
1611
|
+
function isViemWalletClient(wallet) {
|
|
1612
|
+
return wallet.extend !== void 0 && wallet.getPermissions !== void 0;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
// src/utils/number.ts
|
|
1616
|
+
function serializeBigIntsToStrings(obj) {
|
|
1617
|
+
if (typeof obj === "bigint") {
|
|
1618
|
+
return obj.toString();
|
|
1619
|
+
}
|
|
1620
|
+
if (typeof obj === "string" && /^\d+n$/.test(obj)) {
|
|
1621
|
+
return obj.slice(0, -1);
|
|
1622
|
+
}
|
|
1623
|
+
if (Array.isArray(obj)) {
|
|
1624
|
+
return obj.map((item) => serializeBigIntsToStrings(item));
|
|
1625
|
+
}
|
|
1626
|
+
if (obj && typeof obj === "object") {
|
|
1627
|
+
const result = {};
|
|
1628
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1629
|
+
result[key] = serializeBigIntsToStrings(value);
|
|
1630
|
+
}
|
|
1631
|
+
return result;
|
|
1632
|
+
}
|
|
1633
|
+
return obj;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
// src/wallet-adapter/evm-wallet-adapter/adapter.ts
|
|
1637
|
+
import "ethers/lib/ethers.js";
|
|
1638
|
+
import { hexValue } from "ethers/lib/utils.js";
|
|
1639
|
+
import {
|
|
1640
|
+
custom
|
|
1641
|
+
} from "viem";
|
|
1642
|
+
function isEVMTransaction(tx) {
|
|
1643
|
+
return typeof tx.from === "string";
|
|
1644
|
+
}
|
|
1645
|
+
var adaptViemWallet = (wallet) => {
|
|
1646
|
+
const signTypedData = async (signData) => {
|
|
1647
|
+
return await wallet.signTypedData({
|
|
1648
|
+
account: wallet.account,
|
|
1649
|
+
domain: signData.domain,
|
|
1650
|
+
types: signData.types,
|
|
1651
|
+
primaryType: signData.primaryType ?? "Order",
|
|
1652
|
+
message: signData.value
|
|
1653
|
+
});
|
|
1654
|
+
};
|
|
1655
|
+
const sendTransaction = async (transaction) => {
|
|
1656
|
+
if (!isEVMTransaction(transaction)) {
|
|
1657
|
+
throw new Error("Expected EVMTransaction but got SolanaTransaction");
|
|
1658
|
+
}
|
|
1659
|
+
const tx = await wallet.sendTransaction({
|
|
1660
|
+
from: transaction.from,
|
|
1661
|
+
to: transaction.to,
|
|
1662
|
+
data: transaction.data,
|
|
1663
|
+
value: transaction.value,
|
|
1664
|
+
account: wallet.account?.address,
|
|
1665
|
+
chain: wallet.chain
|
|
1666
|
+
});
|
|
1667
|
+
return tx;
|
|
1668
|
+
};
|
|
1669
|
+
const switchChain = async (chainId) => {
|
|
1670
|
+
try {
|
|
1671
|
+
await wallet.switchChain({ id: chainId });
|
|
1672
|
+
} catch (e) {
|
|
1673
|
+
const msg = e?.message || "";
|
|
1674
|
+
if (msg.includes("does not support the requested chain")) {
|
|
1675
|
+
throw new Error("Wallet does not support this chain");
|
|
1676
|
+
}
|
|
1677
|
+
if (msg.includes("rejected")) throw e;
|
|
1678
|
+
if (msg.includes("already pending")) return;
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
const address = async () => {
|
|
1682
|
+
let addr = wallet.account?.address;
|
|
1683
|
+
if (!addr) {
|
|
1684
|
+
const addresses = await wallet.getAddresses();
|
|
1685
|
+
addr = addresses[0];
|
|
1686
|
+
}
|
|
1687
|
+
if (!addr) throw new Error("No address found");
|
|
1688
|
+
return addr;
|
|
1689
|
+
};
|
|
1690
|
+
return {
|
|
1691
|
+
vmType: "EVM" /* EVM */,
|
|
1692
|
+
transport: custom(wallet.transport),
|
|
1693
|
+
getChainId: async () => wallet.getChainId(),
|
|
1694
|
+
address,
|
|
1695
|
+
sendTransaction,
|
|
1696
|
+
signTypedData,
|
|
1697
|
+
switchChain
|
|
1698
|
+
};
|
|
1699
|
+
};
|
|
1700
|
+
|
|
1701
|
+
// src/core/executeOrder/handleEvmExecution.ts
|
|
1702
|
+
import {
|
|
1703
|
+
getEVMSingleChainOrderTypedData,
|
|
1704
|
+
getEVMCrossChainOrderTypedData,
|
|
1705
|
+
PERMIT2_ADDRESS
|
|
1706
|
+
} from "@shogun-sdk/intents-sdk";
|
|
1707
|
+
import { encodeFunctionData, erc20Abi } from "viem";
|
|
1708
|
+
|
|
1709
|
+
// src/core/executeOrder/normalizeNative.ts
|
|
1710
|
+
import { isEvmChain } from "@shogun-sdk/intents-sdk";
|
|
1711
|
+
function normalizeNative(chainId, address) {
|
|
1712
|
+
if (isEvmChain(chainId) && isNativeAddress(address)) {
|
|
1713
|
+
const chain = SupportedChains.find((c) => c.id === chainId);
|
|
1714
|
+
if (!chain?.wrapped)
|
|
1715
|
+
throw new Error(`Wrapped token not found for chainId ${chainId}`);
|
|
1716
|
+
return chain.wrapped;
|
|
1717
|
+
}
|
|
1718
|
+
return address;
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
// src/core/executeOrder/stageMessages.ts
|
|
1722
|
+
var DEFAULT_STAGE_MESSAGES = {
|
|
1723
|
+
processing: "Preparing transaction for execution",
|
|
1724
|
+
approving: "Approving token allowance",
|
|
1725
|
+
approved: "Token approved successfully",
|
|
1726
|
+
signing: "Signing order for submission",
|
|
1727
|
+
submitting: "Submitting order to Auctioneer",
|
|
1728
|
+
success: "Order executed successfully",
|
|
1729
|
+
error: "Order execution failed"
|
|
1730
|
+
};
|
|
1731
|
+
|
|
1732
|
+
// src/core/executeOrder/buildOrder.ts
|
|
1733
|
+
import { CrossChainOrder, SingleChainOrder } from "@shogun-sdk/intents-sdk";
|
|
1734
|
+
async function buildOrder({
|
|
1735
|
+
quote,
|
|
1736
|
+
accountAddress,
|
|
1737
|
+
destination,
|
|
1738
|
+
deadline,
|
|
1739
|
+
isSingleChain
|
|
1740
|
+
}) {
|
|
1741
|
+
const { tokenIn, tokenOut } = quote;
|
|
1742
|
+
if (isSingleChain) {
|
|
1743
|
+
return await SingleChainOrder.create({
|
|
1744
|
+
user: accountAddress,
|
|
1745
|
+
chainId: tokenIn.chainId,
|
|
1746
|
+
tokenIn: tokenIn.address,
|
|
1747
|
+
tokenOut: tokenOut.address,
|
|
1748
|
+
amountIn: quote.amountIn,
|
|
1749
|
+
amountOutMin: quote.internal.estimatedAmountOutReduced,
|
|
1750
|
+
deadline,
|
|
1751
|
+
destinationAddress: destination
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1754
|
+
return await CrossChainOrder.create({
|
|
1755
|
+
user: accountAddress,
|
|
1756
|
+
sourceChainId: tokenIn.chainId,
|
|
1757
|
+
sourceTokenAddress: tokenIn.address,
|
|
1758
|
+
sourceTokenAmount: quote.amountIn,
|
|
1759
|
+
destinationChainId: tokenOut.chainId,
|
|
1760
|
+
destinationTokenAddress: tokenOut.address,
|
|
1761
|
+
destinationAddress: destination,
|
|
1762
|
+
deadline,
|
|
1763
|
+
destinationTokenMinAmount: quote.internal.estimatedAmountOutReduced,
|
|
1764
|
+
minStablecoinAmount: quote.minStablecoinsAmount
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
// src/core/executeOrder/handleEvmExecution.ts
|
|
1769
|
+
async function handleEvmExecution({
|
|
1770
|
+
recipientAddress,
|
|
1771
|
+
quote,
|
|
1772
|
+
chainId,
|
|
1773
|
+
accountAddress,
|
|
1774
|
+
wallet,
|
|
1775
|
+
isSingleChain,
|
|
1776
|
+
deadline,
|
|
1777
|
+
update
|
|
1778
|
+
}) {
|
|
1779
|
+
const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
|
|
1780
|
+
await wallet.switchChain(chainId);
|
|
1781
|
+
const tokenIn = normalizeNative(chainId, quote.tokenIn.address);
|
|
1782
|
+
const shouldWrapNative = isNativeAddress(quote.tokenIn.address);
|
|
1783
|
+
update("processing", shouldWrapNative ? `${messageFor("processing")} (wrapping native token)` : messageFor("processing"));
|
|
1784
|
+
if (shouldWrapNative) {
|
|
1785
|
+
await wallet.sendTransaction({
|
|
1786
|
+
to: tokenIn,
|
|
1787
|
+
data: encodeFunctionData({
|
|
1788
|
+
abi: [{ type: "function", name: "deposit", stateMutability: "payable", inputs: [], outputs: [] }],
|
|
1789
|
+
functionName: "deposit",
|
|
1790
|
+
args: []
|
|
1791
|
+
}),
|
|
1792
|
+
value: BigInt(quote.amountIn),
|
|
1793
|
+
from: accountAddress
|
|
1794
|
+
});
|
|
1795
|
+
}
|
|
1796
|
+
update("approving", messageFor("approving"));
|
|
1797
|
+
await wallet.sendTransaction({
|
|
1798
|
+
to: tokenIn,
|
|
1799
|
+
data: encodeFunctionData({
|
|
1800
|
+
abi: erc20Abi,
|
|
1801
|
+
functionName: "approve",
|
|
1802
|
+
args: [PERMIT2_ADDRESS[chainId], BigInt(quote.amountIn)]
|
|
1803
|
+
}),
|
|
1804
|
+
value: 0n,
|
|
1805
|
+
from: accountAddress
|
|
1806
|
+
});
|
|
1807
|
+
update("approved", messageFor("approved"));
|
|
1808
|
+
const destination = recipientAddress ?? accountAddress;
|
|
1809
|
+
const order = await buildOrder({
|
|
1810
|
+
quote,
|
|
1811
|
+
accountAddress,
|
|
1812
|
+
destination,
|
|
1813
|
+
deadline,
|
|
1814
|
+
isSingleChain
|
|
1815
|
+
});
|
|
1816
|
+
update("signing", messageFor("signing"));
|
|
1817
|
+
const { orderTypedData, nonce } = isSingleChain ? await getEVMSingleChainOrderTypedData(order) : await getEVMCrossChainOrderTypedData(order);
|
|
1818
|
+
if (!wallet.signTypedData) {
|
|
1819
|
+
throw new Error("Wallet does not support EIP-712 signing");
|
|
1820
|
+
}
|
|
1821
|
+
const signature = await wallet.signTypedData(serializeBigIntsToStrings(orderTypedData));
|
|
1822
|
+
update("submitting", messageFor("submitting"));
|
|
1823
|
+
const res = await order.sendToAuctioneer({ signature, nonce: nonce.toString() });
|
|
1824
|
+
if (!res.success) {
|
|
1825
|
+
throw new Error("Auctioneer submission failed");
|
|
1826
|
+
}
|
|
1827
|
+
update("success", messageFor("success"));
|
|
1828
|
+
return { status: true, txHash: res.data, chainId, stage: "success" };
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
// src/core/executeOrder/handleSolanaExecution.ts
|
|
1832
|
+
import {
|
|
1833
|
+
ChainID as ChainID3,
|
|
1834
|
+
getSolanaSingleChainOrderInstructions,
|
|
1835
|
+
getSolanaCrossChainOrderInstructions
|
|
1836
|
+
} from "@shogun-sdk/intents-sdk";
|
|
1837
|
+
import { VersionedTransaction } from "@solana/web3.js";
|
|
1838
|
+
async function handleSolanaExecution({
|
|
1839
|
+
recipientAddress,
|
|
1840
|
+
quote,
|
|
1841
|
+
wallet,
|
|
1842
|
+
isSingleChain,
|
|
1843
|
+
update,
|
|
1844
|
+
accountAddress,
|
|
1845
|
+
deadline
|
|
1846
|
+
}) {
|
|
1847
|
+
if (!wallet.rpcUrl) {
|
|
1848
|
+
throw new Error("Solana wallet is missing rpcUrl");
|
|
1849
|
+
}
|
|
1850
|
+
const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
|
|
1851
|
+
update("processing", messageFor("processing"));
|
|
1852
|
+
const destination = recipientAddress ?? accountAddress;
|
|
1853
|
+
const order = await buildOrder({
|
|
1854
|
+
quote,
|
|
1855
|
+
accountAddress,
|
|
1856
|
+
destination,
|
|
1857
|
+
deadline,
|
|
1858
|
+
isSingleChain
|
|
1859
|
+
});
|
|
1860
|
+
const txData = await getSolanaOrderInstructions({
|
|
1861
|
+
order,
|
|
1862
|
+
isSingleChain,
|
|
1863
|
+
rpcUrl: wallet.rpcUrl
|
|
1864
|
+
});
|
|
1865
|
+
const transaction = VersionedTransaction.deserialize(Uint8Array.from(txData.txBytes));
|
|
1866
|
+
update("signing", messageFor("signing"));
|
|
1867
|
+
console.log({ order });
|
|
1868
|
+
const txSignature = await wallet.sendTransaction(transaction);
|
|
1869
|
+
update("submitting", messageFor("submitting"));
|
|
1870
|
+
const response = await submitToAuctioneer({
|
|
1871
|
+
order,
|
|
1872
|
+
isSingleChain,
|
|
1873
|
+
txData
|
|
1874
|
+
});
|
|
1875
|
+
if (!response.success) {
|
|
1876
|
+
throw new Error("Auctioneer submission failed");
|
|
1877
|
+
}
|
|
1878
|
+
update("success", messageFor("success"));
|
|
1879
|
+
return {
|
|
1880
|
+
status: true,
|
|
1881
|
+
txHash: txSignature,
|
|
1882
|
+
chainId: ChainID3.Solana,
|
|
1883
|
+
stage: "success"
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
async function getSolanaOrderInstructions({
|
|
1887
|
+
order,
|
|
1888
|
+
isSingleChain,
|
|
1889
|
+
rpcUrl
|
|
1890
|
+
}) {
|
|
1891
|
+
if (isSingleChain) {
|
|
1892
|
+
return await getSolanaSingleChainOrderInstructions(order, {
|
|
1893
|
+
rpcUrl
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
return await getSolanaCrossChainOrderInstructions(order, {
|
|
1897
|
+
rpcUrl
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
async function submitToAuctioneer({
|
|
1901
|
+
order,
|
|
1902
|
+
isSingleChain,
|
|
1903
|
+
txData
|
|
1904
|
+
}) {
|
|
1905
|
+
if (isSingleChain) {
|
|
1906
|
+
const { orderAddress, secretNumber } = txData;
|
|
1907
|
+
return await order.sendToAuctioneer({
|
|
1908
|
+
orderPubkey: orderAddress,
|
|
1909
|
+
secretNumber
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
return await order.sendToAuctioneer({
|
|
1913
|
+
orderPubkey: txData.orderAddress
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
// src/core/executeOrder/execute.ts
|
|
1918
|
+
async function executeOrder({
|
|
1919
|
+
quote,
|
|
1920
|
+
accountAddress,
|
|
1921
|
+
recipientAddress,
|
|
1922
|
+
wallet,
|
|
1923
|
+
onStatus,
|
|
1924
|
+
options = {}
|
|
1925
|
+
}) {
|
|
1926
|
+
const deadline = options.deadline ?? Math.floor(Date.now() / 1e3) + 20 * 60;
|
|
1927
|
+
const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
|
|
1928
|
+
const update = (stage, message) => onStatus?.(stage, message ?? messageFor(stage));
|
|
1929
|
+
try {
|
|
1930
|
+
const adapter = normalizeWallet(wallet);
|
|
1931
|
+
if (!adapter) throw new Error("No wallet provided");
|
|
1932
|
+
const { tokenIn, tokenOut } = quote;
|
|
1933
|
+
const isSingleChain = tokenIn.chainId === tokenOut.chainId;
|
|
1934
|
+
const chainId = Number(tokenIn.chainId);
|
|
1935
|
+
update("processing", messageFor("processing"));
|
|
1936
|
+
if (isEvmChain2(chainId)) {
|
|
1937
|
+
return await handleEvmExecution({
|
|
1938
|
+
recipientAddress,
|
|
1939
|
+
quote,
|
|
1940
|
+
chainId,
|
|
1941
|
+
accountAddress,
|
|
1942
|
+
wallet: adapter,
|
|
1943
|
+
isSingleChain,
|
|
1944
|
+
deadline,
|
|
1945
|
+
update
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
if (chainId === ChainID4.Solana) {
|
|
1949
|
+
return await handleSolanaExecution({
|
|
1950
|
+
recipientAddress,
|
|
1951
|
+
quote,
|
|
1952
|
+
accountAddress,
|
|
1953
|
+
wallet: adapter,
|
|
1954
|
+
isSingleChain,
|
|
1955
|
+
deadline,
|
|
1956
|
+
update
|
|
1957
|
+
});
|
|
1958
|
+
}
|
|
1959
|
+
update("error", "Unsupported chain");
|
|
1960
|
+
return { status: false, message: "Unsupported chain", stage: "error" };
|
|
1961
|
+
} catch (error) {
|
|
1962
|
+
const message = error instanceof BaseError ? error.shortMessage : error instanceof Error ? error.message : String(error);
|
|
1963
|
+
update("error", message);
|
|
1964
|
+
return { status: false, message, stage: "error" };
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
function normalizeWallet(wallet) {
|
|
1968
|
+
if (!wallet) return void 0;
|
|
1969
|
+
if (isViemWalletClient(wallet)) return adaptViemWallet(wallet);
|
|
1970
|
+
return wallet;
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
// src/react/useExecuteOrder.ts
|
|
1974
|
+
function useExecuteOrder() {
|
|
1975
|
+
const [status, setStatus] = (0, import_react2.useState)("processing");
|
|
1976
|
+
const [message, setMessage] = (0, import_react2.useState)(null);
|
|
1977
|
+
const [loading, setLoading] = (0, import_react2.useState)(false);
|
|
1978
|
+
const [data, setData] = (0, import_react2.useState)(null);
|
|
1979
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
1980
|
+
const isMounted = (0, import_react2.useRef)(true);
|
|
1981
|
+
(0, import_react2.useEffect)(() => {
|
|
1982
|
+
return () => {
|
|
1983
|
+
isMounted.current = false;
|
|
1984
|
+
};
|
|
1985
|
+
}, []);
|
|
1986
|
+
const execute = (0, import_react2.useCallback)(
|
|
1987
|
+
async ({
|
|
1988
|
+
quote,
|
|
1989
|
+
accountAddress,
|
|
1990
|
+
recipientAddress,
|
|
1991
|
+
wallet,
|
|
1992
|
+
deadline
|
|
1993
|
+
}) => {
|
|
1994
|
+
if (!quote || !wallet) {
|
|
1995
|
+
throw new Error("Quote and wallet are required for order execution.");
|
|
1996
|
+
}
|
|
1997
|
+
setLoading(true);
|
|
1998
|
+
setError(null);
|
|
1999
|
+
setData(null);
|
|
2000
|
+
setMessage(null);
|
|
2001
|
+
try {
|
|
2002
|
+
const effectiveDeadline = deadline ?? Math.floor(Date.now() / 1e3) + 20 * 60;
|
|
2003
|
+
const onStatus = (stage, msg) => {
|
|
2004
|
+
if (!isMounted.current) return;
|
|
2005
|
+
setStatus(stage);
|
|
2006
|
+
if (msg) setMessage(msg);
|
|
2007
|
+
};
|
|
2008
|
+
const result = await executeOrder({
|
|
2009
|
+
quote,
|
|
2010
|
+
accountAddress,
|
|
2011
|
+
recipientAddress,
|
|
2012
|
+
wallet,
|
|
2013
|
+
onStatus,
|
|
2014
|
+
options: { deadline: effectiveDeadline }
|
|
2015
|
+
});
|
|
2016
|
+
if (!isMounted.current) return result;
|
|
2017
|
+
setData(result);
|
|
2018
|
+
setStatus(result.stage);
|
|
2019
|
+
setMessage("Order executed successfully");
|
|
2020
|
+
return result;
|
|
2021
|
+
} catch (err) {
|
|
2022
|
+
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
2023
|
+
if (isMounted.current) {
|
|
2024
|
+
setError(errorObj);
|
|
2025
|
+
setStatus("error");
|
|
2026
|
+
setMessage(errorObj.message);
|
|
2027
|
+
setData({
|
|
2028
|
+
status: false,
|
|
2029
|
+
stage: "error",
|
|
2030
|
+
message: errorObj.message
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
return {
|
|
2034
|
+
status: false,
|
|
2035
|
+
stage: "error",
|
|
2036
|
+
message: errorObj.message
|
|
2037
|
+
};
|
|
2038
|
+
} finally {
|
|
2039
|
+
if (isMounted.current) setLoading(false);
|
|
2040
|
+
}
|
|
2041
|
+
},
|
|
2042
|
+
[]
|
|
2043
|
+
);
|
|
2044
|
+
return {
|
|
2045
|
+
/** Executes the swap order. */
|
|
2046
|
+
execute,
|
|
2047
|
+
/** Current execution stage. */
|
|
2048
|
+
status,
|
|
2049
|
+
/** Human-readable status message. */
|
|
2050
|
+
message,
|
|
2051
|
+
/** Whether execution is ongoing. */
|
|
2052
|
+
loading,
|
|
2053
|
+
/** Raw SDK response data. */
|
|
2054
|
+
data,
|
|
2055
|
+
/** Captured error (if execution failed). */
|
|
2056
|
+
error
|
|
2057
|
+
};
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
// src/react/useQuote.ts
|
|
2061
|
+
var import_react3 = __toESM(require_react(), 1);
|
|
2062
|
+
|
|
2063
|
+
// src/core/getQuote.ts
|
|
2064
|
+
import { QuoteProvider } from "@shogun-sdk/intents-sdk";
|
|
2065
|
+
import { parseUnits } from "viem";
|
|
2066
|
+
async function getQuote(params) {
|
|
2067
|
+
if (!params.tokenIn?.address || !params.tokenOut?.address) {
|
|
2068
|
+
throw new Error("Both tokenIn and tokenOut must include an address.");
|
|
2069
|
+
}
|
|
2070
|
+
if (!params.sourceChainId || !params.destChainId) {
|
|
2071
|
+
throw new Error("Both sourceChainId and destChainId are required.");
|
|
2072
|
+
}
|
|
2073
|
+
if (params.amount <= 0n) {
|
|
2074
|
+
throw new Error("Amount must be greater than 0.");
|
|
2075
|
+
}
|
|
2076
|
+
const normalizedTokenIn = normalizeNative(params.sourceChainId, params.tokenIn.address);
|
|
2077
|
+
const data = await QuoteProvider.getQuote({
|
|
2078
|
+
sourceChainId: params.sourceChainId,
|
|
2079
|
+
destChainId: params.destChainId,
|
|
2080
|
+
tokenIn: normalizedTokenIn,
|
|
2081
|
+
tokenOut: params.tokenOut.address,
|
|
2082
|
+
amount: params.amount
|
|
2083
|
+
});
|
|
2084
|
+
const inputSlippage = params.slippage ?? 5;
|
|
2085
|
+
const slippageDecimal = inputSlippage / 100;
|
|
2086
|
+
const slippage = Math.min(Math.max(slippageDecimal, 0), 0.5);
|
|
2087
|
+
let warning;
|
|
2088
|
+
if (slippage > 0.1) {
|
|
2089
|
+
warning = `\u26A0\uFE0F High slippage tolerance (${(slippage * 100).toFixed(2)}%) \u2014 price may vary significantly.`;
|
|
2090
|
+
}
|
|
2091
|
+
const estimatedAmountOut = BigInt(data.estimatedAmountOutReduced);
|
|
2092
|
+
const slippageBps = BigInt(Math.round(slippage * 1e4));
|
|
2093
|
+
const estimatedAmountOutAfterSlippage = estimatedAmountOut * (10000n - slippageBps) / 10000n;
|
|
2094
|
+
const pricePerInputToken = estimatedAmountOut * 10n ** BigInt(params.tokenIn.decimals ?? 18) / BigInt(params.amount);
|
|
2095
|
+
return {
|
|
2096
|
+
amountOut: estimatedAmountOut,
|
|
2097
|
+
amountOutUsd: data.estimatedAmountOutUsd,
|
|
2098
|
+
amountInUsd: data.amountInUsd,
|
|
2099
|
+
minStablecoinsAmount: data.estimatedAmountInAsMinStablecoinAmount,
|
|
2100
|
+
tokenIn: {
|
|
2101
|
+
address: params.tokenIn.address,
|
|
2102
|
+
decimals: params.tokenIn.decimals ?? 18,
|
|
2103
|
+
chainId: params.sourceChainId
|
|
2104
|
+
},
|
|
2105
|
+
tokenOut: {
|
|
2106
|
+
address: params.tokenOut.address,
|
|
2107
|
+
decimals: params.tokenOut.decimals ?? 18,
|
|
2108
|
+
chainId: params.destChainId
|
|
2109
|
+
},
|
|
2110
|
+
amountIn: params.amount,
|
|
2111
|
+
pricePerInputToken,
|
|
2112
|
+
slippage,
|
|
2113
|
+
internal: {
|
|
2114
|
+
...data,
|
|
2115
|
+
estimatedAmountOutReduced: estimatedAmountOutAfterSlippage
|
|
2116
|
+
},
|
|
2117
|
+
warning
|
|
2118
|
+
};
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
// src/react/useQuote.ts
|
|
2122
|
+
function useQuote(params, options) {
|
|
2123
|
+
const [data, setData] = (0, import_react3.useState)(null);
|
|
2124
|
+
const [loading, setLoading] = (0, import_react3.useState)(false);
|
|
2125
|
+
const [error, setError] = (0, import_react3.useState)(null);
|
|
2126
|
+
const [warning, setWarning] = (0, import_react3.useState)(null);
|
|
2127
|
+
const debounceMs = options?.debounceMs ?? 250;
|
|
2128
|
+
const autoRefreshMs = options?.autoRefreshMs;
|
|
2129
|
+
const abortRef = (0, import_react3.useRef)(null);
|
|
2130
|
+
const debounceRef = (0, import_react3.useRef)(null);
|
|
2131
|
+
const mountedRef = (0, import_react3.useRef)(true);
|
|
2132
|
+
(0, import_react3.useEffect)(() => {
|
|
2133
|
+
return () => {
|
|
2134
|
+
mountedRef.current = false;
|
|
2135
|
+
abortRef.current?.abort();
|
|
2136
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
2137
|
+
};
|
|
2138
|
+
}, []);
|
|
2139
|
+
const fetchQuote = (0, import_react3.useCallback)(
|
|
2140
|
+
async (signal) => {
|
|
2141
|
+
if (!params) return;
|
|
2142
|
+
try {
|
|
2143
|
+
setLoading(true);
|
|
2144
|
+
setWarning(null);
|
|
2145
|
+
const result = await getQuote({ ...params, signal });
|
|
2146
|
+
if (!mountedRef.current) return;
|
|
2147
|
+
setData((prev) => {
|
|
2148
|
+
if (JSON.stringify(prev) === JSON.stringify(result)) return prev;
|
|
2149
|
+
return result;
|
|
2150
|
+
});
|
|
2151
|
+
setWarning(result.warning ?? null);
|
|
2152
|
+
setError(null);
|
|
2153
|
+
} catch (err) {
|
|
2154
|
+
if (err.name === "AbortError") return;
|
|
2155
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
2156
|
+
if (mountedRef.current) setError(e);
|
|
2157
|
+
} finally {
|
|
2158
|
+
if (mountedRef.current) setLoading(false);
|
|
2159
|
+
}
|
|
2160
|
+
},
|
|
2161
|
+
[params]
|
|
2162
|
+
);
|
|
2163
|
+
(0, import_react3.useEffect)(() => {
|
|
2164
|
+
if (!params) return;
|
|
2165
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
2166
|
+
abortRef.current?.abort();
|
|
2167
|
+
const controller = new AbortController();
|
|
2168
|
+
abortRef.current = controller;
|
|
2169
|
+
debounceRef.current = setTimeout(() => {
|
|
2170
|
+
fetchQuote(controller.signal);
|
|
2171
|
+
}, debounceMs);
|
|
2172
|
+
return () => {
|
|
2173
|
+
controller.abort();
|
|
2174
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
2175
|
+
};
|
|
2176
|
+
}, [
|
|
2177
|
+
params?.tokenIn?.address,
|
|
2178
|
+
params?.tokenOut?.address,
|
|
2179
|
+
params?.sourceChainId,
|
|
2180
|
+
params?.destChainId,
|
|
2181
|
+
params?.amount,
|
|
2182
|
+
debounceMs,
|
|
2183
|
+
fetchQuote
|
|
2184
|
+
]);
|
|
2185
|
+
(0, import_react3.useEffect)(() => {
|
|
2186
|
+
if (!autoRefreshMs || !params) return;
|
|
2187
|
+
const interval = setInterval(() => fetchQuote(), autoRefreshMs);
|
|
2188
|
+
return () => clearInterval(interval);
|
|
2189
|
+
}, [autoRefreshMs, params, fetchQuote]);
|
|
2190
|
+
return (0, import_react3.useMemo)(
|
|
2191
|
+
() => ({
|
|
2192
|
+
/** Latest quote data */
|
|
2193
|
+
data,
|
|
2194
|
+
/** Whether a fetch is ongoing */
|
|
2195
|
+
loading,
|
|
2196
|
+
/** Error (if any) */
|
|
2197
|
+
error,
|
|
2198
|
+
/** Warning (e.g. high slippage alert) */
|
|
2199
|
+
warning,
|
|
2200
|
+
/** Manual refetch */
|
|
2201
|
+
refetch: () => fetchQuote()
|
|
2202
|
+
}),
|
|
2203
|
+
[data, loading, error, warning, fetchQuote]
|
|
2204
|
+
);
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
// src/react/useBalances.ts
|
|
2208
|
+
var import_react4 = __toESM(require_react(), 1);
|
|
2209
|
+
|
|
2210
|
+
// src/core/getBalances.ts
|
|
2211
|
+
import { TOKEN_SEARCH_API_BASE_URL } from "@shogun-sdk/intents-sdk";
|
|
2212
|
+
async function getBalances(params, options) {
|
|
2213
|
+
const { addresses, cursorEvm, cursorSvm } = params;
|
|
2214
|
+
const { signal } = options ?? {};
|
|
2215
|
+
if (!addresses?.evm && !addresses?.svm) {
|
|
2216
|
+
throw new Error("At least one address (EVM or SVM) must be provided.");
|
|
2217
|
+
}
|
|
2218
|
+
const payload = JSON.stringify({
|
|
2219
|
+
addresses,
|
|
2220
|
+
cursorEvm,
|
|
2221
|
+
cursorSvm
|
|
2222
|
+
});
|
|
2223
|
+
const start = performance.now();
|
|
2224
|
+
const response = await fetch(`${TOKEN_SEARCH_API_BASE_URL}/tokens/balances`, {
|
|
2225
|
+
method: "POST",
|
|
2226
|
+
headers: {
|
|
2227
|
+
accept: "application/json",
|
|
2228
|
+
"Content-Type": "application/json"
|
|
2229
|
+
},
|
|
2230
|
+
body: payload,
|
|
2231
|
+
signal
|
|
2232
|
+
}).catch((err) => {
|
|
2233
|
+
if (err.name === "AbortError") {
|
|
2234
|
+
throw new Error("Balance request was cancelled.");
|
|
2235
|
+
}
|
|
2236
|
+
throw err;
|
|
2237
|
+
});
|
|
2238
|
+
if (!response.ok) {
|
|
2239
|
+
const text = await response.text().catch(() => "");
|
|
2240
|
+
throw new Error(`Failed to fetch balances: ${response.status} ${text}`);
|
|
2241
|
+
}
|
|
2242
|
+
const data = await response.json().catch(() => {
|
|
2243
|
+
throw new Error("Invalid JSON response from balances API.");
|
|
2244
|
+
});
|
|
2245
|
+
const duration = (performance.now() - start).toFixed(1);
|
|
2246
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2247
|
+
console.debug(`[Shogun SDK] Fetched balances in ${duration}ms`);
|
|
2248
|
+
}
|
|
2249
|
+
const evmItems = data.evm?.items ?? [];
|
|
2250
|
+
const svmItems = data.svm?.items ?? [];
|
|
2251
|
+
const combined = [...evmItems, ...svmItems];
|
|
2252
|
+
return {
|
|
2253
|
+
results: combined,
|
|
2254
|
+
nextCursorEvm: data.evm?.cursor ?? null,
|
|
2255
|
+
nextCursorSvm: data.svm?.cursor ?? null
|
|
2256
|
+
};
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
// src/react/useBalances.ts
|
|
2260
|
+
function useBalances(params) {
|
|
2261
|
+
const [data, setData] = (0, import_react4.useState)(null);
|
|
2262
|
+
const [loading, setLoading] = (0, import_react4.useState)(false);
|
|
2263
|
+
const [error, setError] = (0, import_react4.useState)(null);
|
|
2264
|
+
const abortRef = (0, import_react4.useRef)(null);
|
|
2265
|
+
const stableParams = (0, import_react4.useMemo)(() => {
|
|
2266
|
+
if (!params) return null;
|
|
2267
|
+
const { addresses, cursorEvm, cursorSvm } = params;
|
|
2268
|
+
return {
|
|
2269
|
+
addresses: {
|
|
2270
|
+
evm: addresses?.evm ?? void 0,
|
|
2271
|
+
svm: addresses?.svm ?? void 0
|
|
2272
|
+
},
|
|
2273
|
+
cursorEvm,
|
|
2274
|
+
cursorSvm
|
|
2275
|
+
};
|
|
2276
|
+
}, [params?.addresses?.evm, params?.addresses?.svm, params?.cursorEvm, params?.cursorSvm]);
|
|
2277
|
+
const fetchBalances = (0, import_react4.useCallback)(async () => {
|
|
2278
|
+
if (!stableParams) return;
|
|
2279
|
+
if (abortRef.current) abortRef.current.abort();
|
|
2280
|
+
const controller = new AbortController();
|
|
2281
|
+
abortRef.current = controller;
|
|
2282
|
+
setLoading(true);
|
|
2283
|
+
setError(null);
|
|
2284
|
+
try {
|
|
2285
|
+
const result = await getBalances(stableParams, { signal: controller.signal });
|
|
2286
|
+
setData((prev) => {
|
|
2287
|
+
if (JSON.stringify(prev) === JSON.stringify(result)) return prev;
|
|
2288
|
+
return result;
|
|
2289
|
+
});
|
|
2290
|
+
return result;
|
|
2291
|
+
} catch (err) {
|
|
2292
|
+
if (err.name === "AbortError") return;
|
|
2293
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
2294
|
+
setError(e);
|
|
2295
|
+
throw e;
|
|
2296
|
+
} finally {
|
|
2297
|
+
setLoading(false);
|
|
2298
|
+
}
|
|
2299
|
+
}, [stableParams]);
|
|
2300
|
+
(0, import_react4.useEffect)(() => {
|
|
2301
|
+
if (stableParams) fetchBalances().catch(() => {
|
|
2302
|
+
});
|
|
2303
|
+
return () => {
|
|
2304
|
+
if (abortRef.current) abortRef.current.abort();
|
|
2305
|
+
};
|
|
2306
|
+
}, [fetchBalances]);
|
|
2307
|
+
return (0, import_react4.useMemo)(
|
|
2308
|
+
() => ({
|
|
2309
|
+
/** Latest fetched balance data */
|
|
2310
|
+
data,
|
|
2311
|
+
/** Whether the hook is currently fetching */
|
|
2312
|
+
loading,
|
|
2313
|
+
/** Error object if fetching failed */
|
|
2314
|
+
error,
|
|
2315
|
+
/** Manually trigger a refresh */
|
|
2316
|
+
refetch: fetchBalances
|
|
2317
|
+
}),
|
|
2318
|
+
[data, loading, error, fetchBalances]
|
|
2319
|
+
);
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
// src/react/index.ts
|
|
2323
|
+
import { ChainID as ChainID5, isEvmChain as isEvmChain3 } from "@shogun-sdk/intents-sdk";
|
|
2324
|
+
export {
|
|
2325
|
+
ChainID5 as ChainID,
|
|
2326
|
+
isEvmChain3 as isEvmChain,
|
|
2327
|
+
useBalances,
|
|
2328
|
+
useExecuteOrder,
|
|
2329
|
+
useQuote,
|
|
2330
|
+
useTokenList
|
|
2331
|
+
};
|
|
2332
|
+
/*! Bundled license information:
|
|
2333
|
+
|
|
2334
|
+
react/cjs/react.production.js:
|
|
2335
|
+
(**
|
|
2336
|
+
* @license React
|
|
2337
|
+
* react.production.js
|
|
2338
|
+
*
|
|
2339
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2340
|
+
*
|
|
2341
|
+
* This source code is licensed under the MIT license found in the
|
|
2342
|
+
* LICENSE file in the root directory of this source tree.
|
|
2343
|
+
*)
|
|
2344
|
+
|
|
2345
|
+
react/cjs/react.development.js:
|
|
2346
|
+
(**
|
|
2347
|
+
* @license React
|
|
2348
|
+
* react.development.js
|
|
2349
|
+
*
|
|
2350
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2351
|
+
*
|
|
2352
|
+
* This source code is licensed under the MIT license found in the
|
|
2353
|
+
* LICENSE file in the root directory of this source tree.
|
|
2354
|
+
*)
|
|
2355
|
+
*/
|