Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opensea-js

Package Overview
Dependencies
Maintainers
4
Versions
300
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opensea-js - npm Package Compare versions

Comparing version 7.0.5 to 7.0.6

33

lib/api/types.d.ts

@@ -171,3 +171,3 @@ import { ConsiderationItem } from "@opensea/seaport-js/lib/types";

export type NFT = {
/** NFT Identifier (also commonly referred to as Token Id) */
/** NFT Identifier (also commonly referred to as tokenId) */
identifier: string;

@@ -188,4 +188,2 @@ /** Slug identifier of collection */

metadata_url: string;
/** Date of NFT creation */
created_at: string;
/** Date of latest NFT update */

@@ -197,3 +195,32 @@ updated_at: string;

is_nsfw: boolean;
/** Traits for the NFT, returns null if the NFT has than 50 traits */
traits: Trait[] | null;
};
/**
* Trait type returned by OpenSea API.
* @category API Models
*/
export type Trait = {
/** The name of the trait category (e.g. 'Background') */
trait_type: string;
/** A field indicating how to display. None is used for string traits. */
display_type: TraitDisplayType;
/** Ceiling for possible numeric trait values */
max_value: string;
/** The value of the trait (e.g. 'Red') */
value: string | number | Date;
};
/**
* Trait display type returned by OpenSea API.
* @category API Models
*/
export declare enum TraitDisplayType {
NUMBER = "number",
BOOST_PERCENTAGE = "boost_percentage",
BOOST_NUMBER = "boost_number",
AUTHOR = "author",
DATE = "date",
/** "None" is used for string traits */
NONE = "None"
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TraitDisplayType = void 0;
/**
* Trait display type returned by OpenSea API.
* @category API Models
*/
var TraitDisplayType;
(function (TraitDisplayType) {
TraitDisplayType["NUMBER"] = "number";
TraitDisplayType["BOOST_PERCENTAGE"] = "boost_percentage";
TraitDisplayType["BOOST_NUMBER"] = "boost_number";
TraitDisplayType["AUTHOR"] = "author";
TraitDisplayType["DATE"] = "date";
/** "None" is used for string traits */
TraitDisplayType["NONE"] = "None";
})(TraitDisplayType || (exports.TraitDisplayType = TraitDisplayType = {}));
//# sourceMappingURL=types.js.map

4

lib/constants.d.ts

@@ -1,2 +0,4 @@

export declare const INVERSE_BASIS_POINT = 10000;
import { FixedNumber } from "ethers";
export declare const FIXED_NUMBER_100: FixedNumber;
export declare const INVERSE_BASIS_POINT = 10000n;
export declare const MAX_EXPIRATION_MONTHS = 1;

@@ -3,0 +5,0 @@ export declare const API_BASE_MAINNET = "https://api.opensea.io";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS = exports.SHARED_STOREFRONT_ADDRESSES = exports.ENGLISH_AUCTION_ZONE_TESTNETS = exports.ENGLISH_AUCTION_ZONE_MAINNETS = exports.DEFAULT_ZONE = exports.API_BASE_TESTNET = exports.API_BASE_MAINNET = exports.MAX_EXPIRATION_MONTHS = exports.INVERSE_BASIS_POINT = void 0;
exports.SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS = exports.SHARED_STOREFRONT_ADDRESSES = exports.ENGLISH_AUCTION_ZONE_TESTNETS = exports.ENGLISH_AUCTION_ZONE_MAINNETS = exports.DEFAULT_ZONE = exports.API_BASE_TESTNET = exports.API_BASE_MAINNET = exports.MAX_EXPIRATION_MONTHS = exports.INVERSE_BASIS_POINT = exports.FIXED_NUMBER_100 = void 0;
const ethers_1 = require("ethers");
exports.INVERSE_BASIS_POINT = 10000; // 100 basis points per 1%
exports.FIXED_NUMBER_100 = ethers_1.FixedNumber.fromValue(100);
exports.INVERSE_BASIS_POINT = 10000n; // 100 basis points per 1%
exports.MAX_EXPIRATION_MONTHS = 1;
exports.API_BASE_MAINNET = "https://api.opensea.io";
exports.API_BASE_TESTNET = "https://testnets-api.opensea.io";
exports.DEFAULT_ZONE = ethers_1.ethers.ZeroAddress;
exports.DEFAULT_ZONE = ethers_1.ZeroAddress;
exports.ENGLISH_AUCTION_ZONE_MAINNETS = "0x110b2b128a9ed1be5ef3232d8e4e41640df5c2cd";

@@ -11,0 +12,0 @@ exports.ENGLISH_AUCTION_ZONE_TESTNETS = "0x9B814233894Cd227f561B78Cc65891AA55C62Ad2";

@@ -254,2 +254,18 @@ import { Seaport } from "@opensea/seaport-js";

/**
* Transfer an asset. This asset can be an ERC20, ERC1155, or ERC721.
* @param options
* @param options.asset The Asset to transfer. tokenStandard must be set.
* @param options.amount Amount of asset to transfer. Not used for ERC721.
* @param options.fromAddress The address to transfer from
* @param options.toAddress The address to transfer to
* @param options.overrides Transaction overrides, ignored if not set.
*/
transfer({ asset, amount, fromAddress, toAddress, overrides, }: {
asset: AssetWithTokenStandard;
amount?: BigNumberish;
fromAddress: string;
toAddress: string;
overrides?: Overrides;
}): Promise<void>;
/**
* Instead of signing an off-chain order, this methods allows you to approve an order

@@ -256,0 +272,0 @@ * with on on-chain transaction.

@@ -33,4 +33,3 @@ "use strict";

this.getAmountWithBasisPointsApplied = (amount, basisPoints) => {
return ((amount * BigInt(basisPoints)) /
BigInt(constants_2.INVERSE_BASIS_POINT)).toString();
return ((amount * basisPoints) / constants_2.INVERSE_BASIS_POINT).toString();
};

@@ -109,3 +108,2 @@ // API config

const wethContract = new ethers_1.Contract((0, utils_2.getWETHAddress)(this.chain), ["function deposit() payable"], this._signerOrProvider);
wethContract.connect(this.provider);
try {

@@ -132,3 +130,2 @@ const transaction = await wethContract.deposit({ value });

const wethContract = new ethers_1.Contract((0, utils_2.getWETHAddress)(this.chain), ["function withdraw(uint wad) public"], this._signerOrProvider);
wethContract.connect(this.provider);
try {

@@ -145,3 +142,3 @@ const transaction = await wethContract.withdraw(amount);

const collectionFees = collection.fees;
const collectionFeesBasisPoints = (0, utils_2.feesToBasisPoints)(collectionFees);
const collectionFeesBasisPoints = (0, utils_2.totalBasisPointsForFees)(collectionFees);
const sellerBasisPoints = constants_2.INVERSE_BASIS_POINT - collectionFeesBasisPoints;

@@ -161,3 +158,3 @@ const getConsiderationItem = (basisPoints, recipient) => {

for (const fee of collectionFees) {
considerationItems.push(getConsiderationItem(fee.fee * 100, fee.recipient));
considerationItems.push(getConsiderationItem((0, utils_2.basisPointsForFee)(fee), fee.recipient));
}

@@ -529,11 +526,17 @@ return considerationItems;

case types_2.TokenStandard.ERC20: {
const contract = new ethers_1.ethers.Contract(asset.tokenAddress, contracts_1.ERC20__factory.createInterface(), this.provider);
const contract = contracts_1.ERC20__factory.connect(asset.tokenAddress, this.provider);
return await contract.balanceOf.staticCall(accountAddress);
}
case types_2.TokenStandard.ERC1155: {
const contract = new ethers_1.ethers.Contract(asset.tokenAddress, contracts_1.ERC1155__factory.createInterface(), this.provider);
if (asset.tokenId === undefined || asset.tokenId === null) {
throw new Error("Missing ERC1155 tokenId for getBalance");
}
const contract = contracts_1.ERC1155__factory.connect(asset.tokenAddress, this.provider);
return await contract.balanceOf.staticCall(accountAddress, asset.tokenId);
}
case types_2.TokenStandard.ERC721: {
const contract = new ethers_1.ethers.Contract(asset.tokenAddress, contracts_1.ERC721__factory.createInterface(), this.provider);
if (asset.tokenId === undefined || asset.tokenId === null) {
throw new Error("Missing ERC721 tokenId for getBalance");
}
const contract = contracts_1.ERC721__factory.connect(asset.tokenAddress, this.provider);
try {

@@ -554,2 +557,58 @@ const owner = await contract.ownerOf.staticCall(asset.tokenId);

/**
* Transfer an asset. This asset can be an ERC20, ERC1155, or ERC721.
* @param options
* @param options.asset The Asset to transfer. tokenStandard must be set.
* @param options.amount Amount of asset to transfer. Not used for ERC721.
* @param options.fromAddress The address to transfer from
* @param options.toAddress The address to transfer to
* @param options.overrides Transaction overrides, ignored if not set.
*/
async transfer({ asset, amount, fromAddress, toAddress, overrides, }) {
await this._requireAccountIsAvailable(fromAddress);
overrides = { ...overrides, from: fromAddress };
let transaction;
switch (asset.tokenStandard) {
case types_2.TokenStandard.ERC20: {
if (!amount) {
throw new Error("Missing ERC20 amount for transfer");
}
const contract = contracts_1.ERC20__factory.connect(asset.tokenAddress, this._signerOrProvider);
transaction = contract.transfer(toAddress, amount, overrides);
break;
}
case types_2.TokenStandard.ERC1155: {
if (asset.tokenId === undefined || asset.tokenId === null) {
throw new Error("Missing ERC1155 tokenId for transfer");
}
if (!amount) {
throw new Error("Missing ERC1155 amount for transfer");
}
const contract = contracts_1.ERC1155__factory.connect(asset.tokenAddress, this._signerOrProvider);
transaction = contract.safeTransferFrom(fromAddress, toAddress, asset.tokenId, amount, "", overrides);
break;
}
case types_2.TokenStandard.ERC721: {
if (asset.tokenId === undefined || asset.tokenId === null) {
throw new Error("Missing ERC721 tokenId for transfer");
}
const contract = contracts_1.ERC721__factory.connect(asset.tokenAddress, this._signerOrProvider);
transaction = contract.transferFrom(fromAddress, toAddress, asset.tokenId, overrides);
break;
}
default:
throw new Error("Unsupported token standard for transfer");
}
try {
const transactionResponse = await transaction;
await this._confirmTransaction(transactionResponse.hash, types_2.EventType.Transfer, "Transferring asset");
}
catch (error) {
console.error(error);
this._dispatch(types_2.EventType.TransactionDenied, {
error,
accountAddress: fromAddress,
});
}
}
/**
* Instead of signing an off-chain order, this methods allows you to approve an order

@@ -608,6 +667,6 @@ * with on on-chain transaction.

if (startAmount == null || startAmountWei < 0) {
throw new Error(`Starting price must be a number >= 0`);
throw new Error("Starting price must be a number >= 0");
}
if (isEther && orderSide === types_2.OrderSide.BID) {
throw new Error(`Offers must use wrapped ETH or an ERC-20 token.`);
throw new Error("Offers must use wrapped ETH or an ERC-20 token.");
}

@@ -614,0 +673,0 @@ if (priceDiffWei < 0) {

@@ -45,3 +45,7 @@ import { BigNumberish } from "ethers";

*/
ApproveOrder = "ApproveOrder"
ApproveOrder = "ApproveOrder",
/**
* Emitted when the {@link OpenSeaSDK.transfer} method is called.
*/
Transfer = "Transfer"
}

