@gardenfi/swap 0.0.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +5 -0
- package/dist/index10.cjs +1 -0
- package/dist/index10.js +33 -0
- package/dist/index11.cjs +1 -0
- package/dist/index11.js +36 -0
- package/dist/index12.cjs +1 -0
- package/dist/index12.js +65 -0
- package/dist/index13.cjs +1 -0
- package/dist/index13.js +33 -0
- package/dist/index14.cjs +1 -0
- package/dist/index14.js +190 -0
- package/dist/index15.cjs +1 -0
- package/dist/index15.js +51 -0
- package/dist/index16.cjs +1 -0
- package/dist/index16.js +313 -0
- package/dist/index17.cjs +1 -0
- package/dist/index17.js +29 -0
- package/dist/index18.cjs +1 -0
- package/dist/index18.js +17 -0
- package/dist/index19.cjs +1 -0
- package/dist/index19.js +229 -0
- package/dist/index20.cjs +1 -0
- package/dist/index20.js +15 -0
- package/dist/index21.cjs +1 -0
- package/dist/index21.js +92 -0
- package/dist/index22.cjs +1 -0
- package/dist/index22.js +143 -0
- package/dist/index23.cjs +1 -0
- package/dist/index23.js +22 -0
- package/dist/index24.cjs +1 -0
- package/dist/index24.js +20 -0
- package/dist/index25.cjs +1 -0
- package/dist/index25.js +108 -0
- package/dist/index26.cjs +1 -0
- package/dist/index26.js +85 -0
- package/dist/index27.cjs +1 -0
- package/dist/index27.js +15 -0
- package/dist/index28.cjs +1 -0
- package/dist/index28.js +54 -0
- package/dist/index29.cjs +1 -0
- package/dist/index29.js +63 -0
- package/dist/index3.cjs +1 -0
- package/dist/index3.js +7 -0
- package/dist/index30.cjs +1 -0
- package/dist/index30.js +44 -0
- package/dist/index31.cjs +1 -0
- package/dist/index31.js +43 -0
- package/dist/index4.cjs +1 -0
- package/dist/index4.js +26 -0
- package/dist/index5.cjs +1 -0
- package/dist/index5.js +250 -0
- package/dist/index6.cjs +1 -0
- package/dist/index6.js +98 -0
- package/dist/index7.cjs +1 -0
- package/dist/index7.js +51 -0
- package/dist/index8.cjs +1 -0
- package/dist/index8.js +51 -0
- package/dist/index9.cjs +1 -0
- package/dist/index9.js +101 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/lib/GardenComponent.d.ts +6 -0
- package/dist/src/lib/common/AddressDetails.d.ts +8 -0
- package/dist/src/lib/common/ChainsToolTip.d.ts +8 -0
- package/dist/src/lib/common/Modal.d.ts +9 -0
- package/dist/src/lib/common/ModalComponent.d.ts +7 -0
- package/dist/src/lib/common/Navbar.d.ts +10 -0
- package/dist/src/lib/common/SwapInput.d.ts +17 -0
- package/dist/src/lib/components/CreateSwap.d.ts +4 -0
- package/dist/src/lib/components/SwapSavingsAndAddresses.d.ts +10 -0
- package/dist/src/lib/components/SwapWidget.d.ts +7 -0
- package/dist/src/lib/components/assetSelection/AssetModal.d.ts +8 -0
- package/dist/src/lib/components/assetSelection/AvailableChainsSidebar.d.ts +11 -0
- package/dist/src/lib/components/feesAndRateDetails/FeeAndRateDetails.d.ts +3 -0
- package/dist/src/lib/components/feesAndRateDetails/InputAddress.d.ts +3 -0
- package/dist/src/lib/components/feesAndRateDetails/InputAddressAndFeeRateDetails.d.ts +3 -0
- package/dist/src/lib/components/transactions/SwapInfo.d.ts +12 -0
- package/dist/src/lib/components/transactions/TransactionHistory.d.ts +7 -0
- package/dist/src/lib/components/transactions/TransactionRow.d.ts +11 -0
- package/dist/src/lib/components/transactions/TransactionSkeleton.d.ts +3 -0
- package/dist/src/lib/components/transactions/Transactions.d.ts +4 -0
- package/dist/src/lib/constants/animations.d.ts +7 -0
- package/dist/src/lib/constants/constants.d.ts +29 -0
- package/dist/src/lib/constants/network.d.ts +0 -0
- package/dist/src/lib/hooks/useSwap.d.ts +29 -0
- package/dist/src/lib/store/assetStore.d.ts +23 -0
- package/dist/src/lib/store/swapStore.d.ts +79 -0
- package/dist/src/lib/store/transactionHistoryStore.d.ts +17 -0
- package/dist/src/lib/store/viewPortStore.d.ts +17 -0
- package/dist/src/lib/types/types.d.ts +54 -0
- package/dist/src/lib/utils/utils.d.ts +14 -0
- package/dist/style.css +1 -0
- package/package.json +62 -0
package/dist/index3.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),n=require("@gardenfi/react-hooks"),r=require("./index4.cjs"),o=({...e})=>t.createElement(n.GardenProvider,{...e},t.createElement(r,{network:e.config.environment}));exports.GardenComponent=o;
|
package/dist/index3.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import t from "react";
|
|
2
|
+
import { GardenProvider as r } from "@gardenfi/react-hooks";
|
|
3
|
+
import n from "./index4.js";
|
|
4
|
+
const i = ({ ...e }) => /* @__PURE__ */ t.createElement(r, { ...e }, /* @__PURE__ */ t.createElement(n, { network: e.config.environment }));
|
|
5
|
+
export {
|
|
6
|
+
i as GardenComponent
|
|
7
|
+
};
|
package/dist/index30.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),o=require("@gardenfi/garden-book"),f=require("./index6.cjs"),m=({sendAsset:r,receiveAsset:l,sendAmount:s,receiveAmount:g,equalSplit:n=!1})=>{const{chains:i}=f.assetInfoStore(),t=i.find(a=>a.chain===r.chain),c=i.find(a=>a.chain===l.chain);return e.createElement("div",{className:"flex items-center justify-between"},e.createElement("div",{className:`flex items-center justify-start gap-2 ${n?"w-fit":"w-full"}`},e.createElement(o.Typography,{size:"h3",weight:"regular"},s),e.createElement(o.TokenNetworkLogos,{tokenLogo:r.logo,chainLogo:(t==null?void 0:t.iconUrl)===r.logo?"":(t==null?void 0:t.iconUrl)??""})),e.createElement(o.ArrowRightIcon,{className:n?"":"h-5 w-9"}),e.createElement("div",{className:`flex items-center justify-end gap-2 ${n?"w-fit":"w-full"}`},e.createElement(o.Typography,{size:"h3",weight:"regular"},g),e.createElement(o.TokenNetworkLogos,{tokenLogo:l.logo,chainLogo:(c==null?void 0:c.iconUrl)??""})))};exports.SwapInfo=m;
|
package/dist/index30.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
import { Typography as i, TokenNetworkLogos as m, ArrowRightIcon as s } from "@gardenfi/garden-book";
|
|
3
|
+
import { assetInfoStore as w } from "./index6.js";
|
|
4
|
+
const u = ({
|
|
5
|
+
sendAsset: o,
|
|
6
|
+
receiveAsset: n,
|
|
7
|
+
sendAmount: f,
|
|
8
|
+
receiveAmount: g,
|
|
9
|
+
equalSplit: r = !1
|
|
10
|
+
}) => {
|
|
11
|
+
const { chains: l } = w(), t = l.find((a) => a.chain === o.chain), c = l.find(
|
|
12
|
+
(a) => a.chain === n.chain
|
|
13
|
+
);
|
|
14
|
+
return /* @__PURE__ */ e.createElement("div", { className: "flex items-center justify-between" }, /* @__PURE__ */ e.createElement(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
className: `flex items-center justify-start gap-2 ${r ? "w-fit" : "w-full"}`
|
|
18
|
+
},
|
|
19
|
+
/* @__PURE__ */ e.createElement(i, { size: "h3", weight: "regular" }, f),
|
|
20
|
+
/* @__PURE__ */ e.createElement(
|
|
21
|
+
m,
|
|
22
|
+
{
|
|
23
|
+
tokenLogo: o.logo,
|
|
24
|
+
chainLogo: (t == null ? void 0 : t.iconUrl) === o.logo ? "" : (t == null ? void 0 : t.iconUrl) ?? ""
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
), /* @__PURE__ */ e.createElement(s, { className: r ? "" : "h-5 w-9" }), /* @__PURE__ */ e.createElement(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
className: `flex items-center justify-end gap-2 ${r ? "w-fit" : "w-full"}`
|
|
31
|
+
},
|
|
32
|
+
/* @__PURE__ */ e.createElement(i, { size: "h3", weight: "regular" }, g),
|
|
33
|
+
/* @__PURE__ */ e.createElement(
|
|
34
|
+
m,
|
|
35
|
+
{
|
|
36
|
+
tokenLogo: n.logo,
|
|
37
|
+
chainLogo: (c == null ? void 0 : c.iconUrl) ?? ""
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
));
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
u as SwapInfo
|
|
44
|
+
};
|
package/dist/index31.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),c=require("@gardenfi/orderbook"),r=require("@gardenfi/garden-book"),p=require("./index5.cjs"),m=require("./index17.cjs"),u=({isRefund:a,address:n})=>{const l=e.useId(),{inputAsset:o,outputAsset:i}=p.swapStore(),t=e.useMemo(()=>a?o&&o.chain:i&&i.chain,[o,i,a]);return e.createElement(e.Fragment,null,n&&t&&e.createElement("div",{className:`flex cursor-pointer items-center justify-between px-4 transition-all duration-200 ease-in-out hover:bg-white ${t&&!c.isBitcoin(t)?"pointer-events-auto max-h-7 py-1 opacity-100":"pointer-events-none max-h-0 py-0 opacity-0"}`,onClick:s=>{s.stopPropagation()}},e.createElement(r.Typography,{"data-tooltip-id":a?l:"",size:"h5",weight:"regular",className:"!text-mid-grey"},a?"Refund":"Receive"," address"),e.createElement("div",{className:"flex items-center gap-2"},e.createElement(r.Typography,{size:"h5",weight:"regular"},m.getTrimmedAddress(n)),e.createElement("div",{className:"flex gap-1"},e.createElement(r.EditIcon,{className:`cursor-pointer p-0.5 transition-all duration-500 ease-in-out ${t&&c.isBitcoin(t)?"max-h-4 max-w-4 opacity-100":"-mr-3.5 max-h-0 max-w-0 opacity-0"}`,onClick:s=>{s.stopPropagation()}}),e.createElement(r.ArrowNorthEastIcon,{className:"h-4 w-4 cursor-pointer p-[3px]"})))),e.createElement(r.Typography,{size:"h5",weight:"regular"}))};exports.AddressDetails=u;
|
package/dist/index31.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import e, { useId as p, useMemo as l } from "react";
|
|
2
|
+
import { isBitcoin as m } from "@gardenfi/orderbook";
|
|
3
|
+
import { Typography as n, EditIcon as h, ArrowNorthEastIcon as u } from "@gardenfi/garden-book";
|
|
4
|
+
import { swapStore as g } from "./index5.js";
|
|
5
|
+
import { getTrimmedAddress as d } from "./index17.js";
|
|
6
|
+
const v = ({
|
|
7
|
+
isRefund: r,
|
|
8
|
+
address: s
|
|
9
|
+
}) => {
|
|
10
|
+
const c = p(), { inputAsset: a, outputAsset: o } = g(), t = l(() => r ? a && a.chain : o && o.chain, [a, o, r]);
|
|
11
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, s && t && /* @__PURE__ */ e.createElement(
|
|
12
|
+
"div",
|
|
13
|
+
{
|
|
14
|
+
className: `flex cursor-pointer items-center justify-between px-4 transition-all duration-200 ease-in-out hover:bg-white ${t && !m(t) ? "pointer-events-auto max-h-7 py-1 opacity-100" : "pointer-events-none max-h-0 py-0 opacity-0"}`,
|
|
15
|
+
onClick: (i) => {
|
|
16
|
+
i.stopPropagation();
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
/* @__PURE__ */ e.createElement(
|
|
20
|
+
n,
|
|
21
|
+
{
|
|
22
|
+
"data-tooltip-id": r ? c : "",
|
|
23
|
+
size: "h5",
|
|
24
|
+
weight: "regular",
|
|
25
|
+
className: "!text-mid-grey"
|
|
26
|
+
},
|
|
27
|
+
r ? "Refund" : "Receive",
|
|
28
|
+
" address"
|
|
29
|
+
),
|
|
30
|
+
/* @__PURE__ */ e.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ e.createElement(n, { size: "h5", weight: "regular" }, d(s)), /* @__PURE__ */ e.createElement("div", { className: "flex gap-1" }, /* @__PURE__ */ e.createElement(
|
|
31
|
+
h,
|
|
32
|
+
{
|
|
33
|
+
className: `cursor-pointer p-0.5 transition-all duration-500 ease-in-out ${t && m(t) ? "max-h-4 max-w-4 opacity-100" : "-mr-3.5 max-h-0 max-w-0 opacity-0"}`,
|
|
34
|
+
onClick: (i) => {
|
|
35
|
+
i.stopPropagation();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
), /* @__PURE__ */ e.createElement(u, { className: "h-4 w-4 cursor-pointer p-[3px]" })))
|
|
39
|
+
), /* @__PURE__ */ e.createElement(n, { size: "h5", weight: "regular" }));
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
v as AddressDetails
|
|
43
|
+
};
|
package/dist/index4.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react"),l=require("./index5.cjs"),i=require("./index6.cjs"),m=require("./index7.cjs"),u=require("./index8.cjs"),p=require("./index9.cjs"),n=require("@gardenfi/garden-book"),x=require("./index10.cjs"),d=require("@gardenfi/core"),w=({network:o})=>{const{network:r}=d.resolveApiConfig(o),[t,c]=e.useState("swap"),{setCurrentNetwork:a}=l.swapStore(),{fetchAssets:s}=i.assetInfoStore();return e.useEffect(()=>{s(r),a(r)},[s,a,r]),e.createElement(e.Fragment,null,e.createElement("div",{className:`mx-auto flex h-full w-[424px] rounded-[20px] p-3 pb-4 max-w-[424px] bg-garden-grey flex-col justify-start gap-4 sm:max-w-[424px] ${t==="history"?"max-h-[496px]":""}`},e.createElement(m.Navbar,{active:t,onChange:c}),e.createElement("div",{className:"flex-1 flex flex-col min-h-0 w-full"},t==="swap"&&e.createElement(p,null),t==="history"&&e.createElement(u,null)),e.createElement("div",{className:"text-xs h-4 text-mid-grey flex items-center justify-center gap-1.5 px-2"},e.createElement(n.Typography,{size:"h5",weight:"medium",className:"!text-mid-grey"},"Powered by"),e.createElement(n.GardenFullLogo,{width:58}))),e.createElement(x.Modal,null))};module.exports=w;
|
package/dist/index4.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import e, { useState as s, useEffect as n } from "react";
|
|
2
|
+
import { swapStore as i } from "./index5.js";
|
|
3
|
+
import { assetInfoStore as c } from "./index6.js";
|
|
4
|
+
import { Navbar as p } from "./index7.js";
|
|
5
|
+
import f from "./index8.js";
|
|
6
|
+
import x from "./index9.js";
|
|
7
|
+
import { Typography as u, GardenFullLogo as d } from "@gardenfi/garden-book";
|
|
8
|
+
import { Modal as w } from "./index10.js";
|
|
9
|
+
import { resolveApiConfig as g } from "@gardenfi/core";
|
|
10
|
+
const k = ({ network: m }) => {
|
|
11
|
+
const { network: r } = g(m), [t, l] = s("swap"), { setCurrentNetwork: a } = i(), { fetchAssets: o } = c();
|
|
12
|
+
return n(() => {
|
|
13
|
+
o(r), a(r);
|
|
14
|
+
}, [o, a, r]), /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
className: `mx-auto flex h-full w-[424px] rounded-[20px] p-3 pb-4 max-w-[424px] bg-garden-grey flex-col justify-start gap-4 sm:max-w-[424px] ${t === "history" ? "max-h-[496px]" : ""}`
|
|
18
|
+
},
|
|
19
|
+
/* @__PURE__ */ e.createElement(p, { active: t, onChange: l }),
|
|
20
|
+
/* @__PURE__ */ e.createElement("div", { className: "flex-1 flex flex-col min-h-0 w-full" }, t === "swap" && /* @__PURE__ */ e.createElement(x, null), t === "history" && /* @__PURE__ */ e.createElement(f, null)),
|
|
21
|
+
/* @__PURE__ */ e.createElement("div", { className: "text-xs h-4 text-mid-grey flex items-center justify-center gap-1.5 px-2" }, /* @__PURE__ */ e.createElement(u, { size: "h5", weight: "medium", className: "!text-mid-grey" }, "Powered by"), /* @__PURE__ */ e.createElement(d, { width: 58 }))
|
|
22
|
+
), /* @__PURE__ */ e.createElement(w, null));
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
k as default
|
|
26
|
+
};
|
package/dist/index5.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("zustand"),o=require("./index11.cjs"),n=require("@gardenfi/orderbook"),u=require("@gardenfi/utils"),i={name:"Bitcoin",decimals:8,symbol:"BTC",logo:"https://garden.imgix.net/token-images/bitcoin.svg",tokenAddress:"primary",atomicSwapAddress:"primary",chain:o.DEFAULT_NETWORK===u.Network.TESTNET?n.Chains.bitcoin_testnet:n.Chains.bitcoin,price:115767.9,min_amount:"50000",max_amount:"10000000000"},p=a.create(s=>({inputAsset:i,inputAmount:"",outputAmount:"",rate:0,networkFees:0,btcAddress:"",isApproving:!1,isNetworkFeesLoading:!1,swapInProgress:{isOpen:!1,order:null},isSwapping:!1,tokenPrices:{input:"0",output:"0"},error:{inputError:o.Errors.none,outputError:o.Errors.none,liquidityError:o.Errors.none,insufficientBalanceError:o.Errors.none},isFetchingQuote:{input:!1,output:!1},isEditBTCAddress:!1,isComparisonVisible:!1,isValidBitcoinAddress:!1,showComparison:{isTime:!1,isFees:!1},maxTimeSaved:0,maxCostSaved:0,currentNetwork:o.DEFAULT_NETWORK,setCurrentNetwork:r=>s({currentNetwork:r,inputAsset:{...i,chain:r===u.Network.MAINNET?n.Chains.bitcoin:n.Chains.bitcoin_testnet}}),setAsset:(r,e)=>{s(t=>({...t,[r===o.IOType.input?"inputAsset":"outputAsset"]:e}))},setAmount:(r,e)=>{s(t=>({...t,[r===o.IOType.input?"inputAmount":"outputAmount"]:e}))},setRate:r=>{s(e=>({...e,rate:r}))},setNetworkFees:r=>{s(e=>({...e,networkFees:r}))},setIsNetworkFeesLoading:r=>{s({isNetworkFeesLoading:r})},setBtcAddress:r=>{s(e=>({...e,btcAddress:r}))},swapAssets:()=>{s(r=>{const e=!r.outputAmount||r.outputAmount==="0"?"":r.outputAmount,t=!r.inputAmount||r.inputAmount==="0"?"":r.outputAmount;return{...r,inputAsset:r.outputAsset,outputAsset:r.inputAsset,inputAmount:e,outputAmount:t,error:{...r.error,inputError:o.Errors.none,outputError:o.Errors.none,liquidityError:o.Errors.none,insufficientBalanceError:o.Errors.none}}})},setIsSwapping:r=>{s({isSwapping:r})},setIsEditBTCAddress:r=>{s({isEditBTCAddress:r})},setTokenPrices:r=>{s({tokenPrices:r})},setError:r=>{s(e=>({error:{...e.error,...r}}))},setIsFetchingQuote:r=>{s({isFetchingQuote:r})},setIsApproving:r=>{s({isApproving:r})},setIsComparisonVisible:r=>{s({isComparisonVisible:r})},setIsValidBitcoinAddress:r=>{s({isValidBitcoinAddress:r})},showComparisonHandler:r=>{s({isComparisonVisible:!0,showComparison:{isTime:r==="time",isFees:r==="fees"}})},hideComparison:()=>{s({isComparisonVisible:!1,showComparison:{isTime:!1,isFees:!1}})},updateComparisonSavings:(r,e)=>{s({maxTimeSaved:r,maxCostSaved:e})},clearSwapState:()=>{s({inputAmount:"",outputAmount:"",rate:0,btcAddress:"",outputAsset:void 0,inputAsset:i,isApproving:!1,isSwapping:!1,tokenPrices:{input:"0",output:"0"},error:{inputError:o.Errors.none,outputError:o.Errors.none,liquidityError:o.Errors.none,insufficientBalanceError:o.Errors.none},isFetchingQuote:{input:!1,output:!1},isEditBTCAddress:!1,isValidBitcoinAddress:!1,showComparison:{isTime:!1,isFees:!1},maxTimeSaved:0,maxCostSaved:0})},clear:()=>{s({inputAmount:"",outputAmount:"",btcAddress:"",rate:0,outputAsset:void 0,inputAsset:i,isSwapping:!1,isApproving:!1,tokenPrices:{input:"0",output:"0"},error:{inputError:o.Errors.none,outputError:o.Errors.none,liquidityError:o.Errors.none,insufficientBalanceError:o.Errors.none},isFetchingQuote:{input:!1,output:!1},isEditBTCAddress:!1,isValidBitcoinAddress:!1,showComparison:{isTime:!1,isFees:!1},maxTimeSaved:0,maxCostSaved:0})},clearSwapInputState:()=>{s({inputAmount:"",outputAmount:"",rate:0,tokenPrices:{input:"0",output:"0"},error:{inputError:o.Errors.none,outputError:o.Errors.none,liquidityError:o.Errors.none,insufficientBalanceError:o.Errors.none}})}}));exports.BTC=i;exports.swapStore=p;
|
package/dist/index5.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { create as m } from "zustand";
|
|
2
|
+
import { DEFAULT_NETWORK as p, Errors as e, IOType as u } from "./index11.js";
|
|
3
|
+
import { Chains as r } from "@gardenfi/orderbook";
|
|
4
|
+
import { Network as a } from "@gardenfi/utils";
|
|
5
|
+
const s = {
|
|
6
|
+
name: "Bitcoin",
|
|
7
|
+
decimals: 8,
|
|
8
|
+
symbol: "BTC",
|
|
9
|
+
logo: "https://garden.imgix.net/token-images/bitcoin.svg",
|
|
10
|
+
tokenAddress: "primary",
|
|
11
|
+
atomicSwapAddress: "primary",
|
|
12
|
+
chain: p === a.TESTNET ? r.bitcoin_testnet : r.bitcoin,
|
|
13
|
+
price: 115767.9,
|
|
14
|
+
min_amount: "50000",
|
|
15
|
+
max_amount: "10000000000"
|
|
16
|
+
}, f = m((t) => ({
|
|
17
|
+
inputAsset: s,
|
|
18
|
+
inputAmount: "",
|
|
19
|
+
outputAmount: "",
|
|
20
|
+
rate: 0,
|
|
21
|
+
networkFees: 0,
|
|
22
|
+
btcAddress: "",
|
|
23
|
+
isApproving: !1,
|
|
24
|
+
isNetworkFeesLoading: !1,
|
|
25
|
+
swapInProgress: {
|
|
26
|
+
isOpen: !1,
|
|
27
|
+
order: null
|
|
28
|
+
},
|
|
29
|
+
isSwapping: !1,
|
|
30
|
+
tokenPrices: {
|
|
31
|
+
input: "0",
|
|
32
|
+
output: "0"
|
|
33
|
+
},
|
|
34
|
+
error: {
|
|
35
|
+
inputError: e.none,
|
|
36
|
+
outputError: e.none,
|
|
37
|
+
liquidityError: e.none,
|
|
38
|
+
insufficientBalanceError: e.none
|
|
39
|
+
},
|
|
40
|
+
isFetchingQuote: {
|
|
41
|
+
input: !1,
|
|
42
|
+
output: !1
|
|
43
|
+
},
|
|
44
|
+
isEditBTCAddress: !1,
|
|
45
|
+
isComparisonVisible: !1,
|
|
46
|
+
isValidBitcoinAddress: !1,
|
|
47
|
+
showComparison: {
|
|
48
|
+
isTime: !1,
|
|
49
|
+
isFees: !1
|
|
50
|
+
},
|
|
51
|
+
maxTimeSaved: 0,
|
|
52
|
+
maxCostSaved: 0,
|
|
53
|
+
currentNetwork: p,
|
|
54
|
+
setCurrentNetwork: (o) => t({
|
|
55
|
+
currentNetwork: o,
|
|
56
|
+
inputAsset: {
|
|
57
|
+
...s,
|
|
58
|
+
chain: o === a.MAINNET ? r.bitcoin : r.bitcoin_testnet
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
setAsset: (o, i) => {
|
|
62
|
+
t((n) => ({
|
|
63
|
+
...n,
|
|
64
|
+
[o === u.input ? "inputAsset" : "outputAsset"]: i
|
|
65
|
+
}));
|
|
66
|
+
},
|
|
67
|
+
setAmount: (o, i) => {
|
|
68
|
+
t((n) => ({
|
|
69
|
+
...n,
|
|
70
|
+
[o === u.input ? "inputAmount" : "outputAmount"]: i
|
|
71
|
+
}));
|
|
72
|
+
},
|
|
73
|
+
setRate: (o) => {
|
|
74
|
+
t((i) => ({
|
|
75
|
+
...i,
|
|
76
|
+
rate: o
|
|
77
|
+
}));
|
|
78
|
+
},
|
|
79
|
+
setNetworkFees: (o) => {
|
|
80
|
+
t((i) => ({
|
|
81
|
+
...i,
|
|
82
|
+
networkFees: o
|
|
83
|
+
}));
|
|
84
|
+
},
|
|
85
|
+
setIsNetworkFeesLoading: (o) => {
|
|
86
|
+
t({ isNetworkFeesLoading: o });
|
|
87
|
+
},
|
|
88
|
+
setBtcAddress: (o) => {
|
|
89
|
+
t((i) => ({
|
|
90
|
+
...i,
|
|
91
|
+
btcAddress: o
|
|
92
|
+
}));
|
|
93
|
+
},
|
|
94
|
+
swapAssets: () => {
|
|
95
|
+
t((o) => {
|
|
96
|
+
const i = !o.outputAmount || o.outputAmount === "0" ? "" : o.outputAmount, n = !o.inputAmount || o.inputAmount === "0" ? "" : o.outputAmount;
|
|
97
|
+
return {
|
|
98
|
+
...o,
|
|
99
|
+
inputAsset: o.outputAsset,
|
|
100
|
+
outputAsset: o.inputAsset,
|
|
101
|
+
inputAmount: i,
|
|
102
|
+
outputAmount: n,
|
|
103
|
+
error: {
|
|
104
|
+
...o.error,
|
|
105
|
+
inputError: e.none,
|
|
106
|
+
outputError: e.none,
|
|
107
|
+
liquidityError: e.none,
|
|
108
|
+
insufficientBalanceError: e.none
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
setIsSwapping: (o) => {
|
|
114
|
+
t({ isSwapping: o });
|
|
115
|
+
},
|
|
116
|
+
setIsEditBTCAddress: (o) => {
|
|
117
|
+
t({ isEditBTCAddress: o });
|
|
118
|
+
},
|
|
119
|
+
setTokenPrices: (o) => {
|
|
120
|
+
t({ tokenPrices: o });
|
|
121
|
+
},
|
|
122
|
+
setError: (o) => {
|
|
123
|
+
t((i) => ({ error: { ...i.error, ...o } }));
|
|
124
|
+
},
|
|
125
|
+
setIsFetchingQuote: (o) => {
|
|
126
|
+
t({ isFetchingQuote: o });
|
|
127
|
+
},
|
|
128
|
+
setIsApproving: (o) => {
|
|
129
|
+
t({ isApproving: o });
|
|
130
|
+
},
|
|
131
|
+
setIsComparisonVisible: (o) => {
|
|
132
|
+
t({ isComparisonVisible: o });
|
|
133
|
+
},
|
|
134
|
+
setIsValidBitcoinAddress: (o) => {
|
|
135
|
+
t({ isValidBitcoinAddress: o });
|
|
136
|
+
},
|
|
137
|
+
showComparisonHandler: (o) => {
|
|
138
|
+
t({
|
|
139
|
+
isComparisonVisible: !0,
|
|
140
|
+
showComparison: {
|
|
141
|
+
isTime: o === "time",
|
|
142
|
+
isFees: o === "fees"
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
hideComparison: () => {
|
|
147
|
+
t({
|
|
148
|
+
isComparisonVisible: !1,
|
|
149
|
+
showComparison: {
|
|
150
|
+
isTime: !1,
|
|
151
|
+
isFees: !1
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
updateComparisonSavings: (o, i) => {
|
|
156
|
+
t({
|
|
157
|
+
maxTimeSaved: o,
|
|
158
|
+
maxCostSaved: i
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
clearSwapState: () => {
|
|
162
|
+
t({
|
|
163
|
+
inputAmount: "",
|
|
164
|
+
outputAmount: "",
|
|
165
|
+
rate: 0,
|
|
166
|
+
btcAddress: "",
|
|
167
|
+
outputAsset: void 0,
|
|
168
|
+
inputAsset: s,
|
|
169
|
+
isApproving: !1,
|
|
170
|
+
isSwapping: !1,
|
|
171
|
+
tokenPrices: {
|
|
172
|
+
input: "0",
|
|
173
|
+
output: "0"
|
|
174
|
+
},
|
|
175
|
+
error: {
|
|
176
|
+
inputError: e.none,
|
|
177
|
+
outputError: e.none,
|
|
178
|
+
liquidityError: e.none,
|
|
179
|
+
insufficientBalanceError: e.none
|
|
180
|
+
},
|
|
181
|
+
isFetchingQuote: {
|
|
182
|
+
input: !1,
|
|
183
|
+
output: !1
|
|
184
|
+
},
|
|
185
|
+
isEditBTCAddress: !1,
|
|
186
|
+
isValidBitcoinAddress: !1,
|
|
187
|
+
showComparison: {
|
|
188
|
+
isTime: !1,
|
|
189
|
+
isFees: !1
|
|
190
|
+
},
|
|
191
|
+
maxTimeSaved: 0,
|
|
192
|
+
maxCostSaved: 0
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
clear: () => {
|
|
196
|
+
t({
|
|
197
|
+
inputAmount: "",
|
|
198
|
+
outputAmount: "",
|
|
199
|
+
btcAddress: "",
|
|
200
|
+
rate: 0,
|
|
201
|
+
outputAsset: void 0,
|
|
202
|
+
inputAsset: s,
|
|
203
|
+
isSwapping: !1,
|
|
204
|
+
isApproving: !1,
|
|
205
|
+
tokenPrices: {
|
|
206
|
+
input: "0",
|
|
207
|
+
output: "0"
|
|
208
|
+
},
|
|
209
|
+
error: {
|
|
210
|
+
inputError: e.none,
|
|
211
|
+
outputError: e.none,
|
|
212
|
+
liquidityError: e.none,
|
|
213
|
+
insufficientBalanceError: e.none
|
|
214
|
+
},
|
|
215
|
+
isFetchingQuote: {
|
|
216
|
+
input: !1,
|
|
217
|
+
output: !1
|
|
218
|
+
},
|
|
219
|
+
isEditBTCAddress: !1,
|
|
220
|
+
isValidBitcoinAddress: !1,
|
|
221
|
+
showComparison: {
|
|
222
|
+
isTime: !1,
|
|
223
|
+
isFees: !1
|
|
224
|
+
},
|
|
225
|
+
maxTimeSaved: 0,
|
|
226
|
+
maxCostSaved: 0
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
clearSwapInputState: () => {
|
|
230
|
+
t({
|
|
231
|
+
inputAmount: "",
|
|
232
|
+
outputAmount: "",
|
|
233
|
+
rate: 0,
|
|
234
|
+
tokenPrices: {
|
|
235
|
+
input: "0",
|
|
236
|
+
output: "0"
|
|
237
|
+
},
|
|
238
|
+
error: {
|
|
239
|
+
inputError: e.none,
|
|
240
|
+
outputError: e.none,
|
|
241
|
+
liquidityError: e.none,
|
|
242
|
+
insufficientBalanceError: e.none
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}));
|
|
247
|
+
export {
|
|
248
|
+
s as BTC,
|
|
249
|
+
f as swapStore
|
|
250
|
+
};
|
package/dist/index6.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("zustand"),d=require("./index11.cjs"),u=require("@gardenfi/utils"),m=e=>{const{chain:s,chainName:t}=c(e.chain);return{chainName:t,chain:s,chainId:e.id,iconUrl:e.icon,explorerUrl:e.explorer_url,confirmationTarget:e.confirmation_target,sourceTimelock:parseInt(e.source_timelock),destinationTimelock:parseInt(e.destination_timelock),supportedHtlcSchemas:e.supported_htlc_schemas,supportedTokenSchemas:e.supported_token_schemas,assets:e.assets.map(o=>w(o,e))}},w=(e,s)=>{var a,n;const{chain:t}=c(s.chain),{symbol:o,name:r}=k(e.id);return{name:r,symbol:o,chain:t,decimals:e.decimals,tokenAddress:((a=e.token)==null?void 0:a.address)||"",atomicSwapAddress:((n=e.htlc)==null?void 0:n.address)||"",logo:e.icon,price:e.price,min_amount:e.min_amount,max_amount:e.max_amount}},c=e=>({chain:e.split(":")[0],chainName:e.replace(/[_-]/g," ").replace(/\b\w/g,s=>s.toUpperCase())}),h={wbtc:"Wrapped Bitcoin",sol:"Solana",usdc:"USD Coin",usdt:"Tether USD",btc:"Bitcoin",cbbtc:"Coinbase Wrapped Bitcoin",wcbtc:"Wrapped Citrea Bitcoin"},k=e=>{const s=e.split(":");let t;s.length<2?t=e.toUpperCase():t=s[s.length-1].toUpperCase();const o=h[t.toLowerCase()]??t;return{symbol:t,name:o}},g=p.create((e,s)=>({chains:[],allAssets:[],isLoading:!1,error:null,currentNetwork:u.Network.TESTNET,modalOpenFor:null,isAssetModalOpen:!1,filter:"",fetchAssets:async t=>{const o=t||s().currentNetwork;e({isLoading:!0,error:null});try{const r=await fetch(`${d.getApiEndpoint(o).api}/v2/chains`);if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();if(a.status!=="Ok")throw new Error("API returned error status");const n=a.result.map(m),i=n.flatMap(l=>l.assets);e({chains:n,allAssets:i,isLoading:!1,error:null,currentNetwork:o})}catch(r){e({error:(r==null?void 0:r.message)??"Failed to load assets",isLoading:!1})}},setCurrentNetwork:t=>{e({currentNetwork:t})},openModal:t=>e({modalOpenFor:t}),closeModal:()=>e({modalOpenFor:null}),openAssetModal:()=>e({isAssetModalOpen:!0}),closeAssetModal:()=>e({isAssetModalOpen:!1,filter:""}),setFilter:t=>e({filter:t})}));exports.assetInfoStore=g;
|
package/dist/index6.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { create as p } from "zustand";
|
|
2
|
+
import { getApiEndpoint as d } from "./index11.js";
|
|
3
|
+
import { Network as m } from "@gardenfi/utils";
|
|
4
|
+
const u = (e) => {
|
|
5
|
+
const { chain: r, chainName: t } = i(e.chain);
|
|
6
|
+
return {
|
|
7
|
+
chainName: t,
|
|
8
|
+
chain: r,
|
|
9
|
+
chainId: e.id,
|
|
10
|
+
iconUrl: e.icon,
|
|
11
|
+
explorerUrl: e.explorer_url,
|
|
12
|
+
confirmationTarget: e.confirmation_target,
|
|
13
|
+
sourceTimelock: parseInt(e.source_timelock),
|
|
14
|
+
destinationTimelock: parseInt(e.destination_timelock),
|
|
15
|
+
supportedHtlcSchemas: e.supported_htlc_schemas,
|
|
16
|
+
supportedTokenSchemas: e.supported_token_schemas,
|
|
17
|
+
assets: e.assets.map((o) => w(o, e))
|
|
18
|
+
};
|
|
19
|
+
}, w = (e, r) => {
|
|
20
|
+
var a, n;
|
|
21
|
+
const { chain: t } = i(r.chain), { symbol: o, name: s } = k(e.id);
|
|
22
|
+
return {
|
|
23
|
+
name: s,
|
|
24
|
+
symbol: o,
|
|
25
|
+
chain: t,
|
|
26
|
+
decimals: e.decimals,
|
|
27
|
+
tokenAddress: ((a = e.token) == null ? void 0 : a.address) || "",
|
|
28
|
+
atomicSwapAddress: ((n = e.htlc) == null ? void 0 : n.address) || "",
|
|
29
|
+
logo: e.icon,
|
|
30
|
+
price: e.price,
|
|
31
|
+
min_amount: e.min_amount,
|
|
32
|
+
max_amount: e.max_amount
|
|
33
|
+
};
|
|
34
|
+
}, i = (e) => ({
|
|
35
|
+
chain: e.split(":")[0],
|
|
36
|
+
chainName: e.replace(/[_-]/g, " ").replace(/\b\w/g, (r) => r.toUpperCase())
|
|
37
|
+
}), h = {
|
|
38
|
+
wbtc: "Wrapped Bitcoin",
|
|
39
|
+
sol: "Solana",
|
|
40
|
+
usdc: "USD Coin",
|
|
41
|
+
usdt: "Tether USD",
|
|
42
|
+
btc: "Bitcoin",
|
|
43
|
+
cbbtc: "Coinbase Wrapped Bitcoin",
|
|
44
|
+
wcbtc: "Wrapped Citrea Bitcoin"
|
|
45
|
+
}, k = (e) => {
|
|
46
|
+
const r = e.split(":");
|
|
47
|
+
let t;
|
|
48
|
+
r.length < 2 ? t = e.toUpperCase() : t = r[r.length - 1].toUpperCase();
|
|
49
|
+
const o = h[t.toLowerCase()] ?? t;
|
|
50
|
+
return { symbol: t, name: o };
|
|
51
|
+
}, N = p((e, r) => ({
|
|
52
|
+
chains: [],
|
|
53
|
+
allAssets: [],
|
|
54
|
+
isLoading: !1,
|
|
55
|
+
error: null,
|
|
56
|
+
currentNetwork: m.TESTNET,
|
|
57
|
+
modalOpenFor: null,
|
|
58
|
+
isAssetModalOpen: !1,
|
|
59
|
+
filter: "",
|
|
60
|
+
fetchAssets: async (t) => {
|
|
61
|
+
const o = t || r().currentNetwork;
|
|
62
|
+
e({ isLoading: !0, error: null });
|
|
63
|
+
try {
|
|
64
|
+
const s = await fetch(
|
|
65
|
+
`${d(o).api}/v2/chains`
|
|
66
|
+
);
|
|
67
|
+
if (!s.ok)
|
|
68
|
+
throw new Error(`HTTP ${s.status}`);
|
|
69
|
+
const a = await s.json();
|
|
70
|
+
if (a.status !== "Ok")
|
|
71
|
+
throw new Error("API returned error status");
|
|
72
|
+
const n = a.result.map(u), l = n.flatMap((c) => c.assets);
|
|
73
|
+
e({
|
|
74
|
+
chains: n,
|
|
75
|
+
allAssets: l,
|
|
76
|
+
isLoading: !1,
|
|
77
|
+
error: null,
|
|
78
|
+
currentNetwork: o
|
|
79
|
+
});
|
|
80
|
+
} catch (s) {
|
|
81
|
+
e({
|
|
82
|
+
error: (s == null ? void 0 : s.message) ?? "Failed to load assets",
|
|
83
|
+
isLoading: !1
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
setCurrentNetwork: (t) => {
|
|
88
|
+
e({ currentNetwork: t });
|
|
89
|
+
},
|
|
90
|
+
openModal: (t) => e({ modalOpenFor: t }),
|
|
91
|
+
closeModal: () => e({ modalOpenFor: null }),
|
|
92
|
+
openAssetModal: () => e({ isAssetModalOpen: !0 }),
|
|
93
|
+
closeAssetModal: () => e({ isAssetModalOpen: !1, filter: "" }),
|
|
94
|
+
setFilter: (t) => e({ filter: t })
|
|
95
|
+
}));
|
|
96
|
+
export {
|
|
97
|
+
N as assetInfoStore
|
|
98
|
+
};
|
package/dist/index7.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),n=require("@gardenfi/garden-book"),r=[{key:"swap",label:"Swap",Icon:n.SwapHorizontalIcon},{key:"history",label:"History",Icon:n.BlogIcon}],b=({active:c="swap",onChange:a,className:i})=>{const[l,o]=e.useState(c);function m(t){o(t),a==null||a(t)}const s=r.find(t=>t.key===l),d=r.findIndex(t=>t.key===l)*(48+2);return e.createElement("div",{className:`w-full flex items-center px-2 ${i??""}`},e.createElement("div",{className:"flex items-center gap-2"},e.createElement(n.Typography,{size:"h4",color:"#473C75",weight:"medium"},s&&e.createElement(e.Fragment,null,s.label))),e.createElement("div",{className:"ml-auto relative"},e.createElement("div",{className:"flex justify-center items-center gap-1 max-w-24 w-24 h-8 rounded-[38px] bg-white/30 relative",style:{position:"relative"}},e.createElement("span",{className:"absolute top-0 left-0 h-full w-12 rounded-full bg-white z-0",style:{transform:`translateX(${d}px)`,transition:"transform 0.3s ease-in-out"}}),r.map(({key:t,Icon:u})=>{const p=l===t;return e.createElement("button",{key:t,className:"relative flex items-center justify-center px-4 py-1.5 w-12 rounded-[38px] overflow-hidden z-10 text-dark-grey h-full",onClick:()=>m(t),disabled:p,type:"button",style:{position:"relative"}},e.createElement(u,{className:"h-4 w-4 "}))}))))};exports.Navbar=b;
|
package/dist/index7.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import t, { useState as u } from "react";
|
|
2
|
+
import { SwapHorizontalIcon as f, BlogIcon as b, Typography as v } from "@gardenfi/garden-book";
|
|
3
|
+
const r = [
|
|
4
|
+
{ key: "swap", label: "Swap", Icon: f },
|
|
5
|
+
{ key: "history", label: "History", Icon: b }
|
|
6
|
+
], N = ({
|
|
7
|
+
active: n = "swap",
|
|
8
|
+
onChange: a,
|
|
9
|
+
className: i
|
|
10
|
+
}) => {
|
|
11
|
+
const [l, c] = u(n);
|
|
12
|
+
function o(e) {
|
|
13
|
+
c(e), a == null || a(e);
|
|
14
|
+
}
|
|
15
|
+
const s = r.find((e) => e.key === l), m = r.findIndex((e) => e.key === l) * (48 + 2);
|
|
16
|
+
return /* @__PURE__ */ t.createElement("div", { className: `w-full flex items-center px-2 ${i ?? ""}` }, /* @__PURE__ */ t.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ t.createElement(v, { size: "h4", color: "#473C75", weight: "medium" }, s && /* @__PURE__ */ t.createElement(t.Fragment, null, s.label))), /* @__PURE__ */ t.createElement("div", { className: "ml-auto relative" }, /* @__PURE__ */ t.createElement(
|
|
17
|
+
"div",
|
|
18
|
+
{
|
|
19
|
+
className: "flex justify-center items-center gap-1 max-w-24 w-24 h-8 rounded-[38px] bg-white/30 relative",
|
|
20
|
+
style: { position: "relative" }
|
|
21
|
+
},
|
|
22
|
+
/* @__PURE__ */ t.createElement(
|
|
23
|
+
"span",
|
|
24
|
+
{
|
|
25
|
+
className: "absolute top-0 left-0 h-full w-12 rounded-full bg-white z-0",
|
|
26
|
+
style: {
|
|
27
|
+
transform: `translateX(${m}px)`,
|
|
28
|
+
transition: "transform 0.3s ease-in-out"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
r.map(({ key: e, Icon: p }) => {
|
|
33
|
+
const d = l === e;
|
|
34
|
+
return /* @__PURE__ */ t.createElement(
|
|
35
|
+
"button",
|
|
36
|
+
{
|
|
37
|
+
key: e,
|
|
38
|
+
className: "relative flex items-center justify-center px-4 py-1.5 w-12 rounded-[38px] overflow-hidden z-10 text-dark-grey h-full",
|
|
39
|
+
onClick: () => o(e),
|
|
40
|
+
disabled: d,
|
|
41
|
+
type: "button",
|
|
42
|
+
style: { position: "relative" }
|
|
43
|
+
},
|
|
44
|
+
/* @__PURE__ */ t.createElement(p, { className: "h-4 w-4 " })
|
|
45
|
+
);
|
|
46
|
+
})
|
|
47
|
+
)));
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
N as Navbar
|
|
51
|
+
};
|
package/dist/index8.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react"),E=require("@gardenfi/garden-book"),L=require("@gardenfi/react-hooks"),q=require("./index12.cjs"),N=require("./index13.cjs"),H=({isOpen:s=!0})=>{const[o,l]=e.useState(!1),[w,b]=e.useState({bitcoin:"",evm:"",starknet:"",solana:"",sui:""}),{garden:t}=L.useGarden(),{fetchTransactions:c,totalItems:r,transactions:a,loadMore:y}=q(),M=e.useMemo(()=>a.length<r,[a.length,r]),k=async()=>{if(t){l(!0);try{await y(t,w)}finally{l(!1)}}};return e.useEffect(()=>{var i,u,d,f,h,m,x,A,v;if(!t||!s)return;const n={bitcoin:((u=(i=t==null?void 0:t.htlcs)==null?void 0:i.bitcoin)==null?void 0:u.htlcActorAddress)||"",evm:((d=t==null?void 0:t.htlcs.evm)==null?void 0:d.htlcActorAddress)||"",starknet:((h=(f=t==null?void 0:t.htlcs)==null?void 0:f.starknet)==null?void 0:h.htlcActorAddress)||"",solana:((x=(m=t==null?void 0:t.htlcs)==null?void 0:m.solana)==null?void 0:x.htlcActorAddress)||"",sui:((v=(A=t==null?void 0:t.htlcs)==null?void 0:A.sui)==null?void 0:v.htlcActorAddress)||""};b(n),c(t,n)},[t,s,c]),s?e.createElement("div",{className:"flex flex-col h-full w-full gap-3"},e.createElement("div",{className:"scrollbar-hide flex flex-1 flex-col gap-5 overflow-y-auto items-center rounded-2xl pb-6 min-h-0"},e.createElement("div",{className:"flex flex-col rounded-2xl w-full bg-white/50"},e.createElement(N,null)),M&&e.createElement(E.Button,{onClick:k,variant:o?"disabled":"secondary",className:"mx-auto min-h-10 w-1/4"},o?"Loading...":"Load More"))):null};module.exports=H;
|
package/dist/index8.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import e, { useState as w, useMemo as L, useEffect as k } from "react";
|
|
2
|
+
import { Button as N } from "@gardenfi/garden-book";
|
|
3
|
+
import { useGarden as T } from "@gardenfi/react-hooks";
|
|
4
|
+
import C from "./index12.js";
|
|
5
|
+
import H from "./index13.js";
|
|
6
|
+
const R = ({
|
|
7
|
+
isOpen: o = !0
|
|
8
|
+
}) => {
|
|
9
|
+
const [s, l] = w(!1), [b, p] = w({
|
|
10
|
+
bitcoin: "",
|
|
11
|
+
evm: "",
|
|
12
|
+
starknet: "",
|
|
13
|
+
solana: "",
|
|
14
|
+
sui: ""
|
|
15
|
+
}), { garden: t } = T(), { fetchTransactions: a, totalItems: c, transactions: r, loadMore: y } = C(), M = L(
|
|
16
|
+
() => r.length < c,
|
|
17
|
+
[r.length, c]
|
|
18
|
+
), E = async () => {
|
|
19
|
+
if (t) {
|
|
20
|
+
l(!0);
|
|
21
|
+
try {
|
|
22
|
+
await y(t, b);
|
|
23
|
+
} finally {
|
|
24
|
+
l(!1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return k(() => {
|
|
29
|
+
var i, m, f, d, u, h, x, A, v;
|
|
30
|
+
if (!t || !o) return;
|
|
31
|
+
const n = {
|
|
32
|
+
bitcoin: ((m = (i = t == null ? void 0 : t.htlcs) == null ? void 0 : i.bitcoin) == null ? void 0 : m.htlcActorAddress) || "",
|
|
33
|
+
evm: ((f = t == null ? void 0 : t.htlcs.evm) == null ? void 0 : f.htlcActorAddress) || "",
|
|
34
|
+
starknet: ((u = (d = t == null ? void 0 : t.htlcs) == null ? void 0 : d.starknet) == null ? void 0 : u.htlcActorAddress) || "",
|
|
35
|
+
solana: ((x = (h = t == null ? void 0 : t.htlcs) == null ? void 0 : h.solana) == null ? void 0 : x.htlcActorAddress) || "",
|
|
36
|
+
sui: ((v = (A = t == null ? void 0 : t.htlcs) == null ? void 0 : A.sui) == null ? void 0 : v.htlcActorAddress) || ""
|
|
37
|
+
};
|
|
38
|
+
p(n), a(t, n);
|
|
39
|
+
}, [t, o, a]), o ? /* @__PURE__ */ e.createElement("div", { className: "flex flex-col h-full w-full gap-3" }, /* @__PURE__ */ e.createElement("div", { className: "scrollbar-hide flex flex-1 flex-col gap-5 overflow-y-auto items-center rounded-2xl pb-6 min-h-0" }, /* @__PURE__ */ e.createElement("div", { className: "flex flex-col rounded-2xl w-full bg-white/50" }, /* @__PURE__ */ e.createElement(H, null)), M && /* @__PURE__ */ e.createElement(
|
|
40
|
+
N,
|
|
41
|
+
{
|
|
42
|
+
onClick: E,
|
|
43
|
+
variant: s ? "disabled" : "secondary",
|
|
44
|
+
className: "mx-auto min-h-10 w-1/4"
|
|
45
|
+
},
|
|
46
|
+
s ? "Loading..." : "Load More"
|
|
47
|
+
))) : null;
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
R as default
|
|
51
|
+
};
|
package/dist/index9.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react"),b=require("@gardenfi/garden-book"),S=require("./index14.cjs"),d=require("./index11.cjs"),B=require("./index15.cjs"),u=require("@gardenfi/orderbook"),D=require("./index16.cjs"),w=require("./index17.cjs"),T=()=>{const[C,m]=e.useState(!1),{outputAmount:v,inputAmount:q,inputAsset:t,outputAsset:o,handleInputAmountChange:y,handleOutputAmountChange:A,loading:s,error:r,validSwap:l,tokenPrices:f,isApproving:E,isSwapping:a,handleSwapClick:I,needsWalletConnection:n,controller:g,clearSwapState:h,swapAssets:x}=D.useSwap(),c=e.useMemo(()=>(!t||!o||u.isBitcoin(t.chain)||u.isStarknet(t.chain)||u.isSolana(t.chain)||u.isEVM(t.chain)||u.isSui(t.chain),!0),[t,o]),N=e.useMemo(()=>n?`Connect ${w.capitalizeChain(n)} Wallet`:r.liquidityError?"Insufficient liquidity":c?r.insufficientBalanceError?"Insufficient balance":n?`Connect ${w.capitalizeChain(n)} Wallet`:E?"Approving...":a?"Signing":"Swap":"Wallet does not support the chain",[c,r.liquidityError,E,a,n,r.insufficientBalanceError]),p=e.useMemo(()=>r.liquidityError?!0:n?!1:!c||a?!0:!l,[c,a,l,r.liquidityError,n]),k=e.useMemo(()=>p?"disabled":a?"ternary":n||l?"primary":"disabled",[p,a,l,n]),M=e.useMemo(()=>!t||!o?"":d.getTimeEstimates(t),[t,o]);return e.useEffect(()=>{let i;return s.input||s.output?i=setTimeout(()=>{m(!0)},300):m(!1),()=>{i&&clearTimeout(i)}},[s]),e.useEffect(()=>{const i=g.current;return()=>{i&&i.abort(),h()}},[h,g]),e.createElement("div",{className:"flex flex-col"},e.createElement("div",{className:"relative flex flex-col gap-3"},e.createElement("div",{className:"w-full"},e.createElement(S.SwapInput,{type:d.IOType.input,amount:q,onChange:y,asset:t,loading:s.input,price:f.input,error:r.inputError,balance:void 0})),e.createElement("div",{className:"absolute left-1/2 top-1/2 -translate-x-[8px] -translate-y-[8px] cursor-pointer",onClick:x},e.createElement("div",{className:"h-8 w-8 origin-center rounded-full border border-light-grey bg-white p-1.5 transition-transform hover:scale-[1.05]"}),e.createElement(b.ExchangeIcon,{className:"pointer-events-none absolute bottom-1.5 left-1.5"})),e.createElement("div",{className:"w-full"},e.createElement(S.SwapInput,{type:d.IOType.output,amount:v,onChange:A,asset:o,loading:s.output,price:f.output,error:r.outputError,timeEstimate:M}))),e.createElement(B.InputAddressAndFeeRateDetails,null),e.createElement(b.Button,{className:"w-full mt-3 transition-colors duration-500",variant:k,size:"lg",disabled:p||C,onClick:I},N))};module.exports=T;
|