UNPKG

@cryptovoxels/marketplace-js

Version:

A simple JS sdk to interact with Voxels' marketplace

48 lines (47 loc) 2.21 kB
/// <reference types="node" /> import { ethers } from "ethers"; import { EventEmitter } from "events"; import { Marketplacev1 } from "./lib/contracts"; import { ListingStructOutput } from "./lib/contracts/Marketplacev1"; import { ListingId, ListingParams, Network, ProviderOrSigner } from "./lib/types"; export declare class VoxelsMarketplace extends EventEmitter { private providerOrSigner; private contractInstance; private network; private logger; private emitEvent; constructor(providerOrSigner: ProviderOrSigner, network?: Network, logger?: (args: string) => void); /** * handles the given provider or signer from constructor * @param providerOrSigner ethers Provider or Signer * @param network a network; see Network types; * @returns */ private handleProviderOrSigner; /** * Get a listing from the contract directly given a hash id and index * @param id a hash representing the listings list for given user+contract+tokenid * @param index index of the listing inside the listings[] array (default 0) * @returns */ getListing: (id: ListingId, index?: number) => Promise<ListingStructOutput | undefined>; /** * list an NFT given the parameters * @param params an object containing parameters about the listing: token_id, address,price,quantity,acceptedPayment * @returns */ createListing: (params: ListingParams) => Promise<ethers.providers.TransactionReceipt | undefined>; /** * Purchase an NFT listed given an id or its listing parameters. * @param id hash representing the id of the list of listings for the given user+contract+tokenId * @param index index of the listing inside the list of listings * @param quantityToPurchase Quantity of the NFT to purchase * @returns */ purchase: (id: ListingId, index?: number, quantityToPurchase?: number) => Promise<number | undefined>; private buyWithToken; private buyWithNativeToken; cancelListing: (id: ListingId, index?: number) => Promise<number | undefined>; connect(signer: ethers.Signer): this; get contract(): Marketplacev1; }