@@ -136,4 +140,4 @@ /**

SolanaDevnet = "soldev",
/** Zora Testnet */
ZoraTestnet = "zora_testnet"
/** Zora Sepolia */
ZoraSepolia = "zora_sepolia"
}

@@ -297,4 +301,8 @@ /**

rarity: RarityStrategy | null;
/** Tokens allowed for this collection */
/** Payment tokens allowed for orders for this collection */
paymentTokens: OpenSeaPaymentToken[];
/** The total supply of the collection (minted minus burned) */
totalSupply: number;
/** The created date of the collection */
createdDate: string;
}

@@ -301,0 +309,0 @@ /**

@@ -48,2 +48,6 @@ "use strict";

EventType["ApproveOrder"] = "ApproveOrder";
/**
* Emitted when the {@link OpenSeaSDK.transfer} method is called.
*/
EventType["Transfer"] = "Transfer";
})(EventType || (exports.EventType = EventType = {}));

@@ -101,4 +105,4 @@ /**

Chain["SolanaDevnet"] = "soldev";
/** Zora Testnet */
Chain["ZoraTestnet"] = "zora_testnet";
/** Zora Sepolia */
Chain["ZoraSepolia"] = "zora_sepolia";
})(Chain || (exports.Chain = Chain = {}));

@@ -105,0 +109,0 @@ /**

@@ -41,4 +41,10 @@ import { ItemType } from "@opensea/seaport-js/lib/constants";

*/
export declare const feesToBasisPoints: (fees: Fee[]) => number;
export declare const totalBasisPointsForFees: (fees: Fee[]) => bigint;
/**
* Converts a fee to its basis points representation.
* @param fee The fee to convert
* @returns the basis points
*/
export declare const basisPointsForFee: (fee: Fee) => bigint;
/**
* Checks whether the current chain is a test chain.

@@ -45,0 +51,0 @@ * @param chain Chain to check.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeTokenIds = exports.requireValidProtocol = exports.isValidProtocol = exports.isTestChain = exports.feesToBasisPoints = exports.getAddressAfterRemappingSharedStorefrontAddressToLazyMintAdapterAddress = exports.getWETHAddress = exports.getAssetItemType = exports.hasErrorCode = exports.getMaxOrderExpirationTimestamp = exports.estimateGas = exports.feeFromJSON = exports.accountFromJSON = exports.paymentTokenFromJSON = exports.rarityFromJSON = exports.collectionFromJSON = void 0;
exports.decodeTokenIds = exports.requireValidProtocol = exports.isValidProtocol = exports.isTestChain = exports.basisPointsForFee = exports.totalBasisPointsForFees = exports.getAddressAfterRemappingSharedStorefrontAddressToLazyMintAdapterAddress = exports.getWETHAddress = exports.getAssetItemType = exports.hasErrorCode = exports.getMaxOrderExpirationTimestamp = exports.estimateGas = exports.feeFromJSON = exports.accountFromJSON = exports.paymentTokenFromJSON = exports.rarityFromJSON = exports.collectionFromJSON = void 0;
const constants_1 = require("@opensea/seaport-js/lib/constants");

@@ -38,2 +38,4 @@ const ethers_1 = require("ethers");

paymentTokens: (collection.payment_tokens ?? []).map(exports.paymentTokenFromJSON),
totalSupply: collection.total_supply,
createdDate: collection.created_date,
};

@@ -177,3 +179,3 @@ };

case types_1.Chain.Zora:
case types_1.Chain.ZoraTestnet:
case types_1.Chain.ZoraSepolia:
return "0x4200000000000000000000000000000000000006";

@@ -202,8 +204,21 @@ default:

*/
const feesToBasisPoints = (fees) => {
const feeBasisPoints = fees.map((fee) => fee.fee * 100);
return feeBasisPoints.reduce((sum, basisPoints) => basisPoints + sum, 0);
const totalBasisPointsForFees = (fees) => {
const feeBasisPoints = fees.map((fee) => (0, exports.basisPointsForFee)(fee));
const totalBasisPoints = feeBasisPoints.reduce((sum, basisPoints) => basisPoints + sum, 0n);
return totalBasisPoints;
};
exports.feesToBasisPoints = feesToBasisPoints;
exports.totalBasisPointsForFees = totalBasisPointsForFees;
/**
* Converts a fee to its basis points representation.
* @param fee The fee to convert
* @returns the basis points
*/
const basisPointsForFee = (fee) => {
return BigInt(ethers_1.FixedNumber.fromString(fee.fee.toString())
.mul(constants_2.FIXED_NUMBER_100)
.toFormat(0) // format to 0 decimal places to convert to bigint
.toString());
};
exports.basisPointsForFee = basisPointsForFee;
/**
* Checks whether the current chain is a test chain.

@@ -225,3 +240,3 @@ * @param chain Chain to check.

case types_1.Chain.SolanaDevnet:
case types_1.Chain.ZoraTestnet:
case types_1.Chain.ZoraSepolia:
return true;

@@ -228,0 +243,0 @@ default:

{
"name": "opensea-js",
"version": "7.0.5",
"version": "7.0.6",
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -198,3 +198,3 @@ import { ConsiderationItem } from "@opensea/seaport-js/lib/types";

export type NFT = {
/** NFT Identifier (also commonly referred to as Token Id) */
/** NFT Identifier (also commonly referred to as tokenId) */
identifier: string;

@@ -215,4 +215,2 @@ /** Slug identifier of collection */

metadata_url: string;
/** Date of NFT creation */
created_at: string;
/** Date of latest NFT update */

@@ -224,2 +222,33 @@ updated_at: string;

is_nsfw: boolean;
/** Traits for the NFT, returns null if the NFT has than 50 traits */
traits: Trait[] | null;
};
/**
* Trait type returned by OpenSea API.
* @category API Models
*/
export type Trait = {
/** The name of the trait category (e.g. 'Background') */
trait_type: string;
/** A field indicating how to display. None is used for string traits. */
display_type: TraitDisplayType;
/** Ceiling for possible numeric trait values */
max_value: string;
/** The value of the trait (e.g. 'Red') */
value: string | number | Date;
};
/**
* Trait display type returned by OpenSea API.
* @category API Models
*/
export enum TraitDisplayType {
NUMBER = "number",
BOOST_PERCENTAGE = "boost_percentage",
BOOST_NUMBER = "boost_number",
AUTHOR = "author",
DATE = "date",
/** "None" is used for string traits */
NONE = "None",
}

