@tradeport/sui-trading-sdk 0.1.108 → 0.2.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/CHANGELOG.md +5 -29
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +62 -188
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -188
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
- package/src/SuiTradingClient.ts +1 -1
- package/src/apiClients/graphqlClient.ts +1 -1
- package/src/helpers/kiosk/kioskTxWrapper.ts +24 -15
- package/src/helpers/rpc/getObjectType.ts +1 -9
- package/src/helpers/track.ts +19 -24
- package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +2 -13
- package/src/methods/acceptNftBids/acceptNftBids.ts +4 -4
- package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +1 -7
- package/src/methods/buyListings/addBuyListingTxs.ts +13 -16
- package/src/methods/cancelNftTransfers/cancelNftTransfers.ts +1 -15
- package/src/methods/claimNfts/claimNfts.ts +26 -76
- package/src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts +1 -1
- package/src/methods/removeNftBids/removeNftBids.ts +8 -0
- package/src/methods/transferNfts/transferNfts.ts +13 -3
- package/src/methods/unlistListings/addUnlistListingTxs.ts +3 -3
- package/src/helpers/handleGetBidNonceTypeError.ts +0 -13
- package/src/helpers/handleGetListingNonceError.ts +0 -13
- package/src/helpers/isValidHexAddressFormat.ts +0 -32
- package/src/utils/removeLeadingZerosAfter0x.ts +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,46 +1,22 @@
|
|
|
1
1
|
# @tradeport/sui-trading-sdk
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.2.0
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
- 88ab94f: Added error handling for listing nonces that are not found, and refactored the deleted bid nonce error handling
|
|
8
|
-
|
|
9
|
-
## 0.1.107
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- b6aeaa9: Fixed error handling message for deleted bid in one spot
|
|
14
|
-
|
|
15
|
-
## 0.1.106
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
- ccc8281: Added error handling for sui object fetch
|
|
20
|
-
- 33fb6c4: Fixed error handling for accepting deleted bids
|
|
21
|
-
|
|
22
|
-
## 0.1.105
|
|
23
|
-
|
|
24
|
-
### Patch Changes
|
|
25
|
-
|
|
26
|
-
- c6cc55a: Updated transfer nfts validation for recipient address
|
|
27
|
-
|
|
28
|
-
## 0.1.104
|
|
29
|
-
|
|
30
|
-
### Patch Changes
|
|
5
|
+
### Minor Changes
|
|
31
6
|
|
|
32
|
-
-
|
|
7
|
+
- 2c14d7d: Reverted parallel batching of txs because it doesnt work with Sui trying to access the same objects at same time
|
|
33
8
|
|
|
34
9
|
## 0.1.103
|
|
35
10
|
|
|
36
11
|
### Patch Changes
|
|
37
12
|
|
|
38
|
-
-
|
|
13
|
+
- 924b52c: Reverted parallel batching of txs because it doesnt work with Sui trying to access the same objects at same time
|
|
39
14
|
|
|
40
15
|
## 0.1.102
|
|
41
16
|
|
|
42
17
|
### Patch Changes
|
|
43
18
|
|
|
19
|
+
- 032ffe5: Reverted parallel batching of txs because it doesnt work with Sui trying to access the same objects at same time
|
|
44
20
|
- 03e03db: Disabled trading for 900 Delorean NFTs that were flagged
|
|
45
21
|
|
|
46
22
|
## 0.1.100
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ var createSuiClient_default = createSuiClient;
|
|
|
43
43
|
|
|
44
44
|
// src/apiClients/graphqlClient.ts
|
|
45
45
|
var import_graphql_request = require("graphql-request");
|
|
46
|
-
var graphqlClient = new import_graphql_request.GraphQLClient("https://api.indexer.xyz/
|
|
46
|
+
var graphqlClient = new import_graphql_request.GraphQLClient("https://api.indexer.xyz/graphql");
|
|
47
47
|
var getGraphqlClient = () => graphqlClient;
|
|
48
48
|
function setGraphqlClient(client) {
|
|
49
49
|
graphqlClient = client;
|
|
@@ -1271,19 +1271,6 @@ var normalizedNftType = (nftType) => {
|
|
|
1271
1271
|
// src/helpers/getRoyaltyRuleModule.ts
|
|
1272
1272
|
var getRoyaltyRuleModule = (nftType) => normalizedNftType(nftType) === "0xe7e651e4974fe367aa2837712d68081efb299c470242a15e2b9c26ea326159ec::card::SudoCard" ? "kiosk_royalty_rule" : "royalty_rule";
|
|
1273
1273
|
|
|
1274
|
-
// src/helpers/handleGetBidNonceTypeError.ts
|
|
1275
|
-
function handleGetBidNonceTypeError(error, bidNonce) {
|
|
1276
|
-
if (error instanceof Error) {
|
|
1277
|
-
if (error.message.includes("deleted")) {
|
|
1278
|
-
throw new Error(`Bid ${bidNonce} already accepted`);
|
|
1279
|
-
}
|
|
1280
|
-
if (error.message.includes("notExists")) {
|
|
1281
|
-
throw new Error(`Bid ${bidNonce} does not exist`);
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
throw error;
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
1274
|
// src/graphql/queries/fetchTransferPoliciesByType.ts
|
|
1288
1275
|
var import_graphql_request7 = require("graphql-request");
|
|
1289
1276
|
var fetchTransferPoliciesByType = import_graphql_request7.gql`
|
|
@@ -1436,10 +1423,11 @@ var kioskTxWrapper = async ({
|
|
|
1436
1423
|
kioskTx,
|
|
1437
1424
|
kioskOwner,
|
|
1438
1425
|
kiosk,
|
|
1426
|
+
kioskOwnerKiosks,
|
|
1439
1427
|
runCommands,
|
|
1440
1428
|
shouldConvertToPersonalKiosk,
|
|
1441
1429
|
shouldAssertNftInSharedKiosk,
|
|
1442
|
-
|
|
1430
|
+
shouldAllowNftUnsharedKiosk,
|
|
1443
1431
|
kioskStrategy,
|
|
1444
1432
|
failIfNoKiosk
|
|
1445
1433
|
}) => {
|
|
@@ -1447,15 +1435,15 @@ var kioskTxWrapper = async ({
|
|
|
1447
1435
|
await runCommands(kioskTx);
|
|
1448
1436
|
return;
|
|
1449
1437
|
}
|
|
1450
|
-
let kiosks = (await gqlChainRequest({
|
|
1438
|
+
let kiosks = kioskOwnerKiosks ?? ((await gqlChainRequest({
|
|
1451
1439
|
chain: "sui",
|
|
1452
1440
|
query: fetchKiosksByOwner,
|
|
1453
1441
|
variables: { ownerAddress: addLeadingZerosAfter0x(kioskOwner) }
|
|
1454
|
-
})).kiosks ?? [];
|
|
1442
|
+
})).kiosks ?? []);
|
|
1455
1443
|
if (shouldAssertNftInSharedKiosk) {
|
|
1456
1444
|
await assertNftInSharedKiosk({ kioskId: kiosk, walletAddress: kioskOwner, kiosks });
|
|
1457
1445
|
}
|
|
1458
|
-
kiosks = kiosks?.filter((k) => !k.is_origin_byte && (
|
|
1446
|
+
kiosks = kiosks?.filter((k) => !k.is_origin_byte && (shouldAllowNftUnsharedKiosk || k.is_shared));
|
|
1459
1447
|
if (kiosk) {
|
|
1460
1448
|
let filteredKiosks = [];
|
|
1461
1449
|
switch (kioskStrategy ?? "include") {
|
|
@@ -1634,13 +1622,7 @@ var getObjectType = async ({
|
|
|
1634
1622
|
objectId
|
|
1635
1623
|
}) => {
|
|
1636
1624
|
if ((0, import_utils.isValidSuiObjectId)(objectId)) {
|
|
1637
|
-
const res = await suiClient.getObject({
|
|
1638
|
-
id: objectId,
|
|
1639
|
-
options: { showType: true }
|
|
1640
|
-
});
|
|
1641
|
-
if (res.error) {
|
|
1642
|
-
throw new Error(`Error fetching Sui object: ${res.error.code}`);
|
|
1643
|
-
}
|
|
1625
|
+
const res = await suiClient.getObject({ id: objectId, options: { showType: true } });
|
|
1644
1626
|
return res.data.type;
|
|
1645
1627
|
}
|
|
1646
1628
|
return "";
|
|
@@ -2196,12 +2178,7 @@ function addBluemoveAcceptNftBidTx({
|
|
|
2196
2178
|
});
|
|
2197
2179
|
}
|
|
2198
2180
|
async function addTradePortAcceptNftBidTxHandler(txData) {
|
|
2199
|
-
|
|
2200
|
-
try {
|
|
2201
|
-
bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
|
|
2202
|
-
} catch (error) {
|
|
2203
|
-
handleGetBidNonceTypeError(error, txData?.bidNonce);
|
|
2204
|
-
}
|
|
2181
|
+
const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
|
|
2205
2182
|
if (isOriginByteBid(bidType)) {
|
|
2206
2183
|
if (isOriginByteTx(txData?.sharedObjects)) {
|
|
2207
2184
|
await addOriginByteAcceptNftBidTx(txData);
|
|
@@ -2392,7 +2369,7 @@ async function addTradePortUnlistTxHandler(txData) {
|
|
|
2392
2369
|
kioskClient: txData?.kioskClient,
|
|
2393
2370
|
kioskOwner: txData?.seller,
|
|
2394
2371
|
kiosk: txData?.sellerKiosk,
|
|
2395
|
-
|
|
2372
|
+
shouldAllowNftUnsharedKiosk: true,
|
|
2396
2373
|
async runCommands(kioskTx) {
|
|
2397
2374
|
await addTradePortKioskUnlistTx({
|
|
2398
2375
|
...txData,
|
|
@@ -2413,7 +2390,7 @@ async function addHyperspaceUnlistTxHandler(txData) {
|
|
|
2413
2390
|
kioskClient: txData?.kioskClient,
|
|
2414
2391
|
kioskOwner: txData?.seller,
|
|
2415
2392
|
kiosk: txData?.sellerKiosk,
|
|
2416
|
-
|
|
2393
|
+
shouldAllowNftUnsharedKiosk: true,
|
|
2417
2394
|
async runCommands(kioskTx) {
|
|
2418
2395
|
await addHyperspaceKioskUnlistTx({
|
|
2419
2396
|
...txData,
|
|
@@ -2433,7 +2410,7 @@ async function addBluemoveUnlistTxHandler(txData) {
|
|
|
2433
2410
|
kioskClient: txData?.kioskClient,
|
|
2434
2411
|
kioskOwner: txData?.seller,
|
|
2435
2412
|
kiosk: txData?.sellerKiosk,
|
|
2436
|
-
|
|
2413
|
+
shouldAllowNftUnsharedKiosk: true,
|
|
2437
2414
|
async runCommands(kioskTx) {
|
|
2438
2415
|
await addBluemoveKioskUnlistTx({
|
|
2439
2416
|
...txData,
|
|
@@ -2631,12 +2608,7 @@ function addTocenAcceptCollectionBidTx({
|
|
|
2631
2608
|
});
|
|
2632
2609
|
}
|
|
2633
2610
|
async function addTradePortAcceptCollectionBidTxHandler(txData) {
|
|
2634
|
-
|
|
2635
|
-
try {
|
|
2636
|
-
bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
|
|
2637
|
-
} catch (error) {
|
|
2638
|
-
handleGetBidNonceTypeError(error, txData?.bidNonce);
|
|
2639
|
-
}
|
|
2611
|
+
const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
|
|
2640
2612
|
if (isOriginByteBid(bidType)) {
|
|
2641
2613
|
if (isOriginByteTx(txData?.sharedObjects)) {
|
|
2642
2614
|
await addOriginByteAcceptCollectionBidTx(txData);
|
|
@@ -2692,12 +2664,7 @@ async function addTradePortAcceptCollectionBidTxHandler(txData) {
|
|
|
2692
2664
|
addTradeportAcceptCollectionBidTx(txData);
|
|
2693
2665
|
}
|
|
2694
2666
|
async function addBluemoveAcceptCollectionBidTxHandler(txData) {
|
|
2695
|
-
|
|
2696
|
-
try {
|
|
2697
|
-
bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
|
|
2698
|
-
} catch (error) {
|
|
2699
|
-
handleGetBidNonceTypeError(error, txData?.bidNonce);
|
|
2700
|
-
}
|
|
2667
|
+
const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
|
|
2701
2668
|
if (isOriginByteBid(bidType)) {
|
|
2702
2669
|
if (isOriginByteTx(txData?.sharedObjects)) {
|
|
2703
2670
|
await addOriginByteAcceptCollectionBidTx(txData);
|
|
@@ -3367,19 +3334,6 @@ var destroyZeroCoin = ({ tx, coin }) => {
|
|
|
3367
3334
|
});
|
|
3368
3335
|
};
|
|
3369
3336
|
|
|
3370
|
-
// src/helpers/handleGetListingNonceError.ts
|
|
3371
|
-
function handleGetListingNonceTypeError(error, listingNonce) {
|
|
3372
|
-
if (error instanceof Error) {
|
|
3373
|
-
if (error.message.includes("deleted")) {
|
|
3374
|
-
throw new Error(`Listing ${listingNonce} already bought`);
|
|
3375
|
-
}
|
|
3376
|
-
if (error.message.includes("notExists")) {
|
|
3377
|
-
throw new Error(`Listing ${listingNonce} does not exist`);
|
|
3378
|
-
}
|
|
3379
|
-
}
|
|
3380
|
-
throw error;
|
|
3381
|
-
}
|
|
3382
|
-
|
|
3383
3337
|
// src/helpers/splitCoins.ts
|
|
3384
3338
|
var splitCoins = ({ tx, amounts }) => {
|
|
3385
3339
|
const res = tx.splitCoins(tx.gas, amounts);
|
|
@@ -3435,7 +3389,7 @@ var addTradeportKioskBuyTx = async ({
|
|
|
3435
3389
|
name: { type: "0x2::object::ID", value: nftTokenId }
|
|
3436
3390
|
});
|
|
3437
3391
|
if (response.error?.code === "dynamicFieldNotFound") {
|
|
3438
|
-
throw new Error(`
|
|
3392
|
+
throw new Error(`Not found kiosk listing object of token ${nftTokenId}`);
|
|
3439
3393
|
}
|
|
3440
3394
|
const coin = tx.splitCoins(coinToSplit ? coinToSplit : tx.gas, [
|
|
3441
3395
|
tx.pure.u64(price + Number(response.data.content.fields.commission))
|
|
@@ -3732,18 +3686,18 @@ async function addTradePortBuyTxHandler(txData) {
|
|
|
3732
3686
|
await addOriginByteBuyTx(txData);
|
|
3733
3687
|
return;
|
|
3734
3688
|
}
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
objectId: txData?.listingNonce
|
|
3689
|
+
if (txData.listingNonce?.startsWith("0x")) {
|
|
3690
|
+
const response = await txData?.suiClient.getObject({
|
|
3691
|
+
id: txData.listingNonce,
|
|
3692
|
+
options: { showType: true }
|
|
3740
3693
|
});
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3694
|
+
if (response.error) {
|
|
3695
|
+
throw new Error(response.error.code);
|
|
3696
|
+
}
|
|
3697
|
+
if (response.data.type === NON_KIOSK_LISTING_NONCE_TYPE) {
|
|
3698
|
+
addTradePortBuyTx(txData);
|
|
3699
|
+
return;
|
|
3700
|
+
}
|
|
3747
3701
|
}
|
|
3748
3702
|
if (txData?.sellerKiosk) {
|
|
3749
3703
|
return kioskTxWrapper({
|
|
@@ -4199,22 +4153,12 @@ var cancelNftTransfers = async ({ nftIds, walletAddress }, context) => {
|
|
|
4199
4153
|
if (!txData.senderKiosk || isSenderKioskOriginByte) {
|
|
4200
4154
|
throw new Error("NFT is not inside a native kiosk, cannot cancel transfer");
|
|
4201
4155
|
}
|
|
4202
|
-
const res2 = await gqlChainRequest({
|
|
4203
|
-
chain: "sui",
|
|
4204
|
-
query: fetchKiosksByOwner,
|
|
4205
|
-
variables: { ownerAddress: addLeadingZerosAfter0x(walletAddress) }
|
|
4206
|
-
});
|
|
4207
|
-
const kiosks = res2?.kiosks;
|
|
4208
|
-
let shouldUseNftUnsharedKiosk = false;
|
|
4209
|
-
if (kiosks?.filter((k) => k.id === txData?.senderKiosk)?.[0]?.is_shared === false) {
|
|
4210
|
-
shouldUseNftUnsharedKiosk = true;
|
|
4211
|
-
}
|
|
4212
4156
|
await kioskTxWrapper({
|
|
4213
4157
|
tx: txData?.tx,
|
|
4214
4158
|
kioskClient: context.kioskClient,
|
|
4215
4159
|
kioskOwner: txData?.senderAddress,
|
|
4216
4160
|
kiosk: txData?.senderKiosk,
|
|
4217
|
-
|
|
4161
|
+
shouldAllowNftUnsharedKiosk: true,
|
|
4218
4162
|
async runCommands(kioskTx) {
|
|
4219
4163
|
await addTradeportKioskCancelNftTransferTx({ ...txData, kioskTx });
|
|
4220
4164
|
}
|
|
@@ -4434,6 +4378,12 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
|
|
|
4434
4378
|
}
|
|
4435
4379
|
const nftsForTracking = [];
|
|
4436
4380
|
const tx = existingTx ?? new import_transactions12.Transaction();
|
|
4381
|
+
const kiosksByOwnerRes = await gqlChainRequest({
|
|
4382
|
+
chain: "sui",
|
|
4383
|
+
query: fetchKiosksByOwner,
|
|
4384
|
+
variables: { ownerAddress: addLeadingZerosAfter0x(walletAddress) }
|
|
4385
|
+
});
|
|
4386
|
+
const walletAddressKiosks = kiosksByOwnerRes?.kiosks;
|
|
4437
4387
|
for (const nft of res.nfts) {
|
|
4438
4388
|
if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
|
|
4439
4389
|
throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
|
|
@@ -4449,8 +4399,8 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
|
|
|
4449
4399
|
collectionChainState: nft?.collection?.chain_state,
|
|
4450
4400
|
nft
|
|
4451
4401
|
});
|
|
4452
|
-
const sharedObjects = await getSharedObjects(nftType);
|
|
4453
4402
|
if (nft?.chain_state?.claimable_trade_id) {
|
|
4403
|
+
const sharedObjects = await getSharedObjects(nftType);
|
|
4454
4404
|
const txData = {
|
|
4455
4405
|
tx,
|
|
4456
4406
|
kioskClient: context.kioskClient,
|
|
@@ -4470,38 +4420,22 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
|
|
|
4470
4420
|
tx,
|
|
4471
4421
|
suiClient: context.suiClient,
|
|
4472
4422
|
kioskClient: context.kioskClient,
|
|
4473
|
-
sharedObjects,
|
|
4474
4423
|
claimer: walletAddress,
|
|
4475
4424
|
nftType,
|
|
4476
4425
|
nftTokenId: nft?.token_id,
|
|
4477
4426
|
sellerKiosk: nft?.chain_state?.kiosk_id,
|
|
4478
4427
|
seller: nft?.owner
|
|
4479
4428
|
};
|
|
4480
|
-
const res2 = await gqlChainRequest({
|
|
4481
|
-
chain: "sui",
|
|
4482
|
-
query: fetchKiosksByOwner,
|
|
4483
|
-
variables: { ownerAddress: addLeadingZerosAfter0x(walletAddress) }
|
|
4484
|
-
});
|
|
4485
|
-
const kiosks = res2?.kiosks;
|
|
4486
|
-
let shouldUseNftUnsharedKiosk = false;
|
|
4487
|
-
if (kiosks?.filter((k) => k.id === txData?.sellerKiosk)?.[0]?.is_shared === false) {
|
|
4488
|
-
shouldUseNftUnsharedKiosk = true;
|
|
4489
|
-
}
|
|
4490
4429
|
if (BLUEMOVE_CLAIMABLE_CONTRACT_KEYS?.includes(nft?.chain_state?.claimable_contract_key)) {
|
|
4491
4430
|
await kioskTxWrapper({
|
|
4492
4431
|
tx,
|
|
4493
4432
|
kioskClient: context.kioskClient,
|
|
4494
4433
|
kioskOwner: txData?.claimer,
|
|
4434
|
+
kioskOwnerKiosks: walletAddressKiosks,
|
|
4495
4435
|
kiosk: txData?.sellerKiosk,
|
|
4496
4436
|
shouldConvertToPersonalKiosk: true,
|
|
4497
|
-
|
|
4437
|
+
shouldAllowNftUnsharedKiosk: true,
|
|
4498
4438
|
async runCommands(kioskTx) {
|
|
4499
|
-
if (!shouldUseNftUnsharedKiosk) {
|
|
4500
|
-
await assertNftInSharedKiosk({
|
|
4501
|
-
kioskId: txData?.sellerKiosk,
|
|
4502
|
-
walletAddress: txData?.seller
|
|
4503
|
-
});
|
|
4504
|
-
}
|
|
4505
4439
|
await addBluemoveClaimAcceptedBidNft({
|
|
4506
4440
|
...txData,
|
|
4507
4441
|
suiClient: context.suiClient,
|
|
@@ -4516,16 +4450,11 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
|
|
|
4516
4450
|
tx,
|
|
4517
4451
|
kioskClient: context.kioskClient,
|
|
4518
4452
|
kioskOwner: txData?.claimer,
|
|
4453
|
+
kioskOwnerKiosks: walletAddressKiosks,
|
|
4519
4454
|
kiosk: txData?.sellerKiosk,
|
|
4520
4455
|
shouldConvertToPersonalKiosk: true,
|
|
4521
|
-
|
|
4456
|
+
shouldAllowNftUnsharedKiosk: true,
|
|
4522
4457
|
async runCommands(kioskTx) {
|
|
4523
|
-
if (!shouldUseNftUnsharedKiosk) {
|
|
4524
|
-
await assertNftInSharedKiosk({
|
|
4525
|
-
kioskId: txData?.sellerKiosk,
|
|
4526
|
-
walletAddress: txData?.seller
|
|
4527
|
-
});
|
|
4528
|
-
}
|
|
4529
4458
|
await addClaimAcceptedBidNftTx({ ...txData, kioskTx });
|
|
4530
4459
|
}
|
|
4531
4460
|
});
|
|
@@ -4534,16 +4463,11 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
|
|
|
4534
4463
|
tx,
|
|
4535
4464
|
kioskClient: context.kioskClient,
|
|
4536
4465
|
kioskOwner: txData?.claimer,
|
|
4466
|
+
kioskOwnerKiosks: walletAddressKiosks,
|
|
4537
4467
|
kiosk: txData?.sellerKiosk,
|
|
4538
4468
|
shouldConvertToPersonalKiosk: true,
|
|
4539
|
-
|
|
4469
|
+
shouldAssertNftInSharedKiosk: true,
|
|
4540
4470
|
async runCommands(kioskTx) {
|
|
4541
|
-
if (!shouldUseNftUnsharedKiosk) {
|
|
4542
|
-
await assertNftInSharedKiosk({
|
|
4543
|
-
kioskId: txData?.sellerKiosk,
|
|
4544
|
-
walletAddress: txData?.seller
|
|
4545
|
-
});
|
|
4546
|
-
}
|
|
4547
4471
|
await addClaimAcceptedBidNftWithPurchaseCapTx({ ...txData, kioskTx });
|
|
4548
4472
|
}
|
|
4549
4473
|
});
|
|
@@ -4555,39 +4479,23 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
|
|
|
4555
4479
|
tx,
|
|
4556
4480
|
suiClient: context.suiClient,
|
|
4557
4481
|
kioskClient: context.kioskClient,
|
|
4558
|
-
sharedObjects,
|
|
4559
4482
|
claimer: walletAddress,
|
|
4560
4483
|
nftType,
|
|
4561
4484
|
nftTokenId: nft?.token_id,
|
|
4562
4485
|
sellerKiosk: nft?.chain_state?.kiosk_id,
|
|
4563
4486
|
seller: nft?.owner
|
|
4564
4487
|
};
|
|
4565
|
-
const res2 = await gqlChainRequest({
|
|
4566
|
-
chain: "sui",
|
|
4567
|
-
query: fetchKiosksByOwner,
|
|
4568
|
-
variables: { ownerAddress: addLeadingZerosAfter0x(walletAddress) }
|
|
4569
|
-
});
|
|
4570
|
-
const kiosks = res2?.kiosks;
|
|
4571
|
-
let shouldUseNftUnsharedKiosk = false;
|
|
4572
|
-
if (kiosks?.filter((k) => k.id === txData?.sellerKiosk)?.[0]?.is_shared === false) {
|
|
4573
|
-
shouldUseNftUnsharedKiosk = true;
|
|
4574
|
-
}
|
|
4575
4488
|
if (useOldClaim) {
|
|
4576
4489
|
await kioskTxWrapper({
|
|
4577
4490
|
tx,
|
|
4578
4491
|
kioskClient: context.kioskClient,
|
|
4579
4492
|
kioskOwner: txData?.claimer,
|
|
4580
4493
|
kiosk: txData?.sellerKiosk,
|
|
4494
|
+
kioskOwnerKiosks: walletAddressKiosks,
|
|
4581
4495
|
kioskStrategy: "exclude",
|
|
4582
4496
|
shouldConvertToPersonalKiosk: true,
|
|
4583
|
-
|
|
4497
|
+
shouldAllowNftUnsharedKiosk: true,
|
|
4584
4498
|
async runCommands(kioskTx) {
|
|
4585
|
-
if (!shouldUseNftUnsharedKiosk) {
|
|
4586
|
-
await assertNftInSharedKiosk({
|
|
4587
|
-
kioskId: txData?.sellerKiosk,
|
|
4588
|
-
walletAddress: txData?.seller
|
|
4589
|
-
});
|
|
4590
|
-
}
|
|
4591
4499
|
await addClaimTransferredNftTx({ ...txData, kioskTx });
|
|
4592
4500
|
}
|
|
4593
4501
|
});
|
|
@@ -4597,26 +4505,16 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
|
|
|
4597
4505
|
kioskClient: context.kioskClient,
|
|
4598
4506
|
kioskOwner: txData?.claimer,
|
|
4599
4507
|
kiosk: txData?.sellerKiosk,
|
|
4508
|
+
kioskOwnerKiosks: walletAddressKiosks,
|
|
4600
4509
|
kioskStrategy: "exclude",
|
|
4601
4510
|
shouldConvertToPersonalKiosk: true,
|
|
4602
|
-
|
|
4511
|
+
shouldAllowNftUnsharedKiosk: true,
|
|
4603
4512
|
async runCommands(kioskTx) {
|
|
4604
|
-
if (!shouldUseNftUnsharedKiosk) {
|
|
4605
|
-
await assertNftInSharedKiosk({
|
|
4606
|
-
kioskId: txData?.sellerKiosk,
|
|
4607
|
-
walletAddress: txData?.seller
|
|
4608
|
-
});
|
|
4609
|
-
}
|
|
4610
4513
|
await addClaimTransferredNftWithPurchaseCapTx({ ...txData, kioskTx });
|
|
4611
4514
|
}
|
|
4612
4515
|
});
|
|
4613
4516
|
}
|
|
4614
4517
|
}
|
|
4615
|
-
nftsForTracking.push({
|
|
4616
|
-
nftType,
|
|
4617
|
-
claimer: walletAddress,
|
|
4618
|
-
claimReason: nft?.chain_state?.claimable_reason
|
|
4619
|
-
});
|
|
4620
4518
|
}
|
|
4621
4519
|
return import_transactions12.Transaction.from(tx);
|
|
4622
4520
|
};
|
|
@@ -5265,7 +5163,7 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress }, context)
|
|
|
5265
5163
|
kioskClient: context?.kioskClient,
|
|
5266
5164
|
kioskOwner: walletAddress,
|
|
5267
5165
|
kiosk: unsharedNativeKiosk,
|
|
5268
|
-
|
|
5166
|
+
shouldAllowNftUnsharedKiosk: true,
|
|
5269
5167
|
async runCommands(kioskTx) {
|
|
5270
5168
|
await addTradeportKioskTransferTx({
|
|
5271
5169
|
tx,
|
|
@@ -6033,6 +5931,9 @@ var removeNftBids = async ({ bidIds }, context) => {
|
|
|
6033
5931
|
const bidsForTracking = [];
|
|
6034
5932
|
const tx = new import_transactions20.Transaction();
|
|
6035
5933
|
for (const bid of res.bids) {
|
|
5934
|
+
if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
|
|
5935
|
+
throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
|
|
5936
|
+
}
|
|
6036
5937
|
const nftType = getNftType({
|
|
6037
5938
|
collectionId: bid?.collection?.id,
|
|
6038
5939
|
collectionChainState: bid?.collection?.chain_state,
|
|
@@ -6118,47 +6019,16 @@ var addOneDollarFee = async (tx) => {
|
|
|
6118
6019
|
);
|
|
6119
6020
|
};
|
|
6120
6021
|
|
|
6121
|
-
// src/
|
|
6122
|
-
var
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6022
|
+
// src/helpers/rpc/getAcountBalance.ts
|
|
6023
|
+
var getAccountBalance = async ({ suiClient, owner }) => {
|
|
6024
|
+
try {
|
|
6025
|
+
const res = await suiClient.getBalance({
|
|
6026
|
+
owner: addLeadingZerosAfter0x(owner)
|
|
6027
|
+
});
|
|
6028
|
+
return Number(res?.totalBalance);
|
|
6029
|
+
} catch (err) {
|
|
6030
|
+
return 0;
|
|
6128
6031
|
}
|
|
6129
|
-
address = address?.replace(/^0+/, "");
|
|
6130
|
-
return `0x${address}`;
|
|
6131
|
-
};
|
|
6132
|
-
|
|
6133
|
-
// src/helpers/isValidHexAddressFormat.ts
|
|
6134
|
-
var hexRegex = /^[0-9a-fA-F]+$/;
|
|
6135
|
-
var reserved = [
|
|
6136
|
-
"0x0",
|
|
6137
|
-
"0x1",
|
|
6138
|
-
"0x2",
|
|
6139
|
-
"0x3",
|
|
6140
|
-
"0x4",
|
|
6141
|
-
"0x5",
|
|
6142
|
-
"0x6",
|
|
6143
|
-
"0x7",
|
|
6144
|
-
"0x8",
|
|
6145
|
-
"0x9",
|
|
6146
|
-
"0xa",
|
|
6147
|
-
"0xb",
|
|
6148
|
-
"0xc",
|
|
6149
|
-
"0xd",
|
|
6150
|
-
"0xe",
|
|
6151
|
-
"0xf",
|
|
6152
|
-
"0x403",
|
|
6153
|
-
"0xdee9"
|
|
6154
|
-
];
|
|
6155
|
-
var isValidHexAddressFormat = (address) => {
|
|
6156
|
-
const cleaned = address.replace("0x", "").padStart(64, "0");
|
|
6157
|
-
const isHex = hexRegex.test(cleaned);
|
|
6158
|
-
const length = cleaned.length <= 64;
|
|
6159
|
-
const isReserved = reserved.includes(removeLeadingZerosAfter0x(address));
|
|
6160
|
-
const isEmpty = removeLeadingZerosAfter0x(address) === "0x" || !address.includes("0x");
|
|
6161
|
-
return isHex && length && !isReserved && !isEmpty;
|
|
6162
6032
|
};
|
|
6163
6033
|
|
|
6164
6034
|
// src/methods/transferNfts/transferNfts.ts
|
|
@@ -6166,8 +6036,12 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
|
|
|
6166
6036
|
if (addLeadingZerosAfter0x(recipientAddress) === addLeadingZerosAfter0x(walletAddress)) {
|
|
6167
6037
|
throw new Error("Cannot transfer to self");
|
|
6168
6038
|
}
|
|
6169
|
-
|
|
6170
|
-
|
|
6039
|
+
const recipientAddressBalance = await getAccountBalance({
|
|
6040
|
+
suiClient: context.suiClient,
|
|
6041
|
+
owner: recipientAddress
|
|
6042
|
+
});
|
|
6043
|
+
if (!recipientAddressBalance || !recipientAddress?.includes("0x") || recipientAddress?.length < 65) {
|
|
6044
|
+
throw new Error("Invalid recipient address");
|
|
6171
6045
|
}
|
|
6172
6046
|
const res = await gqlChainRequest({
|
|
6173
6047
|
chain: "sui",
|