@quantabit/nft-marketplace-sdk 1.0.0
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/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/index.cjs +170 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.esm.js +157 -0
- package/dist/index.esm.js.map +1 -0
- package/package.json +73 -0
- package/types/index.d.ts +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QuantaBit Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @quantabit/nft-marketplace-sdk
|
|
2
|
+
|
|
3
|
+
QuantaBit NFT Marketplace SDK offers simplified program wrappers, listing managers, royalty distribution utilities, and bidding state engines for non-fungible tokens on the QuantaBit network.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **NFT Listings**: List NFT tokens for sale specifying prices, reserve limits, and custom payout currencies.
|
|
8
|
+
- **Bidding and Auctioning**: Submit bids for active auctions with reserve validation.
|
|
9
|
+
- **Royalty Tracking**: Automatically calculate creator royalty share payments.
|
|
10
|
+
- **React state sync hooks**: Hooks to fetch, listen, and update market listing lists.
|
|
11
|
+
- **Multilingual dictionary**: Built-in support for localized notifications in EN, ZH, JA, and KO.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @quantabit/nft-marketplace-sdk @quantabit/sdk-config
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import { listNFT, buyNFT, calculateRoyalty } from '@quantabit/nft-marketplace-sdk';
|
|
23
|
+
|
|
24
|
+
// List NFT for sale
|
|
25
|
+
const listing = await listNFT('mint_address_xxx', 500, 'QBT');
|
|
26
|
+
|
|
27
|
+
// Buy listed NFT
|
|
28
|
+
const purchase = await buyNFT(listing.listingId, 'buyer_wallet_address');
|
|
29
|
+
|
|
30
|
+
// Calculate creator royalties
|
|
31
|
+
const royalty = calculateRoyalty(500, 5.0); // 5% royalty on 500 QBT
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Brand & Links
|
|
35
|
+
|
|
36
|
+
- **Official Website**: [https://quantabit.io](https://quantabit.io)
|
|
37
|
+
- **Documentation**: [https://docs.quantabit.io](https://docs.quantabit.io)
|
|
38
|
+
- **Explorer**: [https://explorer.mg.qbitchain.io](https://explorer.mg.qbitchain.io)
|
|
39
|
+
- **Source Code**: [https://github.com/quantabit-chain/qbit-sdk](https://github.com/quantabit-chain/qbit-sdk)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var sdkConfig = require('@quantabit/sdk-config');
|
|
5
|
+
|
|
6
|
+
const messages = {
|
|
7
|
+
en: {
|
|
8
|
+
list_success: "NFT listed successfully for sale",
|
|
9
|
+
buy_success: "NFT purchased successfully",
|
|
10
|
+
bid_success: "Bid submitted successfully",
|
|
11
|
+
cancel_success: "Listing cancelled successfully",
|
|
12
|
+
invalid_price: "Invalid price set for listing",
|
|
13
|
+
below_reserve_price: "Bid price is below reserve price"
|
|
14
|
+
},
|
|
15
|
+
zh: {
|
|
16
|
+
list_success: "NFT已成功挂单出售",
|
|
17
|
+
buy_success: "NFT已成功购买",
|
|
18
|
+
bid_success: "出价已成功提交",
|
|
19
|
+
cancel_success: "挂单已成功取消",
|
|
20
|
+
invalid_price: "设置的挂单价格无效",
|
|
21
|
+
below_reserve_price: "出价低于保留价"
|
|
22
|
+
},
|
|
23
|
+
ja: {
|
|
24
|
+
list_success: "NFTが販売用に正常に出品されました",
|
|
25
|
+
buy_success: "NFTの購入に成功しました",
|
|
26
|
+
bid_success: "入札が正常に送信されました",
|
|
27
|
+
cancel_success: "出品が正常にキャンセルされました",
|
|
28
|
+
invalid_price: "出品に設定された価格が無効です",
|
|
29
|
+
below_reserve_price: "入札価格が最低落札価格を下回っています"
|
|
30
|
+
},
|
|
31
|
+
ko: {
|
|
32
|
+
list_success: "NFT가 판매 등록 완료되었습니다",
|
|
33
|
+
buy_success: "NFT 구매 완료",
|
|
34
|
+
bid_success: "입찰이 성공적으로 완료되었습니다",
|
|
35
|
+
cancel_success: "판매 등록 취소 완료",
|
|
36
|
+
invalid_price: "잘못된 등록 가격입니다",
|
|
37
|
+
below_reserve_price: "입찰가가 최저 낙찰가보다 낮습니다"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
let currentLang = null;
|
|
41
|
+
function getLanguage() {
|
|
42
|
+
return currentLang || sdkConfig.getLanguage() || 'en';
|
|
43
|
+
}
|
|
44
|
+
function setLanguage(lang) {
|
|
45
|
+
if (messages[lang]) {
|
|
46
|
+
currentLang = lang;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function t(key) {
|
|
50
|
+
const lang = getLanguage();
|
|
51
|
+
return messages[lang]?.[key] || messages['en']?.[key] || key;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 模拟市场活跃挂单
|
|
55
|
+
const LISTINGS = {
|
|
56
|
+
"list_001": {
|
|
57
|
+
id: "list_001",
|
|
58
|
+
mintAddress: "mint_qbit_nft_99",
|
|
59
|
+
seller: "seller_wallet_a",
|
|
60
|
+
price: 450,
|
|
61
|
+
currency: "QBT",
|
|
62
|
+
reservePrice: 400,
|
|
63
|
+
royaltyPercent: 5.0,
|
|
64
|
+
status: "active"
|
|
65
|
+
},
|
|
66
|
+
"list_002": {
|
|
67
|
+
id: "list_002",
|
|
68
|
+
mintAddress: "mint_qbit_nft_102",
|
|
69
|
+
seller: "seller_wallet_b",
|
|
70
|
+
price: 1200,
|
|
71
|
+
currency: "USDT",
|
|
72
|
+
reservePrice: 1000,
|
|
73
|
+
royaltyPercent: 2.5,
|
|
74
|
+
status: "active"
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
async function listNFT(mintAddress, price, currency = "QBT") {
|
|
78
|
+
if (price <= 0) {
|
|
79
|
+
throw new Error(t('invalid_price'));
|
|
80
|
+
}
|
|
81
|
+
const listingId = `list_${Math.random().toString(36).substr(2, 9)}`;
|
|
82
|
+
return {
|
|
83
|
+
listingId,
|
|
84
|
+
mintAddress,
|
|
85
|
+
price,
|
|
86
|
+
currency,
|
|
87
|
+
status: "active",
|
|
88
|
+
message: t('list_success')
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
async function buyNFT(listingId, buyerAddress) {
|
|
92
|
+
const listing = LISTINGS[listingId];
|
|
93
|
+
if (!listing) {
|
|
94
|
+
throw new Error("Listing not found");
|
|
95
|
+
}
|
|
96
|
+
const royaltyAmount = calculateRoyalty(listing.price, listing.royaltyPercent);
|
|
97
|
+
return {
|
|
98
|
+
txHash: `buy_tx_${Math.random().toString(36).substr(2, 9)}`,
|
|
99
|
+
listingId,
|
|
100
|
+
buyerAddress,
|
|
101
|
+
pricePaid: listing.price,
|
|
102
|
+
royaltyPaid: royaltyAmount,
|
|
103
|
+
status: "success",
|
|
104
|
+
message: t('buy_success')
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async function placeBid(listingId, bidAmount, bidderAddress) {
|
|
108
|
+
const listing = LISTINGS[listingId];
|
|
109
|
+
if (!listing) {
|
|
110
|
+
throw new Error("Listing not found");
|
|
111
|
+
}
|
|
112
|
+
if (bidAmount < listing.reservePrice) {
|
|
113
|
+
throw new Error(t('below_reserve_price'));
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
txHash: `bid_tx_${Math.random().toString(36).substr(2, 9)}`,
|
|
117
|
+
listingId,
|
|
118
|
+
bidderAddress,
|
|
119
|
+
bidAmount,
|
|
120
|
+
status: "confirmed",
|
|
121
|
+
message: t('bid_success')
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
async function cancelListing(listingId) {
|
|
125
|
+
const listing = LISTINGS[listingId];
|
|
126
|
+
if (!listing) {
|
|
127
|
+
throw new Error("Listing not found");
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
txHash: `cancel_tx_${Math.random().toString(36).substr(2, 9)}`,
|
|
131
|
+
listingId,
|
|
132
|
+
status: "cancelled",
|
|
133
|
+
message: t('cancel_success')
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function calculateRoyalty(price, royaltyPercent) {
|
|
137
|
+
const amount = price * (royaltyPercent / 100);
|
|
138
|
+
return parseFloat(amount.toFixed(4));
|
|
139
|
+
}
|
|
140
|
+
function useNftListings() {
|
|
141
|
+
const [listings, setListings] = react.useState([]);
|
|
142
|
+
const [loading, setLoading] = react.useState(true);
|
|
143
|
+
react.useEffect(() => {
|
|
144
|
+
setLoading(true);
|
|
145
|
+
const timer = setTimeout(() => {
|
|
146
|
+
setListings(Object.values(LISTINGS));
|
|
147
|
+
setLoading(false);
|
|
148
|
+
}, 400);
|
|
149
|
+
return () => clearTimeout(timer);
|
|
150
|
+
}, []);
|
|
151
|
+
return {
|
|
152
|
+
listings,
|
|
153
|
+
loading
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];
|
|
157
|
+
|
|
158
|
+
exports.LISTINGS = LISTINGS;
|
|
159
|
+
exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
|
|
160
|
+
exports.buyNFT = buyNFT;
|
|
161
|
+
exports.calculateRoyalty = calculateRoyalty;
|
|
162
|
+
exports.cancelListing = cancelListing;
|
|
163
|
+
exports.getLanguage = getLanguage;
|
|
164
|
+
exports.listNFT = listNFT;
|
|
165
|
+
exports.messages = messages;
|
|
166
|
+
exports.placeBid = placeBid;
|
|
167
|
+
exports.setLanguage = setLanguage;
|
|
168
|
+
exports.t = t;
|
|
169
|
+
exports.useNftListings = useNftListings;
|
|
170
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/i18n/index.js","../src/index.js"],"sourcesContent":["import { getLanguage as getGlobalLang } from '@quantabit/sdk-config';\n\nexport const messages = {\n en: {\n list_success: \"NFT listed successfully for sale\",\n buy_success: \"NFT purchased successfully\",\n bid_success: \"Bid submitted successfully\",\n cancel_success: \"Listing cancelled successfully\",\n invalid_price: \"Invalid price set for listing\",\n below_reserve_price: \"Bid price is below reserve price\"\n },\n zh: {\n list_success: \"NFT已成功挂单出售\",\n buy_success: \"NFT已成功购买\",\n bid_success: \"出价已成功提交\",\n cancel_success: \"挂单已成功取消\",\n invalid_price: \"设置的挂单价格无效\",\n below_reserve_price: \"出价低于保留价\"\n },\n ja: {\n list_success: \"NFTが販売用に正常に出品されました\",\n buy_success: \"NFTの購入に成功しました\",\n bid_success: \"入札が正常に送信されました\",\n cancel_success: \"出品が正常にキャンセルされました\",\n invalid_price: \"出品に設定された価格が無効です\",\n below_reserve_price: \"入札価格が最低落札価格を下回っています\"\n },\n ko: {\n list_success: \"NFT가 판매 등록 완료되었습니다\",\n buy_success: \"NFT 구매 완료\",\n bid_success: \"입찰이 성공적으로 완료되었습니다\",\n cancel_success: \"판매 등록 취소 완료\",\n invalid_price: \"잘못된 등록 가격입니다\",\n below_reserve_price: \"입찰가가 최저 낙찰가보다 낮습니다\"\n }\n};\n\nlet currentLang = null;\n\nexport function getLanguage() {\n return currentLang || getGlobalLang() || 'en';\n}\n\nexport function setLanguage(lang) {\n if (messages[lang]) {\n currentLang = lang;\n }\n}\n\nexport function t(key) {\n const lang = getLanguage();\n return messages[lang]?.[key] || messages['en']?.[key] || key;\n}\n","import { useState, useEffect } from 'react';\nimport { getConfig } from '@quantabit/sdk-config';\nimport { t, setLanguage, getLanguage, messages } from './i18n/index.js';\n\n// 模拟市场活跃挂单\nconst LISTINGS = {\n \"list_001\": {\n id: \"list_001\",\n mintAddress: \"mint_qbit_nft_99\",\n seller: \"seller_wallet_a\",\n price: 450,\n currency: \"QBT\",\n reservePrice: 400,\n royaltyPercent: 5.0,\n status: \"active\"\n },\n \"list_002\": {\n id: \"list_002\",\n mintAddress: \"mint_qbit_nft_102\",\n seller: \"seller_wallet_b\",\n price: 1200,\n currency: \"USDT\",\n reservePrice: 1000,\n royaltyPercent: 2.5,\n status: \"active\"\n }\n};\n\nexport async function listNFT(mintAddress, price, currency = \"QBT\") {\n if (price <= 0) {\n throw new Error(t('invalid_price'));\n }\n \n const listingId = `list_${Math.random().toString(36).substr(2, 9)}`;\n \n return {\n listingId,\n mintAddress,\n price,\n currency,\n status: \"active\",\n message: t('list_success')\n };\n}\n\nexport async function buyNFT(listingId, buyerAddress) {\n const listing = LISTINGS[listingId];\n if (!listing) {\n throw new Error(\"Listing not found\");\n }\n \n const royaltyAmount = calculateRoyalty(listing.price, listing.royaltyPercent);\n \n return {\n txHash: `buy_tx_${Math.random().toString(36).substr(2, 9)}`,\n listingId,\n buyerAddress,\n pricePaid: listing.price,\n royaltyPaid: royaltyAmount,\n status: \"success\",\n message: t('buy_success')\n };\n}\n\nexport async function placeBid(listingId, bidAmount, bidderAddress) {\n const listing = LISTINGS[listingId];\n if (!listing) {\n throw new Error(\"Listing not found\");\n }\n \n if (bidAmount < listing.reservePrice) {\n throw new Error(t('below_reserve_price'));\n }\n \n return {\n txHash: `bid_tx_${Math.random().toString(36).substr(2, 9)}`,\n listingId,\n bidderAddress,\n bidAmount,\n status: \"confirmed\",\n message: t('bid_success')\n };\n}\n\nexport async function cancelListing(listingId) {\n const listing = LISTINGS[listingId];\n if (!listing) {\n throw new Error(\"Listing not found\");\n }\n \n return {\n txHash: `cancel_tx_${Math.random().toString(36).substr(2, 9)}`,\n listingId,\n status: \"cancelled\",\n message: t('cancel_success')\n };\n}\n\nexport function calculateRoyalty(price, royaltyPercent) {\n const amount = price * (royaltyPercent / 100);\n return parseFloat(amount.toFixed(4));\n}\n\nexport function useNftListings() {\n const [listings, setListings] = useState([]);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n setLoading(true);\n const timer = setTimeout(() => {\n setListings(Object.values(LISTINGS));\n setLoading(false);\n }, 400);\n\n return () => clearTimeout(timer);\n }, []);\n\n return { listings, loading };\n}\n\nexport { t, setLanguage, getLanguage, messages };\nexport const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];\nexport { LISTINGS };\n"],"names":["messages","en","list_success","buy_success","bid_success","cancel_success","invalid_price","below_reserve_price","zh","ja","ko","currentLang","getLanguage","getGlobalLang","setLanguage","lang","t","key","LISTINGS","id","mintAddress","seller","price","currency","reservePrice","royaltyPercent","status","listNFT","Error","listingId","Math","random","toString","substr","message","buyNFT","buyerAddress","listing","royaltyAmount","calculateRoyalty","txHash","pricePaid","royaltyPaid","placeBid","bidAmount","bidderAddress","cancelListing","amount","parseFloat","toFixed","useNftListings","listings","setListings","useState","loading","setLoading","useEffect","timer","setTimeout","Object","values","clearTimeout","SUPPORTED_LANGUAGES"],"mappings":";;;;;AAEO,MAAMA,QAAQ,GAAG;AACtBC,EAAAA,EAAE,EAAE;AACFC,IAAAA,YAAY,EAAE,kCAAkC;AAChDC,IAAAA,WAAW,EAAE,4BAA4B;AACzCC,IAAAA,WAAW,EAAE,4BAA4B;AACzCC,IAAAA,cAAc,EAAE,gCAAgC;AAChDC,IAAAA,aAAa,EAAE,+BAA+B;AAC9CC,IAAAA,mBAAmB,EAAE;GACtB;AACDC,EAAAA,EAAE,EAAE;AACFN,IAAAA,YAAY,EAAE,YAAY;AAC1BC,IAAAA,WAAW,EAAE,UAAU;AACvBC,IAAAA,WAAW,EAAE,SAAS;AACtBC,IAAAA,cAAc,EAAE,SAAS;AACzBC,IAAAA,aAAa,EAAE,WAAW;AAC1BC,IAAAA,mBAAmB,EAAE;GACtB;AACDE,EAAAA,EAAE,EAAE;AACFP,IAAAA,YAAY,EAAE,oBAAoB;AAClCC,IAAAA,WAAW,EAAE,eAAe;AAC5BC,IAAAA,WAAW,EAAE,eAAe;AAC5BC,IAAAA,cAAc,EAAE,kBAAkB;AAClCC,IAAAA,aAAa,EAAE,iBAAiB;AAChCC,IAAAA,mBAAmB,EAAE;GACtB;AACDG,EAAAA,EAAE,EAAE;AACFR,IAAAA,YAAY,EAAE,oBAAoB;AAClCC,IAAAA,WAAW,EAAE,WAAW;AACxBC,IAAAA,WAAW,EAAE,mBAAmB;AAChCC,IAAAA,cAAc,EAAE,aAAa;AAC7BC,IAAAA,aAAa,EAAE,cAAc;AAC7BC,IAAAA,mBAAmB,EAAE;AACvB;AACF;AAEA,IAAII,WAAW,GAAG,IAAI;AAEf,SAASC,WAAWA,GAAG;AAC5B,EAAA,OAAOD,WAAW,IAAIE,qB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IAAI,CAAC;AAChB,IAAA,MAAME,KAAK,GAAGC,UAAU,CAAC,MAAM;AAC7BN,MAAAA,WAAW,CAACO,MAAM,CAACC,MAAM,CAAC1C,QAAQ,CAAC,CAAC;MACpCqC,UAAU,CAAC,KAAK,CAAC;IACnB,CAAC,EAAE,GAAG,CAAC;AAEP,IAAA,OAAO,MAAMM,YAAY,CAACJ,KAAK,CAAC;EAClC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAEN,QAAQ;AAAEG,IAAAA;GAAS;AAC9B;AAGO,MAAMQ,mBAAmB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { getLanguage as getLanguage$1 } from '@quantabit/sdk-config';
|
|
3
|
+
|
|
4
|
+
const messages = {
|
|
5
|
+
en: {
|
|
6
|
+
list_success: "NFT listed successfully for sale",
|
|
7
|
+
buy_success: "NFT purchased successfully",
|
|
8
|
+
bid_success: "Bid submitted successfully",
|
|
9
|
+
cancel_success: "Listing cancelled successfully",
|
|
10
|
+
invalid_price: "Invalid price set for listing",
|
|
11
|
+
below_reserve_price: "Bid price is below reserve price"
|
|
12
|
+
},
|
|
13
|
+
zh: {
|
|
14
|
+
list_success: "NFT已成功挂单出售",
|
|
15
|
+
buy_success: "NFT已成功购买",
|
|
16
|
+
bid_success: "出价已成功提交",
|
|
17
|
+
cancel_success: "挂单已成功取消",
|
|
18
|
+
invalid_price: "设置的挂单价格无效",
|
|
19
|
+
below_reserve_price: "出价低于保留价"
|
|
20
|
+
},
|
|
21
|
+
ja: {
|
|
22
|
+
list_success: "NFTが販売用に正常に出品されました",
|
|
23
|
+
buy_success: "NFTの購入に成功しました",
|
|
24
|
+
bid_success: "入札が正常に送信されました",
|
|
25
|
+
cancel_success: "出品が正常にキャンセルされました",
|
|
26
|
+
invalid_price: "出品に設定された価格が無効です",
|
|
27
|
+
below_reserve_price: "入札価格が最低落札価格を下回っています"
|
|
28
|
+
},
|
|
29
|
+
ko: {
|
|
30
|
+
list_success: "NFT가 판매 등록 완료되었습니다",
|
|
31
|
+
buy_success: "NFT 구매 완료",
|
|
32
|
+
bid_success: "입찰이 성공적으로 완료되었습니다",
|
|
33
|
+
cancel_success: "판매 등록 취소 완료",
|
|
34
|
+
invalid_price: "잘못된 등록 가격입니다",
|
|
35
|
+
below_reserve_price: "입찰가가 최저 낙찰가보다 낮습니다"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
let currentLang = null;
|
|
39
|
+
function getLanguage() {
|
|
40
|
+
return currentLang || getLanguage$1() || 'en';
|
|
41
|
+
}
|
|
42
|
+
function setLanguage(lang) {
|
|
43
|
+
if (messages[lang]) {
|
|
44
|
+
currentLang = lang;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function t(key) {
|
|
48
|
+
const lang = getLanguage();
|
|
49
|
+
return messages[lang]?.[key] || messages['en']?.[key] || key;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 模拟市场活跃挂单
|
|
53
|
+
const LISTINGS = {
|
|
54
|
+
"list_001": {
|
|
55
|
+
id: "list_001",
|
|
56
|
+
mintAddress: "mint_qbit_nft_99",
|
|
57
|
+
seller: "seller_wallet_a",
|
|
58
|
+
price: 450,
|
|
59
|
+
currency: "QBT",
|
|
60
|
+
reservePrice: 400,
|
|
61
|
+
royaltyPercent: 5.0,
|
|
62
|
+
status: "active"
|
|
63
|
+
},
|
|
64
|
+
"list_002": {
|
|
65
|
+
id: "list_002",
|
|
66
|
+
mintAddress: "mint_qbit_nft_102",
|
|
67
|
+
seller: "seller_wallet_b",
|
|
68
|
+
price: 1200,
|
|
69
|
+
currency: "USDT",
|
|
70
|
+
reservePrice: 1000,
|
|
71
|
+
royaltyPercent: 2.5,
|
|
72
|
+
status: "active"
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
async function listNFT(mintAddress, price, currency = "QBT") {
|
|
76
|
+
if (price <= 0) {
|
|
77
|
+
throw new Error(t('invalid_price'));
|
|
78
|
+
}
|
|
79
|
+
const listingId = `list_${Math.random().toString(36).substr(2, 9)}`;
|
|
80
|
+
return {
|
|
81
|
+
listingId,
|
|
82
|
+
mintAddress,
|
|
83
|
+
price,
|
|
84
|
+
currency,
|
|
85
|
+
status: "active",
|
|
86
|
+
message: t('list_success')
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async function buyNFT(listingId, buyerAddress) {
|
|
90
|
+
const listing = LISTINGS[listingId];
|
|
91
|
+
if (!listing) {
|
|
92
|
+
throw new Error("Listing not found");
|
|
93
|
+
}
|
|
94
|
+
const royaltyAmount = calculateRoyalty(listing.price, listing.royaltyPercent);
|
|
95
|
+
return {
|
|
96
|
+
txHash: `buy_tx_${Math.random().toString(36).substr(2, 9)}`,
|
|
97
|
+
listingId,
|
|
98
|
+
buyerAddress,
|
|
99
|
+
pricePaid: listing.price,
|
|
100
|
+
royaltyPaid: royaltyAmount,
|
|
101
|
+
status: "success",
|
|
102
|
+
message: t('buy_success')
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async function placeBid(listingId, bidAmount, bidderAddress) {
|
|
106
|
+
const listing = LISTINGS[listingId];
|
|
107
|
+
if (!listing) {
|
|
108
|
+
throw new Error("Listing not found");
|
|
109
|
+
}
|
|
110
|
+
if (bidAmount < listing.reservePrice) {
|
|
111
|
+
throw new Error(t('below_reserve_price'));
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
txHash: `bid_tx_${Math.random().toString(36).substr(2, 9)}`,
|
|
115
|
+
listingId,
|
|
116
|
+
bidderAddress,
|
|
117
|
+
bidAmount,
|
|
118
|
+
status: "confirmed",
|
|
119
|
+
message: t('bid_success')
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async function cancelListing(listingId) {
|
|
123
|
+
const listing = LISTINGS[listingId];
|
|
124
|
+
if (!listing) {
|
|
125
|
+
throw new Error("Listing not found");
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
txHash: `cancel_tx_${Math.random().toString(36).substr(2, 9)}`,
|
|
129
|
+
listingId,
|
|
130
|
+
status: "cancelled",
|
|
131
|
+
message: t('cancel_success')
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function calculateRoyalty(price, royaltyPercent) {
|
|
135
|
+
const amount = price * (royaltyPercent / 100);
|
|
136
|
+
return parseFloat(amount.toFixed(4));
|
|
137
|
+
}
|
|
138
|
+
function useNftListings() {
|
|
139
|
+
const [listings, setListings] = useState([]);
|
|
140
|
+
const [loading, setLoading] = useState(true);
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
setLoading(true);
|
|
143
|
+
const timer = setTimeout(() => {
|
|
144
|
+
setListings(Object.values(LISTINGS));
|
|
145
|
+
setLoading(false);
|
|
146
|
+
}, 400);
|
|
147
|
+
return () => clearTimeout(timer);
|
|
148
|
+
}, []);
|
|
149
|
+
return {
|
|
150
|
+
listings,
|
|
151
|
+
loading
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];
|
|
155
|
+
|
|
156
|
+
export { LISTINGS, SUPPORTED_LANGUAGES, buyNFT, calculateRoyalty, cancelListing, getLanguage, listNFT, messages, placeBid, setLanguage, t, useNftListings };
|
|
157
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/i18n/index.js","../src/index.js"],"sourcesContent":["import { getLanguage as getGlobalLang } from '@quantabit/sdk-config';\n\nexport const messages = {\n en: {\n list_success: \"NFT listed successfully for sale\",\n buy_success: \"NFT purchased successfully\",\n bid_success: \"Bid submitted successfully\",\n cancel_success: \"Listing cancelled successfully\",\n invalid_price: \"Invalid price set for listing\",\n below_reserve_price: \"Bid price is below reserve price\"\n },\n zh: {\n list_success: \"NFT已成功挂单出售\",\n buy_success: \"NFT已成功购买\",\n bid_success: \"出价已成功提交\",\n cancel_success: \"挂单已成功取消\",\n invalid_price: \"设置的挂单价格无效\",\n below_reserve_price: \"出价低于保留价\"\n },\n ja: {\n list_success: \"NFTが販売用に正常に出品されました\",\n buy_success: \"NFTの購入に成功しました\",\n bid_success: \"入札が正常に送信されました\",\n cancel_success: \"出品が正常にキャンセルされました\",\n invalid_price: \"出品に設定された価格が無効です\",\n below_reserve_price: \"入札価格が最低落札価格を下回っています\"\n },\n ko: {\n list_success: \"NFT가 판매 등록 완료되었습니다\",\n buy_success: \"NFT 구매 완료\",\n bid_success: \"입찰이 성공적으로 완료되었습니다\",\n cancel_success: \"판매 등록 취소 완료\",\n invalid_price: \"잘못된 등록 가격입니다\",\n below_reserve_price: \"입찰가가 최저 낙찰가보다 낮습니다\"\n }\n};\n\nlet currentLang = null;\n\nexport function getLanguage() {\n return currentLang || getGlobalLang() || 'en';\n}\n\nexport function setLanguage(lang) {\n if (messages[lang]) {\n currentLang = lang;\n }\n}\n\nexport function t(key) {\n const lang = getLanguage();\n return messages[lang]?.[key] || messages['en']?.[key] || key;\n}\n","import { useState, useEffect } from 'react';\nimport { getConfig } from '@quantabit/sdk-config';\nimport { t, setLanguage, getLanguage, messages } from './i18n/index.js';\n\n// 模拟市场活跃挂单\nconst LISTINGS = {\n \"list_001\": {\n id: \"list_001\",\n mintAddress: \"mint_qbit_nft_99\",\n seller: \"seller_wallet_a\",\n price: 450,\n currency: \"QBT\",\n reservePrice: 400,\n royaltyPercent: 5.0,\n status: \"active\"\n },\n \"list_002\": {\n id: \"list_002\",\n mintAddress: \"mint_qbit_nft_102\",\n seller: \"seller_wallet_b\",\n price: 1200,\n currency: \"USDT\",\n reservePrice: 1000,\n royaltyPercent: 2.5,\n status: \"active\"\n }\n};\n\nexport async function listNFT(mintAddress, price, currency = \"QBT\") {\n if (price <= 0) {\n throw new Error(t('invalid_price'));\n }\n \n const listingId = `list_${Math.random().toString(36).substr(2, 9)}`;\n \n return {\n listingId,\n mintAddress,\n price,\n currency,\n status: \"active\",\n message: t('list_success')\n };\n}\n\nexport async function buyNFT(listingId, buyerAddress) {\n const listing = LISTINGS[listingId];\n if (!listing) {\n throw new Error(\"Listing not found\");\n }\n \n const royaltyAmount = calculateRoyalty(listing.price, listing.royaltyPercent);\n \n return {\n txHash: `buy_tx_${Math.random().toString(36).substr(2, 9)}`,\n listingId,\n buyerAddress,\n pricePaid: listing.price,\n royaltyPaid: royaltyAmount,\n status: \"success\",\n message: t('buy_success')\n };\n}\n\nexport async function placeBid(listingId, bidAmount, bidderAddress) {\n const listing = LISTINGS[listingId];\n if (!listing) {\n throw new Error(\"Listing not found\");\n }\n \n if (bidAmount < listing.reservePrice) {\n throw new Error(t('below_reserve_price'));\n }\n \n return {\n txHash: `bid_tx_${Math.random().toString(36).substr(2, 9)}`,\n listingId,\n bidderAddress,\n bidAmount,\n status: \"confirmed\",\n message: t('bid_success')\n };\n}\n\nexport async function cancelListing(listingId) {\n const listing = LISTINGS[listingId];\n if (!listing) {\n throw new Error(\"Listing not found\");\n }\n \n return {\n txHash: `cancel_tx_${Math.random().toString(36).substr(2, 9)}`,\n listingId,\n status: \"cancelled\",\n message: t('cancel_success')\n };\n}\n\nexport function calculateRoyalty(price, royaltyPercent) {\n const amount = price * (royaltyPercent / 100);\n return parseFloat(amount.toFixed(4));\n}\n\nexport function useNftListings() {\n const [listings, setListings] = useState([]);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n setLoading(true);\n const timer = setTimeout(() => {\n setListings(Object.values(LISTINGS));\n setLoading(false);\n }, 400);\n\n return () => clearTimeout(timer);\n }, []);\n\n return { listings, loading };\n}\n\nexport { t, setLanguage, getLanguage, messages };\nexport const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];\nexport { LISTINGS };\n"],"names":["messages","en","list_success","buy_success","bid_success","cancel_success","invalid_price","below_reserve_price","zh","ja","ko","currentLang","getLanguage","getGlobalLang","setLanguage","lang","t","key","LISTINGS","id","mintAddress","seller","price","currency","reservePrice","royaltyPercent","status","listNFT","Error","listingId","Math","random","toString","substr","message","buyNFT","buyerAddress","listing","royaltyAmount","calculateRoyalty","txHash","pricePaid","royaltyPaid","placeBid","bidAmount","bidderAddress","cancelListing","amount","parseFloat","toFixed","useNftListings","listings","setListings","useState","loading","setLoading","useEffect","timer","setTimeout","Object","values","clearTimeout","SUPPORTED_LANGUAGES"],"mappings":";;;AAEO,MAAMA,QAAQ,GAAG;AACtBC,EAAAA,EAAE,EAAE;AACFC,IAAAA,YAAY,EAAE,kCAAkC;AAChDC,IAAAA,WAAW,EAAE,4BAA4B;AACzCC,IAAAA,WAAW,EAAE,4BAA4B;AACzCC,IAAAA,cAAc,EAAE,gCAAgC;AAChDC,IAAAA,aAAa,EAAE,+BAA+B;AAC9CC,IAAAA,mBAAmB,EAAE;GACtB;AACDC,EAAAA,EAAE,EAAE;AACFN,IAAAA,YAAY,EAAE,YAAY;AAC1BC,IAAAA,WAAW,EAAE,UAAU;AACvBC,IAAAA,WAAW,EAAE,SAAS;AACtBC,IAAAA,cAAc,EAAE,SAAS;AACzBC,IAAAA,aAAa,EAAE,WAAW;AAC1BC,IAAAA,mBAAmB,EAAE;GACtB;AACDE,EAAAA,EAAE,EAAE;AACFP,IAAAA,YAAY,EAAE,oBAAoB;AAClCC,IAAAA,WAAW,EAAE,eAAe;AAC5BC,IAAAA,WAAW,EAAE,eAAe;AAC5BC,IAAAA,cAAc,EAAE,kBAAkB;AAClCC,IAAAA,aAAa,EAAE,iBAAiB;AAChCC,IAAAA,mBAAmB,EAAE;GACtB;AACDG,EAAAA,EAAE,EAAE;AACFR,IAAAA,YAAY,EAAE,oBAAoB;AAClCC,IAAAA,WAAW,EAAE,WAAW;AACxBC,IAAAA,WAAW,EAAE,mBAAmB;AAChCC,IAAAA,cAAc,EAAE,aAAa;AAC7BC,IAAAA,aAAa,EAAE,cAAc;AAC7BC,IAAAA,mBAAmB,EAAE;AACvB;AACF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,CAAC,GAAGF,QAAQ,CAAC,IAAI,CAAC;AAE5CG,EAAAA,SAAS,CAAC,MAAM;IACdD,UAAU,CAAC,IAAI,CAAC;AAChB,IAAA,MAAME,KAAK,GAAGC,UAAU,CAAC,MAAM;AAC7BN,MAAAA,WAAW,CAACO,MAAM,CAACC,MAAM,CAAC1C,QAAQ,CAAC,CAAC;MACpCqC,UAAU,CAAC,KAAK,CAAC;IACnB,CAAC,EAAE,GAAG,CAAC;AAEP,IAAA,OAAO,MAAMM,YAAY,CAACJ,KAAK,CAAC;EAClC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAEN,QAAQ;AAAEG,IAAAA;GAAS;AAC9B;AAGO,MAAMQ,mBAAmB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quantabit/nft-marketplace-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "QuantaBit NFT Marketplace SDK - Listing, bidding, auctioning and royalty distributions for non-fungible assets",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./types/index.d.ts",
|
|
12
|
+
"import": "./dist/index.esm.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"*.css"
|
|
18
|
+
],
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"types",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "rollup -c",
|
|
27
|
+
"dev": "rollup -c -w",
|
|
28
|
+
"test": "jest --passWithNoTests",
|
|
29
|
+
"prepublishOnly": "npm run build"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/quantabit-chain/qbit-sdk.git",
|
|
34
|
+
"directory": "packages/nft-marketplace-sdk"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"nft",
|
|
38
|
+
"marketplace",
|
|
39
|
+
"auction",
|
|
40
|
+
"bidding",
|
|
41
|
+
"royalty",
|
|
42
|
+
"web3",
|
|
43
|
+
"react",
|
|
44
|
+
"quantabit"
|
|
45
|
+
],
|
|
46
|
+
"author": "QuantaBit Team",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=18.0.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"react": ">=17.0.0",
|
|
53
|
+
"react-dom": ">=17.0.0"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@quantabit/sdk-config": "^1.0.10"
|
|
57
|
+
},
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"qbit": {
|
|
62
|
+
"privacy": {
|
|
63
|
+
"level": "functional",
|
|
64
|
+
"dataCollection": "Fetches active NFT listings and bids. Stored anonymously on chain.",
|
|
65
|
+
"gdprCompliant": true,
|
|
66
|
+
"ccpaCompliant": true
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"homepage": "https://github.com/quantabit-chain/qbit-sdk/tree/main/packages/nft-marketplace-sdk#readme",
|
|
70
|
+
"bugs": {
|
|
71
|
+
"url": "https://github.com/quantabit-chain/qbit-sdk/issues"
|
|
72
|
+
}
|
|
73
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface NFTListing {
|
|
2
|
+
id: string;
|
|
3
|
+
mintAddress: string;
|
|
4
|
+
seller: string;
|
|
5
|
+
price: number;
|
|
6
|
+
currency: string;
|
|
7
|
+
reservePrice: number;
|
|
8
|
+
royaltyPercent: number;
|
|
9
|
+
status: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ListingResult {
|
|
13
|
+
listingId: string;
|
|
14
|
+
mintAddress: string;
|
|
15
|
+
price: number;
|
|
16
|
+
currency: string;
|
|
17
|
+
status: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PurchaseResult {
|
|
22
|
+
txHash: string;
|
|
23
|
+
listingId: string;
|
|
24
|
+
buyerAddress: string;
|
|
25
|
+
pricePaid: number;
|
|
26
|
+
royaltyPaid: number;
|
|
27
|
+
status: string;
|
|
28
|
+
message: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface BidResult {
|
|
32
|
+
txHash: string;
|
|
33
|
+
listingId: string;
|
|
34
|
+
bidderAddress: string;
|
|
35
|
+
bidAmount: number;
|
|
36
|
+
status: string;
|
|
37
|
+
message: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface CancellationResult {
|
|
41
|
+
txHash: string;
|
|
42
|
+
listingId: string;
|
|
43
|
+
status: string;
|
|
44
|
+
message: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function listNFT(mintAddress: string, price: number, currency?: string): Promise<ListingResult>;
|
|
48
|
+
export function buyNFT(listingId: string, buyerAddress: string): Promise<PurchaseResult>;
|
|
49
|
+
export function placeBid(listingId: string, bidAmount: number, bidderAddress: string): Promise<BidResult>;
|
|
50
|
+
export function cancelListing(listingId: string): Promise<CancellationResult>;
|
|
51
|
+
export function calculateRoyalty(price: number, royaltyPercent: number): number;
|
|
52
|
+
|
|
53
|
+
export function useNftListings(): {
|
|
54
|
+
listings: NFTListing[];
|
|
55
|
+
loading: boolean;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export function getLanguage(): string;
|
|
59
|
+
export function setLanguage(lang: string): void;
|
|
60
|
+
export function t(key: string): string;
|
|
61
|
+
export const SUPPORTED_LANGUAGES: string[];
|
|
62
|
+
export const messages: Record<string, Record<string, string>>;
|