From 2e0ea113f269b069ae81e390db2bb9126ba14ed1 Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Tue, 8 Nov 2022 18:37:26 -0800 Subject: [PATCH 01/15] :zap: Update: Updated the feature of getting the listed nft --- package.json | 2 +- samples/package.json | 2 +- samples/src/SigninEE.js | 2 +- src/assistservice.ts | 29 +++++++++++++++-------------- src/contracts/deploy/testnet.json | 2 +- src/market.ts | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index a8e73dd..6a22845 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pasarprotocol/pasar-sdk-development", - "version": "0.0.287", + "version": "0.0.291", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", diff --git a/samples/package.json b/samples/package.json index 4bd1966..0b069b4 100644 --- a/samples/package.json +++ b/samples/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "@ethersproject/providers": "^5.5.2", - "@pasarprotocol/pasar-sdk-development": "^0.0.287", + "@pasarprotocol/pasar-sdk-development": "^0.0.291", "@testing-library/react": "^13.3.0", "@testing-library/user-event": "^13.5.0", "@types/react": "17.0.40", diff --git a/samples/src/SigninEE.js b/samples/src/SigninEE.js index e32bf75..78cc5ee 100644 --- a/samples/src/SigninEE.js +++ b/samples/src/SigninEE.js @@ -18,7 +18,7 @@ function SigninEE() { const handleGetListedItem = async () => { now = (Date.now() / 1000).toFixed(); console.log(now); - let result = await market.queryItems(now, 1, 10); + let result = await market.queryItems(0, 1, 10); console.log(result); } diff --git a/src/assistservice.ts b/src/assistservice.ts index 33944cc..b3ff517 100644 --- a/src/assistservice.ts +++ b/src/assistservice.ts @@ -5,17 +5,18 @@ import { ItemInfo } from "./iteminfo"; import { ItemPage } from "./itempage"; import { ERCType } from "./erctype"; -const getAllListedItems = async (assistUrl: string, earilerThan:number, collectionAddr = '', pageNum = 1, pageSize = 10): Promise => { +const getAllListedItems = async (assistUrl: string, earilerThan:number, pageNum = 1, pageSize = 10): Promise => { try { - let response = await fetch(`${assistUrl}/api/v2/sticker/getDetailedCollectiblesListed?startTime=${earilerThan}&collectionType=${collectionAddr}&tokenType=&status=All&itemType=All&adult=false&minPrice=&maxPrice=&order=0&marketPlace=0&keyword=&pageNum=${pageNum}&pageSize=${pageSize}`) + let response = await fetch(`${assistUrl}/api/v1/listCollectibles?type=listed&after=${earilerThan}&pageNum=${pageNum}&pageSize=${pageSize}`) let data = await response.json(); - if (data['code'] != 200) { + if (data['status'] != 200) { throw new Error("Call API to fetch collection info failed"); } let dataInfo = data['data']; + let totalCount = dataInfo['total']; - let nftData = dataInfo['result']; + let nftData = dataInfo['data']; let listNftInfo: ItemInfo[] = []; for(var i = 0; i < nftData.length; i++) { @@ -33,19 +34,19 @@ const getAllListedItems = async (assistUrl: string, earilerThan:number, collecti nftData[i]['properties'], nftData[i]['tokenJsonVersion'], nftData[i]['marketPlace'], - nftData[i]['holder'], + nftData[i]['tokenOwner'], nftData[i]['royaltyOwner'], nftData[i]['createTime'], parseInt(nftData[i]['marketTime']), - parseInt(nftData[i]['endTime']), - nftData[i]['orderId'], - nftData[i]['quoteToken'], - nftData[i]['price'], - nftData[i]['buyoutPrice'], - nftData[i]['reservePrice'], - nftData[i]['minPrice'], - nftData[i]['orderState'], - nftData[i]['orderType']); + parseInt(nftData[i]['order']['endTime']), + nftData[i]['order']['orderId'], + nftData[i]['order']['quoteToken'], + nftData[i]['order']['price'], + nftData[i]['order']['buyoutPrice'], + nftData[i]['order']['reservePrice'], + nftData[i]['order']['price'], + nftData[i]['order']['orderState'], + nftData[i]['order']['orderType']); listNftInfo.push(itemNft); } return new ItemPage(totalCount, 0, nftData.length, listNftInfo); diff --git a/src/contracts/deploy/testnet.json b/src/contracts/deploy/testnet.json index 70abb99..b2ef67f 100644 --- a/src/contracts/deploy/testnet.json +++ b/src/contracts/deploy/testnet.json @@ -1,6 +1,6 @@ { "ipfsUrl": "https://ipfs-test.pasarprotocol.io", - "assistUrl": "https://assist-test.pasarprotocol.io", + "assistUrl": "https://assist-new.pasarprotocol.io", "didResolver": "https://api.trinity-tech.io/eid", "appDid": "did:elastos:ic8pRXyAT3JqEXo4PzHQHv5rsoYyEyDwpB", diff --git a/src/market.ts b/src/market.ts index d6d37d5..57ee6fb 100644 --- a/src/market.ts +++ b/src/market.ts @@ -22,7 +22,7 @@ export class Market { */ public async queryItems(beforeTime: number, pageNum = 1, pageSize = 10,): Promise { try { - return await getAllListedItems(this.assistUrl, beforeTime, "", pageNum, pageSize) + return await getAllListedItems(this.assistUrl, beforeTime, pageNum, pageSize) } catch (error) { throw new Error(`Query Items from marketplace error ${error}`) } From 3b33b41c3590a8bfb12b770666274e13d0cf7ec2 Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Wed, 9 Nov 2022 01:29:33 -0800 Subject: [PATCH 02/15] :zap: Update: Updated the assist url for getting the owned list nft --- package.json | 2 +- samples/package.json | 2 +- samples/src/SigninEE.js | 2 +- src/assistservice.ts | 63 ++++++++++++++++++++--------------------- src/iteminfo.ts | 2 -- 5 files changed, 33 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index 6a22845..b8e5cb2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pasarprotocol/pasar-sdk-development", - "version": "0.0.291", + "version": "0.0.298", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", diff --git a/samples/package.json b/samples/package.json index 0b069b4..a39767d 100644 --- a/samples/package.json +++ b/samples/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "@ethersproject/providers": "^5.5.2", - "@pasarprotocol/pasar-sdk-development": "^0.0.291", + "@pasarprotocol/pasar-sdk-development": "^0.0.298", "@testing-library/react": "^13.3.0", "@testing-library/user-event": "^13.5.0", "@types/react": "17.0.40", diff --git a/samples/src/SigninEE.js b/samples/src/SigninEE.js index 78cc5ee..0afe4ea 100644 --- a/samples/src/SigninEE.js +++ b/samples/src/SigninEE.js @@ -11,7 +11,7 @@ function SigninEE() { const navigate = useNavigate(); const [login, setLogin] = useState(checkSign()); let appContext = AppContext.getInstance(); - let profile = new Profile(appContext, "", "0xD47e14d54C6B3C5993b7074e6Ec50aBee7C7Fc10"); + let profile = new Profile(appContext, "", "0x35ba08cd8E620d86d255893c3c65628513dABF65"); let market = new Market(appContext); let now = (Date.now() / 1000).toFixed(); diff --git a/src/assistservice.ts b/src/assistservice.ts index b3ff517..b8032d2 100644 --- a/src/assistservice.ts +++ b/src/assistservice.ts @@ -44,7 +44,6 @@ const getAllListedItems = async (assistUrl: string, earilerThan:number, pageNum nftData[i]['order']['price'], nftData[i]['order']['buyoutPrice'], nftData[i]['order']['reservePrice'], - nftData[i]['order']['price'], nftData[i]['order']['orderState'], nftData[i]['order']['orderType']); listNftInfo.push(itemNft); @@ -59,7 +58,7 @@ const getCollectionInfo = async (assistUrl: string, collectionAddr:string, chain try { let response = await fetch(`${assistUrl}/api/v2/sticker/getCollection/${collectionAddr}?marketPlace=${getChainIndexByType(chainType)}`); let json = await response.json(); - if (json['code'] != 200) { + if (json['status'] != 200) { throw new Error("Call API to fetch collection info failed"); } @@ -90,7 +89,7 @@ const getItemByTokenId = async (assistUrl: string, baseToken:string, tokenId:str try { let response = await fetch(`${assistUrl}/api/v2/sticker/getCollectibleByTokenId/${tokenId}/${baseToken}`); let data = await response.json(); - if (data['code'] != 200) { + if (data['status'] != 200) { throw new Error("Call API to fetch specific NFT failed"); } @@ -116,7 +115,6 @@ const getItemByTokenId = async (assistUrl: string, baseToken:string, tokenId:str itemInfo['Price'], itemInfo['buyoutPrice'], itemInfo['reservePrice'], - itemInfo['minPrice'], itemInfo['orderState'], itemInfo['orderType'] ); @@ -129,7 +127,7 @@ const getOwnedCollections = async (assistUrl: string, walletAddress: string): Pr try { let response = await fetch(`${assistUrl}/api/v2/sticker/getCollectionByOwner/${walletAddress}?marketPlace=1`) let data = await response.json(); - if (data['code'] != 200) { + if (data['status'] != 200) { throw new Error("Call API to fetch owned Collections failed"); } let collections: CollectionInfo[] = []; @@ -171,31 +169,30 @@ const packItemPage = (dataArray: any): ItemPage => { let thumbnail = itemInfo['data'] ? itemInfo['data']['thumbnail'] : itemInfo['thumbnail']; let image = itemInfo['data'] ? itemInfo['data']['image'] : itemInfo['asset']; - + console.log(itemInfo['endTime']); let itemNft = new ItemInfo( - itemInfo['tokenId'], - itemInfo['tokenIdHex'], - itemInfo['name'], - itemInfo['description'], + itemInfo['tokenId'] !== undefined ? itemInfo['tokenId'] : itemInfo['token']['tokenId'], + itemInfo['tokenIdHex'] !== undefined ? itemInfo['tokenIdHex'] : itemInfo['token']['tokenIdHex'], + itemInfo['name'] !== undefined ? itemInfo['name'] : itemInfo['token']['name'], + itemInfo['description'] !== undefined ? itemInfo['description'] : itemInfo['token']['description'], thumbnail, image, - itemInfo['adult'], - itemInfo['properties'], - itemInfo['tokenJsonVersion'], - itemInfo['marketPlace'], - itemInfo['holder'], - itemInfo['royaltyOwner'], - itemInfo['createTime'], - parseInt(itemInfo['marketTime']), - parseInt(itemInfo['endTime']), - itemInfo['orderId'], - itemInfo['quoteToken'], - itemInfo['price'], - itemInfo['buyoutPrice'], - itemInfo['reservePrice'], - itemInfo['minPrice'], - itemInfo['orderState'], - itemInfo['orderType'] + itemInfo['adult'] !== undefined? itemInfo['adult'] : itemInfo['token']['adult'], + itemInfo['properties'] !== undefined ? itemInfo['properties'] : itemInfo['token']['properties'], + itemInfo['version'] !== undefined ? itemInfo['version'] : itemInfo['token']['version'], + itemInfo['chain'] !== undefined ? itemInfo['chain'] : itemInfo['token']['chain'], + itemInfo['tokenOwner'] !== undefined ? itemInfo['tokenOwner'] : itemInfo['token']['tokenOwner'], + itemInfo['royaltyOwner'] !== undefined ? itemInfo['royaltyOwner'] : itemInfo['token']['royaltyOwner'], + itemInfo['createTime'] !== undefined ? itemInfo['createTime'] : itemInfo['token']['createTime'], + itemInfo['createTime'] !== undefined ? parseInt(itemInfo['createTime']) : parseInt(itemInfo['order']['createTime']), + itemInfo['endTime'] !== undefined ? parseInt(itemInfo['endTime']) : parseInt(itemInfo['order']['endTime']), + itemInfo['orderId'] !== undefined ? itemInfo['orderId'] : itemInfo['order']['orderId'], + itemInfo['quoteToken'] !== undefined ? itemInfo['quoteToken'] : itemInfo['order']['quoteToken'], + itemInfo['price'] !== undefined ? itemInfo['price'] : itemInfo['order']['price'], + itemInfo['buyoutPrice'] !== undefined ? itemInfo['buyoutPrice'] : itemInfo['order']['buyoutPrice'], + itemInfo['reservePrice'] !== undefined ? itemInfo['reservePrice'] : itemInfo['order']['reservePrice'], + itemInfo['orderState'] !== undefined ? itemInfo['orderState'] : itemInfo['order']['orderState'], + itemInfo['orderType'] !== undefined ? itemInfo['orderType'] : itemInfo['order']['orderType'] ); items.push(itemNft); } @@ -207,7 +204,7 @@ const getOwnedItems = async (assistUrl: string, walletAddress: string): Promise< try { let response = await fetch(`${assistUrl}/api/v2/sticker/getOwnCollectiblesByAddress/${walletAddress}?orderType=0`); let data = await response.json(); - if (data['code'] != 200) { + if (data['status'] != 200) { throw new Error("Call API to fetch bidding NFT failed"); } return packItemPage(data['data']) @@ -220,7 +217,7 @@ const getCreatedItems = async(assistUrl: string, walletAddress: string): Promise try { let response = await fetch(`${assistUrl}/api/v2/sticker/getCreatedCollectiblesByAddress/${walletAddress}?orderType=0`); let data = await response.json(); - if (data['code'] != 200) { + if (data['status'] != 200) { throw new Error("Call API to fetch bidding NFT failed"); } return packItemPage(data['data']) @@ -231,9 +228,9 @@ const getCreatedItems = async(assistUrl: string, walletAddress: string): Promise const getListedItems = async (assistUrl: string, walletAddress: string): Promise => { try { - let response = await fetch(`${assistUrl}/api/v2/sticker/getListedCollectiblesByAddress/${walletAddress}?orderType=0`); + let response = await fetch(`${assistUrl}/api/v1/getListedCollectiblesByWalletAddr?walletAddr=${walletAddress}`); let data = await response.json(); - if (data['code'] != 200) { + if (data['status'] != 200) { throw new Error("Call API to fetch bidding NFT failed"); } return packItemPage(data['data']) @@ -246,7 +243,7 @@ const getBiddingItems = async (assistUrl: string, walletAddress: string): Promis try { let response = await fetch(`${assistUrl}/api/v2/sticker/getBidCollectiblesByAddress/${walletAddress}?orderType=0`); let data = await response.json(); - if (data['code'] != 200) { + if (data['status'] != 200) { throw new Error("Call API to fetch bidding NFT failed"); } return packItemPage(data['data']) @@ -259,7 +256,7 @@ const getSoldItems = async (assistUrl: string, walletAddress: string): Promise Date: Wed, 9 Nov 2022 02:07:48 -0800 Subject: [PATCH 03/15] :zap: Update: Updated the package on npmjs --- package.json | 6 +++--- samples/package.json | 2 +- samples/src/App.js | 2 +- samples/src/SigninEE.js | 2 +- samples/src/bidNft.js | 2 +- samples/src/burnNFT.js | 2 +- samples/src/buyNft.js | 2 +- samples/src/changePrice.js | 2 +- samples/src/createCollection.js | 2 +- samples/src/listNft.js | 2 +- samples/src/mintNFT.js | 2 +- samples/src/settleAuction.js | 2 +- samples/src/transfer.js | 2 +- samples/src/unlistNft.js | 2 +- samples/src/updateCollectionUri.js | 2 +- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index b8e5cb2..59e9fe9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "@pasarprotocol/pasar-sdk-development", - "version": "0.0.298", + "name": "@crypto-dev/pasar-sdk-development", + "version": "0.0.3", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", @@ -20,7 +20,7 @@ "build:debug": "npm run clean && npm run types && rollup -c", "build:release": "npm run lint && npm run clean && npm run types && rollup -c --environment prodbuild", "update": "npm publish && npm run reinstall", - "reinstall": "cd ./samples && npm uninstall @pasarprotocol/pasar-sdk-development && npm i @pasarprotocol/pasar-sdk-development", + "reinstall": "cd ./samples && npm uninstall @crypto-dev/pasar-sdk-development && npm i @crypto-dev/pasar-sdk-development", "dev": "rollup -c -w", "clean": "rm -rf ./dist ./typings ./generated", "types": "npm run clean && tsc --emitDeclarationOnly --outDir typings/ --project tsconfig.types.json", diff --git a/samples/package.json b/samples/package.json index a39767d..e16f557 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,8 +3,8 @@ "version": "0.1.0", "private": true, "dependencies": { + "@crypto-dev/pasar-sdk-development": "^0.0.3", "@ethersproject/providers": "^5.5.2", - "@pasarprotocol/pasar-sdk-development": "^0.0.298", "@testing-library/react": "^13.3.0", "@testing-library/user-event": "^13.5.0", "@types/react": "17.0.40", diff --git a/samples/src/App.js b/samples/src/App.js index e07b589..857bd50 100644 --- a/samples/src/App.js +++ b/samples/src/App.js @@ -1,5 +1,5 @@ import SigninEE from './SigninEE' -import { AppContext } from '@pasarprotocol/pasar-sdk-development'; +import { AppContext } from '@crypto-dev/pasar-sdk-development'; function App() { AppContext.createInstance(true) diff --git a/samples/src/SigninEE.js b/samples/src/SigninEE.js index 0afe4ea..fca8546 100644 --- a/samples/src/SigninEE.js +++ b/samples/src/SigninEE.js @@ -1,6 +1,6 @@ import React, {useEffect, useState} from 'react' -import {Profile, Market, AppContext } from '@pasarprotocol/pasar-sdk-development'; +import {Profile, Market, AppContext } from '@crypto-dev/pasar-sdk-development'; import { useNavigate } from "react-router-dom"; diff --git a/samples/src/bidNft.js b/samples/src/bidNft.js index ac73515..f95ff57 100644 --- a/samples/src/bidNft.js +++ b/samples/src/bidNft.js @@ -1,5 +1,5 @@ import { useState, useEffect } from "react"; -import { MyProfile, AppContext } from "@pasarprotocol/pasar-sdk-development"; +import { MyProfile, AppContext } from "@crypto-dev/pasar-sdk-development"; import { useNavigate } from "react-router-dom"; const BidNFT = () => { diff --git a/samples/src/burnNFT.js b/samples/src/burnNFT.js index cbdcccb..f745415 100644 --- a/samples/src/burnNFT.js +++ b/samples/src/burnNFT.js @@ -1,5 +1,5 @@ import { useState } from "react"; -import { MyProfile, AppContext } from "@pasarprotocol/pasar-sdk-development"; +import { MyProfile, AppContext } from "@crypto-dev/pasar-sdk-development"; const BurnNFT = () => { const [tokenId, setTokenId] = useState(""); diff --git a/samples/src/buyNft.js b/samples/src/buyNft.js index 308f949..b1f4f09 100644 --- a/samples/src/buyNft.js +++ b/samples/src/buyNft.js @@ -1,5 +1,5 @@ import { useState, useEffect } from "react"; -import { MyProfile, AppContext } from "@pasarprotocol/pasar-sdk-development"; +import { MyProfile, AppContext } from "@crypto-dev/pasar-sdk-development"; import { useNavigate } from "react-router-dom"; const BuyNFT = () => { diff --git a/samples/src/changePrice.js b/samples/src/changePrice.js index 71b01f8..fa34bb4 100644 --- a/samples/src/changePrice.js +++ b/samples/src/changePrice.js @@ -1,5 +1,5 @@ import { useState, useEffect } from "react"; -import { MyProfile, ListType, Token, AppContext } from "@pasarprotocol/pasar-sdk-development"; +import { MyProfile, ListType, Token, AppContext } from "@crypto-dev/pasar-sdk-development"; const ChangePrice = () => { const listPricingToken = Token.getToken(); diff --git a/samples/src/createCollection.js b/samples/src/createCollection.js index c4f1fa1..2424587 100644 --- a/samples/src/createCollection.js +++ b/samples/src/createCollection.js @@ -1,5 +1,5 @@ import { useState, useEffect } from "react"; -import { MyProfile, Category, ERCType, SocialLinks, AppContext } from "@pasarprotocol/pasar-sdk-development"; +import { MyProfile, Category, ERCType, SocialLinks, AppContext } from "@crypto-dev/pasar-sdk-development"; const CreateCollection = () => { const [name, setName] = useState(''); diff --git a/samples/src/listNft.js b/samples/src/listNft.js index 25cbb20..5471090 100644 --- a/samples/src/listNft.js +++ b/samples/src/listNft.js @@ -1,5 +1,5 @@ import { useState, useEffect } from "react"; -import { MyProfile, ListType, Token, AppContext } from "@pasarprotocol/pasar-sdk-development"; +import { MyProfile, ListType, Token, AppContext } from "@crypto-dev/pasar-sdk-development"; const ListNFT = () => { const listPricingToken = Token.getToken(); diff --git a/samples/src/mintNFT.js b/samples/src/mintNFT.js index c29e298..93e4062 100644 --- a/samples/src/mintNFT.js +++ b/samples/src/mintNFT.js @@ -1,5 +1,5 @@ import { useState, useEffect } from "react"; -import { MyProfile, AppContext } from "@pasarprotocol/pasar-sdk-development"; +import { MyProfile, AppContext } from "@crypto-dev/pasar-sdk-development"; const MintNFT = () => { const [name, setName] = useState(''); diff --git a/samples/src/settleAuction.js b/samples/src/settleAuction.js index 6a6b85f..c8f9ac1 100644 --- a/samples/src/settleAuction.js +++ b/samples/src/settleAuction.js @@ -1,5 +1,5 @@ import { useState, useEffect } from "react"; -import { MyProfile, AppContext } from "@pasarprotocol/pasar-sdk-development"; +import { MyProfile, AppContext } from "@crypto-dev/pasar-sdk-development"; const SettleAuction = () => { const [orderId, setOrderId] = useState(""); diff --git a/samples/src/transfer.js b/samples/src/transfer.js index 8414555..1ea86bf 100644 --- a/samples/src/transfer.js +++ b/samples/src/transfer.js @@ -1,5 +1,5 @@ import { useState } from "react"; -import { MyProfile, AppContext } from "@pasarprotocol/pasar-sdk-development"; +import { MyProfile, AppContext } from "@crypto-dev/pasar-sdk-development"; const TransferNFT = () => { const [collectionAddr, setCollectionAddr] = useState(""); diff --git a/samples/src/unlistNft.js b/samples/src/unlistNft.js index 4cb7262..1dee1fb 100644 --- a/samples/src/unlistNft.js +++ b/samples/src/unlistNft.js @@ -1,5 +1,5 @@ import { useState, useEffect } from "react"; -import { MyProfile, AppContext } from "@pasarprotocol/pasar-sdk-development"; +import { MyProfile, AppContext } from "@crypto-dev/pasar-sdk-development"; const UnlistNFT = () => { const [orderId, setOrderId] = useState(""); diff --git a/samples/src/updateCollectionUri.js b/samples/src/updateCollectionUri.js index 4661630..b58d557 100644 --- a/samples/src/updateCollectionUri.js +++ b/samples/src/updateCollectionUri.js @@ -1,5 +1,5 @@ import { useState, useEffect } from "react"; -import { Category, MyProfile, SocialLinks, AppContext } from "@pasarprotocol/pasar-sdk-development"; +import { Category, MyProfile, SocialLinks, AppContext } from "@crypto-dev/pasar-sdk-development"; const UpdateCollectionInfo = () => { const [name, setName] = useState(''); From 2a2a0d3d35125371eb8ae91b08ae5c479a5143ce Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Wed, 9 Nov 2022 18:17:57 -0800 Subject: [PATCH 04/15] :zap: Update: Updated the apis for new assist service --- package.json | 2 +- src/assistservice.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 59e9fe9..72239ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@crypto-dev/pasar-sdk-development", - "version": "0.0.3", + "version": "0.0.5", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", diff --git a/src/assistservice.ts b/src/assistservice.ts index b8032d2..c783f4c 100644 --- a/src/assistservice.ts +++ b/src/assistservice.ts @@ -56,7 +56,7 @@ const getAllListedItems = async (assistUrl: string, earilerThan:number, pageNum const getCollectionInfo = async (assistUrl: string, collectionAddr:string, chainType: ChainType): Promise => { try { - let response = await fetch(`${assistUrl}/api/v2/sticker/getCollection/${collectionAddr}?marketPlace=${getChainIndexByType(chainType)}`); + let response = await fetch(`${assistUrl}/api/v1/getCollectionsByWalletAddr?chain=all&walletAddr=${collectionAddr}`); let json = await response.json(); if (json['status'] != 200) { throw new Error("Call API to fetch collection info failed"); @@ -202,7 +202,7 @@ const packItemPage = (dataArray: any): ItemPage => { const getOwnedItems = async (assistUrl: string, walletAddress: string): Promise => { try { - let response = await fetch(`${assistUrl}/api/v2/sticker/getOwnCollectiblesByAddress/${walletAddress}?orderType=0`); + let response = await fetch(`${assistUrl}/api/v1/getOwnedCollectiblesByWalletAddr?walletAddr=${walletAddress}`); let data = await response.json(); if (data['status'] != 200) { throw new Error("Call API to fetch bidding NFT failed"); @@ -215,7 +215,7 @@ const getOwnedItems = async (assistUrl: string, walletAddress: string): Promise< const getCreatedItems = async(assistUrl: string, walletAddress: string): Promise => { try { - let response = await fetch(`${assistUrl}/api/v2/sticker/getCreatedCollectiblesByAddress/${walletAddress}?orderType=0`); + let response = await fetch(`${assistUrl}/api/v1/getMintedCollectiblesByWalletAddr?walletAddr=${walletAddress}`); let data = await response.json(); if (data['status'] != 200) { throw new Error("Call API to fetch bidding NFT failed"); @@ -241,7 +241,7 @@ const getListedItems = async (assistUrl: string, walletAddress: string): Promise const getBiddingItems = async (assistUrl: string, walletAddress: string): Promise => { try { - let response = await fetch(`${assistUrl}/api/v2/sticker/getBidCollectiblesByAddress/${walletAddress}?orderType=0`); + let response = await fetch(`${assistUrl}/api/v1/getBidsCollectiblesByWalletAddr?walletAddr=${walletAddress}`); let data = await response.json(); if (data['status'] != 200) { throw new Error("Call API to fetch bidding NFT failed"); @@ -254,7 +254,7 @@ const getBiddingItems = async (assistUrl: string, walletAddress: string): Promis const getSoldItems = async (assistUrl: string, walletAddress: string): Promise => { try { - let response = await fetch(`${assistUrl}/api/v2/sticker/getSoldCollectiblesByAddress/${walletAddress}?orderType=0`); + let response = await fetch(`${assistUrl}/api/v1/getSoldCollectiblesByWalletAddr?walletAddr=${walletAddress}`); let data = await response.json(); if (data['status'] != 200) { throw new Error("Call API to fetch sold NFT failed"); From 4bad397c6d3557a7957391a14f96ae0561b9ede6 Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Wed, 9 Nov 2022 23:29:31 -0800 Subject: [PATCH 05/15] :bug: Fix: Fixed the issue of getting the buyoutPrice and reservePrice --- src/assistservice.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assistservice.ts b/src/assistservice.ts index c783f4c..8d2c128 100644 --- a/src/assistservice.ts +++ b/src/assistservice.ts @@ -189,8 +189,8 @@ const packItemPage = (dataArray: any): ItemPage => { itemInfo['orderId'] !== undefined ? itemInfo['orderId'] : itemInfo['order']['orderId'], itemInfo['quoteToken'] !== undefined ? itemInfo['quoteToken'] : itemInfo['order']['quoteToken'], itemInfo['price'] !== undefined ? itemInfo['price'] : itemInfo['order']['price'], - itemInfo['buyoutPrice'] !== undefined ? itemInfo['buyoutPrice'] : itemInfo['order']['buyoutPrice'], - itemInfo['reservePrice'] !== undefined ? itemInfo['reservePrice'] : itemInfo['order']['reservePrice'], + itemInfo['buyoutPrice'] !== undefined ? itemInfo['buyoutPrice'] : itemInfo['order']['buyoutPrice'] != undefined ? itemInfo['order']['buyoutPrice'] : null, + itemInfo['reservePrice'] !== undefined ? itemInfo['reservePrice'] : itemInfo['order']['reservePrice'] != undefined ? itemInfo['order']['reservePrice'] : null, itemInfo['orderState'] !== undefined ? itemInfo['orderState'] : itemInfo['order']['orderState'], itemInfo['orderType'] !== undefined ? itemInfo['orderType'] : itemInfo['order']['orderType'] ); From 67483e1a19be368d549c607a22e88fb682ed9680 Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Wed, 9 Nov 2022 23:56:58 -0800 Subject: [PATCH 06/15] :bug: Fix: Fixed an issue of elastos sdk on sample project --- package.json | 2 +- samples/package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 72239ca..b04555d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@crypto-dev/pasar-sdk-development", - "version": "0.0.5", + "version": "0.0.6", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", diff --git a/samples/package.json b/samples/package.json index e16f557..7795633 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,7 +3,8 @@ "version": "0.1.0", "private": true, "dependencies": { - "@crypto-dev/pasar-sdk-development": "^0.0.3", + "@crypto-dev/pasar-sdk-development": "0.0.6", + "@elastosfoundation/elastos-connectivity-sdk-js": "^1.0.23", "@ethersproject/providers": "^5.5.2", "@testing-library/react": "^13.3.0", "@testing-library/user-event": "^13.5.0", From d471969a15411d84300afdfe12b54bfd0439f394 Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Thu, 10 Nov 2022 00:15:17 -0800 Subject: [PATCH 07/15] :bug: Fix: Fixed an issue of parsing the nft information --- package.json | 2 +- samples/package.json | 2 +- src/assistservice.ts | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index b04555d..4dba8d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@crypto-dev/pasar-sdk-development", - "version": "0.0.6", + "version": "0.0.9", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", diff --git a/samples/package.json b/samples/package.json index 7795633..386f3db 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { - "@crypto-dev/pasar-sdk-development": "0.0.6", + "@crypto-dev/pasar-sdk-development": "0.0.9", "@elastosfoundation/elastos-connectivity-sdk-js": "^1.0.23", "@ethersproject/providers": "^5.5.2", "@testing-library/react": "^13.3.0", diff --git a/src/assistservice.ts b/src/assistservice.ts index 8d2c128..95b1c1e 100644 --- a/src/assistservice.ts +++ b/src/assistservice.ts @@ -167,9 +167,10 @@ const packItemPage = (dataArray: any): ItemPage => { for(var i = 0; i < dataArray.length; i++) { let itemInfo = dataArray[i]; - let thumbnail = itemInfo['data'] ? itemInfo['data']['thumbnail'] : itemInfo['thumbnail']; - let image = itemInfo['data'] ? itemInfo['data']['image'] : itemInfo['asset']; - console.log(itemInfo['endTime']); + let tokenData = itemInfo['token'] ? itemInfo['token'] : itemInfo; + let thumbnail = tokenData['data'] ? tokenData['data']['thumbnail'] : tokenData['thumbnail']; + let image = tokenData['data'] ? tokenData['data']['image'] : tokenData['image']; + let itemNft = new ItemInfo( itemInfo['tokenId'] !== undefined ? itemInfo['tokenId'] : itemInfo['token']['tokenId'], itemInfo['tokenIdHex'] !== undefined ? itemInfo['tokenIdHex'] : itemInfo['token']['tokenIdHex'], @@ -189,11 +190,12 @@ const packItemPage = (dataArray: any): ItemPage => { itemInfo['orderId'] !== undefined ? itemInfo['orderId'] : itemInfo['order']['orderId'], itemInfo['quoteToken'] !== undefined ? itemInfo['quoteToken'] : itemInfo['order']['quoteToken'], itemInfo['price'] !== undefined ? itemInfo['price'] : itemInfo['order']['price'], - itemInfo['buyoutPrice'] !== undefined ? itemInfo['buyoutPrice'] : itemInfo['order']['buyoutPrice'] != undefined ? itemInfo['order']['buyoutPrice'] : null, - itemInfo['reservePrice'] !== undefined ? itemInfo['reservePrice'] : itemInfo['order']['reservePrice'] != undefined ? itemInfo['order']['reservePrice'] : null, + itemInfo['buyoutPrice'] !== undefined ? itemInfo['buyoutPrice'] : itemInfo['order'] && itemInfo['order']['buyoutPrice'] !== undefined ? itemInfo['order']['buyoutPrice'] : null, + itemInfo['reservePrice'] !== undefined ? itemInfo['reservePrice'] : itemInfo['order'] && itemInfo['order']['reservePrice'] !== undefined ? itemInfo['order']['reservePrice'] : null, itemInfo['orderState'] !== undefined ? itemInfo['orderState'] : itemInfo['order']['orderState'], itemInfo['orderType'] !== undefined ? itemInfo['orderType'] : itemInfo['order']['orderType'] ); + console.log(itemNft); items.push(itemNft); } From 2b99f8603d213a783fc9a3d05832159b23775b3a Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Sun, 13 Nov 2022 17:45:46 -0800 Subject: [PATCH 08/15] :zap: Update: Updated the feature of getting item information --- package.json | 2 +- samples/package.json | 2 +- src/assistservice.ts | 120 ++++++++++++++----------------------------- 3 files changed, 40 insertions(+), 84 deletions(-) diff --git a/package.json b/package.json index 4dba8d8..df60abe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@crypto-dev/pasar-sdk-development", - "version": "0.0.9", + "version": "0.0.10", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", diff --git a/samples/package.json b/samples/package.json index 386f3db..b065692 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { - "@crypto-dev/pasar-sdk-development": "0.0.9", + "@crypto-dev/pasar-sdk-development": "0.0.10", "@elastosfoundation/elastos-connectivity-sdk-js": "^1.0.23", "@ethersproject/providers": "^5.5.2", "@testing-library/react": "^13.3.0", diff --git a/src/assistservice.ts b/src/assistservice.ts index 95b1c1e..7cd8188 100644 --- a/src/assistservice.ts +++ b/src/assistservice.ts @@ -19,33 +19,7 @@ const getAllListedItems = async (assistUrl: string, earilerThan:number, pageNum let nftData = dataInfo['data']; let listNftInfo: ItemInfo[] = []; for(var i = 0; i < nftData.length; i++) { - - let thumbnail = nftData[i]['data'] ? nftData[i]['data']['thumbnail'] : nftData[i]['thumbnail']; - let image = nftData[i]['data'] ? nftData[i]['data']['image'] : nftData[i]['asset']; - - let itemNft = new ItemInfo( - nftData[i]['tokenId'], - nftData[i]['tokenIdHex'], - nftData[i]['name'], - nftData[i]['description'], - thumbnail, - image, - nftData[i]['adult'], - nftData[i]['properties'], - nftData[i]['tokenJsonVersion'], - nftData[i]['marketPlace'], - nftData[i]['tokenOwner'], - nftData[i]['royaltyOwner'], - nftData[i]['createTime'], - parseInt(nftData[i]['marketTime']), - parseInt(nftData[i]['order']['endTime']), - nftData[i]['order']['orderId'], - nftData[i]['order']['quoteToken'], - nftData[i]['order']['price'], - nftData[i]['order']['buyoutPrice'], - nftData[i]['order']['reservePrice'], - nftData[i]['order']['orderState'], - nftData[i]['order']['orderType']); + let itemNft = getItemInfo(nftData[i]); listNftInfo.push(itemNft); } return new ItemPage(totalCount, 0, nftData.length, listNftInfo); @@ -87,37 +61,15 @@ const getCollectionInfo = async (assistUrl: string, collectionAddr:string, chain const getItemByTokenId = async (assistUrl: string, baseToken:string, tokenId:string): Promise => { try { - let response = await fetch(`${assistUrl}/api/v2/sticker/getCollectibleByTokenId/${tokenId}/${baseToken}`); + let response = await fetch(`${assistUrl}/api/v1/getCollectibleInfo?baseToken=${baseToken}&chain=ela&tokenId=${tokenId}`); let data = await response.json(); if (data['status'] != 200) { throw new Error("Call API to fetch specific NFT failed"); } let itemInfo = data['data']; - return new ItemInfo( - itemInfo['tokenId'], - itemInfo['tokenIdHex'], - itemInfo['name'], - itemInfo['description'], - itemInfo['data'] ? itemInfo['data']['thumbnail'] : itemInfo['thumbnail'], - itemInfo['data'] ? itemInfo['data']['image'] : itemInfo['asset'], - itemInfo['adult'], - itemInfo['properties'], - itemInfo['tokenJsonVersion'], - itemInfo['marketPlace'], - itemInfo['holder'], - itemInfo['royaltyOwner'], - itemInfo['createTime'], - parseInt(itemInfo['marketTime']), - parseInt(itemInfo['endTime']), - itemInfo['OrderId'], - itemInfo['quoteToken'], - itemInfo['Price'], - itemInfo['buyoutPrice'], - itemInfo['reservePrice'], - itemInfo['orderState'], - itemInfo['orderType'] - ); + let itemNFT = getItemInfo(itemInfo); + return itemNFT; }catch (error) { throw new Error(`Failed to get listed NFTs with error: ${error}`); } @@ -162,39 +114,43 @@ const getOwnedCollections = async (assistUrl: string, walletAddress: string): Pr } } +const getItemInfo = (itemInfo:any):ItemInfo => { + let tokenData = itemInfo['token'] ? itemInfo['token'] : itemInfo; + let thumbnail = tokenData['data'] ? tokenData['data']['thumbnail'] : tokenData['thumbnail']; + let image = tokenData['data'] ? tokenData['data']['image'] : tokenData['image']; + + let itemNft = new ItemInfo( + itemInfo['tokenId'] !== undefined ? itemInfo['tokenId'] : itemInfo['token']['tokenId'], + itemInfo['tokenIdHex'] !== undefined ? itemInfo['tokenIdHex'] : itemInfo['token']['tokenIdHex'], + itemInfo['name'] !== undefined ? itemInfo['name'] : itemInfo['token']['name'], + itemInfo['description'] !== undefined ? itemInfo['description'] : itemInfo['token']['description'], + thumbnail, + image, + itemInfo['adult'] !== undefined? itemInfo['adult'] : itemInfo['token']['adult'], + itemInfo['properties'] !== undefined ? itemInfo['properties'] : itemInfo['token']['properties'], + itemInfo['version'] !== undefined ? itemInfo['version'] : itemInfo['token']['version'], + itemInfo['chain'] !== undefined ? itemInfo['chain'] : itemInfo['token']['chain'], + itemInfo['tokenOwner'] !== undefined ? itemInfo['tokenOwner'] : itemInfo['token']['tokenOwner'], + itemInfo['royaltyOwner'] !== undefined ? itemInfo['royaltyOwner'] : itemInfo['token']['royaltyOwner'], + itemInfo['createTime'] !== undefined ? itemInfo['createTime'] : itemInfo['token']['createTime'], + itemInfo['createTime'] !== undefined ? parseInt(itemInfo['createTime']) : parseInt(itemInfo['order']['createTime']), + itemInfo['endTime'] !== undefined ? parseInt(itemInfo['endTime']) : parseInt(itemInfo['order']['endTime']), + itemInfo['orderId'] !== undefined ? itemInfo['orderId'] : itemInfo['order']['orderId'], + itemInfo['quoteToken'] !== undefined ? itemInfo['quoteToken'] : itemInfo['order']['quoteToken'], + itemInfo['price'] !== undefined ? itemInfo['price'] : itemInfo['order']['price'], + itemInfo['buyoutPrice'] !== undefined ? itemInfo['buyoutPrice'] : itemInfo['order'] && itemInfo['order']['buyoutPrice'] !== undefined ? itemInfo['order']['buyoutPrice'] : null, + itemInfo['reservePrice'] !== undefined ? itemInfo['reservePrice'] : itemInfo['order'] && itemInfo['order']['reservePrice'] !== undefined ? itemInfo['order']['reservePrice'] : null, + itemInfo['orderState'] !== undefined ? itemInfo['orderState'] : itemInfo['order']['orderState'], + itemInfo['orderType'] !== undefined ? itemInfo['orderType'] : itemInfo['order']['orderType'] + ); + + return itemNft; +} + const packItemPage = (dataArray: any): ItemPage => { let items: ItemInfo[] = []; for(var i = 0; i < dataArray.length; i++) { - let itemInfo = dataArray[i]; - - let tokenData = itemInfo['token'] ? itemInfo['token'] : itemInfo; - let thumbnail = tokenData['data'] ? tokenData['data']['thumbnail'] : tokenData['thumbnail']; - let image = tokenData['data'] ? tokenData['data']['image'] : tokenData['image']; - - let itemNft = new ItemInfo( - itemInfo['tokenId'] !== undefined ? itemInfo['tokenId'] : itemInfo['token']['tokenId'], - itemInfo['tokenIdHex'] !== undefined ? itemInfo['tokenIdHex'] : itemInfo['token']['tokenIdHex'], - itemInfo['name'] !== undefined ? itemInfo['name'] : itemInfo['token']['name'], - itemInfo['description'] !== undefined ? itemInfo['description'] : itemInfo['token']['description'], - thumbnail, - image, - itemInfo['adult'] !== undefined? itemInfo['adult'] : itemInfo['token']['adult'], - itemInfo['properties'] !== undefined ? itemInfo['properties'] : itemInfo['token']['properties'], - itemInfo['version'] !== undefined ? itemInfo['version'] : itemInfo['token']['version'], - itemInfo['chain'] !== undefined ? itemInfo['chain'] : itemInfo['token']['chain'], - itemInfo['tokenOwner'] !== undefined ? itemInfo['tokenOwner'] : itemInfo['token']['tokenOwner'], - itemInfo['royaltyOwner'] !== undefined ? itemInfo['royaltyOwner'] : itemInfo['token']['royaltyOwner'], - itemInfo['createTime'] !== undefined ? itemInfo['createTime'] : itemInfo['token']['createTime'], - itemInfo['createTime'] !== undefined ? parseInt(itemInfo['createTime']) : parseInt(itemInfo['order']['createTime']), - itemInfo['endTime'] !== undefined ? parseInt(itemInfo['endTime']) : parseInt(itemInfo['order']['endTime']), - itemInfo['orderId'] !== undefined ? itemInfo['orderId'] : itemInfo['order']['orderId'], - itemInfo['quoteToken'] !== undefined ? itemInfo['quoteToken'] : itemInfo['order']['quoteToken'], - itemInfo['price'] !== undefined ? itemInfo['price'] : itemInfo['order']['price'], - itemInfo['buyoutPrice'] !== undefined ? itemInfo['buyoutPrice'] : itemInfo['order'] && itemInfo['order']['buyoutPrice'] !== undefined ? itemInfo['order']['buyoutPrice'] : null, - itemInfo['reservePrice'] !== undefined ? itemInfo['reservePrice'] : itemInfo['order'] && itemInfo['order']['reservePrice'] !== undefined ? itemInfo['order']['reservePrice'] : null, - itemInfo['orderState'] !== undefined ? itemInfo['orderState'] : itemInfo['order']['orderState'], - itemInfo['orderType'] !== undefined ? itemInfo['orderType'] : itemInfo['order']['orderType'] - ); + let itemNft = getItemInfo(dataArray[i]); console.log(itemNft); items.push(itemNft); } From 9c6a07b7dd95a623007b814467eb7bf95e2b102c Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Sun, 13 Nov 2022 18:10:49 -0800 Subject: [PATCH 09/15] :zap: Update: Updated the feature of parsing the nft information --- package.json | 2 +- samples/package.json | 2 +- src/assistservice.ts | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index df60abe..00928c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@crypto-dev/pasar-sdk-development", - "version": "0.0.10", + "version": "0.0.13", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", diff --git a/samples/package.json b/samples/package.json index b065692..f60851f 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { - "@crypto-dev/pasar-sdk-development": "0.0.10", + "@crypto-dev/pasar-sdk-development": "0.0.13", "@elastosfoundation/elastos-connectivity-sdk-js": "^1.0.23", "@ethersproject/providers": "^5.5.2", "@testing-library/react": "^13.3.0", diff --git a/src/assistservice.ts b/src/assistservice.ts index 7cd8188..7a81876 100644 --- a/src/assistservice.ts +++ b/src/assistservice.ts @@ -116,8 +116,9 @@ const getOwnedCollections = async (assistUrl: string, walletAddress: string): Pr const getItemInfo = (itemInfo:any):ItemInfo => { let tokenData = itemInfo['token'] ? itemInfo['token'] : itemInfo; - let thumbnail = tokenData['data'] ? tokenData['data']['thumbnail'] : tokenData['thumbnail']; - let image = tokenData['data'] ? tokenData['data']['image'] : tokenData['image']; + let image = tokenData['image'] ? tokenData['image'] : tokenData['data'] && tokenData['data']['image'] ? tokenData['data']['image'] : null; + let thumbnail = tokenData['thumbnail'] ? tokenData['thumbnail'] : tokenData['data'] && tokenData['data']['thumbnail'] ? tokenData['data']['thumbnail'] : image; + let properties = tokenData['properties'] ? tokenData['properties'] : tokenData['attributes'] ? tokenData['attributes'] : null; let itemNft = new ItemInfo( itemInfo['tokenId'] !== undefined ? itemInfo['tokenId'] : itemInfo['token']['tokenId'], @@ -126,8 +127,8 @@ const getItemInfo = (itemInfo:any):ItemInfo => { itemInfo['description'] !== undefined ? itemInfo['description'] : itemInfo['token']['description'], thumbnail, image, - itemInfo['adult'] !== undefined? itemInfo['adult'] : itemInfo['token']['adult'], - itemInfo['properties'] !== undefined ? itemInfo['properties'] : itemInfo['token']['properties'], + itemInfo['adult'] !== undefined? itemInfo['adult'] : itemInfo['token'] && itemInfo['token']['adult'] ? itemInfo['token']['adult'] : false, + itemInfo['properties'] !== properties, itemInfo['version'] !== undefined ? itemInfo['version'] : itemInfo['token']['version'], itemInfo['chain'] !== undefined ? itemInfo['chain'] : itemInfo['token']['chain'], itemInfo['tokenOwner'] !== undefined ? itemInfo['tokenOwner'] : itemInfo['token']['tokenOwner'], From 3b3f2f3c6d7ca18c42d97574c6b282f7d13ab5f8 Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Sun, 13 Nov 2022 18:40:55 -0800 Subject: [PATCH 10/15] :zap: Update: Updated the feature of parsing the collection information --- package.json | 2 +- samples/package.json | 2 +- src/assistservice.ts | 21 +++++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 00928c7..47849ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@crypto-dev/pasar-sdk-development", - "version": "0.0.13", + "version": "0.0.16", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", diff --git a/samples/package.json b/samples/package.json index f60851f..68b9a57 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { - "@crypto-dev/pasar-sdk-development": "0.0.13", + "@crypto-dev/pasar-sdk-development": "0.0.16", "@elastosfoundation/elastos-connectivity-sdk-js": "^1.0.23", "@ethersproject/providers": "^5.5.2", "@testing-library/react": "^13.3.0", diff --git a/src/assistservice.ts b/src/assistservice.ts index 7a81876..8a6e14b 100644 --- a/src/assistservice.ts +++ b/src/assistservice.ts @@ -77,7 +77,7 @@ const getItemByTokenId = async (assistUrl: string, baseToken:string, tokenId:str const getOwnedCollections = async (assistUrl: string, walletAddress: string): Promise => { try { - let response = await fetch(`${assistUrl}/api/v2/sticker/getCollectionByOwner/${walletAddress}?marketPlace=1`) + let response = await fetch(`${assistUrl}/api/v1/getCollectionsByWalletAddr?chain=all&walletAddr=${walletAddress}`) let data = await response.json(); if (data['status'] != 200) { throw new Error("Call API to fetch owned Collections failed"); @@ -87,23 +87,24 @@ const getOwnedCollections = async (assistUrl: string, walletAddress: string): Pr for (var i = 0; i < body.length; i++) { let item = body[i]; - let data = item['tokenJson']['data']; + let creator = item['creator']; + let data = item['data']; let info = new CollectionInfo( item['token'], - ChainType.ESC, - item['creatorDid'], + item['chain'], + creator && creator['did'] ? creator['did'] : null, item['owner'], item['name'], item['symbol'] ); - info.setSocialLinks(data['socials']) - .setDescription(data['description']) - .setAvatar(data['avatar']) - .setDescription(data['description']) - .setCategory(data['category']) - .setErcType(body['is721'] ? ERCType.ERC721 : ERCType.ERC1155) + info.setSocialLinks(data && data['socials'] ? data['socials'] : null) + .setDescription(data && data['description'] ? data['description'] : null) + .setAvatar(data && data['avatar'] ? data['avatar'] : null) + .setBanner(data && data['background'] ? data['background'] : null) + .setCategory(data && data['category'] ? data['category'] : null) + .setErcType(item['is721'] ? ERCType.ERC721 : ERCType.ERC1155) collections.push(info); } From e5556031219f894101bc93d40326197aeb81c747 Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Sun, 13 Nov 2022 23:25:43 -0800 Subject: [PATCH 11/15] :sparkles: Implement: Implemented the function of parsing the collection --- package.json | 2 +- samples/package.json | 2 +- src/assistservice.ts | 48 ++++++++++++++++++++++++-------------------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 47849ac..5f2a801 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@crypto-dev/pasar-sdk-development", - "version": "0.0.16", + "version": "0.0.18", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", diff --git a/samples/package.json b/samples/package.json index 68b9a57..50c7a81 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { - "@crypto-dev/pasar-sdk-development": "0.0.16", + "@crypto-dev/pasar-sdk-development": "0.0.17", "@elastosfoundation/elastos-connectivity-sdk-js": "^1.0.23", "@ethersproject/providers": "^5.5.2", "@testing-library/react": "^13.3.0", diff --git a/src/assistservice.ts b/src/assistservice.ts index 8a6e14b..aa8a832 100644 --- a/src/assistservice.ts +++ b/src/assistservice.ts @@ -28,7 +28,7 @@ const getAllListedItems = async (assistUrl: string, earilerThan:number, pageNum } } -const getCollectionInfo = async (assistUrl: string, collectionAddr:string, chainType: ChainType): Promise => { +const getAllCollectionInfo = async (assistUrl: string, collectionAddr:string, chainType: ChainType): Promise => { try { let response = await fetch(`${assistUrl}/api/v1/getCollectionsByWalletAddr?chain=all&walletAddr=${collectionAddr}`); let json = await response.json(); @@ -86,26 +86,7 @@ const getOwnedCollections = async (assistUrl: string, walletAddress: string): Pr let body = data['data']; for (var i = 0; i < body.length; i++) { - let item = body[i]; - let creator = item['creator']; - let data = item['data']; - - let info = new CollectionInfo( - item['token'], - item['chain'], - creator && creator['did'] ? creator['did'] : null, - item['owner'], - item['name'], - item['symbol'] - ); - - info.setSocialLinks(data && data['socials'] ? data['socials'] : null) - .setDescription(data && data['description'] ? data['description'] : null) - .setAvatar(data && data['avatar'] ? data['avatar'] : null) - .setBanner(data && data['background'] ? data['background'] : null) - .setCategory(data && data['category'] ? data['category'] : null) - .setErcType(item['is721'] ? ERCType.ERC721 : ERCType.ERC1155) - + let info = getCollectionInfo(body[i]); collections.push(info); } @@ -115,6 +96,29 @@ const getOwnedCollections = async (assistUrl: string, walletAddress: string): Pr } } +const getCollectionInfo = (itemInfo: any): CollectionInfo => { + let creator = itemInfo['creator']; + let data = itemInfo['data']; + + let collectionInfo = new CollectionInfo( + itemInfo['token'], + itemInfo['chain'], + creator && creator['did'] ? creator['did'] : null, + itemInfo['owner'], + itemInfo['name'], + itemInfo['symbol'] + ); + + collectionInfo.setSocialLinks(data && data['socials'] ? data['socials'] : null) + .setDescription(data && data['description'] ? data['description'] : null) + .setAvatar(data && data['avatar'] ? data['avatar'] : null) + .setBanner(data && data['background'] ? data['background'] : null) + .setCategory(data && data['category'] ? data['category'] : null) + .setErcType(itemInfo['is721'] ? ERCType.ERC721 : ERCType.ERC1155) + + return collectionInfo; +} + const getItemInfo = (itemInfo:any):ItemInfo => { let tokenData = itemInfo['token'] ? itemInfo['token'] : itemInfo; let image = tokenData['image'] ? tokenData['image'] : tokenData['data'] && tokenData['data']['image'] ? tokenData['data']['image'] : null; @@ -227,7 +231,7 @@ const getSoldItems = async (assistUrl: string, walletAddress: string): Promise Date: Sun, 13 Nov 2022 23:43:08 -0800 Subject: [PATCH 12/15] :zap: Update: Updated the feature of getting the collection information --- package.json | 2 +- samples/package.json | 2 +- src/assistservice.ts | 30 ++++++++---------------------- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 5f2a801..f544964 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@crypto-dev/pasar-sdk-development", - "version": "0.0.18", + "version": "0.0.19", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", diff --git a/samples/package.json b/samples/package.json index 50c7a81..0d8e7a2 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { - "@crypto-dev/pasar-sdk-development": "0.0.17", + "@crypto-dev/pasar-sdk-development": "0.0.19", "@elastosfoundation/elastos-connectivity-sdk-js": "^1.0.23", "@ethersproject/providers": "^5.5.2", "@testing-library/react": "^13.3.0", diff --git a/src/assistservice.ts b/src/assistservice.ts index aa8a832..a09956e 100644 --- a/src/assistservice.ts +++ b/src/assistservice.ts @@ -28,32 +28,18 @@ const getAllListedItems = async (assistUrl: string, earilerThan:number, pageNum } } -const getAllCollectionInfo = async (assistUrl: string, collectionAddr:string, chainType: ChainType): Promise => { +const getCollectionInfo = async (assistUrl: string, collectionAddr:string, chainType: ChainType): Promise => { try { - let response = await fetch(`${assistUrl}/api/v1/getCollectionsByWalletAddr?chain=all&walletAddr=${collectionAddr}`); + let response = await fetch(`${assistUrl}/api/v1/getCollectionInfo?chain=${chainType}&collection=${collectionAddr}`); let json = await response.json(); if (json['status'] != 200) { throw new Error("Call API to fetch collection info failed"); } let body = json['data']; - let data = body['tokenJson']['data']; - - let info = new CollectionInfo( - body['token'], - chainType, - body['creatorDid'], - body['owner'], - body['name'], - body['symbol'] - ); - - return info.setSocialLinks(data['socials']) - .setDescription(data['description']) - .setAvatar(data['avatar']) - .setDescription(data['description']) - .setCategory(data['category']) - .setErcType(body['is721'] ? ERCType.ERC721 : ERCType.ERC1155) + + let collectionInfo = parseCollectionInfo(body); + return collectionInfo; }catch (error) { throw new Error(`Failed to get Collection Info (erro: ${error}`); } @@ -86,7 +72,7 @@ const getOwnedCollections = async (assistUrl: string, walletAddress: string): Pr let body = data['data']; for (var i = 0; i < body.length; i++) { - let info = getCollectionInfo(body[i]); + let info = parseCollectionInfo(body[i]); collections.push(info); } @@ -96,7 +82,7 @@ const getOwnedCollections = async (assistUrl: string, walletAddress: string): Pr } } -const getCollectionInfo = (itemInfo: any): CollectionInfo => { +const parseCollectionInfo = (itemInfo: any): CollectionInfo => { let creator = itemInfo['creator']; let data = itemInfo['data']; @@ -231,7 +217,7 @@ const getSoldItems = async (assistUrl: string, walletAddress: string): Promise Date: Mon, 14 Nov 2022 00:45:35 -0800 Subject: [PATCH 13/15] :sparkles: Implement: Implemented the some features on collection --- src/collection/collectioninfo.ts | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/collection/collectioninfo.ts b/src/collection/collectioninfo.ts index 7807b21..da0fc4d 100644 --- a/src/collection/collectioninfo.ts +++ b/src/collection/collectioninfo.ts @@ -17,6 +17,11 @@ class CollectionInfo { private description: string; private ercType: ERCType; private category: Category; + private uri: string; + private items: number; + private owners: number; + private lowestPrice: BigInt; + private tradingVolume: BigInt; constructor(contractAddr: string, network: ChainType, @@ -63,6 +68,31 @@ class CollectionInfo { return this; } + public setUri(uri: string): CollectionInfo { + this.uri = uri; + return this; + } + + public setItems(items: number): CollectionInfo { + this.items = items; + return this; + } + + public setOwners(owners: number): CollectionInfo { + this.owners = owners; + return this; + } + + public setLowestPrice(price: BigInt): CollectionInfo { + this.lowestPrice = price; + return this; + } + + public setTradingVolume(value: BigInt): CollectionInfo { + this.tradingVolume = value; + return this; + } + public getContractAddress(): string { return this.constractAddr; } @@ -110,6 +140,26 @@ class CollectionInfo { public getCategory(): string { return this.category; } + + public getUri(): string { + return this.uri; + } + + public getOwners(): number { + return this.owners; + } + + public getItems(): number { + return this.items; + } + + public getLowestPrice(): BigInt { + return this.lowestPrice; + } + + public getTradingVolume(): BigInt { + return this.tradingVolume; + } } export { From 8f1f73142e84a04f0c799408731897f3540b5e23 Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Mon, 14 Nov 2022 17:18:28 -0800 Subject: [PATCH 14/15] :zap: Update: Updated the feature of parsing the collection information --- package.json | 2 +- samples/package.json | 2 +- src/assistservice.ts | 7 ++++++- src/collection/collectioninfo.ts | 12 ++++++------ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index f544964..ec5cf40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@crypto-dev/pasar-sdk-development", - "version": "0.0.19", + "version": "0.0.20", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js", diff --git a/samples/package.json b/samples/package.json index 0d8e7a2..334e300 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { - "@crypto-dev/pasar-sdk-development": "0.0.19", + "@crypto-dev/pasar-sdk-development": "0.0.20", "@elastosfoundation/elastos-connectivity-sdk-js": "^1.0.23", "@ethersproject/providers": "^5.5.2", "@testing-library/react": "^13.3.0", diff --git a/src/assistservice.ts b/src/assistservice.ts index a09956e..eec3150 100644 --- a/src/assistservice.ts +++ b/src/assistservice.ts @@ -101,8 +101,13 @@ const parseCollectionInfo = (itemInfo: any): CollectionInfo => { .setBanner(data && data['background'] ? data['background'] : null) .setCategory(data && data['category'] ? data['category'] : null) .setErcType(itemInfo['is721'] ? ERCType.ERC721 : ERCType.ERC1155) + .setUri(itemInfo['uri']) + .setItems(itemInfo['items']) + .setOwners(itemInfo['owners']) + .setLowestPrice(itemInfo['lowestPrice']) + .setTradingVolume(itemInfo['tradeVolume']) - return collectionInfo; + return collectionInfo; } const getItemInfo = (itemInfo:any):ItemInfo => { diff --git a/src/collection/collectioninfo.ts b/src/collection/collectioninfo.ts index da0fc4d..519b581 100644 --- a/src/collection/collectioninfo.ts +++ b/src/collection/collectioninfo.ts @@ -20,8 +20,8 @@ class CollectionInfo { private uri: string; private items: number; private owners: number; - private lowestPrice: BigInt; - private tradingVolume: BigInt; + private lowestPrice: bigint; + private tradingVolume: bigint; constructor(contractAddr: string, network: ChainType, @@ -83,12 +83,12 @@ class CollectionInfo { return this; } - public setLowestPrice(price: BigInt): CollectionInfo { + public setLowestPrice(price: bigint): CollectionInfo { this.lowestPrice = price; return this; } - public setTradingVolume(value: BigInt): CollectionInfo { + public setTradingVolume(value: bigint): CollectionInfo { this.tradingVolume = value; return this; } @@ -153,11 +153,11 @@ class CollectionInfo { return this.items; } - public getLowestPrice(): BigInt { + public getLowestPrice(): bigint { return this.lowestPrice; } - public getTradingVolume(): BigInt { + public getTradingVolume(): bigint { return this.tradingVolume; } } From 7db72ba24b07392330cd86b4914b4b16a94a2b94 Mon Sep 17 00:00:00 2001 From: cryptodev0115 Date: Mon, 14 Nov 2022 17:28:55 -0800 Subject: [PATCH 15/15] :zap: Update: Updated the package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ec5cf40..35e743e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@crypto-dev/pasar-sdk-development", - "version": "0.0.20", + "version": "0.0.21", "description": "PasarProtocol NFT Marketplace SDK", "exports": { "node": "./dist/pasar-sdk.browser.js",