@ref-finance/ref-sdk 1.3.9 → 1.3.10
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/ref-sdk.cjs.development.css +24 -0
- package/dist/ref-sdk.cjs.development.js +37 -8
- package/dist/ref-sdk.cjs.development.js.map +1 -1
- package/dist/ref-sdk.cjs.production.min.js +1 -1
- package/dist/ref-sdk.cjs.production.min.js.map +1 -1
- package/dist/ref-sdk.esm.js +38 -9
- package/dist/ref-sdk.esm.js.map +1 -1
- package/dist/ref-sdk.umd.development.js +38 -9
- package/dist/ref-sdk.umd.development.js.map +1 -1
- package/dist/ref-sdk.umd.production.min.js +1 -1
- package/dist/ref-sdk.umd.production.min.js.map +1 -1
- package/package.json +1 -1
package/dist/ref-sdk.esm.js
CHANGED
|
@@ -5212,7 +5212,7 @@ function styleInject(css, ref) {
|
|
|
5212
5212
|
}
|
|
5213
5213
|
}
|
|
5214
5214
|
|
|
5215
|
-
var css_248z = ".__ref-swap-widget-container {\n border-radius: 16px;\n padding: 28px;\n padding-bottom: 16px;\n position: relative;\n max-width: 90%;\n}\n\n.__ref-swap-widget-row-flex-center {\n display: flex;\n align-items: center;\n}\n\n.__ref-swap-widget-col-flex-start {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n}\n\n.__ref-swap-widget-header {\n justify-content: space-between;\n margin-bottom: 25px;\n}\n\n.__ref-swap-widget-header-title {\n font-weight: 700;\n font-size: 20px;\n}\n.__ref-swap-widget-header-button-account {\n font-size: 14px;\n margin-right: 8px;\n padding: 4px 13px;\n border-radius: 25px;\n min-width: 120px;\n justify-content: center;\n}\n\n.__ref-swap-widget-header-button-account:hover {\n background: rgba(255, 104, 158, 0.2) !important;\n}\n\n.__ref-swap-widget_slippage_selector {\n box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.25);\n border-radius: 12px;\n position: absolute;\n top: 30px;\n right: 0px;\n padding: 16px;\n padding-right: 20px;\n padding-left: 20px;\n z-index: 100;\n width: 230px;\n font-size: 14px;\n}\n\n.__ref-swap-widget_slippage_selector_input_container {\n width: 100%;\n height: 26px;\n margin-right: 4px;\n padding: 2px 10px;\n}\n.__ref-swap-widget_slippage_selector_button {\n font-size: 14px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 6px 16px;\n}\n\n.__ref-swap-widget-opacity-hover:hover {\n opacity: 0.5;\n}\n\n.__ref-swap-widget-opacity-active:active {\n opacity: 0.5;\n}\n\n.__ref-swap-widger-token-amount {\n padding: 14px;\n padding-bottom: 8px;\n border-radius: 8px;\n display: flex;\n align-items: flex-start;\n}\n\n.__ref-swap-widger-token-amount_input {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n}\n\n.__ref-swap-widget-token-amount_quick_selector {\n}\n\n.__ref-swap-widger-token-amount_balance {\n margin-top: 7px;\n justify-content: space-between;\n}\n\n.__ref-swap-widget-token-amount_quick_selector_item {\n font-size: 12px;\n padding: 6px;\n padding-top: 3px;\n padding-bottom: 3px;\n cursor: pointer;\n}\n.__ref-swap-widget-select-token_input {\n padding: 14px;\n border-radius: 8px;\n}\n\n.__ref-swap-widget_star_token {\n padding: 8px 10px 8px 8px;\n margin: 0px 6px 10px 0px;\n position: relative;\n cursor: pointer;\n border-radius: 8px;\n}\n\n.__ref-swap-widget_token_icon {\n border-radius: 100%;\n flex-shrink: 0;\n}\n\n.__ref-swap-widget_token_list_table {\n table-layout: auto;\n width: 100%;\n font-size: 14px;\n}\n\n.__ref-swap-widget_token_list_table_header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 6px 12px;\n margin: 0px 6px;\n}\n\n.__ref-swap-widget_token-selector-star-tokens {\n margin-top: 20px;\n flex-wrap: wrap;\n}\n.__ref-swap-widget_token_list_table_content {\n display: flex;\n flex-direction: column;\n max-height: 50vh;\n min-height: 30vh;\n overflow-y: auto;\n}\n\n.__ref-swap-widget_token-selector-token-list-item {\n justify-content: space-between;\n padding: 9px 20px;\n}\n.__ref-swap-widget-token-amount_token-select-button {\n font-size: 16px;\n border-radius: 18px;\n padding: 6px 8px;\n cursor: pointer;\n}\n\n.__ref-swap-widget-exchange-button {\n width: 100%;\n justify-content: center;\n padding: 20px 0;\n}\n\n.__ref-swap-widget-submit-button {\n width: 100%;\n justify-content: center;\n font-size: 18px;\n font-weight: 700;\n border-radius: 8px;\n padding: 14px 0 14px 0;\n margin-top: 14px;\n cursor: pointer;\n}\n.__ref-widget-swap-detail-view {\n justify-content: space-between;\n width: 100%;\n font-size: 14px;\n margin-top: 16px;\n}\n\n.__ref-swap-widget-swap-detail-view-item {\n justify-content: space-between;\n margin-bottom: 12px;\n width: 100%;\n}\n\n.__ref-swap-widget-loading {\n animation: spin 2s linear infinite;\n}\n\n.__ref-swap-widget-notification {\n position: absolute;\n top: 50%;\n left: 50%;\n width: 50%;\n transform: translate(-50%, -50%);\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: 100;\n box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.25);\n border-radius: 12px;\n padding: 32px 20px;\n}\n\n.__ref-swap-widget-notification__button {\n border-radius: 8px;\n padding: 8px 20px;\n margin-top: 14px;\n}\n@keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\ninput.__ref-swap-widget-input-class {\n margin: 0;\n background-color: transparent;\n display: block;\n width: 100%;\n padding: 0;\n border-width: 0;\n}\n\ninput.__ref-swap-widget-input-class:focus {\n outline: none;\n border-width: 0;\n}\n\ninput.__ref-swap-widget-input-class::-webkit-outer-spin-button,\ninput.__ref-swap-widget-input-class::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n\ninput.__ref-swap-widget-input-class[type='number'] {\n -moz-appearance: textfield; /* Firefox */\n}\n\nbutton.__ref-swap-widget-button {\n border: none;\n}\n\n.__ref-swap-widget-submit-button:hover {\n opacity: 0.5;\n}\n\n.__ref-swap-widget-active:active {\n color: #00c6a2;\n}\n\n.__ref-swap-widget-hover:hover {\n color: #00c6a2;\n}\n\n.__ref-swap-widget_token_list_table_content::-webkit-scrollbar {\n width: 4px;\n height: 4px;\n border-radius: 3px;\n}\n\n.__ref-swap-widget_token_list_table_content::-webkit-scrollbar-track {\n box-shadow: inset 0 0 6px rgba(0, 0, 0, 0);\n}\n.__ref-swap-widget_token_list_table_content::-webkit-scrollbar-thumb {\n background: #00c6a2;\n border-radius: 8px;\n}\n\n.__ref-swap-widget-swap_routes {\n border-radius: 12px;\n padding: 8px 12px 8px 12px;\n width: 100%;\n}\n\n.__ref-swap-widget-valueStyle {\n background-image: -webkit-linear-gradient(left, #00ffd1, #00ffd1, #8c78ff);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n}\n\n.__ref-swap-widget-swap_route_row {\n justify-content: space-between;\n margin-bottom: 4px;\n}\n";
|
|
5215
|
+
var css_248z = ".__ref-swap-widget-container {\n border-radius: 16px;\n padding: 28px;\n padding-bottom: 16px;\n position: relative;\n max-width: 90%;\n}\n\n.__ref-swap-widget-row-flex-center {\n display: flex;\n align-items: center;\n}\n\n.__ref-swap-widget-col-flex-start {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n}\n\n.__ref-swap-widget-header {\n justify-content: space-between;\n margin-bottom: 25px;\n}\n\n.__ref-swap-widget-header-title {\n font-weight: 700;\n font-size: 20px;\n}\n.__ref-swap-widget-header-button-account {\n font-size: 14px;\n margin-right: 8px;\n padding: 4px 13px;\n border-radius: 25px;\n min-width: 120px;\n justify-content: center;\n}\n\n.__ref-swap-widget-header-button-account:hover {\n background: rgba(255, 104, 158, 0.2) !important;\n}\n\n.__ref-swap-widget_slippage_selector {\n box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.25);\n border-radius: 12px;\n position: absolute;\n top: 30px;\n right: 0px;\n padding: 16px;\n padding-right: 20px;\n padding-left: 20px;\n z-index: 100;\n width: 230px;\n font-size: 14px;\n}\n\n.__ref-swap-widget_slippage_selector_input_container {\n width: 100%;\n height: 26px;\n margin-right: 4px;\n padding: 2px 10px;\n}\n.__ref-swap-widget_slippage_selector_button {\n font-size: 14px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 6px 16px;\n}\n\n.__ref-swap-widget-opacity-hover:hover {\n opacity: 0.5;\n}\n\n.__ref-swap-widget-opacity-active:active {\n opacity: 0.5;\n}\n\n.__ref-swap-widger-token-amount {\n padding: 14px;\n padding-bottom: 8px;\n border-radius: 8px;\n display: flex;\n align-items: flex-start;\n}\n\n.__ref-swap-widger-token-amount_input {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n}\n\n.__ref-swap-widget-token-amount_quick_selector {\n}\n\n.__ref-swap-widger-token-amount_balance {\n margin-top: 7px;\n justify-content: space-between;\n}\n\n.__ref-swap-widget-token-amount_quick_selector_item {\n font-size: 12px;\n padding: 6px;\n padding-top: 3px;\n padding-bottom: 3px;\n cursor: pointer;\n}\n.__ref-swap-widget-select-token_input {\n padding: 14px;\n border-radius: 8px;\n}\n\n.__ref-swap-widget_star_token {\n padding: 8px 10px 8px 8px;\n margin: 0px 6px 10px 0px;\n position: relative;\n cursor: pointer;\n border-radius: 8px;\n}\n\n.__ref-swap-widget_token_icon {\n border-radius: 100%;\n flex-shrink: 0;\n}\n\n.__ref-swap-widget_token_list_table {\n table-layout: auto;\n width: 100%;\n font-size: 14px;\n}\n\n.__ref-swap-widget_token_list_table_header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 6px 12px;\n margin: 0px 6px;\n}\n\n.__ref-swap-widget_token-selector-star-tokens {\n margin-top: 20px;\n flex-wrap: wrap;\n}\n.__ref-swap-widget_token_list_table_content {\n display: flex;\n flex-direction: column;\n max-height: 50vh;\n min-height: 30vh;\n overflow-y: auto;\n}\n\n.__ref-swap-widget_token-selector-token-list-item {\n justify-content: space-between;\n padding: 9px 20px;\n}\n.__ref-swap-widget-token-amount_token-select-button {\n font-size: 16px;\n border-radius: 18px;\n padding: 6px 8px;\n cursor: pointer;\n}\n\n.__ref-swap-widget-exchange-button {\n width: 100%;\n justify-content: center;\n padding: 20px 0;\n}\n\n.__ref-swap-widget-submit-button {\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n font-weight: 700;\n border-radius: 8px;\n padding: 14px 0 14px 0;\n margin-top: 14px;\n cursor: pointer;\n}\n\n.__ref-swap-widget-submit-button-loader {\n width: 20px;\n height: 20px;\n border: 2px solid #fff;\n border-bottom-color: rgb(255, 255, 255);\n border-bottom-color: transparent;\n border-radius: 50%;\n display: inline-block;\n box-sizing: border-box;\n animation: rotation 1s linear infinite;\n}\n\n@keyframes rotation {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.__ref-widget-swap-detail-view {\n justify-content: space-between;\n width: 100%;\n font-size: 14px;\n margin-top: 16px;\n}\n\n.__ref-swap-widget-swap-detail-view-item {\n justify-content: space-between;\n margin-bottom: 12px;\n width: 100%;\n}\n\n.__ref-swap-widget-loading {\n animation: spin 2s linear infinite;\n}\n\n.__ref-swap-widget-notification {\n position: absolute;\n top: 50%;\n left: 50%;\n width: 50%;\n transform: translate(-50%, -50%);\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: 100;\n box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.25);\n border-radius: 12px;\n padding: 32px 20px;\n}\n\n.__ref-swap-widget-notification__button {\n border-radius: 8px;\n padding: 8px 20px;\n margin-top: 14px;\n}\n@keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\ninput.__ref-swap-widget-input-class {\n margin: 0;\n background-color: transparent;\n display: block;\n width: 100%;\n padding: 0;\n border-width: 0;\n}\n\ninput.__ref-swap-widget-input-class:focus {\n outline: none;\n border-width: 0;\n}\n\ninput.__ref-swap-widget-input-class::-webkit-outer-spin-button,\ninput.__ref-swap-widget-input-class::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n\ninput.__ref-swap-widget-input-class[type='number'] {\n -moz-appearance: textfield; /* Firefox */\n}\n\nbutton.__ref-swap-widget-button {\n border: none;\n}\n\n.__ref-swap-widget-submit-button:hover {\n opacity: 0.5;\n}\n\n.__ref-swap-widget-active:active {\n color: #00c6a2;\n}\n\n.__ref-swap-widget-hover:hover {\n color: #00c6a2;\n}\n\n.__ref-swap-widget_token_list_table_content::-webkit-scrollbar {\n width: 4px;\n height: 4px;\n border-radius: 3px;\n}\n\n.__ref-swap-widget_token_list_table_content::-webkit-scrollbar-track {\n box-shadow: inset 0 0 6px rgba(0, 0, 0, 0);\n}\n.__ref-swap-widget_token_list_table_content::-webkit-scrollbar-thumb {\n background: #00c6a2;\n border-radius: 8px;\n}\n\n.__ref-swap-widget-swap_routes {\n border-radius: 12px;\n padding: 8px 12px 8px 12px;\n width: 100%;\n}\n\n.__ref-swap-widget-valueStyle {\n background-image: -webkit-linear-gradient(left, #00ffd1, #00ffd1, #8c78ff);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n}\n\n.__ref-swap-widget-swap_route_row {\n justify-content: space-between;\n margin-bottom: 4px;\n}\n";
|
|
5216
5216
|
styleInject(css_248z);
|
|
5217
5217
|
|
|
5218
5218
|
var getPriceImpact$1 = function getPriceImpact(value, tokenIn, tokenInAmount) {
|
|
@@ -5525,6 +5525,8 @@ var HalfAndMaxAmount = function HalfAndMaxAmount(_ref6) {
|
|
|
5525
5525
|
}
|
|
5526
5526
|
}, "Max"));
|
|
5527
5527
|
};
|
|
5528
|
+
var DECIMAL_POINT = '.';
|
|
5529
|
+
var ALLOWED_KEYS = ['Backspace', 'Tab', 'ArrowLeft', 'ArrowRight', 'Delete', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', DECIMAL_POINT];
|
|
5528
5530
|
var TokenAmount = function TokenAmount(props) {
|
|
5529
5531
|
var _ref$current2;
|
|
5530
5532
|
var balance = props.balance,
|
|
@@ -5545,6 +5547,28 @@ var TokenAmount = function TokenAmount(props) {
|
|
|
5545
5547
|
var _useState5 = useState(false),
|
|
5546
5548
|
hoverSelect = _useState5[0],
|
|
5547
5549
|
setHoverSelect = _useState5[1];
|
|
5550
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
5551
|
+
if (!ALLOWED_KEYS.includes(event.key) && !event.ctrlKey) {
|
|
5552
|
+
event.preventDefault();
|
|
5553
|
+
}
|
|
5554
|
+
var isDecimalPoint = event.key === DECIMAL_POINT;
|
|
5555
|
+
if (!isDecimalPoint) return;
|
|
5556
|
+
// Ensure only one dot is allowed
|
|
5557
|
+
var inputValue = event.target.value;
|
|
5558
|
+
if (inputValue.includes(DECIMAL_POINT)) {
|
|
5559
|
+
event.preventDefault();
|
|
5560
|
+
}
|
|
5561
|
+
// prohibit only one dot
|
|
5562
|
+
if (inputValue.length === 0) {
|
|
5563
|
+
event.preventDefault();
|
|
5564
|
+
}
|
|
5565
|
+
};
|
|
5566
|
+
var handlePaste = function handlePaste(event) {
|
|
5567
|
+
var paste = event.clipboardData.getData('text');
|
|
5568
|
+
if (!/^[0-9.]+$/.test(paste)) {
|
|
5569
|
+
event.preventDefault();
|
|
5570
|
+
}
|
|
5571
|
+
};
|
|
5548
5572
|
var handleChange = function handleChange(amount) {
|
|
5549
5573
|
if (onChangeAmount) {
|
|
5550
5574
|
onChangeAmount(amount);
|
|
@@ -5590,7 +5614,8 @@ var TokenAmount = function TokenAmount(props) {
|
|
|
5590
5614
|
}, !token ? React.createElement(React.Fragment, null, React.createElement("span", {
|
|
5591
5615
|
style: {
|
|
5592
5616
|
whiteSpace: 'nowrap',
|
|
5593
|
-
height: '26px'
|
|
5617
|
+
height: '26px',
|
|
5618
|
+
userSelect: 'none'
|
|
5594
5619
|
},
|
|
5595
5620
|
className: "__ref-swap-widget-row-flex-center"
|
|
5596
5621
|
}, "Select Token")) : React.createElement(React.Fragment, null, React.createElement("img", {
|
|
@@ -5625,16 +5650,16 @@ var TokenAmount = function TokenAmount(props) {
|
|
|
5625
5650
|
}, React.createElement("input", {
|
|
5626
5651
|
ref: ref,
|
|
5627
5652
|
max: !!onChangeAmount ? curMax : undefined,
|
|
5628
|
-
min: "0",
|
|
5629
5653
|
onWheel: function onWheel() {
|
|
5630
5654
|
if (ref.current) {
|
|
5631
5655
|
ref.current.blur();
|
|
5632
5656
|
}
|
|
5633
5657
|
},
|
|
5634
5658
|
className: "__ref-swap-widget-input-class",
|
|
5635
|
-
step: "any",
|
|
5636
5659
|
value: amount,
|
|
5637
|
-
type: "
|
|
5660
|
+
type: "text",
|
|
5661
|
+
onKeyDown: handleKeyDown,
|
|
5662
|
+
onPaste: handlePaste,
|
|
5638
5663
|
placeholder: !onChangeAmount ? '-' : '0.0',
|
|
5639
5664
|
onChange: function onChange(_ref7) {
|
|
5640
5665
|
var target = _ref7.target;
|
|
@@ -5642,9 +5667,6 @@ var TokenAmount = function TokenAmount(props) {
|
|
|
5642
5667
|
handleChange(target.value);
|
|
5643
5668
|
},
|
|
5644
5669
|
disabled: !onChangeAmount,
|
|
5645
|
-
onKeyDown: function onKeyDown(e) {
|
|
5646
|
-
return symbolsArr.includes(e.key) && e.preventDefault();
|
|
5647
|
-
},
|
|
5648
5670
|
style: {
|
|
5649
5671
|
color: primary,
|
|
5650
5672
|
marginBottom: '8px',
|
|
@@ -6621,6 +6643,9 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6621
6643
|
makeSwap();
|
|
6622
6644
|
};
|
|
6623
6645
|
var canSubmit = tokenIn && tokenOut && canSwap && !swapError && isSignedIn && new Big(tokenInBalance || '0').gte(amountIn || '0') && slippageTolerance > 0 && slippageTolerance < 100 && !ONLY_ZEROS.test(tokenInBalance);
|
|
6646
|
+
var tokensLoaded = useMemo(function () {
|
|
6647
|
+
return tokens.length > 0;
|
|
6648
|
+
}, [tokens]);
|
|
6624
6649
|
return React.createElement(ThemeContextProvider, {
|
|
6625
6650
|
customTheme: curTheme
|
|
6626
6651
|
}, React.createElement(TokenPriceContextProvider, null, widgetRoute === 'swap' && React.createElement("form", {
|
|
@@ -6662,6 +6687,7 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6662
6687
|
price: !tokenIn ? null : tokenPriceList == null ? void 0 : (_tokenPriceList$token = tokenPriceList[tokenIn.id]) == null ? void 0 : _tokenPriceList$token.price,
|
|
6663
6688
|
onChangeAmount: setAmountIn,
|
|
6664
6689
|
onSelectToken: function onSelectToken() {
|
|
6690
|
+
if (!tokensLoaded) return;
|
|
6665
6691
|
setWidgetRoute('token-selector-in');
|
|
6666
6692
|
}
|
|
6667
6693
|
}), React.createElement("div", {
|
|
@@ -6687,6 +6713,7 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6687
6713
|
token: tokenOut,
|
|
6688
6714
|
price: !tokenOut ? null : tokenPriceList == null ? void 0 : (_tokenPriceList$token2 = tokenPriceList[tokenOut.id]) == null ? void 0 : _tokenPriceList$token2.price,
|
|
6689
6715
|
onSelectToken: function onSelectToken() {
|
|
6716
|
+
if (!tokensLoaded) return;
|
|
6690
6717
|
setWidgetRoute('token-selector-out');
|
|
6691
6718
|
},
|
|
6692
6719
|
onForceUpdate: function onForceUpdate() {
|
|
@@ -6723,7 +6750,9 @@ var SwapWidget = function SwapWidget(props) {
|
|
|
6723
6750
|
cursor: !canSubmit ? 'not-allowed' : 'pointer'
|
|
6724
6751
|
},
|
|
6725
6752
|
disabled: !canSubmit
|
|
6726
|
-
}, 'Swap'
|
|
6753
|
+
}, tokensLoaded ? 'Swap' : React.createElement("div", {
|
|
6754
|
+
className: "__ref-swap-widget-submit-button-loader"
|
|
6755
|
+
})) : React.createElement("button", {
|
|
6727
6756
|
type: "button",
|
|
6728
6757
|
className: "__ref-swap-widget-submit-button __ref-swap-widget-button",
|
|
6729
6758
|
onClick: onConnect,
|