@@ -1,4 +0,5 @@

import { ethers } from "ethers";
import { FixedNumber, ZeroAddress } from "ethers";
export const INVERSE_BASIS_POINT = 10_000; // 100 basis points per 1%
export const FIXED_NUMBER_100 = FixedNumber.fromValue(100);
export const INVERSE_BASIS_POINT = 10_000n; // 100 basis points per 1%
export const MAX_EXPIRATION_MONTHS = 1;

@@ -9,3 +10,3 @@

export const DEFAULT_ZONE = ethers.ZeroAddress;
export const DEFAULT_ZONE = ZeroAddress;
export const ENGLISH_AUCTION_ZONE_MAINNETS =

@@ -12,0 +13,0 @@ "0x110b2b128a9ed1be5ef3232d8e4e41640df5c2cd";

@@ -19,2 +19,3 @@ import EventEmitter = require("events");

JsonRpcProvider,
ContractTransactionResponse,
} from "ethers";

@@ -57,6 +58,7 @@ import { OpenSeaAPI } from "./api/api";

getAddressAfterRemappingSharedStorefrontAddressToLazyMintAdapterAddress,
feesToBasisPoints,
requireValidProtocol,
getWETHAddress,
isTestChain,
basisPointsForFee,
totalBasisPointsForFees,
} from "./utils/utils";

