@poap-xyz/poaps
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -13,3 +13,3 @@ export declare class POAPReservation { | ||
} | ||
export interface POAPReservationProperties { | ||
interface POAPReservationProperties { | ||
email: string; | ||
@@ -25,1 +25,2 @@ dropId: number; | ||
} | ||
export {}; |
@@ -1,5 +0,5 @@ | ||
export { PoapsSortFields, FetchPoapsInput } from './types/input'; | ||
export { PoapMintStatus } from './types/response'; | ||
export { PoapsSortFields } from './types/PoapsSortFields'; | ||
export { PoapMintStatus } from './types/PoapMintStatus'; | ||
export { PoapsClient } from './PoapsClient'; | ||
export { POAP } from './domain/Poap'; | ||
export { POAP } from './domain/POAP'; | ||
export { POAPReservation } from './domain/POAPReservation'; | ||
@@ -6,0 +6,0 @@ export { FinishedWithError } from './errors/FinishedWithError'; |
import { CompassProvider, TokensApiProvider, Transaction } from '@poap-xyz/providers'; | ||
import { POAP } from './domain/Poap'; | ||
import { PaginatedResult } from '@poap-xyz/utils'; | ||
import { POAP } from './domain/POAP'; | ||
import { POAPReservation } from './domain/POAPReservation'; | ||
import { EmailReservationInput, FetchPoapsInput, PoapMintStatus, WalletMintInput } from './types'; | ||
import { PaginatedResult } from '@poap-xyz/utils'; | ||
import { FetchPoapsInput } from './types/FetchPoapsInput'; | ||
import { PoapMintStatus } from './types/PoapMintStatus'; | ||
import { WalletMintInput } from './types/WalletMintInput'; | ||
import { EmailReservationInput } from './types/EmailReservationInput'; | ||
export declare class PoapsClient { | ||
@@ -7,0 +10,0 @@ private compassProvider; |
import { TokensApiProvider } from '@poap-xyz/providers'; | ||
import { RetryableTask } from './RetryableTask'; | ||
import { PoapMintStatus } from '../types'; | ||
import { PoapMintStatus } from '../types/PoapMintStatus'; | ||
export declare class PoapIndexed extends RetryableTask { | ||
private mintCode; | ||
constructor(mintCode: string, tokensApiProvider: TokensApiProvider); | ||
constructor(tokensApiProvider: TokensApiProvider, mintCode: string); | ||
waitPoapIndexed(): Promise<PoapMintStatus>; | ||
} |
@@ -13,3 +13,3 @@ export declare class POAPReservation { | ||
} | ||
export interface POAPReservationProperties { | ||
interface POAPReservationProperties { | ||
email: string; | ||
@@ -25,1 +25,2 @@ dropId: number; | ||
} | ||
export {}; |
@@ -1,5 +0,5 @@ | ||
export { PoapsSortFields, FetchPoapsInput } from './types/input'; | ||
export { PoapMintStatus } from './types/response'; | ||
export { PoapsSortFields } from './types/PoapsSortFields'; | ||
export { PoapMintStatus } from './types/PoapMintStatus'; | ||
export { PoapsClient } from './PoapsClient'; | ||
export { POAP } from './domain/Poap'; | ||
export { POAP } from './domain/POAP'; | ||
export { POAPReservation } from './domain/POAPReservation'; | ||
@@ -6,0 +6,0 @@ export { FinishedWithError } from './errors/FinishedWithError'; |
import { CompassProvider, TokensApiProvider, Transaction } from '@poap-xyz/providers'; | ||
import { POAP } from './domain/Poap'; | ||
import { PaginatedResult } from '@poap-xyz/utils'; | ||
import { POAP } from './domain/POAP'; | ||
import { POAPReservation } from './domain/POAPReservation'; | ||
import { EmailReservationInput, FetchPoapsInput, PoapMintStatus, WalletMintInput } from './types'; | ||
import { PaginatedResult } from '@poap-xyz/utils'; | ||
import { FetchPoapsInput } from './types/FetchPoapsInput'; | ||
import { PoapMintStatus } from './types/PoapMintStatus'; | ||
import { WalletMintInput } from './types/WalletMintInput'; | ||
import { EmailReservationInput } from './types/EmailReservationInput'; | ||
export declare class PoapsClient { | ||
@@ -7,0 +10,0 @@ private compassProvider; |
import { TokensApiProvider } from '@poap-xyz/providers'; | ||
import { RetryableTask } from './RetryableTask'; | ||
import { PoapMintStatus } from '../types'; | ||
import { PoapMintStatus } from '../types/PoapMintStatus'; | ||
export declare class PoapIndexed extends RetryableTask { | ||
private mintCode; | ||
constructor(mintCode: string, tokensApiProvider: TokensApiProvider); | ||
constructor(tokensApiProvider: TokensApiProvider, mintCode: string); | ||
waitPoapIndexed(): Promise<PoapMintStatus>; | ||
} |
@@ -13,3 +13,3 @@ export declare class POAPReservation { | ||
} | ||
export interface POAPReservationProperties { | ||
interface POAPReservationProperties { | ||
email: string; | ||
@@ -25,1 +25,2 @@ dropId: number; | ||
} | ||
export {}; |
@@ -1,5 +0,5 @@ | ||
export { PoapsSortFields, FetchPoapsInput } from './types/input'; | ||
export { PoapMintStatus } from './types/response'; | ||
export { PoapsSortFields } from './types/PoapsSortFields'; | ||
export { PoapMintStatus } from './types/PoapMintStatus'; | ||
export { PoapsClient } from './PoapsClient'; | ||
export { POAP } from './domain/Poap'; | ||
export { POAP } from './domain/POAP'; | ||
export { POAPReservation } from './domain/POAPReservation'; | ||
@@ -6,0 +6,0 @@ export { FinishedWithError } from './errors/FinishedWithError'; |
@@ -13,60 +13,2 @@ (function (global, factory) { | ||
class POAP { | ||
constructor(properties) { | ||
this.id = properties.id; | ||
this.collectorAddress = properties.collectorAddress; | ||
this.mintedOn = properties.mintedOn; | ||
this.dropId = properties.dropId; | ||
this.transferCount = properties.transferCount; | ||
this.imageUrl = properties.imageUrl; | ||
this.city = properties.city; | ||
this.country = properties.country; | ||
this.description = properties.description; | ||
this.startDate = properties.startDate; | ||
this.endDate = properties.endDate; | ||
this.name = properties.name; | ||
} | ||
} | ||
class POAPReservation { | ||
constructor(properties) { | ||
this.email = properties.email; | ||
this.dropId = properties.dropId; | ||
this.imageUrl = properties.imageUrl; | ||
this.city = properties.city; | ||
this.country = properties.country; | ||
this.description = properties.description; | ||
this.startDate = properties.startDate; | ||
this.endDate = properties.endDate; | ||
this.name = properties.name; | ||
} | ||
} | ||
const PAGINATED_POAPS_QUERY = ` | ||
query PaginatedPoaps( | ||
$limit: Int! | ||
$offset: Int! | ||
$orderBy: [poaps_order_by!] | ||
$where: poaps_bool_exp | ||
) { | ||
poaps(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) { | ||
chain | ||
collector_address | ||
drop_id | ||
id | ||
minted_on | ||
transfer_count | ||
drop { | ||
image_url | ||
city | ||
country | ||
description | ||
start_date | ||
end_date | ||
name | ||
} | ||
} | ||
} | ||
`; | ||
class PaginatedResult { | ||
@@ -160,2 +102,78 @@ constructor(items, nextCursor) { | ||
class POAP { | ||
static fromCompass(response) { | ||
const mintedOn = new Date(0); | ||
mintedOn.setUTCSeconds(response.minted_on); | ||
return new POAP({ | ||
id: Number(response.id), | ||
collectorAddress: response.collector_address, | ||
transferCount: response.transfer_count, | ||
mintedOn, | ||
dropId: Number(response.drop_id), | ||
imageUrl: response.drop.image_url, | ||
city: response.drop.city, | ||
country: response.drop.country, | ||
description: response.drop.description, | ||
startDate: new Date(response.drop.start_date), | ||
endDate: new Date(response.drop.end_date), | ||
name: response.drop.name, | ||
}); | ||
} | ||
constructor(properties) { | ||
this.id = properties.id; | ||
this.collectorAddress = properties.collectorAddress; | ||
this.mintedOn = properties.mintedOn; | ||
this.dropId = properties.dropId; | ||
this.transferCount = properties.transferCount; | ||
this.imageUrl = properties.imageUrl; | ||
this.city = properties.city; | ||
this.country = properties.country; | ||
this.description = properties.description; | ||
this.startDate = properties.startDate; | ||
this.endDate = properties.endDate; | ||
this.name = properties.name; | ||
} | ||
} | ||
class POAPReservation { | ||
constructor(properties) { | ||
this.email = properties.email; | ||
this.dropId = properties.dropId; | ||
this.imageUrl = properties.imageUrl; | ||
this.city = properties.city; | ||
this.country = properties.country; | ||
this.description = properties.description; | ||
this.startDate = properties.startDate; | ||
this.endDate = properties.endDate; | ||
this.name = properties.name; | ||
} | ||
} | ||
const PAGINATED_POAPS_QUERY = ` | ||
query PaginatedPoaps( | ||
$limit: Int! | ||
$offset: Int! | ||
$orderBy: [poaps_order_by!] | ||
$where: poaps_bool_exp | ||
) { | ||
poaps(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) { | ||
chain | ||
collector_address | ||
drop_id | ||
id | ||
minted_on | ||
transfer_count | ||
drop { | ||
image_url | ||
city | ||
country | ||
description | ||
start_date | ||
end_date | ||
name | ||
} | ||
} | ||
} | ||
`; | ||
class CodeAlreadyMintedError extends Error { | ||
@@ -250,3 +268,3 @@ constructor(code) { | ||
class PoapIndexed extends RetryableTask { | ||
constructor(mintCode, tokensApiProvider) { | ||
constructor(tokensApiProvider, mintCode) { | ||
super(tokensApiProvider); | ||
@@ -293,21 +311,3 @@ this.mintCode = mintCode; | ||
const { data } = await this.compassProvider.request(PAGINATED_POAPS_QUERY, variables); | ||
const poaps = data.poaps.map((poap) => { | ||
const { drop } = poap; | ||
const mintedOn = new Date(0); | ||
mintedOn.setUTCSeconds(poap.minted_on); | ||
return new POAP({ | ||
id: Number(poap.id), | ||
collectorAddress: poap.collector_address, | ||
transferCount: poap.transfer_count, | ||
mintedOn, | ||
dropId: Number(poap.drop_id), | ||
imageUrl: drop.image_url, | ||
city: drop.city, | ||
country: drop.country, | ||
description: drop.description, | ||
startDate: new Date(drop.start_date), | ||
name: drop.name, | ||
endDate: new Date(drop.end_date), | ||
}); | ||
}); | ||
const poaps = data.poaps.map((poap) => POAP.fromCompass(poap)); | ||
return new PaginatedResult(poaps, nextCursor(poaps.length, limit, offset)); | ||
@@ -333,3 +333,3 @@ } | ||
async waitPoapIndexed(mintCode) { | ||
const checker = new PoapIndexed(mintCode, this.tokensApiProvider); | ||
const checker = new PoapIndexed(this.tokensApiProvider, mintCode); | ||
return await checker.waitPoapIndexed(); | ||
@@ -336,0 +336,0 @@ } |
import { CompassProvider, TokensApiProvider, Transaction } from '@poap-xyz/providers'; | ||
import { POAP } from './domain/Poap'; | ||
import { PaginatedResult } from '@poap-xyz/utils'; | ||
import { POAP } from './domain/POAP'; | ||
import { POAPReservation } from './domain/POAPReservation'; | ||
import { EmailReservationInput, FetchPoapsInput, PoapMintStatus, WalletMintInput } from './types'; | ||
import { PaginatedResult } from '@poap-xyz/utils'; | ||
import { FetchPoapsInput } from './types/FetchPoapsInput'; | ||
import { PoapMintStatus } from './types/PoapMintStatus'; | ||
import { WalletMintInput } from './types/WalletMintInput'; | ||
import { EmailReservationInput } from './types/EmailReservationInput'; | ||
export declare class PoapsClient { | ||
@@ -7,0 +10,0 @@ private compassProvider; |
import { TokensApiProvider } from '@poap-xyz/providers'; | ||
import { RetryableTask } from './RetryableTask'; | ||
import { PoapMintStatus } from '../types'; | ||
import { PoapMintStatus } from '../types/PoapMintStatus'; | ||
export declare class PoapIndexed extends RetryableTask { | ||
private mintCode; | ||
constructor(mintCode: string, tokensApiProvider: TokensApiProvider); | ||
constructor(tokensApiProvider: TokensApiProvider, mintCode: string); | ||
waitPoapIndexed(): Promise<PoapMintStatus>; | ||
} |
{ | ||
"name": "@poap-xyz/poaps", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Poaps module for the poap.js library", | ||
@@ -29,4 +29,4 @@ "main": "dist/cjs/index.cjs", | ||
"dependencies": { | ||
"@poap-xyz/providers": "0.4.0", | ||
"@poap-xyz/utils": "0.4.0" | ||
"@poap-xyz/providers": "0.5.0", | ||
"@poap-xyz/utils": "0.5.0" | ||
}, | ||
@@ -33,0 +33,0 @@ "engines": { |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1621
271262
58
+ Added@poap-xyz/providers@0.5.0(transitive)
+ Added@poap-xyz/utils@0.5.0(transitive)
- Removed@poap-xyz/providers@0.4.0(transitive)
- Removed@poap-xyz/utils@0.4.0(transitive)
Updated@poap-xyz/providers@0.5.0
Updated@poap-xyz/utils@0.5.0