@nftvillage/marketplace-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.1.40 • Public • Published

@nftvillage/marketplace-sdk

Marketplace Hooks and functions to interect with Nft Village.

Dependencies

"@react-dapp/utils": "^0.0.20",
"bignumber.js": "^9.0.1",
"ethereum-multicall": "^2.9.0",
"ethers": "^5.5.1",
"react": "^17.0.2",

Collection Hooks

useCreateCollection

  • createCollection this hook takes collection data,interface of collection data
  • Useage this hook is used to create the user collection
CollectionData {
  name?: string
  description?: string
  symbol?: string
  shortUrl?: string
  coverImage?:string
  logoImage?:string
  royalty?: number
  isVerified?: boolean
}
  • Return values this hook returns Api response interface where T is the collection interface
ApiResponse<T> {
 status: boolean
 message: string
 data?: T
}
Collection {
 userAddress: string
 isVerified?: boolean
 address: string
 name?: string
 description?: string
 symbol?: string
 shortUrl?: string
 coverImage?:string
 logoImage?:string
 royalty?: number
 collectionStandard:AssetType
}

useCollectionByShortURL

  • fetchCollection this hook takes shortUrl as string.
shortUrl: string
  • Return values this hook returns collection interface and loading State
Collection {
 userAddress: string
 isVerified?: boolean
 address: string
 name?: string
 description?: string
 symbol?: string
 shortUrl?: string
 coverImage?:string
 logoImage?:string
 royalty?: number
 collectionStandard:AssetType
},
loading:boolean

useCollectionByCollectionAddress

  • fetchCollectionAddress this hook takes collection address as string.
address: string
  • Return values this hook returns collection interface and loading State
Collection {
 userAddress: string
 isVerified?: boolean
 address: string
 name?: string
 description?: string
 symbol?: string
 shortUrl?: string
 coverImage?:string
 logoImage?:string
 royalty?: number
 collectionStandard:AssetType
},
loading:boolean

useAllCollectionsByUserAddress

  • fetchAllCollectionOfUser this hook takes User address as string.
address: string
  • Return values this hook returns Array of collection interface and loading State
[
Collection{
 userAddress: string
 isVerified?: boolean
 address: string
 name?: string
 description?: string
 symbol?: string
 shortUrl?: string
 coverImage?:string
 logoImage?:string
 royalty?: number
 collectionStandard:AssetType
},
],
loading:boolean

useCheckShortUrlAvailability

  • _checkShortUrlAvailability this hook takes User shortUrl as string.
shortUrl: string
  • Return values this hook returns Boolean isURLAvailable and loading State

Token Hooks

useMintERC721

  • mintToken

this hook takes Token interface.

Token {
  address: string
  metadata: MetaData
  fees: Fee[] | []
  minter: string
  owner: string
}

type Fee = {
  recipient: string
  value: number
}
  • Return values this hook returns Api response and tokenId as number where T is the token interface
ApiResponse<T> {
 status: boolean
 message: string
 data?: T
}
Token {
 address: string
 tokenId?: number
 metadata: MetaData
 fees: Fee[] | []
 minter: string
 owner: string
}
tokenId:number

Order Hooks

useSellOrder