@@ -194,3 +196,2 @@

wethContract.connect(this.provider);
try {

@@ -235,3 +236,2 @@ const transaction = await wethContract.deposit({ value });

wethContract.connect(this.provider);
try {

@@ -252,8 +252,5 @@ const transaction = await wethContract.withdraw(amount);

amount: bigint,
basisPoints: number,
basisPoints: bigint,
): string => {
return (
(amount * BigInt(basisPoints)) /
BigInt(INVERSE_BASIS_POINT)
).toString();
return ((amount * basisPoints) / INVERSE_BASIS_POINT).toString();
};

@@ -275,6 +272,6 @@

const collectionFees = collection.fees;
const collectionFeesBasisPoints = feesToBasisPoints(collectionFees);
const collectionFeesBasisPoints = totalBasisPointsForFees(collectionFees);
const sellerBasisPoints = INVERSE_BASIS_POINT - collectionFeesBasisPoints;
const getConsiderationItem = (basisPoints: number, recipient?: string) => {
const getConsiderationItem = (basisPoints: bigint, recipient?: string) => {
return {

@@ -298,3 +295,3 @@ token: paymentTokenAddress,

considerationItems.push(
getConsiderationItem(fee.fee * 100, fee.recipient),
getConsiderationItem(basisPointsForFee(fee), fee.recipient),
);

@@ -907,5 +904,4 @@ }

case TokenStandard.ERC20: {
const contract = new ethers.Contract(
const contract = ERC20__factory.connect(
asset.tokenAddress,
ERC20__factory.createInterface(),
this.provider,

@@ -916,5 +912,7 @@ );

case TokenStandard.ERC1155: {
const contract = new ethers.Contract(
if (asset.tokenId === undefined || asset.tokenId === null) {
throw new Error("Missing ERC1155 tokenId for getBalance");
}
const contract = ERC1155__factory.connect(
asset.tokenAddress,
ERC1155__factory.createInterface(),
this.provider,

@@ -928,5 +926,7 @@ );

case TokenStandard.ERC721: {
const contract = new ethers.Contract(
if (asset.tokenId === undefined || asset.tokenId === null) {
throw new Error("Missing ERC721 tokenId for getBalance");
}
const contract = ERC721__factory.connect(
asset.tokenAddress,
ERC721__factory.createInterface(),
this.provider,

@@ -951,2 +951,97 @@ );

/**
* Transfer an asset. This asset can be an ERC20, ERC1155, or ERC721.
* @param options
* @param options.asset The Asset to transfer. tokenStandard must be set.
* @param options.amount Amount of asset to transfer. Not used for ERC721.
* @param options.fromAddress The address to transfer from
* @param options.toAddress The address to transfer to
* @param options.overrides Transaction overrides, ignored if not set.
*/
public async transfer({
asset,
amount,
fromAddress,
toAddress,
overrides,
}: {
asset: AssetWithTokenStandard;
amount?: BigNumberish;
fromAddress: string;
toAddress: string;
overrides?: Overrides;
}): Promise<void> {
await this._requireAccountIsAvailable(fromAddress);
overrides = { ...overrides, from: fromAddress };
let transaction: Promise<ContractTransactionResponse>;
switch (asset.tokenStandard) {
case TokenStandard.ERC20: {
if (!amount) {
throw new Error("Missing ERC20 amount for transfer");
}
const contract = ERC20__factory.connect(
asset.tokenAddress,
this._signerOrProvider,
);
transaction = contract.transfer(toAddress, amount, overrides);
break;
}
case TokenStandard.ERC1155: {
if (asset.tokenId === undefined || asset.tokenId === null) {
throw new Error("Missing ERC1155 tokenId for transfer");
}
if (!amount) {
throw new Error("Missing ERC1155 amount for transfer");
}
const contract = ERC1155__factory.connect(
asset.tokenAddress,
this._signerOrProvider,
);
transaction = contract.safeTransferFrom(
fromAddress,
toAddress,
asset.tokenId,
amount,
"",
overrides,
);
break;
}
case TokenStandard.ERC721: {
if (asset.tokenId === undefined || asset.tokenId === null) {
throw new Error("Missing ERC721 tokenId for transfer");
}
const contract = ERC721__factory.connect(
asset.tokenAddress,
this._signerOrProvider,
);
transaction = contract.transferFrom(
fromAddress,
toAddress,
asset.tokenId,
overrides,
);
break;
}
default:
throw new Error("Unsupported token standard for transfer");
}
try {
const transactionResponse = await transaction;
await this._confirmTransaction(
transactionResponse.hash,
EventType.Transfer,
"Transferring asset",
);
} catch (error) {
console.error(error);
this._dispatch(EventType.TransactionDenied, {
error,
accountAddress: fromAddress,
});
}
}
/**
* Instead of signing an off-chain order, this methods allows you to approve an order

@@ -1023,6 +1118,6 @@ * with on on-chain transaction.

if (startAmount == null || startAmountWei < 0) {
throw new Error(`Starting price must be a number >= 0`);
throw new Error("Starting price must be a number >= 0");
}
if (isEther && orderSide === OrderSide.BID) {
throw new Error(`Offers must use wrapped ETH or an ERC-20 token.`);
throw new Error("Offers must use wrapped ETH or an ERC-20 token.");
}

@@ -1029,0 +1124,0 @@ if (priceDiffWei < 0) {

@@ -47,2 +47,6 @@ import { BigNumberish } from "ethers";

ApproveOrder = "ApproveOrder",
/**
* Emitted when the {@link OpenSeaSDK.transfer} method is called.
*/
Transfer = "Transfer",
}

@@ -144,4 +148,4 @@

SolanaDevnet = "soldev",
/** Zora Testnet */
ZoraTestnet = "zora_testnet",
/** Zora Sepolia */
ZoraSepolia = "zora_sepolia",
}

@@ -313,4 +317,8 @@

rarity: RarityStrategy | null;
/** Tokens allowed for this collection */
/** Payment tokens allowed for orders for this collection */
paymentTokens: OpenSeaPaymentToken[];
/** The total supply of the collection (minted minus burned) */
totalSupply: number;
/** The created date of the collection */
createdDate: string;
}

@@ -317,0 +325,0 @@

@@ -5,3 +5,3 @@ import {

} from "@opensea/seaport-js/lib/constants";
import { ethers } from "ethers";
import { ethers, FixedNumber } from "ethers";
import {

@@ -11,2 +11,3 @@ MAX_EXPIRATION_MONTHS,

SHARED_STOREFRONT_ADDRESSES,
FIXED_NUMBER_100,
} from "../constants";

@@ -53,2 +54,4 @@ import {

paymentTokens: (collection.payment_tokens ?? []).map(paymentTokenFromJSON),
totalSupply: collection.total_supply,
createdDate: collection.created_date,
};

@@ -205,3 +208,3 @@ };

case Chain.Zora:
case Chain.ZoraTestnet:
case Chain.ZoraSepolia:
return "0x4200000000000000000000000000000000000006";

@@ -231,8 +234,26 @@ default:

*/
export const feesToBasisPoints = (fees: Fee[]): number => {
const feeBasisPoints = fees.map((fee) => fee.fee * 100);
return feeBasisPoints.reduce((sum, basisPoints) => basisPoints + sum, 0);
export const totalBasisPointsForFees = (fees: Fee[]): bigint => {
const feeBasisPoints = fees.map((fee) => basisPointsForFee(fee));
const totalBasisPoints = feeBasisPoints.reduce(
(sum, basisPoints) => basisPoints + sum,
0n,
);
return totalBasisPoints;
};
/**
* Converts a fee to its basis points representation.
* @param fee The fee to convert
* @returns the basis points
*/
export const basisPointsForFee = (fee: Fee): bigint => {
return BigInt(
FixedNumber.fromString(fee.fee.toString())
.mul(FIXED_NUMBER_100)
.toFormat(0) // format to 0 decimal places to convert to bigint
.toString(),
);
};
/**
* Checks whether the current chain is a test chain.

@@ -254,3 +275,3 @@ * @param chain Chain to check.

case Chain.SolanaDevnet:
case Chain.ZoraTestnet:
case Chain.ZoraSepolia:
return true;

@@ -257,0 +278,0 @@ default:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc