opensea-js
Version:
TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data
117 lines (116 loc) • 6.81 kB
TypeScript
import { ItemType } from "@opensea/seaport-js/lib/constants";
import { ethers } from "ethers";
import { Chain, Fee, OpenSeaAccount, OpenSeaCollection, OpenSeaPaymentToken, RarityStrategy, TokenStandard } from "../types";
export declare const collectionFromJSON: (collection: any) => OpenSeaCollection;
export declare const rarityFromJSON: (rarity: any) => RarityStrategy | null;
export declare const paymentTokenFromJSON: (token: any) => OpenSeaPaymentToken;
export declare const accountFromJSON: (account: any) => OpenSeaAccount;
export declare const feeFromJSON: (fee: any) => Fee;
/**
* Estimate gas usage for a transaction.
* @param provider The Provider
* @param from Address sending transaction
* @param to Destination contract address
* @param data Data to send to contract
* @param value Value in ETH to send with data
*/
export declare function estimateGas(provider: ethers.Provider, { from, to, data, value }: ethers.Transaction): Promise<bigint>;
/**
* The longest time that an order is valid for is one month from the current date
* @returns unix timestamp
*/
export declare const getMaxOrderExpirationTimestamp: () => number;
interface ErrorWithCode extends Error {
code: string;
}
export declare const hasErrorCode: (error: unknown) => error is ErrorWithCode;
export declare const getAssetItemType: (tokenStandard: TokenStandard) => ItemType.ERC20 | ItemType.ERC721 | ItemType.ERC1155;
export declare const getChainId: (chain: Chain) => "1" | "137" | "43114" | "42161" | "42170" | "238" | "8453" | "10" | "7777777" | "1329" | "8333" | "80094" | "747" | "33139" | "2020" | "2741" | "360" | "130" | "43419";
/** Returns the default currency for offers on the given chain. */
export declare const getOfferPaymentToken: (chain: Chain) => "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" | "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619" | "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7" | "0x82af49447d8a07e3bd95bd0d56f35241523fbab1" | "0x722e8bdd2ce80a4422e880164f2079488e115365" | "0x4300000000000000000000000000000000000004" | "0x4200000000000000000000000000000000000006" | "0x6969696969696969696969696969696969696969" | "0xe30fedd158a2e3b13e9badaeabafc5516e95e8c7" | "0xd3bf53dac106a0290b0483ecbc89d40fcc961f3e" | "0x48b62137edfa95a428d35c09e44256a739f6b557" | "0xe514d9deb7966c8be0ca922de8a064264ea6bcd4" | "0x3439153eb7af838ad19d56e1571fbd09333c2809" | "0x5aad7bba61d95c2c4e525a35f4062040264611f1";
/** Returns the default currency for listings on the given chain. */
export declare const getListingPaymentToken: (chain: Chain) => "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619" | "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7" | "0xd3bf53dac106a0290b0483ecbc89d40fcc961f3e" | "0xe514d9deb7966c8be0ca922de8a064264ea6bcd4" | "0x0000000000000000000000000000000000000000";
/** @deprecated Use getOfferPaymentToken instead. Backward compatibility alias. */
export declare const getWETHAddress: (chain: Chain) => "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" | "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619" | "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7" | "0x82af49447d8a07e3bd95bd0d56f35241523fbab1" | "0x722e8bdd2ce80a4422e880164f2079488e115365" | "0x4300000000000000000000000000000000000004" | "0x4200000000000000000000000000000000000006" | "0x6969696969696969696969696969696969696969" | "0xe30fedd158a2e3b13e9badaeabafc5516e95e8c7" | "0xd3bf53dac106a0290b0483ecbc89d40fcc961f3e" | "0x48b62137edfa95a428d35c09e44256a739f6b557" | "0xe514d9deb7966c8be0ca922de8a064264ea6bcd4" | "0x3439153eb7af838ad19d56e1571fbd09333c2809" | "0x5aad7bba61d95c2c4e525a35f4062040264611f1";
/**
* Checks if the token address is the shared storefront address and if so replaces
* that address with the lazy mint adapter address. Otherwise, returns the input token address
* @param tokenAddress token address
* @returns input token address or lazy mint adapter address
*/
export declare const getAddressAfterRemappingSharedStorefrontAddressToLazyMintAdapterAddress: (tokenAddress: string) => string;
/**
* Sums up the basis points for fees.
* @param fees The fees to sum up
* @returns sum of basis points
*/
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;
/**
* Returns if a protocol address is valid.
* @param protocolAddress The protocol address
*/
export declare const isValidProtocol: (protocolAddress: string) => boolean;
/**
* Throws an error if the protocol address is not valid.
* @param protocolAddress The protocol address
*/
export declare const requireValidProtocol: (protocolAddress: string) => void;
/**
* Get the default conduit key for a given chain.
* @param chain The chain to get the conduit key for
* @returns The conduit key for the chain
*/
export declare const getDefaultConduitKey: (chain: Chain) => string;
/**
* Get the Seaport 1.6 contract address for a given chain.
* @param chain The chain to get the Seaport address for
* @returns The Seaport 1.6 address for the chain
*/
export declare const getSeaportAddress: (chain: Chain) => string;
/**
* Get the signed zone address for a given chain.
* @param chain The chain to get the signed zone address for
* @returns The signed zone address for the chain
*/
export declare const getSignedZone: (chain: Chain) => string;
/**
* Get the fee recipient address for a given chain
* @param chain The blockchain chain
* @returns The fee recipient address for the chain
*/
export declare const getFeeRecipient: (chain: Chain) => string;
/**
* Decodes an encoded string of token IDs into an array of individual token IDs using bigint for precise calculations.
*
* The encoded token IDs can be in the following formats:
* 1. Single numbers: '123' => ['123']
* 2. Comma-separated numbers: '1,2,3,4' => ['1', '2', '3', '4']
* 3. Ranges of numbers: '5:8' => ['5', '6', '7', '8']
* 4. Combinations of single numbers and ranges: '1,3:5,8' => ['1', '3', '4', '5', '8']
* 5. Wildcard '*' (matches all token IDs): '*' => ['*']
*
* @param encodedTokenIds - The encoded string of token IDs to be decoded.
* @returns An array of individual token IDs after decoding the input.
*
* @throws {Error} If the input is not correctly formatted or if bigint operations fail.
*
* @example
* const encoded = '1,3:5,8';
* const decoded = decodeTokenIds(encoded); // Output: ['1', '3', '4', '5', '8']
*
* @example
* const encodedWildcard = '*';
* const decodedWildcard = decodeTokenIds(encodedWildcard); // Output: ['*']
*
* @example
* const emptyEncoded = '';
* const decodedEmpty = decodeTokenIds(emptyEncoded); // Output: []
*/
export declare const decodeTokenIds: (encodedTokenIds: string) => string[];
export {};