this takes asset(it's a collection address) as string

  • create this hook takes Order interface
Order {
  order: OrderData
  metadata: {
    attributes: Attributes[] | []
    image?: string
    background_color?: string
    external_url?: string
    animation_url?: string
    youtube_url?: string
    category?: string
    name?: string
    description?: string
    address: string
    tokenId: number
    collectionName: string
    makerAddress: string
    price: number
  }
}

OrderData  {
      assetId:number,
      assetType:AssetType,
      assetAmount?:number,
      maker:string,
      paymentToken?:string,
      expirationTime?:number,
      basePrice:number,
    }

Attributes = {
  trait_type: string
  value: string | number
  display_type?: string
}

enum AssetType {
  ERC721,
  ERC1155,
}
enum SaleKind {
  BUYNOW = 0,
  ENGLISHAUCTION = 1,
  DUTCHAUCTION = 2,
}

  • Return values this hook returns Api response interface where T is the Order interface
ApiResponse<T> {
 status: boolean
 message: string
 data?: T
}
Order {
 order: OrderData
 orderHash?: string
 referrer?: string
 status?: StatusType
 expirationTime?: number
 signature?: string
 metadata: {
   attributes: Attributes[] | []
   image?: string
   background_color?: string
   external_url?: string
   animation_url?: string
   youtube_url?: string
   category?: string
   name?: string
   description?: string
   address: string
   tokenId: number
   collectionName: string
   makerAddress: string
   price: number
 }
 bids?: Bids[] | []
}

useCancelOrder

  • cancel this hook takes Order interface
 Order {
  order: OrderData
  orderHash?: string
  referrer?: string
  status?: StatusType
  expirationTime?: number
  signature?: string
  metadata: {
    attributes: Attributes[] | []
    image?: string
    background_color?: string
    external_url?: string
    animation_url?: string
    youtube_url?: string
    category?: string
    name?: string
    description?: string
    address: string
    tokenId: number
    collectionName: string
    makerAddress: string
    price: number
  }
  bids?: Bids[] | []
}
  • Return values this hook returns Delete interface
Delete{
 message:string,
 status:boolean
}

useOrderBid

  • createBidOrder this hook takes Order interface
Order {
  order: OrderData
  metadata: {
    attributes: Attributes[] | []
    image?: string
    background_color?: string
    external_url?: string
    animation_url?: string
    youtube_url?: string
    category?: string
    name?: string
    description?: string
    address: string
    tokenId: number
    collectionName: string
    makerAddress: string
    price: number
  }
}

OrderData {
      asset,
      assetId,
      maker,
      paymentToken,
      side,
      taker,
      expirationTime,
      basePrice
    }

Attributes = {
  trait_type: string
  value: string | number
  display_type?: string
}
OrderSide {
  BUY,
  SELL,
}
SaleKind {
  BUYNOW = 0,
  ENGLISHAUCTION = 1,
  DUTCHAUCTION = 2,
}

  • Return values this hook returns Api response interface where T is the Order interface
ApiResponse<T> {
 status: boolean
 message: string
 data?: T
}
Order {
 order: OrderData
 orderHash?: string
 referrer?: string
 status?: StatusType
 expirationTime?: number
 signature?: string
 metadata: {
   attributes: Attributes[] | []
   image?: string
   background_color?: string
   external_url?: string
   animation_url?: string
   youtube_url?: string
   category?: string
   name?: string
   description?: string
   address: string
   tokenId: number
   collectionName: string
   makerAddress: string
   price: number
 }
 bids?: Bids[] | []
}

useBuyFixPriceOrder

  • buyFixOrder this hook takes asset: string, assetId: number, maker: string where maker is the buyer of the order

  • approve no params

  • Return values this hook returns txResponse interface

{
   tx: any;
   receipt: any;
   error: any;
   status: boolean;
}

isApproved:boolean

useBuyOrder

  • buy

this hook takes two Orders interface buyOrder , sellOrder

Order {
  order: OrderData
  orderHash?: string
  referrer?: string
  status?: StatusType
  expirationTime?: number
  signature?: string
  metadata: {
    attributes: Attributes[] | []
    image?: string
    background_color?: string
    external_url?: string
    animation_url?: string
    youtube_url?: string
    category?: string
    name?: string
    description?: string
    address: string
    tokenId: number
    collectionName: string
    makerAddress: string
    price: number
  }
  bids?: Bids[] | []
}
  • Return values this hook returns txResponse interface
{
   tx: any;
   receipt: any;
   error: any;
   status: boolean;
}

useOrder

  • singleOrder this hook takes orderAsset
OrderAsset {
  asset: string
  assetId: number
}

  • Return values this hook returns Order and loading as boolean
Order {
  order: OrderData
  orderHash?: string
  referrer?: string
  status?: StatusType
  expirationTime?: number
  signature?: string
  metadata: {
    attributes: Attributes[] | []
    image?: string
    background_color?: string
    external_url?: string
    animation_url?: string
    youtube_url?: string
    category?: string
    name?: string
    description?: string
    address: string
    tokenId: number
    collectionName: string
    makerAddress: string
    price: number
  }
  bids?: Bids[] | []
}

loading:boolean

useOrders

  • fetchOrders this hook takes
saleKind: SaleKind, 
page: number, 
limit: number, 
status: StatusType
  • Return values this hook returns Array of Order and loading as boolean
[
Order {
 order: OrderData
 orderHash?: string
 referrer?: string
 status?: StatusType
 expirationTime?: number
 signature?: string
 metadata: {
   attributes: Attributes[] | []
   image?: string
   background_color?: string
   external_url?: string
   animation_url?: string
   youtube_url?: string
   category?: string
   name?: string
   description?: string
   address: string
   tokenId: number
   collectionName: string
   makerAddress: string
   price: number
 }
 bids?: Bids[] | []
}
],
loading:boolean

useOrdersOfCollection

  • fetchOrdersForCollection this hook takes
address: string, 
saleKind: SaleKind

  • Return values this hook returns Array of Order and loading as boolean
[
Order {
 order: OrderData
 orderHash?: string
 referrer?: string
 status?: StatusType
 expirationTime?: number
 signature?: string
 metadata: {
   attributes: Attributes[] | []
   image?: string
   background_color?: string
   external_url?: string
   animation_url?: string
   youtube_url?: string
   category?: string
   name?: string
   description?: string
   address: string
   tokenId: number
   collectionName: string
   makerAddress: string
   price: number
 }
 bids?: Bids[] | []
}
],
loading:boolean

useAllListedOrdersForAddress

  • fetchOrdersForAddress

this hooks takes

userAddress: string
  • Return values this hook returns Array of Order and loading as boolean
[
Order {
 order: OrderData
 orderHash?: string
 referrer?: string
 status?: StatusType
 expirationTime?: number
 signature?: string
 metadata: {
   attributes: Attributes[] | []
   image?: string
   background_color?: string
   external_url?: string
   animation_url?: string
   youtube_url?: string
   category?: string
   name?: string
   description?: string
   address: string
   tokenId: number
   collectionName: string
   makerAddress: string
   price: number
 }
 bids?: Bids[] | []
}
],
loading:boolean

useOrderHistory

  • fetchOrderHistory

this hooks takes

orderData: OrderAsset, 
page: number, 
limit: number
  • Return values this hook returns Array of Order and loading as boolean
[
Order {
 order: OrderData
 orderHash?: string
 referrer?: string
 status?: StatusType
 expirationTime?: number
 signature?: string
 metadata: {
   attributes: Attributes[] | []
   image?: string
   background_color?: string
   external_url?: string
   animation_url?: string
   youtube_url?: string
   category?: string
   name?: string
   description?: string
   address: string
   tokenId: number
   collectionName: string
   makerAddress: string
   price: number
 }
 bids?: Bids[] | []
}
],
loading:boolean

useSpecificOrders

  • fetchSpecificOrders this hook takes specificOrderData interface key is the collection address number array is tokeIds
SpecificOrderData {
  [key: string]: number[]
}
  • Return values this hook returns Array of Order and loading as boolean
[
Order {
 order: OrderData
 orderHash?: string
 referrer?: string
 status?: StatusType
 expirationTime?: number
 signature?: string
 metadata: {
   attributes: Attributes[] | []
   image?: string
   background_color?: string
   external_url?: string
   animation_url?: string
   youtube_url?: string
   category?: string
   name?: string
   description?: string
   address: string
   tokenId: number
   collectionName: string
   makerAddress: string
   price: number
 }
 bids?: Bids[] | []
}
],
loading:boolean

Search hooks

useFilterMarketPlace

-filterMarketPlace this hooks takes FilterMarketPlace interface

FilterMarketPlace {
  address?: string
  makerAddress?: string
  name?: string
  collectionName?: string
  category?: string
  minPrice?: number
  maxPrice?: number
  sortBy?: SortBy
}

SortBy = {
  LATEST?: string
  OLDEST?: string
  PRICE_LOW_TO_HIGH?: string
  PRICE_HIGH_TO_LOW?: string
}

  • Return values this hook returns Array of Order and loading as boolean
[
Order {
 order: OrderData
 orderHash?: string
 referrer?: string
 status?: StatusType
 expirationTime?: number
 signature?: string
 metadata: {
   attributes: Attributes[] | []
   image?: string
   background_color?: string
   external_url?: string
   animation_url?: string
   youtube_url?: string
   category?: string
   name?: string
   description?: string
   address: string
   tokenId: number
   collectionName: string
   makerAddress: string
   price: number
 }
 bids?: Bids[] | []
}
],
loading:boolean

useSearchMarketPlace

  • searchMarketPlace

this hooks takes

 query: string

  • Return values this hook returns SearchMarketPlace and loading as boolean

SearchMarketPlace {
 names: string[]
 collectionNames: string[]
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.401latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.401
0.1.390
0.1.380
0.1.370
0.1.360
0.1.350
0.1.340
0.1.330
0.1.320
0.1.310
0.1.300
0.1.290
0.1.280
0.1.270
0.1.260
0.1.250
0.1.240
0.1.230
0.1.220
0.1.210
0.1.200
0.1.190
0.1.180
0.1.170
0.1.160
0.1.150
0.1.140
0.1.130
0.1.120
0.1.110
0.1.100
0.1.90
0.1.80
0.1.70
0.1.60
0.1.50
0.1.40
0.1.30
0.1.20
0.1.10
0.1.00
0.0.790
0.0.781
0.0.770
0.0.760
0.0.750
0.0.740
0.0.730
0.0.721
0.0.710
0.0.700
0.0.690
0.0.680
0.0.670
0.0.660
0.0.650
0.0.640
0.0.630
0.0.620
0.0.610
0.0.600
0.0.590
0.0.580
0.0.570
0.0.560
0.0.550
0.0.540
0.0.530
0.0.520
0.0.510
0.0.501
0.0.490
0.0.480
0.0.470
0.0.460
0.0.450
0.0.440
0.0.430
0.0.420
0.0.410
0.0.400
0.0.390
0.0.380
0.0.370
0.0.360
0.0.340
0.0.330
0.0.320
0.0.310
0.0.300
0.0.291
0.0.280
0.0.250
0.0.240
0.0.230
0.0.220
0.0.210
0.0.200
0.0.191
0.0.180
0.0.170
0.0.160
0.0.150
0.0.130
0.0.120
0.0.110
0.0.100
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i @nftvillage/marketplace-sdk

Weekly Downloads

6

Version

0.1.40

License

none

Unpacked Size

17.5 MB

Total Files

1496

Last publish

Collaborators

  • dev-dechains
  • saqlain1020
  • abdul_rafay
  • sharjeel288