Skip to content

Commit

Permalink
Add param to exclude optional creator fees (#1367)
Browse files Browse the repository at this point in the history
* add param to exclude optional creator fees

* bump package.json version

* lint:fix

* improve keywords

* lint
  • Loading branch information
ryanio authored Jan 22, 2024
1 parent ef4d4c9 commit 4ce43c1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opensea-js",
"version": "7.0.7",
"version": "7.0.8",
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data",
"license": "MIT",
"author": "OpenSea Developers",
Expand Down Expand Up @@ -76,14 +76,14 @@
"crypto",
"ethereum",
"javascript",
"typescript",
"marketplace",
"nft",
"node",
"non-fungible-tokens",
"project-opensea",
"non-fungible tokens",
"opensea",
"sdk",
"smart-contracts"
"smart contracts",
"typescript"
],
"engines": {
"node": ">=16.0.0"
Expand Down
21 changes: 19 additions & 2 deletions src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,19 @@ export class OpenSeaSDK {
paymentTokenAddress,
startAmount,
endAmount,
excludeOptionalCreatorFees,
}: {
collection: OpenSeaCollection;
seller?: string;
paymentTokenAddress: string;
startAmount: bigint;
endAmount?: bigint;
excludeOptionalCreatorFees?: boolean;
}): Promise<ConsiderationInputItem[]> {
const collectionFees = collection.fees;
let collectionFees = collection.fees;
if (excludeOptionalCreatorFees) {
collectionFees = collectionFees.filter((fee) => fee.required);
}
const collectionFeesBasisPoints = totalBasisPointsForFees(collectionFees);
const sellerBasisPoints = INVERSE_BASIS_POINT - collectionFeesBasisPoints;

Expand Down Expand Up @@ -320,6 +325,7 @@ export class OpenSeaSDK {
* @param options.salt Arbitrary salt. If not passed in, a random salt will be generated with the first four bytes being the domain hash or empty.
* @param options.expirationTime Expiration time for the order, in UTC seconds
* @param options.paymentTokenAddress ERC20 address for the payment token in the order. If unspecified, defaults to WETH
* @param options.excludeOptionalCreatorFees If true, optional creator fees will be excluded from the offer. Default: false.
* @returns The {@link OrderV2} that was created.
*
* @throws Error if the asset does not contain a token id.
Expand All @@ -336,6 +342,7 @@ export class OpenSeaSDK {
salt,
expirationTime,
paymentTokenAddress = getWETHAddress(this.chain),
excludeOptionalCreatorFees = false,
}: {
asset: AssetWithTokenId;
accountAddress: string;
Expand All @@ -345,6 +352,7 @@ export class OpenSeaSDK {
salt?: BigNumberish;
expirationTime?: BigNumberish;
paymentTokenAddress?: string;
excludeOptionalCreatorFees?: boolean;
}): Promise<OrderV2> {
await this._requireAccountIsAvailable(accountAddress);

Expand All @@ -367,6 +375,7 @@ export class OpenSeaSDK {
collection,
paymentTokenAddress,
startAmount: basePrice,
excludeOptionalCreatorFees,
});

const { executeAllActions } = await this.seaport_v1_5.createOrder(
Expand Down Expand Up @@ -414,6 +423,7 @@ export class OpenSeaSDK {
* @param options.paymentTokenAddress ERC20 address for the payment token in the order. If unspecified, defaults to ETH
* @param options.buyerAddress Optional address that's allowed to purchase this item. If specified, no other address will be able to take the order, unless its value is the null address.
* @param options.englishAuction If true, the order will be listed as an English auction.
* @param options.excludeOptionalCreatorFees If true, optional creator fees will be excluded from the listing. Default: false.
* @returns The {@link OrderV2} that was created.
*
* @throws Error if the asset does not contain a token id.
Expand All @@ -434,6 +444,7 @@ export class OpenSeaSDK {
paymentTokenAddress = ethers.ZeroAddress,
buyerAddress,
englishAuction,
excludeOptionalCreatorFees = false,
}: {
asset: AssetWithTokenId;
accountAddress: string;
Expand All @@ -447,6 +458,7 @@ export class OpenSeaSDK {
paymentTokenAddress?: string;
buyerAddress?: string;
englishAuction?: boolean;
excludeOptionalCreatorFees?: boolean;
}): Promise<OrderV2> {
await this._requireAccountIsAvailable(accountAddress);

Expand Down Expand Up @@ -475,6 +487,7 @@ export class OpenSeaSDK {
paymentTokenAddress,
startAmount: basePrice,
endAmount: endPrice,
excludeOptionalCreatorFees,
});

if (buyerAddress) {
Expand Down Expand Up @@ -523,6 +536,7 @@ export class OpenSeaSDK {
* @param options.salt Arbitrary salt. If not passed in, a random salt will be generated with the first four bytes being the domain hash or empty.
* @param options.expirationTime Expiration time for the order, in UTC seconds.
* @param options.paymentTokenAddress ERC20 address for the payment token in the order. If unspecified, defaults to WETH.
* @param options.excludeOptionalCreatorFees If true, optional creator fees will be excluded from the offer. Default: false.
* @returns The {@link CollectionOffer} that was created.
*/
public async createCollectionOffer({
Expand All @@ -533,7 +547,8 @@ export class OpenSeaSDK {
domain,
salt,
expirationTime,
paymentTokenAddress,
paymentTokenAddress = getWETHAddress(this.chain),
excludeOptionalCreatorFees = false,
}: {
collectionSlug: string;
accountAddress: string;
Expand All @@ -543,6 +558,7 @@ export class OpenSeaSDK {
salt?: BigNumberish;
expirationTime?: number | string;
paymentTokenAddress: string;
excludeOptionalCreatorFees?: boolean;
}): Promise<CollectionOffer | null> {
await this._requireAccountIsAvailable(accountAddress);

Expand Down Expand Up @@ -571,6 +587,7 @@ export class OpenSeaSDK {
paymentTokenAddress,
startAmount: basePrice,
endAmount: basePrice,
excludeOptionalCreatorFees,
});

const considerationItems = [
Expand Down

0 comments on commit 4ce43c1

Please sign in to comment.