@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.406latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.406
0.1.394
0.1.384
0.1.374
0.1.364
0.1.354
0.1.344
0.1.334
0.1.324
0.1.314
0.1.304
0.1.294
0.1.284
0.1.274
0.1.264
0.1.254
0.1.244
0.1.234
0.1.224
0.1.214
0.1.204
0.1.194
0.1.184
0.1.174
0.1.164
0.1.155
0.1.144
0.1.135
0.1.124
0.1.114
0.1.104
0.1.94
0.1.84
0.1.74
0.1.64
0.1.54
0.1.44
0.1.34
0.1.24
0.1.14
0.1.04
0.0.794
0.0.784
0.0.774
0.0.765
0.0.754
0.0.744
0.0.734
0.0.724
0.0.714
0.0.704
0.0.693
0.0.683
0.0.673
0.0.663
0.0.653
0.0.643
0.0.633
0.0.623
0.0.613
0.0.603
0.0.593
0.0.583
0.0.573
0.0.563
0.0.553
0.0.543
0.0.533
0.0.523
0.0.513
0.0.503
0.0.493
0.0.483
0.0.474
0.0.463
0.0.453
0.0.443
0.0.433
0.0.423
0.0.413
0.0.403
0.0.393
0.0.383
0.0.373
0.0.363
0.0.343
0.0.333
0.0.323
0.0.313
0.0.303
0.0.293
0.0.283
0.0.253
0.0.243
0.0.233
0.0.223
0.0.214
0.0.204
0.0.194
0.0.184
0.0.175
0.0.164
0.0.154
0.0.134
0.0.124
0.0.114
0.0.104
0.0.94
0.0.84
0.0.74
0.0.63
0.0.53
0.0.43
0.0.33
0.0.23
0.0.13

Package Sidebar

Install

npm i @nftvillage/marketplace-sdk

Weekly Downloads

5

Version

0.1.40

License

none

Unpacked Size

17.5 MB

Total Files

1496

Last publish

Collaborators

  • dev-dechains
  • saqlain1020
  • abdul_rafay
  • sharjeel288