@pollar/react 0.10.1-rc.10 → 0.10.1-rc.11
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.css +7 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +67 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1035,7 +1035,7 @@ var PollarModalFooter = () => {
|
|
|
1035
1035
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
|
|
1036
1036
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-footer-version", children: [
|
|
1037
1037
|
"v",
|
|
1038
|
-
"0.10.1-rc.
|
|
1038
|
+
"0.10.1-rc.11"
|
|
1039
1039
|
] })
|
|
1040
1040
|
] })
|
|
1041
1041
|
] });
|
|
@@ -3429,6 +3429,7 @@ function AssetSelect({
|
|
|
3429
3429
|
options,
|
|
3430
3430
|
onChange,
|
|
3431
3431
|
loading = false,
|
|
3432
|
+
loadingLabel,
|
|
3432
3433
|
disabled = false,
|
|
3433
3434
|
appGroupLabel = "App assets",
|
|
3434
3435
|
otherGroupLabel = "Other assets",
|
|
@@ -3438,7 +3439,10 @@ function AssetSelect({
|
|
|
3438
3439
|
const otherAssets = options.filter((o) => !o.enabledInApp);
|
|
3439
3440
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
|
|
3440
3441
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: label }),
|
|
3441
|
-
loading ? /* @__PURE__ */ jsxRuntime.
|
|
3442
|
+
loading ? loadingLabel ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-input pollar-select-loading", children: [
|
|
3443
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
|
|
3444
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: loadingLabel })
|
|
3445
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3442
3446
|
"select",
|
|
3443
3447
|
{
|
|
3444
3448
|
className: "pollar-input pollar-send-select",
|
|
@@ -4111,10 +4115,6 @@ function SwapModalTemplate({
|
|
|
4111
4115
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
4112
4116
|
] })
|
|
4113
4117
|
] }),
|
|
4114
|
-
step === "form" && configLoading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-loading-block", children: [
|
|
4115
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-spinner" }),
|
|
4116
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading swap options\u2026" })
|
|
4117
|
-
] }),
|
|
4118
4118
|
step === "form" && !configLoading && swapUnavailable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Swap is not available for this app." }),
|
|
4119
4119
|
step === "form" && !swapUnavailable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4120
4120
|
smartUnsupported && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Swaps are not yet available for smart (passkey) wallets." }),
|
|
@@ -4123,7 +4123,8 @@ function SwapModalTemplate({
|
|
|
4123
4123
|
{
|
|
4124
4124
|
label: "You pay",
|
|
4125
4125
|
value: sellKey,
|
|
4126
|
-
loading: isLoadingData,
|
|
4126
|
+
loading: isLoadingData || configLoading,
|
|
4127
|
+
loadingLabel: "Loading assets\u2026",
|
|
4127
4128
|
disabled: configLoading,
|
|
4128
4129
|
options: sellOptions.map((o) => ({
|
|
4129
4130
|
key: assetOptionKey(o),
|
|
@@ -4165,7 +4166,8 @@ function SwapModalTemplate({
|
|
|
4165
4166
|
{
|
|
4166
4167
|
label: "You receive",
|
|
4167
4168
|
value: buyKey,
|
|
4168
|
-
loading: isLoadingData,
|
|
4169
|
+
loading: isLoadingData || configLoading,
|
|
4170
|
+
loadingLabel: "Loading assets\u2026",
|
|
4169
4171
|
disabled: configLoading,
|
|
4170
4172
|
options: buyOptions.map((o) => ({
|
|
4171
4173
|
key: assetOptionKey(o),
|
|
@@ -4596,6 +4598,8 @@ function EarnModal({ onClose }) {
|
|
|
4596
4598
|
earnWithdraw,
|
|
4597
4599
|
tx: transaction,
|
|
4598
4600
|
wallet,
|
|
4601
|
+
walletBalance,
|
|
4602
|
+
refreshWalletBalance,
|
|
4599
4603
|
network,
|
|
4600
4604
|
styles
|
|
4601
4605
|
} = usePollar();
|
|
@@ -4627,6 +4631,9 @@ function EarnModal({ onClose }) {
|
|
|
4627
4631
|
react.useEffect(() => {
|
|
4628
4632
|
void loadProviders();
|
|
4629
4633
|
}, [loadProviders]);
|
|
4634
|
+
react.useEffect(() => {
|
|
4635
|
+
void refreshWalletBalance();
|
|
4636
|
+
}, [refreshWalletBalance]);
|
|
4630
4637
|
react.useEffect(() => {
|
|
4631
4638
|
if (!provider) return;
|
|
4632
4639
|
let cancelled = false;
|
|
@@ -4670,6 +4677,15 @@ function EarnModal({ onClose }) {
|
|
|
4670
4677
|
const withdrawUnit = position?.withdrawUnit ?? "asset";
|
|
4671
4678
|
const assetCode = selectedOpportunity?.asset.code ?? "";
|
|
4672
4679
|
const amountUnitLabel = tab === "deposit" ? assetCode : withdrawUnit === "shares" ? "shares" : assetCode;
|
|
4680
|
+
const walletAvailable = (() => {
|
|
4681
|
+
if (!selectedOpportunity) return null;
|
|
4682
|
+
const balances = walletBalance.step === "loaded" ? walletBalance.data.balances : [];
|
|
4683
|
+
const issuer = selectedOpportunity.asset.issuer;
|
|
4684
|
+
const rec = balances.find(
|
|
4685
|
+
(b) => issuer === null ? b.type === "native" : b.code === assetCode && b.issuer === issuer
|
|
4686
|
+
);
|
|
4687
|
+
return rec ? rec.available : null;
|
|
4688
|
+
})();
|
|
4673
4689
|
const hash = transaction.step === "success" ? transaction.hash : null;
|
|
4674
4690
|
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
4675
4691
|
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
|
|
@@ -4677,7 +4693,9 @@ function EarnModal({ onClose }) {
|
|
|
4677
4693
|
const isInProgress = IN_FLIGHT_STEPS2.includes(transaction.step);
|
|
4678
4694
|
const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
|
|
4679
4695
|
const txTitle = isInProgress ? tab === "deposit" ? "Depositing\u2026" : "Withdrawing\u2026" : transaction.step === "success" ? "Done!" : transaction.step === "error" ? tab === "deposit" ? "Deposit failed" : "Withdraw failed" : "Confirm";
|
|
4680
|
-
const
|
|
4696
|
+
const parsedAmount = parseFloat(amount);
|
|
4697
|
+
const exceedsAvailable = tab === "deposit" ? walletAvailable != null && parsedAmount > parseFloat(walletAvailable) : position != null && parsedAmount > parseFloat(position.withdrawable);
|
|
4698
|
+
const canSubmit = !smartUnsupported && !!provider && !!opportunityId && !!amount && parsedAmount > 0 && !exceedsAvailable && !providersLoading && !loadingOpps;
|
|
4681
4699
|
const cssVars = {
|
|
4682
4700
|
"--pollar-accent": accentColor,
|
|
4683
4701
|
"--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
|
|
@@ -4710,6 +4728,10 @@ function EarnModal({ onClose }) {
|
|
|
4710
4728
|
setFormError("Enter a valid amount");
|
|
4711
4729
|
return;
|
|
4712
4730
|
}
|
|
4731
|
+
if (tab === "deposit" && walletAvailable != null && parsed > parseFloat(walletAvailable)) {
|
|
4732
|
+
setFormError("Amount exceeds your wallet balance");
|
|
4733
|
+
return;
|
|
4734
|
+
}
|
|
4713
4735
|
if (tab === "withdraw" && position && parsed > parseFloat(position.withdrawable)) {
|
|
4714
4736
|
setFormError("Amount exceeds your position");
|
|
4715
4737
|
return;
|
|
@@ -4749,6 +4771,7 @@ function EarnModal({ onClose }) {
|
|
|
4749
4771
|
if (refreshing || !provider) return;
|
|
4750
4772
|
setRefreshing(true);
|
|
4751
4773
|
try {
|
|
4774
|
+
void refreshWalletBalance();
|
|
4752
4775
|
const opps = await getEarnOpportunities(provider);
|
|
4753
4776
|
setOpportunities(opps);
|
|
4754
4777
|
setOpportunityId((cur) => opps.some((o) => o.id === cur) ? cur : opps[0]?.id ?? "");
|
|
@@ -4876,6 +4899,14 @@ function EarnModal({ onClose }) {
|
|
|
4876
4899
|
)
|
|
4877
4900
|
] }),
|
|
4878
4901
|
selectedOpportunity && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote", children: [
|
|
4902
|
+
tab === "deposit" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4903
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "In your wallet" }),
|
|
4904
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
4905
|
+
walletAvailable != null ? formatAmount4(walletAvailable) : "\u2026",
|
|
4906
|
+
" ",
|
|
4907
|
+
assetCode
|
|
4908
|
+
] })
|
|
4909
|
+
] }),
|
|
4879
4910
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4880
4911
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Your position" }),
|
|
4881
4912
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
@@ -4895,6 +4926,12 @@ function EarnModal({ onClose }) {
|
|
|
4895
4926
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
|
|
4896
4927
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-label-row", children: [
|
|
4897
4928
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: tab === "deposit" ? "Amount" : "Withdraw amount" }),
|
|
4929
|
+
tab === "deposit" && walletAvailable != null && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-swap-custom-toggle", onClick: () => setAmount(walletAvailable), children: [
|
|
4930
|
+
"Max: ",
|
|
4931
|
+
formatAmount4(walletAvailable),
|
|
4932
|
+
" ",
|
|
4933
|
+
amountUnitLabel
|
|
4934
|
+
] }),
|
|
4898
4935
|
tab === "withdraw" && position && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-swap-custom-toggle", onClick: () => setAmount(position.withdrawable), children: [
|
|
4899
4936
|
"Max: ",
|
|
4900
4937
|
formatAmount4(position.withdrawable),
|
|
@@ -5870,6 +5907,9 @@ function PollarProvider({
|
|
|
5870
5907
|
const [sendModalOpen, setSendModalOpen] = react.useState(false);
|
|
5871
5908
|
const [swapModalOpen, setSwapModalOpen] = react.useState(false);
|
|
5872
5909
|
const [earnModalOpen, setEarnModalOpen] = react.useState(false);
|
|
5910
|
+
const [sendModalKey, setSendModalKey] = react.useState(0);
|
|
5911
|
+
const [swapModalKey, setSwapModalKey] = react.useState(0);
|
|
5912
|
+
const [earnModalKey, setEarnModalKey] = react.useState(0);
|
|
5873
5913
|
const [receiveModalOpen, setReceiveModalOpen] = react.useState(false);
|
|
5874
5914
|
const [sessionsModalOpen, setSessionsModalOpen] = react.useState(false);
|
|
5875
5915
|
const [distributionRulesModalOpen, setDistributionRulesModalOpen] = react.useState(false);
|
|
@@ -5912,21 +5952,33 @@ function PollarProvider({
|
|
|
5912
5952
|
setTrustline: (asset, opts) => pollarClient.setTrustline(asset, opts),
|
|
5913
5953
|
openEnabledAssetsModal: () => setEnabledAssetsModalOpen(true),
|
|
5914
5954
|
// send / receive
|
|
5915
|
-
openSendModal: () =>
|
|
5955
|
+
openSendModal: () => {
|
|
5956
|
+
pollarClient.resetTransactionState();
|
|
5957
|
+
setSendModalKey((k) => k + 1);
|
|
5958
|
+
setSendModalOpen(true);
|
|
5959
|
+
},
|
|
5916
5960
|
openReceiveModal: () => setReceiveModalOpen(true),
|
|
5917
5961
|
// swap
|
|
5918
5962
|
getSwapConfig: () => pollarClient.getSwapConfig(),
|
|
5919
5963
|
getSwapTokens: () => pollarClient.getSwapTokens(),
|
|
5920
5964
|
getSwapQuote: (params) => pollarClient.getSwapQuote(params),
|
|
5921
5965
|
swap: (quote, opts) => pollarClient.swap(quote, opts),
|
|
5922
|
-
openSwapModal: () =>
|
|
5966
|
+
openSwapModal: () => {
|
|
5967
|
+
pollarClient.resetTransactionState();
|
|
5968
|
+
setSwapModalKey((k) => k + 1);
|
|
5969
|
+
setSwapModalOpen(true);
|
|
5970
|
+
},
|
|
5923
5971
|
// earn
|
|
5924
5972
|
getEarnProviders: () => pollarClient.getEarnProviders(),
|
|
5925
5973
|
getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider),
|
|
5926
5974
|
getEarnPosition: (params) => pollarClient.getEarnPosition(params),
|
|
5927
5975
|
earnDeposit: (params) => pollarClient.earnDeposit(params),
|
|
5928
5976
|
earnWithdraw: (params) => pollarClient.earnWithdraw(params),
|
|
5929
|
-
openEarnModal: () =>
|
|
5977
|
+
openEarnModal: () => {
|
|
5978
|
+
pollarClient.resetTransactionState();
|
|
5979
|
+
setEarnModalKey((k) => k + 1);
|
|
5980
|
+
setEarnModalOpen(true);
|
|
5981
|
+
},
|
|
5930
5982
|
// sessions
|
|
5931
5983
|
sessions,
|
|
5932
5984
|
openSessionsModal: () => setSessionsModalOpen(true),
|
|
@@ -5980,9 +6032,9 @@ function PollarProvider({
|
|
|
5980
6032
|
txHistoryModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setTxHistoryModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(TxHistoryModal, { onClose: () => setTxHistoryModalOpen(false) }) }),
|
|
5981
6033
|
walletBalanceModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) }),
|
|
5982
6034
|
enabledAssetsModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setEnabledAssetsModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(EnabledAssetsModal, { onClose: () => setEnabledAssetsModalOpen(false) }) }),
|
|
5983
|
-
sendModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }),
|
|
5984
|
-
swapModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSwapModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SwapModal, { onClose: () => setSwapModalOpen(false) }) }),
|
|
5985
|
-
earnModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setEarnModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(EarnModal, { onClose: () => setEarnModalOpen(false) }) }),
|
|
6035
|
+
sendModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }, sendModalKey),
|
|
6036
|
+
swapModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSwapModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SwapModal, { onClose: () => setSwapModalOpen(false) }) }, swapModalKey),
|
|
6037
|
+
earnModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setEarnModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(EarnModal, { onClose: () => setEarnModalOpen(false) }) }, earnModalKey),
|
|
5986
6038
|
receiveModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false) }) }),
|
|
5987
6039
|
sessionsModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSessionsModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SessionsModal, { onClose: () => setSessionsModalOpen(false) }) }),
|
|
5988
6040
|
distributionRulesModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setDistributionRulesModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(DistributionRulesModal, { onClose: () => setDistributionRulesModalOpen(false) }) })
|