@poap-xyz/poaps
Advanced tools
Comparing version 0.0.35 to 0.0.36-beta-v0.0.16
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@poap-xyz/utils')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@poap-xyz/utils'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@poap-xyz/poaps"] = {}, global.utils)); | ||
})(this, (function (exports, utils) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@poap-xyz/poaps"] = {})); | ||
})(this, (function (exports) { 'use strict'; | ||
@@ -57,2 +57,59 @@ exports.PoapsSortFields = void 0; | ||
var Chain; | ||
(function (Chain) { | ||
Chain["Ethereum"] = "mainnet"; | ||
Chain["Gnosis"] = "xdai"; | ||
})(Chain || (Chain = {})); | ||
var Order; | ||
(function (Order) { | ||
Order["ASC"] = "asc"; | ||
Order["DESC"] = "desc"; | ||
})(Order || (Order = {})); | ||
class PaginatedResult { | ||
constructor(items, nextCursor) { | ||
this.items = items; | ||
this.nextCursor = nextCursor; | ||
} | ||
} | ||
function nextCursor(length, limit, offset) { | ||
const endIndex = offset + length; | ||
return endIndex < offset + limit ? null : endIndex; | ||
} | ||
function creatUndefinedOrder(key, value) { | ||
return key && value ? { [key]: value } : {}; | ||
} | ||
function creatEqFilter(key, value) { | ||
return value ? { [key]: { _eq: value } } : {}; | ||
} | ||
function filterZeroAddress(filter) { | ||
return filter ? { _neq: '0x0000000000000000000000000000000000000000' } : {}; | ||
} | ||
function creatAddressFilter(key, filter, value) { | ||
const addressFilter = { | ||
[key]: { | ||
...filterZeroAddress(filter), | ||
}, | ||
}; | ||
if (value) { | ||
addressFilter[key]._eq = value.toLocaleLowerCase(); | ||
} | ||
return filter || value ? addressFilter : {}; | ||
} | ||
function createInFilter(key, values) { | ||
return values && values.length ? { [key]: { _in: values } } : {}; | ||
} | ||
function createBetweenFilter(key, from, to) { | ||
const dateFilter = {}; | ||
if (from) { | ||
dateFilter._gte = from; | ||
} | ||
if (to) { | ||
dateFilter._lte = to; | ||
} | ||
return from || to ? { [key]: dateFilter } : {}; | ||
} | ||
class PoapsClient { | ||
@@ -67,9 +124,9 @@ constructor(CompassProvider) { | ||
offset, | ||
orderBy: utils.creatUndefinedOrder(sort_field, sort_dir), | ||
orderBy: creatUndefinedOrder(sort_field, sort_dir), | ||
where: { | ||
...utils.creatAddressFilter('collector_address', filter_by_zero_address, collector_address), | ||
...utils.creatEqFilter('chain', chain), | ||
...utils.creatEqFilter('drop_id', drop_id), | ||
...utils.createBetweenFilter('minted_on', minted_date_from, minted_date_to), | ||
...utils.createInFilter('id', ids), | ||
...creatAddressFilter('collector_address', filter_by_zero_address, collector_address), | ||
...creatEqFilter('chain', chain), | ||
...creatEqFilter('drop_id', drop_id), | ||
...createBetweenFilter('minted_on', minted_date_from, minted_date_to), | ||
...createInFilter('id', ids), | ||
}, | ||
@@ -92,3 +149,3 @@ }; | ||
}); | ||
return new utils.PaginatedResult(poaps, utils.nextCursor(poaps.length, limit, offset)); | ||
return new PaginatedResult(poaps, nextCursor(poaps.length, limit, offset)); | ||
} | ||
@@ -95,0 +152,0 @@ } |
{ | ||
"name": "@poap-xyz/poaps", | ||
"version": "0.0.35", | ||
"version": "0.0.36-beta-v0.0.16", | ||
"description": "Poaps module for the poap.js library", | ||
@@ -28,9 +28,7 @@ "main": "dist/cjs/index.cjs", | ||
}, | ||
"devDependencies": { | ||
"rollup": "^3.20.2" | ||
"dependencies": { | ||
"@poap-xyz/providers": "0.0.36-beta-v0.0.16", | ||
"@poap-xyz/utils": "0.0.36-beta-v0.0.16" | ||
}, | ||
"peerDependencies": { | ||
"@poap-xyz/providers": "0.0.35", | ||
"@poap-xyz/utils": "0.0.35" | ||
} | ||
"stableVersion": "0.0.35" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
59932
0
672
+ Added@poap-xyz/providers@0.0.36-beta-v0.0.16(transitive)
+ Added@poap-xyz/utils@0.0.36-beta-v0.0.16(transitive)
- Removed@poap-xyz/providers@0.0.35(transitive)
- Removed@poap-xyz/utils@0.0.35(transitive)