@tradeport/sui-trading-sdk 0.4.63 → 0.4.64

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tradeport/sui-trading-sdk",
3
3
  "license": "MIT",
4
- "version": "0.4.63",
4
+ "version": "0.4.64",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -121,7 +121,6 @@ export const listNfts = async (
121
121
  if (inputNft?.sponsorOptions?.shouldSponsor) {
122
122
  await addSponsorListingTx({
123
123
  tx,
124
- coinToSplit: inputNft?.sponsorOptions?.coinToSplit,
125
124
  nftTokenId: nft?.token_id,
126
125
  nftType,
127
126
  sponsorOptions: inputNft?.sponsorOptions,
@@ -1,28 +1,30 @@
1
- import type { Transaction } from '@mysten/sui/transactions';
1
+ import { coinWithBalance, type Transaction } from '@mysten/sui/transactions';
2
2
  import BigNumber from '../../bigNumberConfig';
3
- import { TRADEPORT_LISTINGS_PACKAGE, TRADEPORT_LISTINGS_STORE } from '../../constants';
3
+ import {
4
+ TRADEPORT_LISTINGS_PACKAGE,
5
+ TRADEPORT_LISTINGS_STORE,
6
+ USDC_COIN_TYPE,
7
+ } from '../../constants';
4
8
  import { type SponsorNftListingOptions } from './sponsorNftListing';
5
9
 
6
10
  export const addSponsorListingTx = async ({
7
11
  tx,
8
- coinToSplit,
9
12
  nftTokenId,
10
13
  nftType,
11
14
  sponsorOptions,
12
15
  }: {
13
16
  tx: Transaction;
14
- coinToSplit: any;
15
17
  nftTokenId: string;
16
18
  nftType: string;
17
19
  sponsorOptions: SponsorNftListingOptions;
18
20
  }) => {
19
- const [sponsorFeeCoin] = tx.splitCoins(coinToSplit, [
20
- tx.pure.u64(
21
- new BigNumber(sponsorOptions?.usdcFeeAmountPerPeriod)
22
- ?.times(sponsorOptions?.numOfPeriods)
23
- .toString(),
24
- ),
25
- ]);
21
+ const totalFee = new BigNumber(sponsorOptions?.usdcFeeAmountPerPeriod)
22
+ ?.times(sponsorOptions?.numOfPeriods)
23
+ .toString();
24
+
25
+ const sponsorCoin = sponsorOptions.coinToSplit
26
+ ? tx.splitCoins(sponsorOptions.coinToSplit, [tx.pure.u64(totalFee)])[0]
27
+ : coinWithBalance({ type: USDC_COIN_TYPE, balance: BigInt(totalFee) });
26
28
 
27
29
  tx.moveCall({
28
30
  target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::add_sponsored_listing`,
@@ -31,7 +33,7 @@ export const addSponsorListingTx = async ({
31
33
  tx.object.clock(),
32
34
  tx.pure.id(nftTokenId),
33
35
  tx.pure.u64(sponsorOptions?.numOfPeriods),
34
- tx.object(sponsorFeeCoin),
36
+ tx.object(sponsorCoin),
35
37
  ],
36
38
  typeArguments: [nftType],
37
39
  });
@@ -14,14 +14,12 @@ export type SponsorNftListingOptions = {
14
14
 
15
15
  export type SponsorNftListing = {
16
16
  tx?: Transaction;
17
- coinToSplit?: any;
18
17
  nftTokenId: string;
19
18
  options: SponsorNftListingOptions;
20
19
  };
21
20
 
22
21
  export const sponsorNftListing = async ({
23
22
  tx: existingTx,
24
- coinToSplit,
25
23
  nftTokenId,
26
24
  options,
27
25
  }: SponsorNftListing): Promise<Transaction> => {
@@ -53,7 +51,6 @@ export const sponsorNftListing = async ({
53
51
 
54
52
  await addSponsorListingTx({
55
53
  tx,
56
- coinToSplit,
57
54
  nftTokenId,
58
55
  nftType,
59
56
  sponsorOptions: options,