@kodiak-finance/orderly-react-app 2.8.32-alpha.2 → 2.8.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +43 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useTrack, OrderlyConfigProvider, useAccount, ERROR_MSG_CODES, useTrackingInstance, useRestrictedInfo, useEventEmitter, useSymbolsInfo, useOrderlyContext, useLocalStorage, useUpdatedRef,
|
|
1
|
+
import { useTrack, OrderlyConfigProvider, useAccount, ERROR_MSG_CODES, useTrackingInstance, useRestrictedInfo, useEventEmitter, useSymbolsInfo, useOrderlyContext, useLocalStorage, useUpdatedRef, useDebouncedCallback, useStorageChain, useChains, useConfig, useWalletConnector, useKeyStore, useSessionStorage, useWalletSubscription, useSettleSubscription, useWS, useStorageLedgerAddress, parseJSON } from '@kodiak-finance/orderly-hooks';
|
|
2
2
|
import { OrderlyThemeProvider, LocaleProvider, TooltipProvider, ModalProvider, Toaster, Flex, cn, Text, Button, useCanLinkDevice, toast, modal, parseNumber } from '@kodiak-finance/orderly-ui';
|
|
3
3
|
import { createContext, useContext, useCallback, Component, useMemo, useEffect, useState, useRef } from 'react';
|
|
4
4
|
import { AccountStatusEnum, SDKError, ABSTRACT_CHAIN_ID_MAP, ChainNamespace, TrackerEventName, OrderStatus, AlgoOrderRootType } from '@kodiak-finance/orderly-types';
|
|
@@ -87,6 +87,32 @@ function getOrderExecutionReportMsg(data, symbolsInfo) {
|
|
|
87
87
|
}
|
|
88
88
|
var ORDERLY_ORDER_SOUND_ALERT_KEY = "orderly_order_sound_alert";
|
|
89
89
|
var ORDERLY_TRADING_TOAST_ALERT_KEY = "orderly_trading_toast_alert";
|
|
90
|
+
var getStoredBoolean = (key, fallback) => {
|
|
91
|
+
if (typeof window === "undefined") {
|
|
92
|
+
return fallback;
|
|
93
|
+
}
|
|
94
|
+
const value = window.localStorage.getItem(key);
|
|
95
|
+
if (value === null) {
|
|
96
|
+
return fallback;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const parsed = JSON.parse(value);
|
|
100
|
+
if (typeof parsed === "boolean") {
|
|
101
|
+
return parsed;
|
|
102
|
+
}
|
|
103
|
+
if (typeof parsed === "string") {
|
|
104
|
+
if (parsed.toLowerCase() === "true") {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
if (parsed.toLowerCase() === "false") {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return fallback;
|
|
112
|
+
} catch {
|
|
113
|
+
return fallback;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
90
116
|
var useExecutionReport = () => {
|
|
91
117
|
const ee = useEventEmitter();
|
|
92
118
|
const symbolsInfo = useSymbolsInfo();
|
|
@@ -105,12 +131,13 @@ var useExecutionReport = () => {
|
|
|
105
131
|
true
|
|
106
132
|
);
|
|
107
133
|
const tradingToastAlertRef = useUpdatedRef(tradingToastAlert);
|
|
108
|
-
const
|
|
109
|
-
autoPlay: soundAutoPlay,
|
|
110
|
-
volume: 1
|
|
111
|
-
});
|
|
134
|
+
const soundAutoPlayRef = useUpdatedRef(soundAutoPlay);
|
|
112
135
|
const handler = useDebouncedCallback((data) => {
|
|
113
|
-
|
|
136
|
+
const latestTradingToastAlert = getStoredBoolean(
|
|
137
|
+
ORDERLY_TRADING_TOAST_ALERT_KEY,
|
|
138
|
+
tradingToastAlertRef.current
|
|
139
|
+
);
|
|
140
|
+
if (!latestTradingToastAlert) {
|
|
114
141
|
return;
|
|
115
142
|
}
|
|
116
143
|
const showToast = (data2) => {
|
|
@@ -118,15 +145,23 @@ var useExecutionReport = () => {
|
|
|
118
145
|
data2,
|
|
119
146
|
symbolsInfoRef.current
|
|
120
147
|
);
|
|
121
|
-
const
|
|
148
|
+
const shouldPlaySound = getStoredBoolean(
|
|
149
|
+
ORDERLY_ORDER_SOUND_ALERT_KEY,
|
|
150
|
+
soundAutoPlayRef.current
|
|
151
|
+
) && latestTradingToastAlert && (status === OrderStatus.FILLED || status === OrderStatus.PARTIAL_FILLED || status === OrderStatus.CANCELLED);
|
|
152
|
+
if (shouldPlaySound && src) {
|
|
153
|
+
const audio = new Audio(src);
|
|
154
|
+
audio.volume = 1;
|
|
155
|
+
audio.play().catch(() => {
|
|
156
|
+
});
|
|
157
|
+
}
|
|
122
158
|
const orderType = data2.algo_type || data2.type;
|
|
123
159
|
if (title && msg) {
|
|
124
160
|
toast.success(
|
|
125
161
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
126
162
|
title,
|
|
127
163
|
/* @__PURE__ */ jsx("br", {}),
|
|
128
|
-
/* @__PURE__ */ jsx("div", { className: "orderly-text-white/[0.54] orderly-text-xs", children: msg })
|
|
129
|
-
isFilled && audioElement
|
|
164
|
+
/* @__PURE__ */ jsx("div", { className: "orderly-text-white/[0.54] orderly-text-xs", children: msg })
|
|
130
165
|
] }),
|
|
131
166
|
{ id: orderType }
|
|
132
167
|
);
|