@tradeport/sui-trading-sdk 0.3.0 → 0.3.2
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 +12 -0
- package/dist/index.d.mts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +24 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/SuiTradingClient.ts +10 -10
- package/src/graphql/queries/fetchCollectionBidById.ts +3 -3
- package/src/methods/{removeCollectionBid/addRemoveCollectionBidTxs.ts → removeCollectionBids/addRemoveCollectionBidsTxs.ts} +8 -4
- package/src/methods/{removeCollectionBid/removeCollectionBid.ts → removeCollectionBids/removeCollectionBids.ts} +15 -18
- package/src/methods/removeNftBids/removeNftBids.ts +8 -11
- package/src/tests/SuiWallet.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -55,9 +55,9 @@ var gqlChainRequest = async ({ chain, query, variables }) => {
|
|
|
55
55
|
|
|
56
56
|
// src/graphql/queries/fetchCollectionBidById.ts
|
|
57
57
|
import { gql as gql2 } from "graphql-request";
|
|
58
|
-
var
|
|
59
|
-
query
|
|
60
|
-
bids(where: { id: {
|
|
58
|
+
var fetchCollectionBidsById = gql2`
|
|
59
|
+
query fetchCollectionBidsById($bidIds: [uuid!]) {
|
|
60
|
+
bids(where: { id: { _in: $bidIds } }) {
|
|
61
61
|
nonce
|
|
62
62
|
price
|
|
63
63
|
bidder
|
|
@@ -5759,7 +5759,7 @@ var placeNftBids = async ({ nfts, walletAddress }, context) => {
|
|
|
5759
5759
|
return Transaction18.from(tx);
|
|
5760
5760
|
};
|
|
5761
5761
|
|
|
5762
|
-
// src/methods/
|
|
5762
|
+
// src/methods/removeCollectionBids/removeCollectionBids.ts
|
|
5763
5763
|
import { Transaction as Transaction19 } from "@mysten/sui/transactions";
|
|
5764
5764
|
|
|
5765
5765
|
// src/methods/removeNftBids/addRemoveNftBidTxs.ts
|
|
@@ -5819,7 +5819,7 @@ async function addTradePortRemoveNftBidTxHandler(txData) {
|
|
|
5819
5819
|
addTradeportRemoveNftBidTx(txData);
|
|
5820
5820
|
}
|
|
5821
5821
|
|
|
5822
|
-
// src/methods/
|
|
5822
|
+
// src/methods/removeCollectionBids/addRemoveCollectionBidsTxs.ts
|
|
5823
5823
|
function addTradeportRemoveCollectionBidTx({
|
|
5824
5824
|
tx,
|
|
5825
5825
|
nftType,
|
|
@@ -5878,7 +5878,8 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
|
|
|
5878
5878
|
objectId: txData?.bidNonce
|
|
5879
5879
|
});
|
|
5880
5880
|
if (isOriginByteBid(bidType)) {
|
|
5881
|
-
|
|
5881
|
+
const sharedObjects = await getSharedObjects(txData?.nftType);
|
|
5882
|
+
addOriginByteRemoveCollectionBidTx({ ...txData, sharedObjects });
|
|
5882
5883
|
return;
|
|
5883
5884
|
}
|
|
5884
5885
|
if (isTradePortKioskBid(bidType)) {
|
|
@@ -5890,7 +5891,8 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
|
|
|
5890
5891
|
async function addBluemoveRemoveCollectionBidTxHandler(txData) {
|
|
5891
5892
|
const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
|
|
5892
5893
|
if (isOriginByteBid(bidType)) {
|
|
5893
|
-
|
|
5894
|
+
const sharedObjects = await getSharedObjects(txData?.nftType);
|
|
5895
|
+
addOriginByteRemoveCollectionBidTx({ ...txData, sharedObjects });
|
|
5894
5896
|
return;
|
|
5895
5897
|
}
|
|
5896
5898
|
if (isBluemoveKioskBid(txData?.bidNonce)) {
|
|
@@ -5900,21 +5902,22 @@ async function addBluemoveRemoveCollectionBidTxHandler(txData) {
|
|
|
5900
5902
|
addBluemoveRemoveCollectionBidTx(txData);
|
|
5901
5903
|
}
|
|
5902
5904
|
async function addClutchyRemoveCollectionBidTxHandler(txData) {
|
|
5903
|
-
|
|
5905
|
+
const sharedObjects = await getSharedObjects(txData?.nftType);
|
|
5906
|
+
addOriginByteRemoveCollectionBidTx({ ...txData, sharedObjects });
|
|
5904
5907
|
}
|
|
5905
5908
|
|
|
5906
|
-
// src/methods/
|
|
5907
|
-
var
|
|
5909
|
+
// src/methods/removeCollectionBids/removeCollectionBids.ts
|
|
5910
|
+
var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
5908
5911
|
const res = await gqlChainRequest({
|
|
5909
5912
|
chain: "sui",
|
|
5910
|
-
query:
|
|
5911
|
-
variables: {
|
|
5913
|
+
query: fetchCollectionBidsById,
|
|
5914
|
+
variables: { bidIds }
|
|
5912
5915
|
});
|
|
5913
5916
|
if (res?.bids?.length === 0) {
|
|
5914
5917
|
throw new Error("No bids found");
|
|
5915
5918
|
}
|
|
5916
5919
|
const bidsForTracking = [];
|
|
5917
|
-
const tx = new Transaction19();
|
|
5920
|
+
const tx = Transaction19.from(existingTx) ?? new Transaction19();
|
|
5918
5921
|
for (const bid of res.bids) {
|
|
5919
5922
|
if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
|
|
5920
5923
|
throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
|
|
@@ -5929,11 +5932,9 @@ var removeCollectionBid = async ({ bidId }, context) => {
|
|
|
5929
5932
|
collectionChainState: collectionWithOneNftRes?.collections?.[0]?.chain_state,
|
|
5930
5933
|
nft: collectionWithOneNftRes?.collections?.[0]?.nfts?.[0]
|
|
5931
5934
|
});
|
|
5932
|
-
const sharedObjects = await getSharedObjects(nftType);
|
|
5933
5935
|
const txData = {
|
|
5934
5936
|
tx,
|
|
5935
5937
|
suiClient: context.suiClient,
|
|
5936
|
-
sharedObjects,
|
|
5937
5938
|
bidNonce: bid?.nonce,
|
|
5938
5939
|
bidder: bid?.bidder,
|
|
5939
5940
|
nftType,
|
|
@@ -5968,7 +5969,7 @@ var removeCollectionBid = async ({ bidId }, context) => {
|
|
|
5968
5969
|
|
|
5969
5970
|
// src/methods/removeNftBids/removeNftBids.ts
|
|
5970
5971
|
import { Transaction as Transaction20 } from "@mysten/sui/transactions";
|
|
5971
|
-
var removeNftBids = async ({ bidIds }, context) => {
|
|
5972
|
+
var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
|
|
5972
5973
|
const res = await gqlChainRequest({
|
|
5973
5974
|
chain: "sui",
|
|
5974
5975
|
query: fetchBidsById,
|
|
@@ -5978,7 +5979,7 @@ var removeNftBids = async ({ bidIds }, context) => {
|
|
|
5978
5979
|
throw new Error("No bids found");
|
|
5979
5980
|
}
|
|
5980
5981
|
const bidsForTracking = [];
|
|
5981
|
-
const tx = new Transaction20();
|
|
5982
|
+
const tx = Transaction20.from(existingTx) ?? new Transaction20();
|
|
5982
5983
|
for (const bid of res.bids) {
|
|
5983
5984
|
if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
|
|
5984
5985
|
throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
|
|
@@ -5988,11 +5989,9 @@ var removeNftBids = async ({ bidIds }, context) => {
|
|
|
5988
5989
|
collectionChainState: bid?.collection?.chain_state,
|
|
5989
5990
|
nft: bid?.nft
|
|
5990
5991
|
});
|
|
5991
|
-
const sharedObjects = await getSharedObjects(nftType);
|
|
5992
5992
|
const txData = {
|
|
5993
5993
|
tx,
|
|
5994
5994
|
suiClient: context.suiClient,
|
|
5995
|
-
sharedObjects,
|
|
5996
5995
|
bidNonce: bid?.nonce,
|
|
5997
5996
|
nftType,
|
|
5998
5997
|
nftTokenId: bid?.nft?.token_id,
|
|
@@ -6326,14 +6325,14 @@ var SuiTradingClient = class {
|
|
|
6326
6325
|
};
|
|
6327
6326
|
return placeNftBids({ nfts, walletAddress }, context);
|
|
6328
6327
|
}
|
|
6329
|
-
async removeNftBids({ bidIds }) {
|
|
6328
|
+
async removeNftBids({ bidIds, tx }) {
|
|
6330
6329
|
const context = {
|
|
6331
6330
|
apiUser: this.apiUser,
|
|
6332
6331
|
apiKey: this.apiKey,
|
|
6333
6332
|
suiClient: this.suiClient,
|
|
6334
6333
|
kioskClient: this.kioskClient
|
|
6335
6334
|
};
|
|
6336
|
-
return removeNftBids({ bidIds }, context);
|
|
6335
|
+
return removeNftBids({ bidIds, tx }, context);
|
|
6337
6336
|
}
|
|
6338
6337
|
async acceptNftBids({ bidIds }) {
|
|
6339
6338
|
const context = {
|
|
@@ -6379,8 +6378,8 @@ var SuiTradingClient = class {
|
|
|
6379
6378
|
};
|
|
6380
6379
|
const collectionBidRes = await gqlChainRequest({
|
|
6381
6380
|
chain: "sui",
|
|
6382
|
-
query:
|
|
6383
|
-
variables: { bidId }
|
|
6381
|
+
query: fetchCollectionBidsById,
|
|
6382
|
+
variables: { bidIds: [bidId] }
|
|
6384
6383
|
});
|
|
6385
6384
|
const bid = collectionBidRes?.bids?.[0];
|
|
6386
6385
|
if (!bid) {
|
|
@@ -6442,14 +6441,14 @@ var SuiTradingClient = class {
|
|
|
6442
6441
|
}
|
|
6443
6442
|
}
|
|
6444
6443
|
}
|
|
6445
|
-
async
|
|
6444
|
+
async removeCollectionBids({ bidIds, tx }) {
|
|
6446
6445
|
const context = {
|
|
6447
6446
|
apiUser: this.apiUser,
|
|
6448
6447
|
apiKey: this.apiKey,
|
|
6449
6448
|
suiClient: this.suiClient,
|
|
6450
6449
|
kioskClient: this.kioskClient
|
|
6451
6450
|
};
|
|
6452
|
-
return
|
|
6451
|
+
return removeCollectionBids({ bidIds, tx }, context);
|
|
6453
6452
|
}
|
|
6454
6453
|
async transferNfts({ nftIds, recipientAddress, walletAddress }) {
|
|
6455
6454
|
const context = {
|