@crypto-dev/pasar-sdk-development
Version:
PasarProtocol NFT Marketplace SDK
233 lines (232 loc) • 11.4 kB
TypeScript
import { Category } from "./collection/category";
import { RoyaltyRate } from "./collection/RoyaltyRate";
import { AppContext } from './appcontext';
import { SocialLinks } from './sociallinks';
/**
* This class represent the Profile of current signed-in user.
*/
export declare class MyProfile {
private appContext;
private contractHelper;
private ipfsUrl;
private name;
private userDid;
private description;
private avatar;
private walletAddress;
constructor(appContext: AppContext, userDid: string, walletAddress: string, name: string, description: string, avatar: string);
updateName(name: string): MyProfile;
updateDescription(description: string): MyProfile;
updateAvatar(avatar: string): MyProfile;
getUserDid(): string;
getWalletAddress(): string;
getName(): string;
getDescription(): string;
/**
* Generate a metadata json file of the NFT collection that is about to be registered.
*
* @param category The category of NFT collection
* @param description The brief description of NFT collection
* @param avatarPath The avatar image path
* @param bannerPath The background image path
* @param socialLinks The social media related to this NFT collection
* @returns The URI to this collection metadata json file on IPFS storage.
*/
createCollectionURI(category: Category, description: string, avatarPath: string, bannerPath: string, socialLinks: SocialLinks): Promise<string>;
/**
* Create a NFT collection contract and deploy it on specific EVM blockchain.
* Currently only ERC721 standard is supported.
*
* @param name The name of NFT collection
* @param symbol The symbol of NFT collection
* @returns The deployed NFT collection contract address.
*/
createCollection(name: string, symbol: string): Promise<string>;
/**
* Register an specific NFT collection onto Pasar marketplace.
* Once the collection is registered to Pasar marketplace, the NFTs in this collection can
* be listed onto market for trading.
*
* @param collection The NFT collection contract address
* @param collectionURI The uri of the NFT collection referring to the metadata json file on
* IPFS storage
* @param royalties The roraylty rates for this NFT collection
* @returns The result of whether this NFT collection contract is registered ont Pasar or not
*/
registerCollection(collection: string, name: string, collectionURI: string, royalties: RoyaltyRate[]): Promise<void>;
/**
* Update collection URI or name for the NFT collection
* Notice: the current wallet address should be the owner of this NFT collection.
* @param collection The NFT collection contract address
* @param name The new name of NFT collection
* @param collectionURI The new uri of NFT collection to metadata json file on IPFS storage
* @returns The result of whether the NFT collection is updated or not.
*/
updateCollectionUri(collection: string, name: string, collectionURI: string): Promise<void>;
/**
* Update royalties for the NFT collection
* @param collection The NFT collection contract address
* @param royaltyRates The roraylty rates for this NFT collection
* @result
*/
updateCollectionRoyalty(collection: string, royaltyRates: RoyaltyRate[]): Promise<void>;
/**
* Generate an metadata json file of the NFT that is about to be minted
*
* @param itemName The name of NFT item to be minted
* @param itemDescription The brief description of an NFT item
* @param itemImage The actual image of an NFT item
* @param properties properties of nft
* @param sensitive Indicator whether the NFT item contains sensitive content or not
* @returns the tokenId and uri information
*/
createTokenURI(itemName: string, itemDescription: string, itemImage: any, properties?: any, // TODO: Must be json
sensitive?: boolean): Promise<any>;
/**
* Mint an NFT item from a specific collection contract with single quantity, in
* this function, the tokenId of this NFT item would be generated by SHA25 agorithm
* on tokenURI string of metadata json file on IPFS sotrage.
* Notice: This function should be used for minting NFTs from dedicated collection.
*
* @param collection The collection contract where NFT items would be minted
* @param tokenId the id of new nft
* @param tokenURI The token uri to this new NFT item
* @returns
*/
createItem(collection: string, tokenId: string, tokenURI: string): Promise<void>;
/**
* Mint an NFT item from a specific collection contract with single quantity, in
* this function, the tokenId of this NFT item would be generated by SHA25 agorithm
* on tokenURI string of metadata json file on IPFS sotrage.
* Notice: This function should be used for minting NFTs from public collection.
*
* @param tokenId the id of new nft
* @param tokenURI The token uri to this new NFT item
* @param roylatyFee The royalty fee to the new NFT item
* @returns
*/
createItemFromFeeds(tokenId: string, tokenURI: string, roylatyFee: number): Promise<void>;
/**
* Mint a nft on Pasar collection
*
* @param tokenId the id of new nft
* @param tokenURI The token uri to this new NFT item
* @param roylatyFee The royalty fee to the new NFT item
* @returns
*/
createItemFromPasar(tokenId: string, tokenURI: string, roylatyFee: number): Promise<void>;
/**
* Transfer NFT item to another address.
*
* @param collection the collection of this NFT item
* @param tokenId The tokenId of NFT item
* @param toAddr the target wallet address to recieve the NFT item
* @returns
*/
transferItem(collection: string, tokenId: string, toAddr: string): Promise<void>;
transferItemInFeeds(tokenId: string, toAddr: string): Promise<void>;
transferItemInPasar(tokenId: string, toAddr: string): Promise<void>;
/**
* Delete exiting NFT item.
* Notice: the NFT item should be unlisted from marketplace first before deleting
* the item.
*
* @param collection The collection contract where NFT items would be burned
* @param tokenId The tokenId of NFT item to be burned
* @returns The result of whether the NFT is deleted or not.
*/
deleteItem(collection: string, tokenId: string): Promise<void>;
deleteItemFromFeeds(tokenId: string): Promise<void>;
deleteItemInPasar(tokenId: string): Promise<void>;
/**
* Create a metadata json file for trading either buyer or seller.
*
* @eturns The uri of metadata json file pushed onto IPFS storage.
*/
createUserURI(): Promise<string>;
/**
* List an specific NFT item onto marketplace for rading with fixed price.
*
* @param collection The collection of this NFT item
* @param tokenId The tokenId of NFT item
* @param pricingToken The token address of pricing token
* @param price The price value to sell
* @param sellerURI:
*/
listItem(collection: string, tokenId: string, pricingToken: string, price: number, sellerURI: string): Promise<void>;
private listItem1155;
listItemFromFeeds(tokenId: string, pricingToken: string, price: number, sellerURI: string): Promise<void>;
listItemFromPasar(tokenId: string, pricingToken: string, price: number, sellerURI: string): Promise<void>;
/**
* Change the listed price for NFT item on marketplace
* This function would be used to change the price of listed item with fixed price.
*
* @param orderId The orderId of NFT item on maketplace
* @param newPricingToken The token address of new pricing token
* @param newPrice The new listed price
* @returns The result of bidding action.
*/
changePrice(orderId: string, newPricingToken: string, newPrice: number): Promise<void>;
/**
* Buy an item listed on marketplace
* This function is used to buy the item with fixed price.
*
* @param orderId The orderId of NFT item on maketplace
* @returns The orderId of buying the order
*/
buyItem(orderId: string, buyingPrice: number, buyingToken: string, buyerURI: string): Promise<void>;
/**
* List an specific NFT item onto marketplace for rading on auction.
*
* @param collection The collection of this NFT item
* @param tokenId The tokenId of NFT item
* @param pricingToken The contract address of ERC20 token as pricing token
* @param minPrice The minimum starting price for bidding on the auction
* @param reservePrice The minimum pricing that user
* @param buyoutPrice The buyout price for the auction order, set to 0 to disable buyout
* @param expirationTime: The time for ending the auction
* @param sellerURI The uri of seller information on IPFS storage
*/
listItemOnAuction(collection: string, tokenId: string, pricingToken: string, minPrice: number, reservePrice: number, buyoutPrice: number, expirationTime: number, sellerURI: string): Promise<void>;
private listItemERC1155OnAuction;
listItemOnAuctionFromFeeds(tokenId: string, pricingToken: string, minPrice: number, reservePrice: number, buyoutPrice: number, expirationTime: number, sellerURI: string): Promise<void>;
listItemOnAuctionFromPasar(tokenId: string, pricingToken: string, minPrice: number, reservePrice: number, buyoutPrice: number, expirationTime: number, sellerURI: string): Promise<void>;
/**
* Change the auction price for listed item on marketplace
* This function would be used to change the price of listed item on auction
*
* @param orderId The orderId of NFT item on maketplace
* @param newPricingToken The token address of new pricing token
* @param newMinPrice The new minimum starting price for bidding on the auction
* @param newReservedPrice The new minimum pricing that user
* @param newBuyoutPrice The new buyout price for the auction order, set to 0 to disable
* buyout
* @returns The orderId
*/
changePriceOnAuction(orderId: string, newPricingToken: string, newMinPrice: number, newReservedPrice: number, newBuyoutPrice: number): Promise<void>;
/**
* Offer a bidding price on list item that is being on auciton on marketplace.
*
* @param orderId The orderId of NFT item listed on auciton.
* @param pricingToken
* @param price The price offered by bidder
* @param bidderURI The uri of bidder information on IPFS storage
* @returns The result of bidding action.
*/
bidItemOnAuction(orderId: string, pricingToken: string, price: number, bidderURI: string): Promise<void>;
/**
* Settle the listed NFT item on auction on marketplace
*
* @param orderId The orderId of NFT item listed on auciton.
*/
settleAuction(orderId: string): Promise<void>;
/**
* Unlist an item from marketplace, either it's with fixed price or on auction
* When the item is on auction with bidding price, it would fail to call this function
* to unlist NFT item.
*
* @param orderId The orderId of NFT item listed on marketplace
* @returns
*/
unlistItem(orderId: string): Promise<void>;
}