@0xsequence/marketplace-sdk 0.3.7 → 0.3.8
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/{chunk-QGELCUYG.js → chunk-5BPDO2U3.js} +20 -7
- package/dist/chunk-5BPDO2U3.js.map +1 -0
- package/dist/{chunk-3LGNSRBR.js → chunk-PPSIO23Z.js} +79 -28
- package/dist/chunk-PPSIO23Z.js.map +1 -0
- package/dist/index.js +5 -5
- package/dist/react/hooks/index.d.ts +60 -7
- package/dist/react/hooks/index.js +2 -2
- package/dist/react/index.js +3 -3
- package/dist/react/ui/components/index.d.ts +3 -2
- package/dist/react/ui/components/index.js +3 -3
- package/dist/react/ui/index.d.ts +3 -1
- package/dist/react/ui/index.js +3 -3
- package/dist/utils/abi/index.js +5 -5
- package/dist/utils/index.js +5 -5
- package/package.json +1 -1
- package/src/react/_internal/transaction-machine/execute-transaction.ts +12 -3
- package/src/react/_internal/transaction-machine/useTransactionMachine.ts +6 -8
- package/src/react/hooks/useBuyCollectable.tsx +1 -1
- package/src/react/hooks/useCancelOrder.tsx +1 -1
- package/src/react/hooks/useCurrencies.tsx +8 -1
- package/src/react/hooks/useCurrencyBalance.tsx +52 -0
- package/src/react/hooks/useSell.tsx +1 -1
- package/src/react/ui/components/_internals/action-button/ActionButton.tsx +5 -1
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +4 -0
- package/src/react/ui/components/collectible-card/Footer.tsx +18 -14
- package/src/react/ui/modals/CreateListingModal/_store.ts +4 -1
- package/src/react/ui/modals/CreateListingModal/index.tsx +4 -2
- package/src/react/ui/modals/MakeOfferModal/_store.ts +5 -1
- package/src/react/ui/modals/MakeOfferModal/index.tsx +4 -2
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +0 -2
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +10 -11
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-3LGNSRBR.js.map +0 -1
- package/dist/chunk-QGELCUYG.js.map +0 -1
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
useSwitchChainModal,
|
|
49
49
|
useTransactionMachine,
|
|
50
50
|
useTransferTokens
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-5BPDO2U3.js";
|
|
52
52
|
import {
|
|
53
53
|
iconVariants
|
|
54
54
|
} from "./chunk-SBVLWSRZ.js";
|
|
@@ -730,8 +730,8 @@ function FloorPriceText({
|
|
|
730
730
|
import { Box as Box7, NumericInput as NumericInput2, TokenImage as TokenImage2 } from "@0xsequence/design-system";
|
|
731
731
|
import { observer as observer5 } from "@legendapp/state/react";
|
|
732
732
|
import { useState as useState3 } from "react";
|
|
733
|
-
import {
|
|
734
|
-
import { useAccount as useAccount2
|
|
733
|
+
import { parseUnits as parseUnits2 } from "viem";
|
|
734
|
+
import { useAccount as useAccount2 } from "wagmi";
|
|
735
735
|
|
|
736
736
|
// src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx
|
|
737
737
|
import { Skeleton as Skeleton2 } from "@0xsequence/design-system";
|
|
@@ -768,7 +768,6 @@ var CurrencyOptionsSelect = observer4(function CurrencyOptionsSelect2({
|
|
|
768
768
|
);
|
|
769
769
|
selectedCurrency$.set(c);
|
|
770
770
|
};
|
|
771
|
-
console.log("currency", currency);
|
|
772
771
|
return /* @__PURE__ */ jsx11(
|
|
773
772
|
CustomSelect,
|
|
774
773
|
{
|
|
@@ -780,6 +779,50 @@ var CurrencyOptionsSelect = observer4(function CurrencyOptionsSelect2({
|
|
|
780
779
|
});
|
|
781
780
|
var currencyOptionsSelect_default = CurrencyOptionsSelect;
|
|
782
781
|
|
|
782
|
+
// src/react/hooks/useCurrencyBalance.tsx
|
|
783
|
+
import { useQuery } from "@tanstack/react-query";
|
|
784
|
+
import { erc20Abi, formatUnits as formatUnits2, zeroAddress } from "viem";
|
|
785
|
+
function useCurrencyBalance({
|
|
786
|
+
currencyAddress,
|
|
787
|
+
chainId,
|
|
788
|
+
userAddress
|
|
789
|
+
}) {
|
|
790
|
+
const publicClient = getPublicRpcClient(chainId);
|
|
791
|
+
return useQuery({
|
|
792
|
+
queryKey: ["balance", currencyAddress, chainId, userAddress],
|
|
793
|
+
queryFn: async () => {
|
|
794
|
+
if (!userAddress) return null;
|
|
795
|
+
if (currencyAddress === zeroAddress) {
|
|
796
|
+
const balance2 = await publicClient.getBalance({
|
|
797
|
+
address: userAddress
|
|
798
|
+
});
|
|
799
|
+
return {
|
|
800
|
+
value: balance2,
|
|
801
|
+
formatted: formatUnits2(balance2, 18)
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
const [balance, decimals] = await Promise.all([
|
|
805
|
+
publicClient.readContract({
|
|
806
|
+
address: currencyAddress,
|
|
807
|
+
abi: erc20Abi,
|
|
808
|
+
functionName: "balanceOf",
|
|
809
|
+
args: [userAddress]
|
|
810
|
+
}),
|
|
811
|
+
publicClient.readContract({
|
|
812
|
+
address: currencyAddress,
|
|
813
|
+
abi: erc20Abi,
|
|
814
|
+
functionName: "decimals"
|
|
815
|
+
})
|
|
816
|
+
]);
|
|
817
|
+
return {
|
|
818
|
+
value: balance,
|
|
819
|
+
formatted: formatUnits2(balance, decimals)
|
|
820
|
+
};
|
|
821
|
+
},
|
|
822
|
+
enabled: !!userAddress && !!chainId && !!currencyAddress
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
|
|
783
826
|
// src/react/ui/modals/_internal/components/priceInput/index.tsx
|
|
784
827
|
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
785
828
|
var PriceInput = observer5(function PriceInput2({
|
|
@@ -790,19 +833,15 @@ var PriceInput = observer5(function PriceInput2({
|
|
|
790
833
|
}) {
|
|
791
834
|
const [balanceError, setBalanceError] = useState3("");
|
|
792
835
|
const { address: accountAddress } = useAccount2();
|
|
793
|
-
const { data: balance, isSuccess: isBalanceSuccess } =
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
args: [accountAddress],
|
|
798
|
-
query: {
|
|
799
|
-
enabled: checkBalance?.enabled
|
|
800
|
-
}
|
|
836
|
+
const { data: balance, isSuccess: isBalanceSuccess } = useCurrencyBalance({
|
|
837
|
+
currencyAddress: $listingPrice.currency.contractAddress.get(),
|
|
838
|
+
chainId: Number(chainId),
|
|
839
|
+
userAddress: accountAddress
|
|
801
840
|
});
|
|
802
841
|
const currencyDecimals = $listingPrice.currency.decimals.get();
|
|
803
842
|
const [value, setValue] = useState3("");
|
|
804
843
|
const checkInsufficientBalance = (priceAmountRaw) => {
|
|
805
|
-
const hasInsufficientBalance = isBalanceSuccess && priceAmountRaw && currencyDecimals && BigInt(priceAmountRaw) > (balance || 0);
|
|
844
|
+
const hasInsufficientBalance = isBalanceSuccess && priceAmountRaw && currencyDecimals && BigInt(priceAmountRaw) > (balance?.value || 0);
|
|
806
845
|
if (!checkBalance) return;
|
|
807
846
|
if (hasInsufficientBalance) {
|
|
808
847
|
setBalanceError("Insufficient balance");
|
|
@@ -921,7 +960,7 @@ function TokenPreview({
|
|
|
921
960
|
|
|
922
961
|
// src/react/ui/modals/_internal/components/transactionDetails/index.tsx
|
|
923
962
|
import { Box as Box9, Image as Image2, Skeleton as Skeleton4, Text as Text6 } from "@0xsequence/design-system";
|
|
924
|
-
import { formatUnits as
|
|
963
|
+
import { formatUnits as formatUnits3 } from "viem";
|
|
925
964
|
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
926
965
|
var DEFAULT_MARKETPLACE_FEE_PERCENTAGE = 2.5;
|
|
927
966
|
function TransactionDetails({
|
|
@@ -941,7 +980,7 @@ function TransactionDetails({
|
|
|
941
980
|
collectibleId
|
|
942
981
|
});
|
|
943
982
|
const priceLoading = !price || marketplaceConfigLoading || royaltyPercentageLoading;
|
|
944
|
-
let formattedAmount = price &&
|
|
983
|
+
let formattedAmount = price && formatUnits3(BigInt(price.amountRaw), price.currency.decimals);
|
|
945
984
|
if (royaltyPercentage !== void 0 && formattedAmount) {
|
|
946
985
|
formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * Number(royaltyPercentage) / 100).toString();
|
|
947
986
|
}
|
|
@@ -1046,7 +1085,7 @@ import {
|
|
|
1046
1085
|
Text as Text9
|
|
1047
1086
|
} from "@0xsequence/design-system";
|
|
1048
1087
|
import { observer as observer6 } from "@legendapp/state/react";
|
|
1049
|
-
import { formatUnits as
|
|
1088
|
+
import { formatUnits as formatUnits4 } from "viem";
|
|
1050
1089
|
|
|
1051
1090
|
// src/react/ui/modals/_internal/components/timeAgo/index.tsx
|
|
1052
1091
|
import { Box as Box11, Text as Text8 } from "@0xsequence/design-system";
|
|
@@ -1203,7 +1242,7 @@ var TransactionPreview = observer6(
|
|
|
1203
1242
|
const collectibleImage2 = collectible?.image;
|
|
1204
1243
|
const collectibleName = collectible?.name;
|
|
1205
1244
|
const collectionName = collection?.name;
|
|
1206
|
-
const priceFormatted = price ?
|
|
1245
|
+
const priceFormatted = price ? formatUnits4(BigInt(price.amountRaw), price.currency.decimals) : void 0;
|
|
1207
1246
|
if (collectibleLoading || collectionLoading) {
|
|
1208
1247
|
return /* @__PURE__ */ jsx17(Box12, { style: { height: 83 }, width: "full", borderRadius: "md", children: /* @__PURE__ */ jsx17(Skeleton5, { style: { width: "100%", height: "100%" } }) });
|
|
1209
1248
|
}
|
|
@@ -1490,6 +1529,7 @@ var initialState3 = {
|
|
|
1490
1529
|
collectionAddress: "",
|
|
1491
1530
|
chainId: "",
|
|
1492
1531
|
collectibleId: "",
|
|
1532
|
+
orderbookKind: "sequence_marketplace_v2" /* sequence_marketplace_v2 */,
|
|
1493
1533
|
collectionName: "",
|
|
1494
1534
|
collectionType: void 0,
|
|
1495
1535
|
listingPrice: {
|
|
@@ -1506,6 +1546,7 @@ var initialState3 = {
|
|
|
1506
1546
|
createListingModal$.collectionAddress.set(args.collectionAddress);
|
|
1507
1547
|
createListingModal$.chainId.set(args.chainId);
|
|
1508
1548
|
createListingModal$.collectibleId.set(args.collectibleId);
|
|
1549
|
+
createListingModal$.orderbookKind.set(args.orderbookKind);
|
|
1509
1550
|
createListingModal$.callbacks.set(args.callbacks || args.defaultCallbacks);
|
|
1510
1551
|
createListingModal$.onSuccess.set(args.onSuccess);
|
|
1511
1552
|
createListingModal$.onError.set(args.onError);
|
|
@@ -1535,7 +1576,7 @@ var Modal2 = observer8(
|
|
|
1535
1576
|
showTransactionStatusModal
|
|
1536
1577
|
}) => {
|
|
1537
1578
|
const state = createListingModal$.get();
|
|
1538
|
-
const { collectionAddress, chainId, listingPrice, collectibleId } = state;
|
|
1579
|
+
const { collectionAddress, chainId, listingPrice, collectibleId, orderbookKind } = state;
|
|
1539
1580
|
const {
|
|
1540
1581
|
data: collectible,
|
|
1541
1582
|
isLoading: collectableIsLoading,
|
|
@@ -1561,6 +1602,7 @@ var Modal2 = observer8(
|
|
|
1561
1602
|
userAddress: address
|
|
1562
1603
|
});
|
|
1563
1604
|
const { getListingSteps, isLoading: machineLoading } = useCreateListing({
|
|
1605
|
+
orderbookKind,
|
|
1564
1606
|
chainId,
|
|
1565
1607
|
collectionAddress,
|
|
1566
1608
|
onTransactionSent: (hash) => {
|
|
@@ -1762,6 +1804,7 @@ var initialState4 = {
|
|
|
1762
1804
|
collectionAddress: "",
|
|
1763
1805
|
chainId: "",
|
|
1764
1806
|
collectibleId: "",
|
|
1807
|
+
orderbookKind: "sequence_marketplace_v2" /* sequence_marketplace_v2 */,
|
|
1765
1808
|
callbacks: void 0,
|
|
1766
1809
|
offerPrice: {
|
|
1767
1810
|
amountRaw: "1",
|
|
@@ -1774,6 +1817,7 @@ var initialState4 = {
|
|
|
1774
1817
|
makeOfferModal$.collectionAddress.set(args.collectionAddress);
|
|
1775
1818
|
makeOfferModal$.chainId.set(args.chainId);
|
|
1776
1819
|
makeOfferModal$.collectibleId.set(args.collectibleId);
|
|
1820
|
+
makeOfferModal$.orderbookKind.set(args.orderbookKind);
|
|
1777
1821
|
makeOfferModal$.callbacks.set(args.callbacks);
|
|
1778
1822
|
makeOfferModal$.isOpen.set(true);
|
|
1779
1823
|
},
|
|
@@ -1799,7 +1843,7 @@ var ModalContent = observer9(
|
|
|
1799
1843
|
showTransactionStatusModal
|
|
1800
1844
|
}) => {
|
|
1801
1845
|
const state = makeOfferModal$.get();
|
|
1802
|
-
const { collectionAddress, chainId, offerPrice, collectibleId } = state;
|
|
1846
|
+
const { collectionAddress, chainId, offerPrice, collectibleId, orderbookKind } = state;
|
|
1803
1847
|
const [insufficientBalance, setInsufficientBalance] = useState7(false);
|
|
1804
1848
|
const {
|
|
1805
1849
|
data: collectible,
|
|
@@ -1825,6 +1869,7 @@ var ModalContent = observer9(
|
|
|
1825
1869
|
const { getMakeOfferSteps } = useMakeOffer({
|
|
1826
1870
|
chainId,
|
|
1827
1871
|
collectionAddress,
|
|
1872
|
+
orderbookKind,
|
|
1828
1873
|
onTransactionSent: (hash) => {
|
|
1829
1874
|
if (!hash) return;
|
|
1830
1875
|
showTransactionStatusModal({
|
|
@@ -2810,6 +2855,7 @@ var ActionButton = observer15(
|
|
|
2810
2855
|
collectionAddress,
|
|
2811
2856
|
chainId,
|
|
2812
2857
|
tokenId,
|
|
2858
|
+
orderbookKind,
|
|
2813
2859
|
action,
|
|
2814
2860
|
highestOffer,
|
|
2815
2861
|
lowestListing
|
|
@@ -2859,7 +2905,8 @@ var ActionButton = observer15(
|
|
|
2859
2905
|
onClick: () => showCreateListingModal({
|
|
2860
2906
|
collectionAddress,
|
|
2861
2907
|
chainId,
|
|
2862
|
-
collectibleId: tokenId
|
|
2908
|
+
collectibleId: tokenId,
|
|
2909
|
+
orderbookKind
|
|
2863
2910
|
})
|
|
2864
2911
|
}
|
|
2865
2912
|
);
|
|
@@ -2872,7 +2919,8 @@ var ActionButton = observer15(
|
|
|
2872
2919
|
onClick: () => showMakeOfferModal({
|
|
2873
2920
|
collectionAddress,
|
|
2874
2921
|
chainId,
|
|
2875
|
-
collectibleId: tokenId
|
|
2922
|
+
collectibleId: tokenId,
|
|
2923
|
+
orderbookKind
|
|
2876
2924
|
})
|
|
2877
2925
|
}
|
|
2878
2926
|
);
|
|
@@ -2913,7 +2961,7 @@ function ActionButtonBody({ label, onClick }) {
|
|
|
2913
2961
|
|
|
2914
2962
|
// src/react/ui/components/collectible-card/Footer.tsx
|
|
2915
2963
|
import { Box as Box20, IconButton as IconButton5, Image as Image6, Text as Text15 } from "@0xsequence/design-system";
|
|
2916
|
-
import { formatUnits as
|
|
2964
|
+
import { formatUnits as formatUnits5 } from "viem";
|
|
2917
2965
|
import { useAccount as useAccount6 } from "wagmi";
|
|
2918
2966
|
|
|
2919
2967
|
// src/react/ui/icons/Bell.tsx
|
|
@@ -2963,6 +3011,7 @@ var Footer = ({
|
|
|
2963
3011
|
isAnimated
|
|
2964
3012
|
}) => {
|
|
2965
3013
|
const { address } = useAccount6();
|
|
3014
|
+
const listed = !!lowestListingPriceAmount && !!lowestListingCurrency;
|
|
2966
3015
|
if (name.length > 15 && highestOffer) {
|
|
2967
3016
|
name = name.substring(0, 13) + "...";
|
|
2968
3017
|
}
|
|
@@ -3020,22 +3069,22 @@ var Footer = ({
|
|
|
3020
3069
|
]
|
|
3021
3070
|
}
|
|
3022
3071
|
),
|
|
3023
|
-
|
|
3024
|
-
/* @__PURE__ */ jsx31(Image6, { src: lowestListingCurrency?.imageUrl, width: "3", height: "3" }),
|
|
3072
|
+
/* @__PURE__ */ jsxs22(Box20, { display: "flex", alignItems: "center", gap: "1", children: [
|
|
3073
|
+
listed && /* @__PURE__ */ jsx31(Image6, { src: lowestListingCurrency?.imageUrl, width: "3", height: "3" }),
|
|
3025
3074
|
/* @__PURE__ */ jsxs22(
|
|
3026
3075
|
Text15,
|
|
3027
3076
|
{
|
|
3028
|
-
color: "text100",
|
|
3077
|
+
color: listed ? "text100" : "text50",
|
|
3029
3078
|
fontSize: "small",
|
|
3030
3079
|
fontWeight: "bold",
|
|
3031
3080
|
textAlign: "left",
|
|
3032
3081
|
fontFamily: "body",
|
|
3033
3082
|
children: [
|
|
3034
|
-
|
|
3083
|
+
listed && formatUnits5(
|
|
3035
3084
|
BigInt(lowestListingPriceAmount),
|
|
3036
3085
|
lowestListingCurrency.decimals
|
|
3037
3086
|
),
|
|
3038
|
-
" "
|
|
3087
|
+
!listed && "Not listed yet"
|
|
3039
3088
|
]
|
|
3040
3089
|
}
|
|
3041
3090
|
)
|
|
@@ -3107,6 +3156,7 @@ function CollectibleCard({
|
|
|
3107
3156
|
collectibleId,
|
|
3108
3157
|
chainId,
|
|
3109
3158
|
collectionAddress,
|
|
3159
|
+
orderbookKind,
|
|
3110
3160
|
collectionType,
|
|
3111
3161
|
lowestListing,
|
|
3112
3162
|
onCollectibleClick,
|
|
@@ -3210,6 +3260,7 @@ function CollectibleCard({
|
|
|
3210
3260
|
chainId: String(chainId),
|
|
3211
3261
|
collectionAddress,
|
|
3212
3262
|
tokenId: collectibleId,
|
|
3263
|
+
orderbookKind,
|
|
3213
3264
|
action,
|
|
3214
3265
|
highestOffer: highestOffer?.order,
|
|
3215
3266
|
lowestListing: lowestListing?.order,
|
|
@@ -3235,4 +3286,4 @@ export {
|
|
|
3235
3286
|
ModalProvider,
|
|
3236
3287
|
CollectibleCard
|
|
3237
3288
|
};
|
|
3238
|
-
//# sourceMappingURL=chunk-
|
|
3289
|
+
//# sourceMappingURL=chunk-PPSIO23Z.js.map
|