@@ -3,8 +3,7 @@ import { Database } from "@tableland/sdk";
33
44const db = new Database ( ) ;
55
6- // Type Simplehash Blur rigs
7- type SimplehashBlurRig = {
6+ type Rig = {
87 id : string ;
98 permalink : string ;
109 bundle_item_number : string | null ;
@@ -29,75 +28,11 @@ type SimplehashBlurRig = {
2928 is_private : boolean ;
3029} ;
3130
32- // OpenSea API response
33- type OsRig = {
34- order_hash : string ;
35- chain : string ;
36- type : string ;
37- price : {
38- current : {
39- currency : string ;
40- decimals : number ;
41- value : string ;
42- } ;
43- } ;
44- protocol_data : {
45- parameters : {
46- offerer : string ;
47- offer : Array < {
48- itemType : number ;
49- token : string ;
50- identifierOrCriteria : string ; // Rig tokenId
51- startAmount : string ;
52- endAmount : string ;
53- } > ;
54- consideration : Array < {
55- itemType : number ;
56- token : string ;
57- identifierOrCriteria : string ;
58- startAmount : string ;
59- endAmount : string ;
60- recipient : string ;
61- } > ;
62- startTime : string ;
63- endTime : string ;
64- orderType : number ;
65- zone : string ;
66- zoneHash : string ;
67- salt : string ;
68- conduitKey : string ;
69- totalOrginalConsiderationItems : number ;
70- counter : number ;
71- } ;
72- signature : string | null ;
73- } ;
74- protocol_address : string ;
75- } ;
76-
77- // LooksRare API
78- type LooksRareRig = {
79- id : string ;
80- hash : string ;
81- quoteType : number ;
82- globalNonce : string ;
83- subsetNonce : string ;
84- orderNonce : string ;
85- collection : string ;
86- currency : string ;
87- signer : string ;
88- strategyId : number ;
89- collectionType : number ;
90- startTime : number ;
91- endTime : number ;
92- price : string ;
93- additionalParameters : string ;
94- signature : string ;
95- createdAt : string ;
96- merkleRoot : null ;
97- merkleProof : null ;
98- amounts : Array < string > ;
99- itemIds : Array < string > ; // Rig tokenId
100- status : string ;
31+ type Res = {
32+ next_cursor : string | null ;
33+ next : string | null ;
34+ previous : string | null ;
35+ listings : Rig [ ] ;
10136} ;
10237
10338async function getInFlight ( rigIds : number [ ] ) : Promise < number [ ] > {
@@ -116,6 +51,27 @@ async function getInFlight(rigIds: number[]): Promise<number[]> {
11651 return ids ;
11752}
11853
54+ async function getListedRigs ( nextCursor ?: string ) : Promise < Res > {
55+ const params = new URLSearchParams ( {
56+ limit : "50" ,
57+ } ) ;
58+ if ( nextCursor ) {
59+ params . append ( "cursor" , nextCursor ) ;
60+ }
61+ const req = await fetch (
62+ `https://api.simplehash.com/api/v0/nfts/listings/ethereum/${ rigsDeployment . contractAddress } ?` +
63+ params ,
64+ {
65+ headers : {
66+ accept : "application/json" ,
67+ "X-API-KEY" : process . env . SIMPLEHASH_API_KEY ! ,
68+ } ,
69+ }
70+ ) ;
71+ const res : Res = await req . json ( ) ;
72+ return res ;
73+ }
74+
11975async function main ( ) {
12076 console . log (
12177 `\nGetting listed rigs that are in-flight on '${ network . name } '...`
@@ -127,71 +83,29 @@ async function main() {
12783 }
12884 console . log ( `Using address '${ rigsDeployment . contractAddress } '` ) ;
12985
130- // Get listings on Blur
131- const blurReq = await fetch (
132- `https://api.simplehash.com/api/v0/nfts/listings/ethereum/${ rigsDeployment . contractAddress } ` +
133- new URLSearchParams ( {
134- marketplaces : "blur" ,
135- limit : "50" , // Note: max is 50 listings; we can assume this won't be exceeded on a single marketplace
136- } ) ,
137- {
138- headers : {
139- "X-API-KEY" : process . env . OPENBLUR_API_KEY ! ,
140- } ,
141- }
142- ) ;
143- const blurRes = await blurReq . json ( ) ;
144- const blurListed : SimplehashBlurRig [ ] = blurRes . listings || [ ] ;
145-
146- // Get listings on OpenSea
147- const osSlug = "tableland-rigs" ; // Must query by OS slug, not contract address
148- const osReq = await fetch (
149- `https://api.opensea.io/v2/listings/collection/${ osSlug } /all` ,
150- {
151- headers : {
152- accept : "application/json" ,
153- "X-API-KEY" : process . env . OPENSEA_API_KEY ! ,
154- } ,
86+ let listed : Rig [ ] = [ ] ;
87+ let nextCursor : string | null = null ;
88+ do {
89+ let res : Res ;
90+ if ( ! nextCursor ) {
91+ res = await getListedRigs ( ) ;
92+ } else {
93+ res = await getListedRigs ( nextCursor ) ;
15594 }
156- ) ;
157- const osRes = await osReq . json ( ) ;
158- const osListed : OsRig [ ] = osRes . listings ;
159-
160- // Get listings on LooksRare
161- const lrReq = await fetch (
162- `https://api.looksrare.org/api/v2/orders?quoteType=1&collection=${ rigsDeployment . contractAddress } &status=VALID` ,
163- {
164- headers : {
165- accept : "application/json" ,
166- "X-Looks-Api-Key" : process . env . LOOKSRARE_API_KEY ! ,
167- } ,
168- }
169- ) ;
170- const lrRes = await lrReq . json ( ) ;
171- const lrListed : LooksRareRig [ ] = lrRes . data ;
95+ listed = [ ...listed , ...( res . listings || [ ] ) ] ;
96+ nextCursor = res . next_cursor ;
97+ } while ( nextCursor ) ;
17298
173- // Check if Rigs are in-flight on each marketplace
174- const blurIds = blurListed . map ( ( l ) => {
99+ // Check if Rigs are in-flight
100+ const ids = listed . map ( ( l ) => {
175101 // Parse tokenId from nft_id (e.g. `2359` from `ethereum.<contract>.2359`)
176102 const tokenId = l . nft_id . split ( "." ) [ 2 ] ;
177103 return parseInt ( tokenId ) ;
178104 } ) ;
179- const osIds =
180- osListed . map ( ( l ) => {
181- return parseInt ( l . protocol_data . parameters . offer [ 0 ] . identifierOrCriteria ) ;
182- } ) || [ ] ;
183- const lrIds =
184- lrListed . map ( ( l ) => {
185- return parseInt ( l . itemIds [ 0 ] ) ;
186- } ) || [ ] ;
187- const blurToPark = await getInFlight ( blurIds ) ;
188- const osToPark = await getInFlight ( osIds ) ;
189- const lrToPark = await getInFlight ( lrIds ) ;
105+ const toPark = await getInFlight ( ids ) ;
190106 console . log (
191107 `----\nForce park Rigs:\n` ,
192- `Blur: ${ blurToPark . length > 0 ? blurToPark . join ( "," ) : "none" } \n` ,
193- `OpenSea: ${ osToPark . length > 0 ? osToPark . join ( "," ) : "none" } \n` ,
194- `LooksRare: ${ lrToPark . length > 0 ? lrToPark . join ( "," ) : "none" } `
108+ `IDs: ${ toPark . length > 0 ? toPark . join ( "," ) : "none" } \n`
195109 ) ;
196110}
197111
0 commit comments