UNPKG

opensea-js

Version:

TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data

242 lines 9.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNativeWrapTokenAddress = exports.getFeeRecipient = exports.getSignedZone = exports.getSeaportAddress = exports.getDefaultConduit = exports.getListingPaymentToken = exports.getOfferPaymentToken = exports.getChainId = void 0; const constants_1 = require("@opensea/seaport-js/lib/constants"); const constants_2 = require("../constants"); const types_1 = require("../types"); /** * Gets the chain ID for a given chain. * @param chain The chain to get the ID for * @returns The chain ID as a string */ const getChainId = (chain) => { switch (chain) { case types_1.Chain.Mainnet: return "1"; case types_1.Chain.Polygon: return "137"; case types_1.Chain.Avalanche: return "43114"; case types_1.Chain.Arbitrum: return "42161"; case types_1.Chain.Blast: return "238"; case types_1.Chain.Base: return "8453"; case types_1.Chain.Optimism: return "10"; case types_1.Chain.Zora: return "7777777"; case types_1.Chain.Sei: return "1329"; case types_1.Chain.B3: return "8333"; case types_1.Chain.BeraChain: return "80094"; case types_1.Chain.Flow: return "747"; case types_1.Chain.ApeChain: return "33139"; case types_1.Chain.Ronin: return "2020"; case types_1.Chain.Abstract: return "2741"; case types_1.Chain.Shape: return "360"; case types_1.Chain.Unichain: return "130"; case types_1.Chain.Gunzilla: return "43419"; case types_1.Chain.HyperEVM: return "999"; case types_1.Chain.Somnia: return "5031"; case types_1.Chain.Monad: return "143"; default: throw new Error(`Unknown chainId for ${chain}`); } }; exports.getChainId = getChainId; /** * Returns the default currency for offers on the given chain. * @param chain The chain to get the offer payment token for * @returns The token address for offers */ const getOfferPaymentToken = (chain) => { switch (chain) { case types_1.Chain.Mainnet: return "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"; // WETH case types_1.Chain.Polygon: return "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619"; // WETH case types_1.Chain.Avalanche: return "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7"; // WAVAX case types_1.Chain.Arbitrum: return "0x82af49447d8a07e3bd95bd0d56f35241523fbab1"; // WETH case types_1.Chain.Blast: return "0x4300000000000000000000000000000000000004"; // WETH // OP Chains have WETH at the same address case types_1.Chain.Base: case types_1.Chain.Optimism: case types_1.Chain.Zora: case types_1.Chain.B3: case types_1.Chain.Shape: case types_1.Chain.Unichain: return "0x4200000000000000000000000000000000000006"; // WETH case types_1.Chain.BeraChain: return "0x6969696969696969696969696969696969696969"; // WBERA case types_1.Chain.Sei: return "0xe30fedd158a2e3b13e9badaeabafc5516e95e8c7"; // WSEI case types_1.Chain.Flow: return "0xd3bf53dac106a0290b0483ecbc89d40fcc961f3e"; // WFLOW case types_1.Chain.ApeChain: return "0x48b62137edfa95a428d35c09e44256a739f6b557"; // WAPE case types_1.Chain.Ronin: return "0xe514d9deb7966c8be0ca922de8a064264ea6bcd4"; // WRON case types_1.Chain.Abstract: return "0x3439153eb7af838ad19d56e1571fbd09333c2809"; // WETH case types_1.Chain.Gunzilla: return "0x5aad7bba61d95c2c4e525a35f4062040264611f1"; // WGUN case types_1.Chain.HyperEVM: return "0x5555555555555555555555555555555555555555"; // WHYPE case types_1.Chain.Somnia: return "0x046ede9564a72571df6f5e44d0405360c0f4dcab"; // WSOMI case types_1.Chain.Monad: return "0x3bd359c1119da7da1d913d1c4d2b7c461115433a"; // WMON default: throw new Error(`Unknown offer currency for ${chain}`); } }; exports.getOfferPaymentToken = getOfferPaymentToken; /** * Returns the default currency for listings on the given chain. * @param chain The chain to get the listing payment token for * @returns The token address for listings */ const getListingPaymentToken = (chain) => { switch (chain) { case types_1.Chain.Mainnet: case types_1.Chain.Somnia: case types_1.Chain.HyperEVM: case types_1.Chain.Arbitrum: case types_1.Chain.Blast: case types_1.Chain.Base: case types_1.Chain.Optimism: case types_1.Chain.Zora: case types_1.Chain.B3: case types_1.Chain.Abstract: case types_1.Chain.Shape: case types_1.Chain.Unichain: case types_1.Chain.Monad: return "0x0000000000000000000000000000000000000000"; // ETH case types_1.Chain.Polygon: return "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619"; // WETH case types_1.Chain.Avalanche: return "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7"; // WETH case types_1.Chain.BeraChain: return "0x0000000000000000000000000000000000000000"; // BERA case types_1.Chain.Sei: return "0x0000000000000000000000000000000000000000"; // SEI case types_1.Chain.Flow: return "0xd3bf53dac106a0290b0483ecbc89d40fcc961f3e"; // WETH case types_1.Chain.ApeChain: return "0x0000000000000000000000000000000000000000"; // APE case types_1.Chain.Ronin: return "0xe514d9deb7966c8be0ca922de8a064264ea6bcd4"; // WETH case types_1.Chain.Gunzilla: return "0x0000000000000000000000000000000000000000"; // GUN default: throw new Error(`Unknown listing currency for ${chain}`); } }; exports.getListingPaymentToken = getListingPaymentToken; /** * Get the default conduit key and address for a given chain. * @param chain The chain to get the conduit for * @returns The conduit key and address for the chain */ const getDefaultConduit = (chain) => { switch (chain) { case types_1.Chain.Abstract: case types_1.Chain.HyperEVM: case types_1.Chain.Monad: return { key: constants_2.OPENSEA_CONDUIT_KEY_2, address: constants_2.OPENSEA_CONDUIT_ADDRESS_2, }; case types_1.Chain.Gunzilla: case types_1.Chain.Somnia: return { key: constants_2.GUNZILLA_CONDUIT_KEY, address: constants_2.GUNZILLA_CONDUIT_ADDRESS, }; default: return { key: constants_2.OPENSEA_CONDUIT_KEY, address: constants_2.OPENSEA_CONDUIT_ADDRESS, }; } }; exports.getDefaultConduit = getDefaultConduit; /** * 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 */ const getSeaportAddress = (chain) => { switch (chain) { case types_1.Chain.Gunzilla: case types_1.Chain.Somnia: return constants_2.GUNZILLA_SEAPORT_1_6_ADDRESS; default: return constants_1.CROSS_CHAIN_SEAPORT_V1_6_ADDRESS; } }; exports.getSeaportAddress = getSeaportAddress; /** * 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 */ const getSignedZone = (chain) => { switch (chain) { case types_1.Chain.Gunzilla: case types_1.Chain.Somnia: return constants_2.GUNZILLA_SIGNED_ZONE_V2_ADDRESS; default: return constants_2.SIGNED_ZONE; } }; exports.getSignedZone = getSignedZone; /** * Get the fee recipient address for a given chain * @param chain The blockchain chain * @returns The fee recipient address for the chain */ const getFeeRecipient = (chain) => { switch (chain) { case types_1.Chain.Gunzilla: return constants_2.GUNZILLA_FEE_RECIPIENT; case types_1.Chain.Somnia: return constants_2.SOMNIA_FEE_RECIPIENT; default: return constants_2.OPENSEA_FEE_RECIPIENT; } }; exports.getFeeRecipient = getFeeRecipient; /** * Get the appropriate token address for wrap/unwrap operations. * For Polygon, use WPOL. For other chains, use the wrapped native asset. * @param chain The chain to get the token address for * @returns The token address for wrap/unwrap operations */ const getNativeWrapTokenAddress = (chain) => { switch (chain) { case types_1.Chain.Polygon: return constants_2.WPOL_ADDRESS; default: return (0, exports.getOfferPaymentToken)(chain); } }; exports.getNativeWrapTokenAddress = getNativeWrapTokenAddress; //# sourceMappingURL=chain.js.map