|
|
@ -24,66 +24,15 @@ app.get('/api/contracts', (req, res) => {
|
|
|
|
res.status(200).json(ALL_CONTRACTS)
|
|
|
|
res.status(200).json(ALL_CONTRACTS)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
app.get('/api/:contractAddress/offers', (req, res) => {
|
|
|
|
|
|
|
|
const results = [];
|
|
|
|
|
|
|
|
const stmt = db.prepare(`select *
|
|
|
|
|
|
|
|
from events ev
|
|
|
|
|
|
|
|
where contract = '${req.params.contractAddress}'
|
|
|
|
|
|
|
|
collate nocase
|
|
|
|
|
|
|
|
and event_type = 'tokenoffered'
|
|
|
|
|
|
|
|
and not token_id in
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
select token_id from events
|
|
|
|
|
|
|
|
where event_type == 'tokennolongerforsale'
|
|
|
|
|
|
|
|
and token_id = token_id
|
|
|
|
|
|
|
|
and contract = '${req.params.contractAddress}'
|
|
|
|
|
|
|
|
collate nocase
|
|
|
|
|
|
|
|
and tx_date > ev.tx_date
|
|
|
|
|
|
|
|
order by tx_date asc
|
|
|
|
|
|
|
|
limit 1
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
order by tx_date desc
|
|
|
|
|
|
|
|
`);
|
|
|
|
|
|
|
|
for (const entry of stmt.iterate()) {
|
|
|
|
|
|
|
|
results.push(entry);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
res.status(200).json(results);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.get('/api/:contractAddress/bids', (req, res) => {
|
|
|
|
|
|
|
|
const results = [];
|
|
|
|
|
|
|
|
const stmt = db.prepare(`select *
|
|
|
|
|
|
|
|
from events ev
|
|
|
|
|
|
|
|
where contract = '${req.params.contractAddress}'
|
|
|
|
|
|
|
|
collate nocase
|
|
|
|
|
|
|
|
and event_type = 'tokenbidentered'
|
|
|
|
|
|
|
|
and not token_id in
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
select token_id from events
|
|
|
|
|
|
|
|
where event_type == 'tokenbidwithdrawn'
|
|
|
|
|
|
|
|
and token_id = token_id
|
|
|
|
|
|
|
|
and contract = '${req.params.contractAddress}'
|
|
|
|
|
|
|
|
collate nocase
|
|
|
|
|
|
|
|
and tx_date > ev.tx_date
|
|
|
|
|
|
|
|
order by tx_date asc
|
|
|
|
|
|
|
|
limit 1
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
order by tx_date desc
|
|
|
|
|
|
|
|
`);
|
|
|
|
|
|
|
|
for (const entry of stmt.iterate()) {
|
|
|
|
|
|
|
|
results.push(entry);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
res.status(200).json(results);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.get('/api/:contractAddress/events', (req, res) => {
|
|
|
|
app.get('/api/:contractAddress/events', (req, res) => {
|
|
|
|
const results = [];
|
|
|
|
const results = [];
|
|
|
|
const stmt = db.prepare(`select *
|
|
|
|
const stmt = db.prepare(`select *
|
|
|
|
from events
|
|
|
|
from events
|
|
|
|
where contract = '${req.params.contractAddress}'
|
|
|
|
where contract = '${req.params.contractAddress}'
|
|
|
|
collate nocase
|
|
|
|
collate nocase
|
|
|
|
and event_type != 'sale' and event_type != 'transfer'
|
|
|
|
and event_type == 'sale' or event_type == 'transfer'
|
|
|
|
order by tx_date desc
|
|
|
|
order by tx_date desc
|
|
|
|
|
|
|
|
limit 100
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|
for (const entry of stmt.iterate()) {
|
|
|
|
for (const entry of stmt.iterate()) {
|
|
|
|
results.push(entry);
|
|
|
|
results.push(entry);
|
|
|
|