@tradeport/sui-trading-sdk 0.3.7 → 0.3.9
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/SuiTradingClient.ts +6 -2
- package/src/helpers/kiosk/kioskTxWrapper.ts +4 -5
- package/src/methods/acceptNftBids/acceptNftBids.ts +17 -9
package/package.json
CHANGED
package/src/SuiTradingClient.ts
CHANGED
|
@@ -157,7 +157,7 @@ class SuiTradingClient {
|
|
|
157
157
|
return removeNftBids({ bidIds, tx }, context);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
public async acceptNftBids({ bidIds }: AcceptNftBids) {
|
|
160
|
+
public async acceptNftBids({ bidIds, walletAddress }: AcceptNftBids) {
|
|
161
161
|
const context: RequestContext = {
|
|
162
162
|
apiUser: this.apiUser,
|
|
163
163
|
apiKey: this.apiKey,
|
|
@@ -165,7 +165,7 @@ class SuiTradingClient {
|
|
|
165
165
|
kioskClient: this.kioskClient,
|
|
166
166
|
};
|
|
167
167
|
|
|
168
|
-
return acceptNftBids({ bidIds }, context);
|
|
168
|
+
return acceptNftBids({ bidIds, walletAddress }, context);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
public async placeCollectionBid({
|
|
@@ -215,6 +215,10 @@ class SuiTradingClient {
|
|
|
215
215
|
throw new Error('No bid found');
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
if (addLeadingZerosAfter0x(bid?.bidder) === addLeadingZerosAfter0x(walletAddress)) {
|
|
219
|
+
throw new Error('Wallet cannot accept its own bid');
|
|
220
|
+
}
|
|
221
|
+
|
|
218
222
|
if (bid?.status !== 'active') {
|
|
219
223
|
throw new Error('Bid not active');
|
|
220
224
|
}
|
|
@@ -110,7 +110,10 @@ export const kioskTxWrapper = async ({
|
|
|
110
110
|
version: '',
|
|
111
111
|
},
|
|
112
112
|
});
|
|
113
|
-
} else if (kiosks.length
|
|
113
|
+
} else if (shouldConvertToPersonalKiosk || kiosks.length === 0) {
|
|
114
|
+
kioskTx = new KioskTransaction({ transactionBlock: tx as any, kioskClient });
|
|
115
|
+
kioskTx.createPersonal(true);
|
|
116
|
+
} else {
|
|
114
117
|
const kioskCapId = (
|
|
115
118
|
await gqlChainRequest({
|
|
116
119
|
chain: 'sui',
|
|
@@ -130,10 +133,6 @@ export const kioskTxWrapper = async ({
|
|
|
130
133
|
version: '',
|
|
131
134
|
},
|
|
132
135
|
});
|
|
133
|
-
} else {
|
|
134
|
-
// creating new personal kiosk
|
|
135
|
-
kioskTx = new KioskTransaction({ transactionBlock: tx as any, kioskClient });
|
|
136
|
-
kioskTx.createPersonal(true);
|
|
137
136
|
}
|
|
138
137
|
|
|
139
138
|
await runCommands(kioskTx);
|
|
@@ -2,19 +2,20 @@ import { type KioskClient, type KioskTransaction } from '@mysten/kiosk';
|
|
|
2
2
|
import { type SuiClient } from '@mysten/sui/client';
|
|
3
3
|
import { Transaction } from '@mysten/sui/transactions';
|
|
4
4
|
import { type RequestContext } from '../../SuiTradingClient';
|
|
5
|
+
import {
|
|
6
|
+
DELOREAN_TOKEN_IDS_TO_DISABLE,
|
|
7
|
+
DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE,
|
|
8
|
+
} from '../../constants';
|
|
5
9
|
import { gqlChainRequest } from '../../graphql/gqlChainRequest';
|
|
6
10
|
import { fetchBidsById } from '../../graphql/queries/fetchBidsById';
|
|
7
11
|
import { getNftType } from '../../helpers/getNftType';
|
|
8
12
|
import { getSharedObjects } from '../../helpers/getSharedObjects';
|
|
13
|
+
import { addLeadingZerosAfter0x } from '../../utils/addLeadingZerosAfter0x';
|
|
9
14
|
import {
|
|
10
15
|
addBluemoveAcceptNftBidTx,
|
|
11
16
|
addOriginByteAcceptNftBidTx,
|
|
12
17
|
addTradePortAcceptNftBidTxHandler,
|
|
13
18
|
} from './addAcceptNftBidTxs';
|
|
14
|
-
import {
|
|
15
|
-
DELOREAN_TOKEN_IDS_TO_DISABLE,
|
|
16
|
-
DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE,
|
|
17
|
-
} from '../../constants';
|
|
18
19
|
|
|
19
20
|
export type AcceptNftBidTx = {
|
|
20
21
|
tx: Transaction;
|
|
@@ -38,12 +39,9 @@ export type AcceptNftBidTx = {
|
|
|
38
39
|
beforeResolveKioskTransferRequest?: (coin: any, transferRequest: any) => void | Promise<void>;
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
export type AcceptNftBid = {
|
|
42
|
-
bidId: string;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
42
|
export type AcceptNftBids = {
|
|
46
43
|
bidIds: string[];
|
|
44
|
+
walletAddress: string;
|
|
47
45
|
tx?: Transaction;
|
|
48
46
|
kioskTx?: KioskTransaction;
|
|
49
47
|
beforeResolveKioskTransferRequest?: (coin: any, transferRequest: any) => void | Promise<void>;
|
|
@@ -52,7 +50,13 @@ export type AcceptNftBids = {
|
|
|
52
50
|
const ERROR_UNLIST_FIRST = 'Item must be unlisted first before you can accept a solo bid on it';
|
|
53
51
|
|
|
54
52
|
export const acceptNftBids = async (
|
|
55
|
-
{
|
|
53
|
+
{
|
|
54
|
+
bidIds,
|
|
55
|
+
walletAddress,
|
|
56
|
+
tx: existingTx,
|
|
57
|
+
kioskTx,
|
|
58
|
+
beforeResolveKioskTransferRequest,
|
|
59
|
+
}: AcceptNftBids,
|
|
56
60
|
context: RequestContext,
|
|
57
61
|
): Promise<Transaction> => {
|
|
58
62
|
const res = await gqlChainRequest({
|
|
@@ -73,6 +77,10 @@ export const acceptNftBids = async (
|
|
|
73
77
|
throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
if (addLeadingZerosAfter0x(bid?.bidder) === addLeadingZerosAfter0x(walletAddress)) {
|
|
81
|
+
throw new Error('Wallet cannot accept its own bid');
|
|
82
|
+
}
|
|
83
|
+
|
|
76
84
|
if (bid?.status !== 'active') {
|
|
77
85
|
throw new Error('Bid not active');
|
|
78
86
|
}
|