hyperspace-sdk
Version:
An unofficial SDK for Hyperspace NFT Marketplace on Avalanche
103 lines (102 loc) • 4.88 kB
TypeScript
import { Wallet } from "ethers";
import { JsonRpcBatchProvider } from "@ethersproject/providers";
import { Result, Listing, CollectionBid, Buy, Sale, Order, Nft, OrderConfig, ProjectStats } from "./types";
import { PaginationConfig } from "./types";
export declare class Hyperspace {
apiKey: string;
wallet: Wallet;
provider: JsonRpcBatchProvider;
gasPriceMultiplier: number;
gasLimitMultiplier: number;
constructor(apiKey: string, rpcHttpUrl: string, privateKey: string);
getGasPriceMultiplier(): number;
updateGasPriceMultiplier(newGasPriceMultiplier: number): Result<number, Error>;
getGasLimitMultiplier(): number;
updateGasLimitMultiplier(newGasLimitMultiplier: number): Result<number, Error>;
getListingsForProject(projectId?: string, paginationInfo?: PaginationConfig): Promise<Result<Listing[], Error>>;
/**
* Fetch listings for a specific collection.
* Right now, it ONLY fetches in ASCENDING order of price.
* @param projectId Project ID of the collection to fetch listings for.
* @param quantity Maximum number of listings to fetch.
* @returns Array of listings or error.
*/
getListingsForUser(userAddress?: string, projectId?: string, paginationInfo?: PaginationConfig): Promise<Result<Listing[], Error>>;
/**
* Get a specific listing.
* @param collectionAddress Address of the collection to fetch listing for.
* @param tokenId Token ID of the listing to fetch.
* @returns Listing or error.
*/
getListing(collectionAddress: string, tokenId: string): Promise<Result<Listing, Error>>;
/**
* Fetch collection bids for a specific collection.
* Right now, it ONLY outputs collection bids in DESCENDING order of price.
* @param collectionAddress
* @returns Array of collection bids or error.
*/
getCollectionBidsForProject(collectionAddress: string): Promise<Result<CollectionBid[], Error>>;
getCollectionBidsForProjectAndUser(collectionAddress: string, userAddress?: string): Promise<Result<CollectionBid[], Error>>;
getTokenRarityScore(collectionAddress: string, tokenId: string): Promise<Result<number, Error>>;
/**
* List a specific NFT (executes on chain).
* @param collectionAddress
* @param tokenId
* @param listingPriceAvax
* @returns Order or error.
*/
list(collectionAddress: string, tokenId: string, listingPriceWei: number): Promise<Result<Order, Error>>;
/**
* Delist a specific NFT (executes on chain).
* @param listing
* @returns Transaction hash or error.
*/
delist(collectionAddress: string, price: number, metadata: any): Promise<Result<string, Error>>;
/**
* Creates a collection bid (), executes on chain
* @param contractAddress
* @param bidAmount
* @returns
*/
collectionBid(contractAddress: string, bidAmountWei: number): Promise<Result<Order, Error>>;
/**
* Cancel a collection bid (executes on-chain).
* @param collection_bid
* @returns Transaction hash or error.
*/
cancelCollectionBid(collectionBid: CollectionBid): Promise<Result<string, Error>>;
updateCollectionBid(): Promise<void>;
/**
* Buy (create buy transaction) a specific NFT on-chain.
* @param collectionAddress
* @param tokenId
* @returns Transaction hash or error.
*/
buy(collectionAddress: string, tokenId: string): Promise<Result<Buy, Error>>;
/**
* Sell (create accept collection bid transaction) a specific NFT on-chain.
* By default, it will accept the highest bid for the NFT.
* If you want to accept a specific bid, pass the bid amount as a parameter.
* @param collectionAddress
* @param tokenId
* @returns Transaction hash, price, and fee or error.
*/
executeSell(collectionAddress: string, tokenId: string): Promise<Result<Sale, Error>>;
userBids(contractAddress?: string, tokenId?: string): Promise<{
digest: null;
errors: any;
} | undefined>;
userListings(): Promise<{
digest: null;
errors: any;
} | undefined>;
validateSignature(signedOrder: any): Promise<import("axios").AxiosResponse<any, any>>;
/**
* Get all NFTs owned by a specific user.
* If no user address is provided, it will fetch NFTs owned by this client's wallet address.
*/
getUserOwnedNfts(userAddress?: string, projectId?: string, pagination?: PaginationConfig): Promise<Result<Nft[], Error>>;
getCollectionStats(projectId?: string, orderBy?: OrderConfig[], pagination?: PaginationConfig): Promise<Result<ProjectStats[], Error>>;
getCollectionActivity(collection: string, actionTypes?: string[], pagination?: PaginationConfig): Promise<any>;
getUserActivity(walletAddress: string, actionTypes?: string[], pagination?: PaginationConfig): Promise<any>;
}