@poap-xyz/poaps
Advanced tools
| import { PoapsResponse } from '../queries/PaginatedPoaps'; | ||
| export declare class POAP { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| endDate: Date; | ||
| name: string; | ||
| static fromCompass(response: PoapsResponse): POAP; | ||
| constructor(properties: PoapProperties); | ||
| } | ||
| interface PoapProperties { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| endDate: Date; | ||
| name: string; | ||
| } | ||
| export {}; |
| export interface EmailReservationInput { | ||
| mintCode: string; | ||
| email: string; | ||
| sendEmail?: boolean; | ||
| } |
| import { Order, Chain, PaginationInput } from '@poap-xyz/utils'; | ||
| import { PoapsSortFields } from './PoapsSortFields'; | ||
| export interface FetchPoapsInput extends PaginationInput { | ||
| name?: string; | ||
| chain?: Chain; | ||
| mintedDateFrom?: string; | ||
| mintedDateTo?: string; | ||
| ids?: number[]; | ||
| collectorAddress?: string; | ||
| dropId?: number; | ||
| sortField?: PoapsSortFields; | ||
| sortDir?: Order; | ||
| filterZeroAddress?: boolean; | ||
| filterDeadAddress?: boolean; | ||
| } |
| export interface PoapMintStatus { | ||
| minted: boolean; | ||
| isActive: boolean; | ||
| secretCode: string; | ||
| poapId: number; | ||
| } |
| export declare enum PoapsSortFields { | ||
| MintedOn = "minted_on", | ||
| Id = "id" | ||
| } |
| export interface WalletMintInput { | ||
| mintCode: string; | ||
| address: string; | ||
| } |
| import { PoapsResponse } from '../queries/PaginatedPoaps'; | ||
| export declare class POAP { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| endDate: Date; | ||
| name: string; | ||
| static fromCompass(response: PoapsResponse): POAP; | ||
| constructor(properties: PoapProperties); | ||
| } | ||
| interface PoapProperties { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| endDate: Date; | ||
| name: string; | ||
| } | ||
| export {}; |
| export interface EmailReservationInput { | ||
| mintCode: string; | ||
| email: string; | ||
| sendEmail?: boolean; | ||
| } |
| import { Order, Chain, PaginationInput } from '@poap-xyz/utils'; | ||
| import { PoapsSortFields } from './PoapsSortFields'; | ||
| export interface FetchPoapsInput extends PaginationInput { | ||
| name?: string; | ||
| chain?: Chain; | ||
| mintedDateFrom?: string; | ||
| mintedDateTo?: string; | ||
| ids?: number[]; | ||
| collectorAddress?: string; | ||
| dropId?: number; | ||
| sortField?: PoapsSortFields; | ||
| sortDir?: Order; | ||
| filterZeroAddress?: boolean; | ||
| filterDeadAddress?: boolean; | ||
| } |
| export interface PoapMintStatus { | ||
| minted: boolean; | ||
| isActive: boolean; | ||
| secretCode: string; | ||
| poapId: number; | ||
| } |
| export declare enum PoapsSortFields { | ||
| MintedOn = "minted_on", | ||
| Id = "id" | ||
| } |
| export interface WalletMintInput { | ||
| mintCode: string; | ||
| address: string; | ||
| } |
| import { PoapsResponse } from '../queries/PaginatedPoaps'; | ||
| export declare class POAP { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| endDate: Date; | ||
| name: string; | ||
| static fromCompass(response: PoapsResponse): POAP; | ||
| constructor(properties: PoapProperties); | ||
| } | ||
| interface PoapProperties { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| endDate: Date; | ||
| name: string; | ||
| } | ||
| export {}; |
| export interface EmailReservationInput { | ||
| mintCode: string; | ||
| email: string; | ||
| sendEmail?: boolean; | ||
| } |
| import { Order, Chain, PaginationInput } from '@poap-xyz/utils'; | ||
| import { PoapsSortFields } from './PoapsSortFields'; | ||
| export interface FetchPoapsInput extends PaginationInput { | ||
| name?: string; | ||
| chain?: Chain; | ||
| mintedDateFrom?: string; | ||
| mintedDateTo?: string; | ||
| ids?: number[]; | ||
| collectorAddress?: string; | ||
| dropId?: number; | ||
| sortField?: PoapsSortFields; | ||
| sortDir?: Order; | ||
| filterZeroAddress?: boolean; | ||
| filterDeadAddress?: boolean; | ||
| } |
| export interface PoapMintStatus { | ||
| minted: boolean; | ||
| isActive: boolean; | ||
| secretCode: string; | ||
| poapId: number; | ||
| } |
| export declare enum PoapsSortFields { | ||
| MintedOn = "minted_on", | ||
| Id = "id" | ||
| } |
| export interface WalletMintInput { | ||
| mintCode: string; | ||
| address: string; | ||
| } |
@@ -13,3 +13,3 @@ export declare class POAPReservation { | ||
| } | ||
| export interface POAPReservationProperties { | ||
| interface POAPReservationProperties { | ||
| email: string; | ||
@@ -25,1 +25,2 @@ dropId: number; | ||
| } | ||
| export {}; |
+79
-79
@@ -11,60 +11,2 @@ 'use strict'; | ||
| 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 { | ||
@@ -158,2 +100,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 { | ||
@@ -248,3 +266,3 @@ constructor(code) { | ||
| class PoapIndexed extends RetryableTask { | ||
| constructor(mintCode, tokensApiProvider) { | ||
| constructor(tokensApiProvider, mintCode) { | ||
| super(tokensApiProvider); | ||
@@ -291,21 +309,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)); | ||
@@ -331,3 +331,3 @@ } | ||
| async waitPoapIndexed(mintCode) { | ||
| const checker = new PoapIndexed(mintCode, this.tokensApiProvider); | ||
| const checker = new PoapIndexed(this.tokensApiProvider, mintCode); | ||
| return await checker.waitPoapIndexed(); | ||
@@ -334,0 +334,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.cjs","sources":["../../src/types/input.ts","../../src/domain/Poap.ts","../../src/domain/POAPReservation.ts","../../src/queries/PaginatedPoaps.ts","../../../utils/dist/esm/index.mjs","../../src/errors/CodeAlreadyMintedError.ts","../../src/errors/CodeExpiredError.ts","../../../providers/dist/esm/index.mjs","../../src/errors/FinishedWithError.ts","../../src/utils/RetryableTask.ts","../../src/utils/MintChecker.ts","../../src/utils/PoapIndexed.ts","../../src/PoapsClient.ts"],"sourcesContent":["import { Order, Chain, PaginationInput } from '@poap-xyz/utils';\n\n/**\n * Enum to define available fields for sorting POAPs.\n *\n * @export\n * @enum {string}\n */\nexport enum PoapsSortFields {\n /** Represents sorting by the date when a POAP was minted. */\n MintedOn = 'minted_on',\n /** Represents sorting by the ID of a POAP. */\n Id = 'id',\n}\n\n/**\n * Represents the input fields for fetching POAPs.\n * This interface extends `PaginationInput` to provide pagination capability.\n *\n * @export\n * @interface FetchPoapsInput\n * @extends {PaginationInput}\n */\nexport interface FetchPoapsInput extends PaginationInput {\n /** Optional filter for the name of a POAP. */\n name?: string;\n /** Optional filter for the blockchain chain of a POAP. */\n chain?: Chain;\n /** Optional filter for the start date when a POAP was minted. */\n mintedDateFrom?: string;\n /** Optional filter for the end date when a POAP was minted. */\n mintedDateTo?: string;\n /** Optional filter for specific POAP IDs. */\n ids?: number[];\n /** Optional filter for the collector's address. */\n collectorAddress?: string;\n /** Optional filter for a specific drop ID. */\n dropId?: number;\n /** Field by which to sort the results. */\n sortField?: PoapsSortFields;\n /** Direction in which to sort the results. */\n sortDir?: Order;\n /** Filter to include/exclude POAPs with zero addresses. */\n filterZeroAddress?: boolean;\n /** Filter out dead addresses? */\n filterDeadAddress?: boolean;\n}\n\n/**\n * Represents the input fields required to mint a POAP for a wallet.\n *\n * @export\n * @interface WalletMintInput\n */\nexport interface WalletMintInput {\n mintCode: string;\n address: string;\n}\n\n/**\n * Represents the input fields required to reserve a POAP via email.\n *\n * @export\n * @interface EmailReservationInput\n */\nexport interface EmailReservationInput {\n mintCode: string;\n email: string;\n sendEmail?: boolean;\n}\n","/* eslint-disable max-statements */\nexport class POAP {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n constructor(properties: PoapProperties) {\n this.id = properties.id;\n this.collectorAddress = properties.collectorAddress;\n this.mintedOn = properties.mintedOn;\n this.dropId = properties.dropId;\n this.transferCount = properties.transferCount;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\nexport interface PoapProperties {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n name: string;\n endDate: Date;\n}\n","/* eslint-disable max-statements */\nexport class POAPReservation {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n constructor(properties: POAPReservationProperties) {\n this.email = properties.email;\n this.dropId = properties.dropId;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\nexport interface POAPReservationProperties {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n name: string;\n endDate: Date;\n}\n","import {\n FilterVariables,\n OrderByVariables,\n PaginatedVariables,\n} from '@poap-xyz/utils';\n\nexport const PAGINATED_POAPS_QUERY = `\n query PaginatedPoaps(\n $limit: Int!\n $offset: Int!\n $orderBy: [poaps_order_by!]\n $where: poaps_bool_exp\n ) {\n poaps(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) {\n chain\n collector_address\n drop_id\n id\n minted_on\n transfer_count\n drop {\n image_url\n city\n country\n description\n start_date\n end_date\n name\n }\n }\n }\n`;\n\nexport interface PoapsResponse {\n id: number;\n collector_address: string;\n transfer_count: number;\n minted_on: number;\n drop_id: number;\n drop: {\n image_url: string;\n city: string;\n country: string;\n description: string;\n start_date: string;\n end_date: string;\n name: string;\n };\n}\n\nexport interface PaginatedPoapsResponse {\n poaps: PoapsResponse[];\n}\n\nexport type PaginatedPoapsVariables = FilterVariables &\n OrderByVariables &\n PaginatedVariables;\n","class PaginatedResult {\n constructor(items, nextCursor) {\n this.items = items;\n this.nextCursor = nextCursor;\n }\n}\n\nvar Order;\n(function (Order) {\n Order[\"ASC\"] = \"asc\";\n Order[\"DESC\"] = \"desc\";\n})(Order || (Order = {}));\n\nvar Chain;\n(function (Chain) {\n Chain[\"Ethereum\"] = \"mainnet\";\n Chain[\"Gnosis\"] = \"xdai\";\n})(Chain || (Chain = {}));\n\nvar TransactionRequestStatus;\n(function (TransactionRequestStatus) {\n TransactionRequestStatus[\"PENDING\"] = \"PENDING\";\n TransactionRequestStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n TransactionRequestStatus[\"FINISH\"] = \"FINISH\";\n TransactionRequestStatus[\"FINISH_WITH_ERROR\"] = \"FINISH_WITH_ERROR\";\n})(TransactionRequestStatus || (TransactionRequestStatus = {}));\n\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\nconst DEAD_ADDRESS = '0x000000000000000000000000000000000000dead';\n\nfunction nextCursor(length, limit, offset) {\n const endIndex = offset + length;\n return endIndex < offset + limit ? null : endIndex;\n}\n\nfunction createField(keys, value) {\n return keys.split('.').reduceRight((prev, key) => ({\n [key]: prev,\n }), value);\n}\n\nfunction createLikeFilter(key, value) {\n return value\n ? createField(key, { _ilike: `%${value}%` })\n : {};\n}\nfunction createEqFilter(key, value) {\n return value ? createField(key, { _eq: value }) : {};\n}\nfunction createNeqFilter(key, value) {\n return value ? createField(key, { _neq: value }) : {};\n}\nfunction createBoolFilter(key, value) {\n return typeof value === 'boolean'\n ? createField(key, {\n _eq: value ? 'true' : 'false',\n })\n : {};\n}\nfunction createAddressFilter(key, value) {\n return value\n ? createField(key, { _eq: value.toLowerCase() })\n : {};\n}\nfunction createNotNullAddressFilter(key, filterZeroAddress = true, filterDeadAddress = true) {\n if (filterZeroAddress && filterDeadAddress) {\n return createField(key, {\n _nin: [ZERO_ADDRESS, DEAD_ADDRESS],\n });\n }\n if (filterZeroAddress) {\n return createField(key, {\n _neq: ZERO_ADDRESS,\n });\n }\n if (filterDeadAddress) {\n return createField(key, {\n _neq: DEAD_ADDRESS,\n });\n }\n return {};\n}\nfunction createInFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _in: values })\n : {};\n}\nfunction createNinFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _nin: values })\n : {};\n}\nfunction createLtFilter(key, value) {\n return value ? createField(key, { _lt: value }) : {};\n}\nfunction createLteFilter(key, value) {\n return value ? createField(key, { _lte: value }) : {};\n}\nfunction createGtFilter(key, value) {\n return value ? createField(key, { _gt: value }) : {};\n}\nfunction createGteFilter(key, value) {\n return value ? createField(key, { _gte: value }) : {};\n}\nfunction createBetweenFilter(key, from, to) {\n const betweenFilter = {};\n if (from) {\n betweenFilter._gte = from;\n }\n if (to) {\n betweenFilter._lte = to;\n }\n return from || to\n ? createField(key, betweenFilter)\n : {};\n}\n\nfunction createOrderBy(key, value) {\n return key && value ? createField(key, value) : {};\n}\n\nfunction removeSpecialCharacters(str) {\n return str.replace(/[^a-zA-Z0-9 ]/g, '');\n}\n\nfunction isNumeric(value, allowNegative = false) {\n if (typeof value === 'string') {\n return (allowNegative ? /^-?\\d+$/ : /^\\d+$/).test(value);\n }\n if (typeof value === 'number') {\n return true;\n }\n return false;\n}\n\nexport { Chain, DEAD_ADDRESS, Order, PaginatedResult, TransactionRequestStatus, ZERO_ADDRESS, createAddressFilter, createBetweenFilter, createBoolFilter, createEqFilter, createGtFilter, createGteFilter, createInFilter, createLikeFilter, createLtFilter, createLteFilter, createNeqFilter, createNinFilter, createNotNullAddressFilter, createOrderBy, isNumeric, nextCursor, removeSpecialCharacters };\n//# sourceMappingURL=index.mjs.map\n","export class CodeAlreadyMintedError extends Error {\n constructor(code: string) {\n super(`Code: '${code}' already minted `);\n }\n}\n","export class CodeExpiredError extends Error {\n constructor(code: string) {\n super(`Code: '${code}', has been expired`);\n }\n}\n","import axios, { AxiosError } from 'axios';\n\nclass InvalidMediaError extends Error {\n constructor(reason) {\n super(`There was an while creating Moment. Invalid media file. Reason: ${reason}`);\n this.name = InvalidMediaError.name;\n }\n}\n\nvar MediaStatus;\n(function (MediaStatus) {\n MediaStatus[\"INVALID\"] = \"INVALID\";\n MediaStatus[\"PROCESSED\"] = \"PROCESSED\";\n MediaStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n})(MediaStatus || (MediaStatus = {}));\n\nvar TransactionStatus;\n(function (TransactionStatus) {\n TransactionStatus[\"pending\"] = \"pending\";\n TransactionStatus[\"passed\"] = \"passed\";\n TransactionStatus[\"failed\"] = \"failed\";\n TransactionStatus[\"waiting\"] = \"waiting_tx\";\n})(TransactionStatus || (TransactionStatus = {}));\n\nclass CompassRequestError extends Error {\n constructor(compassErrors) {\n super(`Error fetching Compass data: ${compassErrors.errors.map((error) => error.message).join(', ')}`);\n this.errors = compassErrors.errors;\n }\n}\n\nclass CompassMissingDataError extends Error {\n constructor() {\n super('Compass response is missing data');\n }\n}\n\nclass CompassBadRequestError extends Error {\n constructor() {\n super('Compass malformed request');\n }\n}\n\nclass CompassUnauthorizedError extends Error {\n constructor() {\n super('Unauthorized access, API key may be invalid or expired');\n }\n}\n\nclass MissingAuthenticationProviderError extends Error {\n constructor() {\n super(`An AuthenticationProvider is required for write operations`);\n }\n}\n\nconst DEFAULT_MOMENTS_BASE_URL = 'https://moments.poap.tech';\nclass PoapMomentsApi {\n constructor(params) {\n var _a;\n this.baseUrl = (_a = params.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_MOMENTS_BASE_URL;\n this.authenticationProvider = params.authenticationProvider;\n }\n async getSignedUrl() {\n const response = await axios.post(`${this.baseUrl}/moments/media-upload-url`, undefined, {\n headers: {\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n async uploadFile(fileBinary, signedUrl, fileType, onProgress) {\n await axios.put(signedUrl, fileBinary, {\n headers: {\n 'Content-Type': fileType,\n },\n onUploadProgress: (progressEvent) => {\n if (onProgress) {\n onProgress(progressEvent.progress || 0);\n }\n },\n });\n }\n async fetchMediaStatus(mediaKey) {\n var _a;\n try {\n const response = await axios.get(`${this.baseUrl}/media/${mediaKey}`);\n return response.data.status;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {\n return MediaStatus.IN_PROCESS;\n }\n throw error;\n }\n }\n async waitForMediaProcessing(mediaKey, timeOut = 60000) {\n const delay = 2000;\n const maxTries = timeOut / delay;\n const checkStatus = async (tries) => {\n if (tries >= maxTries) {\n throw new Error('Exceeded maximum number of tries to check media processing status.');\n }\n const status = await this.fetchMediaStatus(mediaKey);\n if (status === MediaStatus.PROCESSED) {\n return;\n }\n if (status === MediaStatus.INVALID) {\n throw new InvalidMediaError('status is invalid');\n }\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(tries + 1);\n };\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(0);\n }\n async createMoment(input) {\n var _a;\n try {\n const response = await axios.post(`${this.baseUrl}/moments`, input, {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 409) {\n throw new InvalidMediaError(error.response.data.message);\n }\n throw error;\n }\n }\n async patchMoment(id, input) {\n await fetch(`${this.baseUrl}/moments/${id}`, {\n method: 'PATCH',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new Error('An AuthenticationProvider is required for write operations');\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nconst DEFAULT_DROP_BASE_URL$1 = 'https://api.poap.tech';\nclass PoapDropApi {\n constructor(config) {\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl || DEFAULT_DROP_BASE_URL$1;\n }\n async createDrop(input) {\n const form = new FormData();\n for (const key in input) {\n if (Object.prototype.hasOwnProperty.call(input, key)) {\n if (key === 'image') {\n form.append(key, input[key]);\n }\n else {\n form.append(key, input[key] + '');\n }\n }\n }\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'POST',\n body: form,\n headers: {},\n });\n }\n async updateDrop(input) {\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'PUT',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n };\n const response = await fetch(url, {\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n });\n return await response.json();\n }\n}\n\nfunction getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\n/**\n * lodash (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors <https://jquery.org/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991,\n MAX_INTEGER = 1.7976931348623157e+308,\n NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n symbolTag = '[object Symbol]';\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeCeil = Math.ceil,\n nativeMax = Math.max;\n\n/**\n * The base implementation of `_.slice` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\nfunction baseSlice(array, start, end) {\n var index = -1,\n length = array.length;\n\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = end > length ? length : end;\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : ((end - start) >>> 0);\n start >>>= 0;\n\n var result = Array(length);\n while (++index < length) {\n result[index] = array[index + start];\n }\n return result;\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\n/**\n * Creates an array of elements split into groups the length of `size`.\n * If `array` can't be split evenly, the final chunk will be the remaining\n * elements.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to process.\n * @param {number} [size=1] The length of each chunk\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the new array of chunks.\n * @example\n *\n * _.chunk(['a', 'b', 'c', 'd'], 2);\n * // => [['a', 'b'], ['c', 'd']]\n *\n * _.chunk(['a', 'b', 'c', 'd'], 3);\n * // => [['a', 'b', 'c'], ['d']]\n */\nfunction chunk(array, size, guard) {\n if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {\n size = 1;\n } else {\n size = nativeMax(toInteger(size), 0);\n }\n var length = array ? array.length : 0;\n if (!length || size < 1) {\n return [];\n }\n var index = 0,\n resIndex = 0,\n result = Array(nativeCeil(length / size));\n\n while (index < length) {\n result[resIndex++] = baseSlice(array, index, (index += size));\n }\n return result;\n}\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\nfunction toFinite(value) {\n if (!value) {\n return value === 0 ? value : 0;\n }\n value = toNumber(value);\n if (value === INFINITY || value === -INFINITY) {\n var sign = (value < 0 ? -1 : 1);\n return sign * MAX_INTEGER;\n }\n return value === value ? value : 0;\n}\n\n/**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\nfunction toInteger(value) {\n var result = toFinite(value),\n remainder = result % 1;\n\n return result === result ? (remainder ? result - remainder : result) : 0;\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nvar lodash_chunk = chunk;\n\nvar chunk$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_chunk);\n\nconst DEFAULT_COMPASS_BASE_URL = 'https://public.compass.poap.tech/v1/graphql';\nclass PoapCompass {\n constructor(config) {\n var _a;\n this.batchSize = 5;\n this.apiKey = config.apiKey;\n this.baseUrl = (_a = config.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_COMPASS_BASE_URL;\n }\n async fetchGraphQL(query, variables, signal) {\n let response;\n try {\n response = await fetch(this.baseUrl, {\n signal,\n method: 'POST',\n body: JSON.stringify({\n query,\n variables,\n }),\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': this.apiKey,\n },\n });\n }\n catch (error) {\n throw new Error(`Network error, received error ${error}`);\n }\n this.handleResponseStatus(response);\n const body = await response.json();\n this.handleResponseErrors(body);\n return body;\n }\n handleResponseStatus(response) {\n switch (response.status) {\n case 400:\n throw new CompassBadRequestError();\n case 401:\n throw new CompassUnauthorizedError();\n case 200:\n return;\n default:\n throw new Error(`Response error, received status code ${response.status}`);\n }\n }\n handleResponseErrors(response) {\n if (this.isError(response)) {\n throw new CompassRequestError(response);\n }\n if (!this.hasData(response)) {\n throw new CompassMissingDataError();\n }\n }\n isError(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'errors' in response &&\n Array.isArray(response.errors) &&\n response.errors.every((error) => error != null &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'));\n }\n hasData(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'data' in response &&\n response.data != null &&\n typeof response.data === 'object');\n }\n async request(query, variables, signal) {\n return await this.fetchGraphQL(query, variables !== null && variables !== void 0 ? variables : {}, signal);\n }\n async batch(query, variables, signal) {\n const results = [];\n const chunks = chunk$1(variables, this.batchSize);\n for (const chunk of chunks) {\n const responses = await Promise.all(chunk.map((variables) => this.request(query, variables, signal)));\n results.push(...responses);\n }\n return results;\n }\n}\n\nconst DEFAULT_OAUTH_SERVER = 'auth.accounts.poap.xyz';\nclass AuthenticationProviderHttp {\n constructor(clientId, clientSecret, oAuthServerDomain) {\n this.clientId = clientId;\n this.clientSecret = clientSecret;\n this.oAuthServerDomain = oAuthServerDomain || DEFAULT_OAUTH_SERVER;\n }\n async getJWT(audience) {\n if (this.tokenData && !this.isTokenExpired()) {\n return this.tokenData.accessToken;\n }\n const response = await fetch(`https://${this.oAuthServerDomain}/oauth/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n client_id: this.clientId,\n client_secret: this.clientSecret,\n audience,\n grant_type: 'client_credentials',\n }),\n });\n if (!response.ok) {\n throw new Error(`Network response was not ok: ${response.statusText}`);\n }\n const responseData = await response.json();\n this.tokenData = {\n accessToken: responseData.access_token,\n expiresAt: Date.now() + responseData.expires_in * 1000,\n };\n return responseData.access_token;\n }\n isTokenExpired() {\n return !this.tokenData || this.tokenData.expiresAt < Date.now();\n }\n}\n\nconst DEFAULT_DROP_BASE_URL = 'https://api.poap.tech';\nclass PoapTokenApi {\n constructor({ apiKey, baseUrl = DEFAULT_DROP_BASE_URL, authenticationProvider, }) {\n this.apiKey = apiKey;\n this.baseUrl = baseUrl;\n this.authenticationProvider = authenticationProvider;\n }\n async getMintCode(code) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr?qr_hash=${code}`, {\n method: 'GET',\n headers: {},\n });\n }\n async postMintCode(input) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr`, {\n method: 'POST',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async getMintTransaction(qrHash) {\n const transactions = await this.secureFetch(`${this.baseUrl}/transactions?qr_hash=${qrHash}`, {\n method: 'GET',\n });\n if (transactions.total === 0) {\n return null;\n }\n const status = transactions.transactions[0].status;\n if (status === TransactionStatus.waiting) {\n return null;\n }\n return transactions.transactions[0];\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n Authorization: await this.getAuthorizationToken(),\n };\n const response = await fetch(url, {\n ...options,\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n signal: AbortSignal.timeout(10000),\n });\n return await response.json();\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new MissingAuthenticationProviderError();\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nexport { AuthenticationProviderHttp, CompassBadRequestError, CompassMissingDataError, CompassRequestError, CompassUnauthorizedError, InvalidMediaError, MediaStatus, MissingAuthenticationProviderError, PoapCompass, PoapDropApi, PoapMomentsApi, PoapTokenApi, TransactionStatus };\n//# sourceMappingURL=index.mjs.map\n","export class FinishedWithError extends Error {\n constructor(error: string, code: string) {\n super(\n `Code: '${code}', finished with error: '${error}', please try again later `,\n );\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\n\nconst MAX_RETRIES = 20;\nconst INITIAL_DELAY = 1000;\nconst BACKOFF_FACTOR = 1.2;\n\n/**\n * Abstract class representing a task that can be retried with an increasing delay.\n */\nexport abstract class RetryableTask {\n protected retries = 0;\n protected delay: number = INITIAL_DELAY;\n protected tokensApiProvider: TokensApiProvider;\n\n /**\n * Constructs a new RetryableTask instance.\n *\n * @param {TokensApiProvider} tokensApiProvider - The provider used to perform operations that might be retried.\n */\n constructor(tokensApiProvider: TokensApiProvider) {\n this.tokensApiProvider = tokensApiProvider;\n }\n\n /**\n * Attempts to perform a given task. If the task fails, it retries with an increasing delay until\n * maximum retries are reached.\n *\n * @protected\n * @template T - The type of value that the callback returns.\n * @param {() => Promise<T>} callback - The asynchronous function representing the task to be retried.\n * @returns {Promise<T>} A promise that resolves to the result of the task or rejects with an error.\n * @throws {Error} Throws an error if maximum retries are reached.\n */\n protected backoffAndRetry<T>(callback: () => Promise<T>): Promise<T> {\n if (this.retries >= MAX_RETRIES) {\n throw new Error('Max retries reached');\n }\n this.retries++;\n this.delay *= BACKOFF_FACTOR;\n\n return new Promise<T>((resolve, reject) => {\n setTimeout(() => {\n callback().then(resolve, reject);\n }, this.delay);\n });\n }\n}\n","import {\n TokensApiProvider,\n Transaction,\n TransactionStatus,\n} from '@poap-xyz/providers';\nimport { FinishedWithError } from '../errors/FinishedWithError';\nimport { RetryableTask } from './RetryableTask';\n\n/**\n * A utility class designed to continually check the status of a POAP token mint.\n * If a mint is still pending or in process, it implements a backoff retry mechanism.\n */\nexport class MintChecker extends RetryableTask {\n private mintCode: string;\n\n /**\n * Constructs a new instance of the MintChecker class.\n *\n * @param {string} mintCode - The unique code for the token mint.\n * @param {TokensApiProvider} tokensApiProvider - The provider to fetch the mint status.\n */\n constructor(tokensApiProvider: TokensApiProvider, mintCode: string) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Checks the current status of a token mint.\n * If the mint is still pending or in process, it will retry the check with an increased delay.\n *\n * @public\n * @returns {Promise<void>} A promise that resolves once the status has been checked.\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n public async checkMintStatus(): Promise<void> {\n try {\n const transaction = await this.tokensApiProvider.getMintTransaction(\n this.mintCode,\n );\n\n if (this.shouldRetry(transaction)) {\n await this.backoffAndRetry(() => this.checkMintStatus());\n } else {\n this.handleErrorStatus(transaction, this.mintCode);\n }\n } catch (e) {\n if (e instanceof FinishedWithError) {\n throw e;\n }\n\n await this.backoffAndRetry(() => this.checkMintStatus());\n }\n }\n\n /**\n * Determines if a retry should be performed based on the provided minting status.\n *\n * @private\n * @returns {boolean} Returns true if a retry should be performed, otherwise false.\n * @param transaction - The transaction to check for retry.\n */\n private shouldRetry(transaction: Transaction | null): boolean {\n return !transaction || transaction.status === TransactionStatus.pending;\n }\n\n /**\n * Handles any error statuses from the mint status response.\n * If the minting process finishes with an error, an exception will be thrown.\n *\n * @private\n * @param {Transaction} transaction - The transaction to check for errors.\n * @param mintCode\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n private handleErrorStatus(\n transaction: Transaction | null,\n mintCode: string,\n ): void {\n if (transaction?.status === TransactionStatus.failed) {\n throw new FinishedWithError(\n 'The Transaction associated with this mint failed',\n mintCode,\n );\n }\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\nimport { RetryableTask } from './RetryableTask';\nimport { PoapMintStatus } from '../types';\n\n/**\n * @class PoapIndexed\n * @extends {RetryableTask}\n *\n * Represents a utility class designed to periodically check if a POAP token is indexed on our database.\n * This class extends `RetryableTask` to utilize its backoff retry mechanism in case the token hasn't been indexed yet.\n */\nexport class PoapIndexed extends RetryableTask {\n private mintCode: string;\n\n /**\n * Creates an instance of the PoapIndexed class.\n *\n * @param {string} mintCode - A unique Mint Code representing the token.\n * @param {TokensApiProvider} tokensApiProvider - An instance of the TokensApiProvider used to check the indexing status of the token.\n */\n constructor(mintCode: string, tokensApiProvider: TokensApiProvider) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Periodically checks if the POAP token, represented by its Mint Code, is indexed on our database.\n * This method will continue retrying with an increasing delay until either the token is indexed or it reaches the maximum allowed retries.\n *\n * @returns {Promise<GetClaimCodeResponse>} A promise that either resolves with the indexed token's mint code response or rejects due to reaching the max retry limit.\n */\n public async waitPoapIndexed(): Promise<PoapMintStatus> {\n let response = await this.tokensApiProvider.getMintCode(this.mintCode);\n while (response.result == null) {\n response = await this.backoffAndRetry(() =>\n this.tokensApiProvider.getMintCode(this.mintCode),\n );\n }\n return {\n minted: response.claimed,\n isActive: response.is_active,\n secretCode: response.secret,\n poapId: response.result?.token,\n };\n }\n}\n","import {\n CompassProvider,\n TokensApiProvider,\n Transaction,\n} from '@poap-xyz/providers';\nimport { POAP } from './domain/Poap';\nimport { POAPReservation } from './domain/POAPReservation';\nimport {\n PAGINATED_POAPS_QUERY,\n PaginatedPoapsResponse,\n PaginatedPoapsVariables,\n} from './queries';\nimport {\n EmailReservationInput,\n FetchPoapsInput,\n PoapMintStatus,\n PoapsSortFields,\n WalletMintInput,\n} from './types';\nimport {\n createAddressFilter,\n createBetweenFilter,\n createEqFilter,\n createInFilter,\n createNotNullAddressFilter,\n createOrderBy,\n nextCursor,\n PaginatedResult,\n} from '@poap-xyz/utils';\nimport { CodeAlreadyMintedError } from './errors/CodeAlreadyMintedError';\nimport { CodeExpiredError } from './errors/CodeExpiredError';\nimport { MintChecker } from './utils/MintChecker';\nimport { PoapIndexed } from './utils/PoapIndexed';\n\n/**\n * Represents a client for interacting with POAPs .\n * @class\n */\nexport class PoapsClient {\n /**\n * Initializes a new instance of the PoapsClient.\n * @param {CompassProvider} compassProvider - The provider for the POAP compass API.\n * @param {TokensApiProvider} tokensApiProvider - The provider for the Tokens API.\n */\n constructor(\n private compassProvider: CompassProvider,\n private tokensApiProvider: TokensApiProvider,\n ) {}\n\n /**\n * Fetches a list of POAP tokens based on the given input criteria.\n * @async\n * @param {FetchPoapsInput} input - Criteria for fetching POAP tokens.\n * @returns {Promise<PaginatedResult<POAP>>} A paginated list of POAP tokens.\n */\n async fetch(input: FetchPoapsInput): Promise<PaginatedResult<POAP>> {\n const {\n limit,\n offset,\n chain,\n collectorAddress,\n mintedDateFrom,\n mintedDateTo,\n ids,\n dropId,\n sortField,\n sortDir,\n filterZeroAddress = true,\n filterDeadAddress = true,\n } = input;\n\n const variables: PaginatedPoapsVariables = {\n limit,\n offset,\n orderBy: createOrderBy<PoapsSortFields>(sortField, sortDir),\n where: {\n ...createAddressFilter('collector_address', collectorAddress),\n ...(collectorAddress == undefined\n ? createNotNullAddressFilter(\n 'collector_address',\n filterZeroAddress,\n filterDeadAddress,\n )\n : {}),\n ...createEqFilter('chain', chain),\n ...createEqFilter('drop_id', dropId),\n ...createBetweenFilter('minted_on', mintedDateFrom, mintedDateTo),\n ...createInFilter('id', ids),\n },\n };\n\n const { data } = await this.compassProvider.request<\n PaginatedPoapsResponse,\n PaginatedPoapsVariables\n >(PAGINATED_POAPS_QUERY, variables);\n\n const poaps = data.poaps.map((poap) => {\n const { drop } = poap;\n const mintedOn = new Date(0);\n mintedOn.setUTCSeconds(poap.minted_on);\n return new POAP({\n id: Number(poap.id),\n collectorAddress: poap.collector_address,\n transferCount: poap.transfer_count,\n mintedOn,\n dropId: Number(poap.drop_id),\n imageUrl: drop.image_url,\n city: drop.city,\n country: drop.country,\n description: drop.description,\n startDate: new Date(drop.start_date),\n name: drop.name,\n endDate: new Date(drop.end_date),\n });\n });\n\n return new PaginatedResult<POAP>(\n poaps,\n nextCursor(poaps.length, limit, offset),\n );\n }\n\n /**\n * Retrieves mint code details for a specific Mint Code.\n * @async\n * @param {string} mintCode - The Mint Code for which to get the mint code.\n * @returns {Promise<PoapMintStatus>} The Mint status.\n */\n async getMintCode(mintCode: string): Promise<PoapMintStatus> {\n const getMintCodeRaw = await this.tokensApiProvider.getMintCode(mintCode);\n return {\n minted: getMintCodeRaw.claimed,\n isActive: getMintCodeRaw.is_active,\n secretCode: getMintCodeRaw.secret,\n poapId: getMintCodeRaw.result?.token,\n };\n }\n\n /**\n * Gets the Transaction associated with the mint.\n * The Transaction could change in case of a bump.\n * It returns null if the mint has no transaction associated.\n *\n * @param {string} qrHash - The qrHash of the mint.\n * @returns {Promise<Transaction> | null} The Transaction associated with the mint. Null if no transaction is found.\n */\n public async getMintTransaction(qrHash: string): Promise<Transaction | null> {\n return await this.tokensApiProvider.getMintTransaction(qrHash);\n }\n\n /**\n * Awaits until we have a final Transaction status for a specific Mint Code.\n * @async\n * @returns {Promise<void>}\n * @param mintCode - The Mint Code\n */\n public async waitMintStatus(mintCode: string): Promise<void> {\n const checker = new MintChecker(this.tokensApiProvider, mintCode);\n await checker.checkMintStatus();\n }\n\n /**\n * Awaits until a specific POAP, identified by its Mint Code, is indexed on our database.\n * @async\n * @param {string} mintCode - The Mint Code identifying the POAP to be indexed.\n * @returns {Promise<PoapMintStatus>} - The status of the POAP mint.\n */\n public async waitPoapIndexed(mintCode: string): Promise<PoapMintStatus> {\n const checker = new PoapIndexed(mintCode, this.tokensApiProvider);\n return await checker.waitPoapIndexed();\n }\n\n /**\n * Begins an asynchronous mint process and provides a unique queue ID in return.\n * @async\n * @param {WalletMintInput} input - Details required for the mint.\n */\n public async mintAsync(input: WalletMintInput): Promise<void> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n await this.tokensApiProvider.postMintCode({\n address: input.address,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: false,\n });\n }\n\n /**\n * Starts a synchronous mint process. The method waits for the mint to be processed and then\n * fetches the associated POAP. It combines the asynchronous mint and subsequent status checking\n * into a synchronous process for ease of use.\n * @async\n * @param {WalletMintInput} input - Details needed for the mint.\n * @returns {Promise<POAP>} The associated POAP upon successful mint completion.\n * @throws {FinishedWithError} If there's an error concluding the mint process.\n */\n async mintSync(input: WalletMintInput): Promise<POAP> {\n await this.mintAsync(input);\n\n await this.waitMintStatus(input.mintCode);\n\n const getCodeResponse = await this.waitPoapIndexed(input.mintCode);\n\n return (\n await this.fetch({\n limit: 1,\n offset: 0,\n ids: [getCodeResponse.poapId],\n })\n ).items[0];\n }\n\n /**\n * Reserves a POAP to an email address and provides reservation details.\n * @async\n * @param {EmailReservationInput} input - Information for the reservation.\n * @returns {Promise<POAPReservation>} The reservation details of the POAP.\n */\n public async emailReservation(\n input: EmailReservationInput,\n ): Promise<POAPReservation> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n const response = await this.tokensApiProvider.postMintCode({\n address: input.email,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: input.sendEmail || true,\n });\n\n return new POAPReservation({\n email: input.email,\n dropId: response.event.id,\n imageUrl: response.event.image_url,\n city: response.event.city,\n country: response.event.country,\n description: response.event.description,\n startDate: new Date(response.event.start_date),\n endDate: new Date(response.event.end_date),\n name: response.event.name,\n });\n }\n\n /**\n * Retrieves the secret code associated with a POAP code.\n * @async\n * @param {string} mintCode - The POAP code for which to get the secret.\n * @returns {Promise<string>} The associated secret code.\n * @throws {CodeAlreadyMintedError} Thrown when the POAP code has already been minted.\n * @throws {CodeExpiredError} Thrown when the POAP code is expired.\n */\n private async getSecretCode(mintCode: string): Promise<string> {\n const getCodeResponse = await this.getMintCode(mintCode);\n\n if (getCodeResponse.minted) {\n throw new CodeAlreadyMintedError(mintCode);\n }\n if (!getCodeResponse.isActive) {\n throw new CodeExpiredError(mintCode);\n }\n\n return getCodeResponse.secretCode;\n }\n}\n"],"names":["PoapsSortFields"],"mappings":";;;;AAQYA,iCAKX;AALD,CAAA,UAAY,eAAe,EAAA;AAEzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,WAAsB,CAAA;AAEtB,IAAA,eAAA,CAAA,IAAA,CAAA,GAAA,IAAS,CAAA;AACX,CAAC,EALWA,uBAAe,KAAfA,uBAAe,GAK1B,EAAA,CAAA,CAAA;;MCZY,IAAI,CAAA;AAcf,IAAA,WAAA,CAAY,UAA0B,EAAA;AACpC,QAAA,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC;AACxB,QAAA,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC,gBAAgB,CAAC;AACpD,QAAA,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;AACpC,QAAA,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;AAChC,QAAA,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC;AAC9C,QAAA,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;AACpC,QAAA,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;AAC5B,QAAA,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;AAClC,QAAA,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;AAC1C,QAAA,IAAI,CAAC,SAAS,GAAG,UAAU,C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B,YAAA,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS;AAClC,YAAA,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI;AACzB,YAAA,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO;AAC/B,YAAA,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW;YACvC,SAAS,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;YAC9C,OAAO,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;AAC1C,YAAA,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI;AAC1B,SAAA,CAAC,CAAC;KACJ;IAUO,MAAM,aAAa,CAAC,QAAgB,EAAA;QAC1C,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AAEzD,QAAA,IAAI,eAAe,CAAC,MAAM,EAAE;AAC1B,YAAA,MAAM,IAAI,sBAAsB,CAAC,QAAQ,CAAC,CAAC;SAC5C;AACD,QAAA,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;AAC7B,YAAA,MAAM,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;SACtC;QAED,OAAO,eAAe,CAAC,UAAU,CAAC;KACnC;AACF;;;;;;;;;"} | ||
| {"version":3,"file":"index.cjs","sources":["../../src/types/PoapsSortFields.ts","../../../utils/dist/esm/index.mjs","../../src/domain/POAP.ts","../../src/domain/POAPReservation.ts","../../src/queries/PaginatedPoaps.ts","../../src/errors/CodeAlreadyMintedError.ts","../../src/errors/CodeExpiredError.ts","../../../providers/dist/esm/index.mjs","../../src/errors/FinishedWithError.ts","../../src/utils/RetryableTask.ts","../../src/utils/MintChecker.ts","../../src/utils/PoapIndexed.ts","../../src/PoapsClient.ts"],"sourcesContent":["/**\n * Enum to define available fields for sorting POAPs.\n *\n * @export\n * @enum {string}\n */\nexport enum PoapsSortFields {\n /** Represents sorting by the date when a POAP was minted. */\n MintedOn = 'minted_on',\n /** Represents sorting by the ID of a POAP. */\n Id = 'id',\n}\n","class PaginatedResult {\n constructor(items, nextCursor) {\n this.items = items;\n this.nextCursor = nextCursor;\n }\n}\n\nvar Order;\n(function (Order) {\n Order[\"ASC\"] = \"asc\";\n Order[\"DESC\"] = \"desc\";\n})(Order || (Order = {}));\n\nvar Chain;\n(function (Chain) {\n Chain[\"Ethereum\"] = \"mainnet\";\n Chain[\"Gnosis\"] = \"xdai\";\n})(Chain || (Chain = {}));\n\nvar TransactionRequestStatus;\n(function (TransactionRequestStatus) {\n TransactionRequestStatus[\"PENDING\"] = \"PENDING\";\n TransactionRequestStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n TransactionRequestStatus[\"FINISH\"] = \"FINISH\";\n TransactionRequestStatus[\"FINISH_WITH_ERROR\"] = \"FINISH_WITH_ERROR\";\n})(TransactionRequestStatus || (TransactionRequestStatus = {}));\n\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\nconst DEAD_ADDRESS = '0x000000000000000000000000000000000000dead';\n\nfunction nextCursor(length, limit, offset) {\n const endIndex = offset + length;\n return endIndex < offset + limit ? null : endIndex;\n}\n\nfunction createField(keys, value) {\n return keys.split('.').reduceRight((prev, key) => ({\n [key]: prev,\n }), value);\n}\n\nfunction createLikeFilter(key, value) {\n return value\n ? createField(key, { _ilike: `%${value}%` })\n : {};\n}\nfunction createEqFilter(key, value) {\n return value ? createField(key, { _eq: value }) : {};\n}\nfunction createNeqFilter(key, value) {\n return value ? createField(key, { _neq: value }) : {};\n}\nfunction createBoolFilter(key, value) {\n return typeof value === 'boolean'\n ? createField(key, {\n _eq: value ? 'true' : 'false',\n })\n : {};\n}\nfunction createAddressFilter(key, value) {\n return value\n ? createField(key, { _eq: value.toLowerCase() })\n : {};\n}\nfunction createNotNullAddressFilter(key, filterZeroAddress = true, filterDeadAddress = true) {\n if (filterZeroAddress && filterDeadAddress) {\n return createField(key, {\n _nin: [ZERO_ADDRESS, DEAD_ADDRESS],\n });\n }\n if (filterZeroAddress) {\n return createField(key, {\n _neq: ZERO_ADDRESS,\n });\n }\n if (filterDeadAddress) {\n return createField(key, {\n _neq: DEAD_ADDRESS,\n });\n }\n return {};\n}\nfunction createInFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _in: values })\n : {};\n}\nfunction createNinFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _nin: values })\n : {};\n}\nfunction createLtFilter(key, value) {\n return value ? createField(key, { _lt: value }) : {};\n}\nfunction createLteFilter(key, value) {\n return value ? createField(key, { _lte: value }) : {};\n}\nfunction createGtFilter(key, value) {\n return value ? createField(key, { _gt: value }) : {};\n}\nfunction createGteFilter(key, value) {\n return value ? createField(key, { _gte: value }) : {};\n}\nfunction createBetweenFilter(key, from, to) {\n const betweenFilter = {};\n if (from) {\n betweenFilter._gte = from;\n }\n if (to) {\n betweenFilter._lte = to;\n }\n return from || to\n ? createField(key, betweenFilter)\n : {};\n}\n\nfunction createOrderBy(key, value) {\n return key && value ? createField(key, value) : {};\n}\n\nfunction removeSpecialCharacters(str) {\n return str.replace(/[^a-zA-Z0-9 ]/g, '');\n}\n\nfunction isNumeric(value, allowNegative = false) {\n if (typeof value === 'string') {\n return (allowNegative ? /^-?\\d+$/ : /^\\d+$/).test(value);\n }\n if (typeof value === 'number') {\n return true;\n }\n return false;\n}\n\nexport { Chain, DEAD_ADDRESS, Order, PaginatedResult, TransactionRequestStatus, ZERO_ADDRESS, createAddressFilter, createBetweenFilter, createBoolFilter, createEqFilter, createGtFilter, createGteFilter, createInFilter, createLikeFilter, createLtFilter, createLteFilter, createNeqFilter, createNinFilter, createNotNullAddressFilter, createOrderBy, isNumeric, nextCursor, removeSpecialCharacters };\n//# sourceMappingURL=index.mjs.map\n","import { PoapsResponse } from '../queries/PaginatedPoaps';\n\nexport class POAP {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n public static fromCompass(response: PoapsResponse): POAP {\n const mintedOn = new Date(0);\n mintedOn.setUTCSeconds(response.minted_on);\n\n return new POAP({\n id: Number(response.id),\n collectorAddress: response.collector_address,\n transferCount: response.transfer_count,\n mintedOn,\n dropId: Number(response.drop_id),\n imageUrl: response.drop.image_url,\n city: response.drop.city,\n country: response.drop.country,\n description: response.drop.description,\n startDate: new Date(response.drop.start_date),\n endDate: new Date(response.drop.end_date),\n name: response.drop.name,\n });\n }\n\n // eslint-disable-next-line max-statements\n constructor(properties: PoapProperties) {\n this.id = properties.id;\n this.collectorAddress = properties.collectorAddress;\n this.mintedOn = properties.mintedOn;\n this.dropId = properties.dropId;\n this.transferCount = properties.transferCount;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\ninterface PoapProperties {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n}\n","export class POAPReservation {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n constructor(properties: POAPReservationProperties) {\n this.email = properties.email;\n this.dropId = properties.dropId;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\ninterface POAPReservationProperties {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n name: string;\n endDate: Date;\n}\n","import {\n FilterVariables,\n OrderByVariables,\n PaginatedVariables,\n} from '@poap-xyz/utils';\n\nexport const PAGINATED_POAPS_QUERY = `\n query PaginatedPoaps(\n $limit: Int!\n $offset: Int!\n $orderBy: [poaps_order_by!]\n $where: poaps_bool_exp\n ) {\n poaps(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) {\n chain\n collector_address\n drop_id\n id\n minted_on\n transfer_count\n drop {\n image_url\n city\n country\n description\n start_date\n end_date\n name\n }\n }\n }\n`;\n\nexport interface PoapsResponse {\n id: number;\n collector_address: string;\n transfer_count: number;\n minted_on: number;\n drop_id: number;\n drop: {\n image_url: string;\n city: string;\n country: string;\n description: string;\n start_date: string;\n end_date: string;\n name: string;\n };\n}\n\nexport interface PaginatedPoapsResponse {\n poaps: PoapsResponse[];\n}\n\nexport type PaginatedPoapsVariables = FilterVariables &\n OrderByVariables &\n PaginatedVariables;\n","export class CodeAlreadyMintedError extends Error {\n constructor(code: string) {\n super(`Code: '${code}' already minted `);\n }\n}\n","export class CodeExpiredError extends Error {\n constructor(code: string) {\n super(`Code: '${code}', has been expired`);\n }\n}\n","import axios, { AxiosError } from 'axios';\n\nclass InvalidMediaError extends Error {\n constructor(reason) {\n super(`There was an while creating Moment. Invalid media file. Reason: ${reason}`);\n this.name = InvalidMediaError.name;\n }\n}\n\nvar MediaStatus;\n(function (MediaStatus) {\n MediaStatus[\"INVALID\"] = \"INVALID\";\n MediaStatus[\"PROCESSED\"] = \"PROCESSED\";\n MediaStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n})(MediaStatus || (MediaStatus = {}));\n\nvar TransactionStatus;\n(function (TransactionStatus) {\n TransactionStatus[\"pending\"] = \"pending\";\n TransactionStatus[\"passed\"] = \"passed\";\n TransactionStatus[\"failed\"] = \"failed\";\n TransactionStatus[\"waiting\"] = \"waiting_tx\";\n})(TransactionStatus || (TransactionStatus = {}));\n\nclass CompassRequestError extends Error {\n constructor(compassErrors) {\n super(`Error fetching Compass data: ${compassErrors.errors.map((error) => error.message).join(', ')}`);\n this.errors = compassErrors.errors;\n }\n}\n\nclass CompassMissingDataError extends Error {\n constructor() {\n super('Compass response is missing data');\n }\n}\n\nclass CompassBadRequestError extends Error {\n constructor() {\n super('Compass malformed request');\n }\n}\n\nclass CompassUnauthorizedError extends Error {\n constructor() {\n super('Unauthorized access, API key may be invalid or expired');\n }\n}\n\nclass MissingAuthenticationProviderError extends Error {\n constructor() {\n super(`An AuthenticationProvider is required for write operations`);\n }\n}\n\nconst DEFAULT_MOMENTS_BASE_URL = 'https://moments.poap.tech';\nclass PoapMomentsApi {\n constructor(params) {\n var _a;\n this.baseUrl = (_a = params.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_MOMENTS_BASE_URL;\n this.authenticationProvider = params.authenticationProvider;\n }\n async getSignedUrl() {\n const response = await axios.post(`${this.baseUrl}/moments/media-upload-url`, undefined, {\n headers: {\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n async uploadFile(fileBinary, signedUrl, fileType, onProgress) {\n await axios.put(signedUrl, fileBinary, {\n headers: {\n 'Content-Type': fileType,\n },\n onUploadProgress: (progressEvent) => {\n if (onProgress) {\n onProgress(progressEvent.progress || 0);\n }\n },\n });\n }\n async fetchMediaStatus(mediaKey) {\n var _a;\n try {\n const response = await axios.get(`${this.baseUrl}/media/${mediaKey}`);\n return response.data.status;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {\n return MediaStatus.IN_PROCESS;\n }\n throw error;\n }\n }\n async waitForMediaProcessing(mediaKey, timeOut = 60000) {\n const delay = 2000;\n const maxTries = timeOut / delay;\n const checkStatus = async (tries) => {\n if (tries >= maxTries) {\n throw new Error('Exceeded maximum number of tries to check media processing status.');\n }\n const status = await this.fetchMediaStatus(mediaKey);\n if (status === MediaStatus.PROCESSED) {\n return;\n }\n if (status === MediaStatus.INVALID) {\n throw new InvalidMediaError('status is invalid');\n }\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(tries + 1);\n };\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(0);\n }\n async createMoment(input) {\n var _a;\n try {\n const response = await axios.post(`${this.baseUrl}/moments`, input, {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 409) {\n throw new InvalidMediaError(error.response.data.message);\n }\n throw error;\n }\n }\n async patchMoment(id, input) {\n await fetch(`${this.baseUrl}/moments/${id}`, {\n method: 'PATCH',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new Error('An AuthenticationProvider is required for write operations');\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nconst DEFAULT_DROP_BASE_URL$1 = 'https://api.poap.tech';\nclass PoapDropApi {\n constructor(config) {\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl || DEFAULT_DROP_BASE_URL$1;\n }\n async createDrop(input) {\n const form = new FormData();\n for (const key in input) {\n if (Object.prototype.hasOwnProperty.call(input, key)) {\n if (key === 'image') {\n form.append(key, input[key]);\n }\n else {\n form.append(key, input[key] + '');\n }\n }\n }\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'POST',\n body: form,\n headers: {},\n });\n }\n async updateDrop(input) {\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'PUT',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n };\n const response = await fetch(url, {\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n });\n return await response.json();\n }\n}\n\nfunction getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\n/**\n * lodash (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors <https://jquery.org/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991,\n MAX_INTEGER = 1.7976931348623157e+308,\n NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n symbolTag = '[object Symbol]';\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeCeil = Math.ceil,\n nativeMax = Math.max;\n\n/**\n * The base implementation of `_.slice` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\nfunction baseSlice(array, start, end) {\n var index = -1,\n length = array.length;\n\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = end > length ? length : end;\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : ((end - start) >>> 0);\n start >>>= 0;\n\n var result = Array(length);\n while (++index < length) {\n result[index] = array[index + start];\n }\n return result;\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\n/**\n * Creates an array of elements split into groups the length of `size`.\n * If `array` can't be split evenly, the final chunk will be the remaining\n * elements.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to process.\n * @param {number} [size=1] The length of each chunk\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the new array of chunks.\n * @example\n *\n * _.chunk(['a', 'b', 'c', 'd'], 2);\n * // => [['a', 'b'], ['c', 'd']]\n *\n * _.chunk(['a', 'b', 'c', 'd'], 3);\n * // => [['a', 'b', 'c'], ['d']]\n */\nfunction chunk(array, size, guard) {\n if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {\n size = 1;\n } else {\n size = nativeMax(toInteger(size), 0);\n }\n var length = array ? array.length : 0;\n if (!length || size < 1) {\n return [];\n }\n var index = 0,\n resIndex = 0,\n result = Array(nativeCeil(length / size));\n\n while (index < length) {\n result[resIndex++] = baseSlice(array, index, (index += size));\n }\n return result;\n}\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\nfunction toFinite(value) {\n if (!value) {\n return value === 0 ? value : 0;\n }\n value = toNumber(value);\n if (value === INFINITY || value === -INFINITY) {\n var sign = (value < 0 ? -1 : 1);\n return sign * MAX_INTEGER;\n }\n return value === value ? value : 0;\n}\n\n/**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\nfunction toInteger(value) {\n var result = toFinite(value),\n remainder = result % 1;\n\n return result === result ? (remainder ? result - remainder : result) : 0;\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nvar lodash_chunk = chunk;\n\nvar chunk$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_chunk);\n\nconst DEFAULT_COMPASS_BASE_URL = 'https://public.compass.poap.tech/v1/graphql';\nclass PoapCompass {\n constructor(config) {\n var _a;\n this.batchSize = 5;\n this.apiKey = config.apiKey;\n this.baseUrl = (_a = config.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_COMPASS_BASE_URL;\n }\n async fetchGraphQL(query, variables, signal) {\n let response;\n try {\n response = await fetch(this.baseUrl, {\n signal,\n method: 'POST',\n body: JSON.stringify({\n query,\n variables,\n }),\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': this.apiKey,\n },\n });\n }\n catch (error) {\n throw new Error(`Network error, received error ${error}`);\n }\n this.handleResponseStatus(response);\n const body = await response.json();\n this.handleResponseErrors(body);\n return body;\n }\n handleResponseStatus(response) {\n switch (response.status) {\n case 400:\n throw new CompassBadRequestError();\n case 401:\n throw new CompassUnauthorizedError();\n case 200:\n return;\n default:\n throw new Error(`Response error, received status code ${response.status}`);\n }\n }\n handleResponseErrors(response) {\n if (this.isError(response)) {\n throw new CompassRequestError(response);\n }\n if (!this.hasData(response)) {\n throw new CompassMissingDataError();\n }\n }\n isError(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'errors' in response &&\n Array.isArray(response.errors) &&\n response.errors.every((error) => error != null &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'));\n }\n hasData(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'data' in response &&\n response.data != null &&\n typeof response.data === 'object');\n }\n async request(query, variables, signal) {\n return await this.fetchGraphQL(query, variables !== null && variables !== void 0 ? variables : {}, signal);\n }\n async batch(query, variables, signal) {\n const results = [];\n const chunks = chunk$1(variables, this.batchSize);\n for (const chunk of chunks) {\n const responses = await Promise.all(chunk.map((variables) => this.request(query, variables, signal)));\n results.push(...responses);\n }\n return results;\n }\n}\n\nconst DEFAULT_OAUTH_SERVER = 'auth.accounts.poap.xyz';\nclass AuthenticationProviderHttp {\n constructor(clientId, clientSecret, oAuthServerDomain) {\n this.clientId = clientId;\n this.clientSecret = clientSecret;\n this.oAuthServerDomain = oAuthServerDomain || DEFAULT_OAUTH_SERVER;\n }\n async getJWT(audience) {\n if (this.tokenData && !this.isTokenExpired()) {\n return this.tokenData.accessToken;\n }\n const response = await fetch(`https://${this.oAuthServerDomain}/oauth/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n client_id: this.clientId,\n client_secret: this.clientSecret,\n audience,\n grant_type: 'client_credentials',\n }),\n });\n if (!response.ok) {\n throw new Error(`Network response was not ok: ${response.statusText}`);\n }\n const responseData = await response.json();\n this.tokenData = {\n accessToken: responseData.access_token,\n expiresAt: Date.now() + responseData.expires_in * 1000,\n };\n return responseData.access_token;\n }\n isTokenExpired() {\n return !this.tokenData || this.tokenData.expiresAt < Date.now();\n }\n}\n\nconst DEFAULT_DROP_BASE_URL = 'https://api.poap.tech';\nclass PoapTokenApi {\n constructor({ apiKey, baseUrl = DEFAULT_DROP_BASE_URL, authenticationProvider, }) {\n this.apiKey = apiKey;\n this.baseUrl = baseUrl;\n this.authenticationProvider = authenticationProvider;\n }\n async getMintCode(code) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr?qr_hash=${code}`, {\n method: 'GET',\n headers: {},\n });\n }\n async postMintCode(input) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr`, {\n method: 'POST',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async getMintTransaction(qrHash) {\n const transactions = await this.secureFetch(`${this.baseUrl}/transactions?qr_hash=${qrHash}`, {\n method: 'GET',\n });\n if (transactions.total === 0) {\n return null;\n }\n const status = transactions.transactions[0].status;\n if (status === TransactionStatus.waiting) {\n return null;\n }\n return transactions.transactions[0];\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n Authorization: await this.getAuthorizationToken(),\n };\n const response = await fetch(url, {\n ...options,\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n signal: AbortSignal.timeout(10000),\n });\n return await response.json();\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new MissingAuthenticationProviderError();\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nexport { AuthenticationProviderHttp, CompassBadRequestError, CompassMissingDataError, CompassRequestError, CompassUnauthorizedError, InvalidMediaError, MediaStatus, MissingAuthenticationProviderError, PoapCompass, PoapDropApi, PoapMomentsApi, PoapTokenApi, TransactionStatus };\n//# sourceMappingURL=index.mjs.map\n","export class FinishedWithError extends Error {\n constructor(error: string, code: string) {\n super(\n `Code: '${code}', finished with error: '${error}', please try again later `,\n );\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\n\nconst MAX_RETRIES = 20;\nconst INITIAL_DELAY = 1000;\nconst BACKOFF_FACTOR = 1.2;\n\n/**\n * Abstract class representing a task that can be retried with an increasing delay.\n */\nexport abstract class RetryableTask {\n protected retries = 0;\n protected delay: number = INITIAL_DELAY;\n protected tokensApiProvider: TokensApiProvider;\n\n /**\n * Constructs a new RetryableTask instance.\n *\n * @param {TokensApiProvider} tokensApiProvider - The provider used to perform operations that might be retried.\n */\n constructor(tokensApiProvider: TokensApiProvider) {\n this.tokensApiProvider = tokensApiProvider;\n }\n\n /**\n * Attempts to perform a given task. If the task fails, it retries with an increasing delay until\n * maximum retries are reached.\n *\n * @protected\n * @template T - The type of value that the callback returns.\n * @param {() => Promise<T>} callback - The asynchronous function representing the task to be retried.\n * @returns {Promise<T>} A promise that resolves to the result of the task or rejects with an error.\n * @throws {Error} Throws an error if maximum retries are reached.\n */\n protected backoffAndRetry<T>(callback: () => Promise<T>): Promise<T> {\n if (this.retries >= MAX_RETRIES) {\n throw new Error('Max retries reached');\n }\n this.retries++;\n this.delay *= BACKOFF_FACTOR;\n\n return new Promise<T>((resolve, reject) => {\n setTimeout(() => {\n callback().then(resolve, reject);\n }, this.delay);\n });\n }\n}\n","import {\n TokensApiProvider,\n Transaction,\n TransactionStatus,\n} from '@poap-xyz/providers';\nimport { FinishedWithError } from '../errors/FinishedWithError';\nimport { RetryableTask } from './RetryableTask';\n\n/**\n * A utility class designed to continually check the status of a POAP token mint.\n * If a mint is still pending or in process, it implements a backoff retry mechanism.\n */\nexport class MintChecker extends RetryableTask {\n private mintCode: string;\n\n /**\n * Constructs a new instance of the MintChecker class.\n *\n * @param {string} mintCode - The unique code for the token mint.\n * @param {TokensApiProvider} tokensApiProvider - The provider to fetch the mint status.\n */\n constructor(tokensApiProvider: TokensApiProvider, mintCode: string) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Checks the current status of a token mint.\n * If the mint is still pending or in process, it will retry the check with an increased delay.\n *\n * @public\n * @returns {Promise<void>} A promise that resolves once the status has been checked.\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n public async checkMintStatus(): Promise<void> {\n try {\n const transaction = await this.tokensApiProvider.getMintTransaction(\n this.mintCode,\n );\n\n if (this.shouldRetry(transaction)) {\n await this.backoffAndRetry(() => this.checkMintStatus());\n } else {\n this.handleErrorStatus(transaction, this.mintCode);\n }\n } catch (e) {\n if (e instanceof FinishedWithError) {\n throw e;\n }\n\n await this.backoffAndRetry(() => this.checkMintStatus());\n }\n }\n\n /**\n * Determines if a retry should be performed based on the provided minting status.\n *\n * @private\n * @returns {boolean} Returns true if a retry should be performed, otherwise false.\n * @param transaction - The transaction to check for retry.\n */\n private shouldRetry(transaction: Transaction | null): boolean {\n return !transaction || transaction.status === TransactionStatus.pending;\n }\n\n /**\n * Handles any error statuses from the mint status response.\n * If the minting process finishes with an error, an exception will be thrown.\n *\n * @private\n * @param {Transaction} transaction - The transaction to check for errors.\n * @param mintCode\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n private handleErrorStatus(\n transaction: Transaction | null,\n mintCode: string,\n ): void {\n if (transaction?.status === TransactionStatus.failed) {\n throw new FinishedWithError(\n 'The Transaction associated with this mint failed',\n mintCode,\n );\n }\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\nimport { RetryableTask } from './RetryableTask';\nimport { PoapMintStatus } from '../types/PoapMintStatus';\n\n/**\n * @class PoapIndexed\n * @extends {RetryableTask}\n *\n * Represents a utility class designed to periodically check if a POAP token is indexed on our database.\n * This class extends `RetryableTask` to utilize its backoff retry mechanism in case the token hasn't been indexed yet.\n */\nexport class PoapIndexed extends RetryableTask {\n private mintCode: string;\n\n /**\n * Creates an instance of the PoapIndexed class.\n *\n * @param {TokensApiProvider} tokensApiProvider - An instance of the TokensApiProvider used to check the indexing status of the token.\n * @param {string} mintCode - A unique Mint Code representing the token.\n */\n constructor(tokensApiProvider: TokensApiProvider, mintCode: string) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Periodically checks if the POAP token, represented by its Mint Code, is indexed on our database.\n * This method will continue retrying with an increasing delay until either the token is indexed or it reaches the maximum allowed retries.\n *\n * @returns {Promise<GetClaimCodeResponse>} A promise that either resolves with the indexed token's mint code response or rejects due to reaching the max retry limit.\n */\n public async waitPoapIndexed(): Promise<PoapMintStatus> {\n let response = await this.tokensApiProvider.getMintCode(this.mintCode);\n while (response.result == null) {\n response = await this.backoffAndRetry(() =>\n this.tokensApiProvider.getMintCode(this.mintCode),\n );\n }\n return {\n minted: response.claimed,\n isActive: response.is_active,\n secretCode: response.secret,\n poapId: response.result?.token,\n };\n }\n}\n","import {\n CompassProvider,\n TokensApiProvider,\n Transaction,\n} from '@poap-xyz/providers';\nimport {\n createAddressFilter,\n createBetweenFilter,\n createEqFilter,\n createInFilter,\n createNotNullAddressFilter,\n createOrderBy,\n nextCursor,\n PaginatedResult,\n} from '@poap-xyz/utils';\nimport { POAP } from './domain/POAP';\nimport { POAPReservation } from './domain/POAPReservation';\nimport {\n PAGINATED_POAPS_QUERY,\n PaginatedPoapsResponse,\n PaginatedPoapsVariables,\n} from './queries/PaginatedPoaps';\nimport { FetchPoapsInput } from './types/FetchPoapsInput';\nimport { PoapsSortFields } from './types/PoapsSortFields';\nimport { PoapMintStatus } from './types/PoapMintStatus';\nimport { WalletMintInput } from './types/WalletMintInput';\nimport { EmailReservationInput } from './types/EmailReservationInput';\nimport { CodeAlreadyMintedError } from './errors/CodeAlreadyMintedError';\nimport { CodeExpiredError } from './errors/CodeExpiredError';\nimport { MintChecker } from './utils/MintChecker';\nimport { PoapIndexed } from './utils/PoapIndexed';\n\n/**\n * Represents a client for interacting with POAPs.\n *\n * @class\n */\nexport class PoapsClient {\n /**\n * Initializes a new instance of the PoapsClient.\n *\n * @param {CompassProvider} compassProvider - The provider for the POAP compass API.\n * @param {TokensApiProvider} tokensApiProvider - The provider for the Tokens API.\n */\n constructor(\n private compassProvider: CompassProvider,\n private tokensApiProvider: TokensApiProvider,\n ) {}\n\n /**\n * Fetches a list of POAP tokens based on the given input criteria.\n *\n * @async\n * @param {FetchPoapsInput} input - Criteria for fetching POAP tokens.\n * @returns {Promise<PaginatedResult<POAP>>} A paginated list of POAP tokens.\n */\n async fetch(input: FetchPoapsInput): Promise<PaginatedResult<POAP>> {\n const {\n limit,\n offset,\n chain,\n collectorAddress,\n mintedDateFrom,\n mintedDateTo,\n ids,\n dropId,\n sortField,\n sortDir,\n filterZeroAddress = true,\n filterDeadAddress = true,\n } = input;\n\n const variables: PaginatedPoapsVariables = {\n limit,\n offset,\n orderBy: createOrderBy<PoapsSortFields>(sortField, sortDir),\n where: {\n ...createAddressFilter('collector_address', collectorAddress),\n ...(collectorAddress == undefined\n ? createNotNullAddressFilter(\n 'collector_address',\n filterZeroAddress,\n filterDeadAddress,\n )\n : {}),\n ...createEqFilter('chain', chain),\n ...createEqFilter('drop_id', dropId),\n ...createBetweenFilter('minted_on', mintedDateFrom, mintedDateTo),\n ...createInFilter('id', ids),\n },\n };\n\n const { data } = await this.compassProvider.request<\n PaginatedPoapsResponse,\n PaginatedPoapsVariables\n >(PAGINATED_POAPS_QUERY, variables);\n\n const poaps = data.poaps.map((poap) => POAP.fromCompass(poap));\n\n return new PaginatedResult<POAP>(\n poaps,\n nextCursor(poaps.length, limit, offset),\n );\n }\n\n /**\n * Retrieves mint code details for a specific Mint Code.\n *\n * @async\n * @param {string} mintCode - The Mint Code for which to get the mint code.\n * @returns {Promise<PoapMintStatus>} The Mint status.\n */\n async getMintCode(mintCode: string): Promise<PoapMintStatus> {\n const getMintCodeRaw = await this.tokensApiProvider.getMintCode(mintCode);\n return {\n minted: getMintCodeRaw.claimed,\n isActive: getMintCodeRaw.is_active,\n secretCode: getMintCodeRaw.secret,\n poapId: getMintCodeRaw.result?.token,\n };\n }\n\n /**\n * Gets the Transaction associated with the mint.\n * The Transaction could change in case of a bump.\n * It returns null if the mint has no transaction associated.\n *\n * @param {string} qrHash - The qrHash of the mint.\n * @returns {Promise<Transaction> | null} The Transaction associated with the mint. Null if no transaction is found.\n */\n public async getMintTransaction(qrHash: string): Promise<Transaction | null> {\n return await this.tokensApiProvider.getMintTransaction(qrHash);\n }\n\n /**\n * Awaits until we have a final Transaction status for a specific Mint Code.\n *\n * @async\n * @returns {Promise<void>}\n * @param mintCode - The Mint Code\n */\n public async waitMintStatus(mintCode: string): Promise<void> {\n const checker = new MintChecker(this.tokensApiProvider, mintCode);\n await checker.checkMintStatus();\n }\n\n /**\n * Awaits until a specific POAP, identified by its Mint Code, is indexed on our database.\n *\n * @async\n * @param {string} mintCode - The Mint Code identifying the POAP to be indexed.\n * @returns {Promise<PoapMintStatus>} - The status of the POAP mint.\n */\n public async waitPoapIndexed(mintCode: string): Promise<PoapMintStatus> {\n const checker = new PoapIndexed(this.tokensApiProvider, mintCode);\n return await checker.waitPoapIndexed();\n }\n\n /**\n * Begins an asynchronous mint process and provides a unique queue ID in return.\n *\n * @async\n * @param {WalletMintInput} input - Details required for the mint.\n */\n public async mintAsync(input: WalletMintInput): Promise<void> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n await this.tokensApiProvider.postMintCode({\n address: input.address,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: false,\n });\n }\n\n /**\n * Starts a synchronous mint process. The method waits for the mint to be processed and then\n * fetches the associated POAP. It combines the asynchronous mint and subsequent status checking\n * into a synchronous process for ease of use.\n *\n * @async\n * @param {WalletMintInput} input - Details needed for the mint.\n * @returns {Promise<POAP>} The associated POAP upon successful mint completion.\n * @throws {FinishedWithError} If there's an error concluding the mint process.\n */\n async mintSync(input: WalletMintInput): Promise<POAP> {\n await this.mintAsync(input);\n\n await this.waitMintStatus(input.mintCode);\n\n const getCodeResponse = await this.waitPoapIndexed(input.mintCode);\n\n return (\n await this.fetch({\n limit: 1,\n offset: 0,\n ids: [getCodeResponse.poapId],\n })\n ).items[0];\n }\n\n /**\n * Reserves a POAP to an email address and provides reservation details.\n *\n * @async\n * @param {EmailReservationInput} input - Information for the reservation.\n * @returns {Promise<POAPReservation>} The reservation details of the POAP.\n */\n public async emailReservation(\n input: EmailReservationInput,\n ): Promise<POAPReservation> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n const response = await this.tokensApiProvider.postMintCode({\n address: input.email,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: input.sendEmail || true,\n });\n\n return new POAPReservation({\n email: input.email,\n dropId: response.event.id,\n imageUrl: response.event.image_url,\n city: response.event.city,\n country: response.event.country,\n description: response.event.description,\n startDate: new Date(response.event.start_date),\n endDate: new Date(response.event.end_date),\n name: response.event.name,\n });\n }\n\n /**\n * Retrieves the secret code associated with a POAP code.\n *\n * @async\n * @param {string} mintCode - The POAP code for which to get the secret.\n * @returns {Promise<string>} The associated secret code.\n * @throws {CodeAlreadyMintedError} Thrown when the POAP code has already been minted.\n * @throws {CodeExpiredError} Thrown when the POAP code is expired.\n */\n private async getSecretCode(mintCode: string): Promise<string> {\n const getCodeResponse = await this.getMintCode(mintCode);\n\n if (getCodeResponse.minted) {\n throw new CodeAlreadyMintedError(mintCode);\n }\n if (!getCodeResponse.isActive) {\n throw new CodeExpiredError(mintCode);\n }\n\n return getCodeResponse.secretCode;\n }\n}\n"],"names":["PoapsSortFields"],"mappings":";;;;AAMYA,iCAKX;AALD,CAAA,UAAY,eAAe,EAAA;AAEzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,WAAsB,CAAA;AAEtB,IAAA,eAAA,CAAA,IAAA,CAAA,GAAA,IAAS,CAAA;AACX,CAAC,EALWA,uBAAe,KAAfA,uBAAe,GAK1B,EAAA,CAAA,CAAA;;ACXD,MAAM,eAAe,CAAC;AACtB,IAAI,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE;AACnC,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,QAAQ,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;AACrC,KAAK;AACL,CAAC;AACD;AACA,IAAI,KAAK,CAAC;AACV,CAAC,UAAU,KAAK,EAAE;AAClB,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;AACzB,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAC3B,CAAC,EAAE,KAAK,KAAK,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC;AAC1B;AACA,IAAI,KAAK,CAAC;AACV,CAAC,UAAU,KAAK,EAAE;AAClB,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;AAClC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;AAC7B,CAAC,EA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AI,IAAI;AACnC,SAAA,CAAC,CAAC;QAEH,OAAO,IAAI,eAAe,CAAC;YACzB,KAAK,EAAE,KAAK,CAAC,KAAK;AAClB,YAAA,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE;AACzB,YAAA,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS;AAClC,YAAA,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI;AACzB,YAAA,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO;AAC/B,YAAA,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW;YACvC,SAAS,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;YAC9C,OAAO,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;AAC1C,YAAA,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI;AAC1B,SAAA,CAAC,CAAC;KACJ;IAWO,MAAM,aAAa,CAAC,QAAgB,EAAA;QAC1C,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AAEzD,QAAA,IAAI,eAAe,CAAC,MAAM,EAAE;AAC1B,YAAA,MAAM,IAAI,sBAAsB,CAAC,QAAQ,CAAC,CAAC;SAC5C;AACD,QAAA,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;AAC7B,YAAA,MAAM,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;SACtC;QAED,OAAO,eAAe,CAAC,UAAU,CAAC;KACnC;AACF;;;;;;;;;"} |
+79
-79
@@ -11,60 +11,2 @@ 'use strict'; | ||
| 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 { | ||
@@ -158,2 +100,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 { | ||
@@ -248,3 +266,3 @@ constructor(code) { | ||
| class PoapIndexed extends RetryableTask { | ||
| constructor(mintCode, tokensApiProvider) { | ||
| constructor(tokensApiProvider, mintCode) { | ||
| super(tokensApiProvider); | ||
@@ -291,21 +309,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)); | ||
@@ -331,3 +331,3 @@ } | ||
| async waitPoapIndexed(mintCode) { | ||
| const checker = new PoapIndexed(mintCode, this.tokensApiProvider); | ||
| const checker = new PoapIndexed(this.tokensApiProvider, mintCode); | ||
| return await checker.waitPoapIndexed(); | ||
@@ -334,0 +334,0 @@ } |
@@ -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 {}; |
+79
-79
@@ -9,60 +9,2 @@ import 'axios'; | ||
| 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 { | ||
@@ -156,2 +98,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 { | ||
@@ -246,3 +264,3 @@ constructor(code) { | ||
| class PoapIndexed extends RetryableTask { | ||
| constructor(mintCode, tokensApiProvider) { | ||
| constructor(tokensApiProvider, mintCode) { | ||
| super(tokensApiProvider); | ||
@@ -289,21 +307,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)); | ||
@@ -329,3 +329,3 @@ } | ||
| async waitPoapIndexed(mintCode) { | ||
| const checker = new PoapIndexed(mintCode, this.tokensApiProvider); | ||
| const checker = new PoapIndexed(this.tokensApiProvider, mintCode); | ||
| return await checker.waitPoapIndexed(); | ||
@@ -332,0 +332,0 @@ } |
@@ -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'; |
+79
-79
@@ -9,60 +9,2 @@ import 'axios'; | ||
| 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 { | ||
@@ -156,2 +98,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 { | ||
@@ -246,3 +264,3 @@ constructor(code) { | ||
| class PoapIndexed extends RetryableTask { | ||
| constructor(mintCode, tokensApiProvider) { | ||
| constructor(tokensApiProvider, mintCode) { | ||
| super(tokensApiProvider); | ||
@@ -289,21 +307,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)); | ||
@@ -329,3 +329,3 @@ } | ||
| async waitPoapIndexed(mintCode) { | ||
| const checker = new PoapIndexed(mintCode, this.tokensApiProvider); | ||
| const checker = new PoapIndexed(this.tokensApiProvider, mintCode); | ||
| return await checker.waitPoapIndexed(); | ||
@@ -332,0 +332,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.mjs","sources":["../../src/types/input.ts","../../src/domain/Poap.ts","../../src/domain/POAPReservation.ts","../../src/queries/PaginatedPoaps.ts","../../../utils/dist/esm/index.mjs","../../src/errors/CodeAlreadyMintedError.ts","../../src/errors/CodeExpiredError.ts","../../../providers/dist/esm/index.mjs","../../src/errors/FinishedWithError.ts","../../src/utils/RetryableTask.ts","../../src/utils/MintChecker.ts","../../src/utils/PoapIndexed.ts","../../src/PoapsClient.ts"],"sourcesContent":["import { Order, Chain, PaginationInput } from '@poap-xyz/utils';\n\n/**\n * Enum to define available fields for sorting POAPs.\n *\n * @export\n * @enum {string}\n */\nexport enum PoapsSortFields {\n /** Represents sorting by the date when a POAP was minted. */\n MintedOn = 'minted_on',\n /** Represents sorting by the ID of a POAP. */\n Id = 'id',\n}\n\n/**\n * Represents the input fields for fetching POAPs.\n * This interface extends `PaginationInput` to provide pagination capability.\n *\n * @export\n * @interface FetchPoapsInput\n * @extends {PaginationInput}\n */\nexport interface FetchPoapsInput extends PaginationInput {\n /** Optional filter for the name of a POAP. */\n name?: string;\n /** Optional filter for the blockchain chain of a POAP. */\n chain?: Chain;\n /** Optional filter for the start date when a POAP was minted. */\n mintedDateFrom?: string;\n /** Optional filter for the end date when a POAP was minted. */\n mintedDateTo?: string;\n /** Optional filter for specific POAP IDs. */\n ids?: number[];\n /** Optional filter for the collector's address. */\n collectorAddress?: string;\n /** Optional filter for a specific drop ID. */\n dropId?: number;\n /** Field by which to sort the results. */\n sortField?: PoapsSortFields;\n /** Direction in which to sort the results. */\n sortDir?: Order;\n /** Filter to include/exclude POAPs with zero addresses. */\n filterZeroAddress?: boolean;\n /** Filter out dead addresses? */\n filterDeadAddress?: boolean;\n}\n\n/**\n * Represents the input fields required to mint a POAP for a wallet.\n *\n * @export\n * @interface WalletMintInput\n */\nexport interface WalletMintInput {\n mintCode: string;\n address: string;\n}\n\n/**\n * Represents the input fields required to reserve a POAP via email.\n *\n * @export\n * @interface EmailReservationInput\n */\nexport interface EmailReservationInput {\n mintCode: string;\n email: string;\n sendEmail?: boolean;\n}\n","/* eslint-disable max-statements */\nexport class POAP {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n constructor(properties: PoapProperties) {\n this.id = properties.id;\n this.collectorAddress = properties.collectorAddress;\n this.mintedOn = properties.mintedOn;\n this.dropId = properties.dropId;\n this.transferCount = properties.transferCount;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\nexport interface PoapProperties {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n name: string;\n endDate: Date;\n}\n","/* eslint-disable max-statements */\nexport class POAPReservation {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n constructor(properties: POAPReservationProperties) {\n this.email = properties.email;\n this.dropId = properties.dropId;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\nexport interface POAPReservationProperties {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n name: string;\n endDate: Date;\n}\n","import {\n FilterVariables,\n OrderByVariables,\n PaginatedVariables,\n} from '@poap-xyz/utils';\n\nexport const PAGINATED_POAPS_QUERY = `\n query PaginatedPoaps(\n $limit: Int!\n $offset: Int!\n $orderBy: [poaps_order_by!]\n $where: poaps_bool_exp\n ) {\n poaps(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) {\n chain\n collector_address\n drop_id\n id\n minted_on\n transfer_count\n drop {\n image_url\n city\n country\n description\n start_date\n end_date\n name\n }\n }\n }\n`;\n\nexport interface PoapsResponse {\n id: number;\n collector_address: string;\n transfer_count: number;\n minted_on: number;\n drop_id: number;\n drop: {\n image_url: string;\n city: string;\n country: string;\n description: string;\n start_date: string;\n end_date: string;\n name: string;\n };\n}\n\nexport interface PaginatedPoapsResponse {\n poaps: PoapsResponse[];\n}\n\nexport type PaginatedPoapsVariables = FilterVariables &\n OrderByVariables &\n PaginatedVariables;\n","class PaginatedResult {\n constructor(items, nextCursor) {\n this.items = items;\n this.nextCursor = nextCursor;\n }\n}\n\nvar Order;\n(function (Order) {\n Order[\"ASC\"] = \"asc\";\n Order[\"DESC\"] = \"desc\";\n})(Order || (Order = {}));\n\nvar Chain;\n(function (Chain) {\n Chain[\"Ethereum\"] = \"mainnet\";\n Chain[\"Gnosis\"] = \"xdai\";\n})(Chain || (Chain = {}));\n\nvar TransactionRequestStatus;\n(function (TransactionRequestStatus) {\n TransactionRequestStatus[\"PENDING\"] = \"PENDING\";\n TransactionRequestStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n TransactionRequestStatus[\"FINISH\"] = \"FINISH\";\n TransactionRequestStatus[\"FINISH_WITH_ERROR\"] = \"FINISH_WITH_ERROR\";\n})(TransactionRequestStatus || (TransactionRequestStatus = {}));\n\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\nconst DEAD_ADDRESS = '0x000000000000000000000000000000000000dead';\n\nfunction nextCursor(length, limit, offset) {\n const endIndex = offset + length;\n return endIndex < offset + limit ? null : endIndex;\n}\n\nfunction createField(keys, value) {\n return keys.split('.').reduceRight((prev, key) => ({\n [key]: prev,\n }), value);\n}\n\nfunction createLikeFilter(key, value) {\n return value\n ? createField(key, { _ilike: `%${value}%` })\n : {};\n}\nfunction createEqFilter(key, value) {\n return value ? createField(key, { _eq: value }) : {};\n}\nfunction createNeqFilter(key, value) {\n return value ? createField(key, { _neq: value }) : {};\n}\nfunction createBoolFilter(key, value) {\n return typeof value === 'boolean'\n ? createField(key, {\n _eq: value ? 'true' : 'false',\n })\n : {};\n}\nfunction createAddressFilter(key, value) {\n return value\n ? createField(key, { _eq: value.toLowerCase() })\n : {};\n}\nfunction createNotNullAddressFilter(key, filterZeroAddress = true, filterDeadAddress = true) {\n if (filterZeroAddress && filterDeadAddress) {\n return createField(key, {\n _nin: [ZERO_ADDRESS, DEAD_ADDRESS],\n });\n }\n if (filterZeroAddress) {\n return createField(key, {\n _neq: ZERO_ADDRESS,\n });\n }\n if (filterDeadAddress) {\n return createField(key, {\n _neq: DEAD_ADDRESS,\n });\n }\n return {};\n}\nfunction createInFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _in: values })\n : {};\n}\nfunction createNinFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _nin: values })\n : {};\n}\nfunction createLtFilter(key, value) {\n return value ? createField(key, { _lt: value }) : {};\n}\nfunction createLteFilter(key, value) {\n return value ? createField(key, { _lte: value }) : {};\n}\nfunction createGtFilter(key, value) {\n return value ? createField(key, { _gt: value }) : {};\n}\nfunction createGteFilter(key, value) {\n return value ? createField(key, { _gte: value }) : {};\n}\nfunction createBetweenFilter(key, from, to) {\n const betweenFilter = {};\n if (from) {\n betweenFilter._gte = from;\n }\n if (to) {\n betweenFilter._lte = to;\n }\n return from || to\n ? createField(key, betweenFilter)\n : {};\n}\n\nfunction createOrderBy(key, value) {\n return key && value ? createField(key, value) : {};\n}\n\nfunction removeSpecialCharacters(str) {\n return str.replace(/[^a-zA-Z0-9 ]/g, '');\n}\n\nfunction isNumeric(value, allowNegative = false) {\n if (typeof value === 'string') {\n return (allowNegative ? /^-?\\d+$/ : /^\\d+$/).test(value);\n }\n if (typeof value === 'number') {\n return true;\n }\n return false;\n}\n\nexport { Chain, DEAD_ADDRESS, Order, PaginatedResult, TransactionRequestStatus, ZERO_ADDRESS, createAddressFilter, createBetweenFilter, createBoolFilter, createEqFilter, createGtFilter, createGteFilter, createInFilter, createLikeFilter, createLtFilter, createLteFilter, createNeqFilter, createNinFilter, createNotNullAddressFilter, createOrderBy, isNumeric, nextCursor, removeSpecialCharacters };\n//# sourceMappingURL=index.mjs.map\n","export class CodeAlreadyMintedError extends Error {\n constructor(code: string) {\n super(`Code: '${code}' already minted `);\n }\n}\n","export class CodeExpiredError extends Error {\n constructor(code: string) {\n super(`Code: '${code}', has been expired`);\n }\n}\n","import axios, { AxiosError } from 'axios';\n\nclass InvalidMediaError extends Error {\n constructor(reason) {\n super(`There was an while creating Moment. Invalid media file. Reason: ${reason}`);\n this.name = InvalidMediaError.name;\n }\n}\n\nvar MediaStatus;\n(function (MediaStatus) {\n MediaStatus[\"INVALID\"] = \"INVALID\";\n MediaStatus[\"PROCESSED\"] = \"PROCESSED\";\n MediaStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n})(MediaStatus || (MediaStatus = {}));\n\nvar TransactionStatus;\n(function (TransactionStatus) {\n TransactionStatus[\"pending\"] = \"pending\";\n TransactionStatus[\"passed\"] = \"passed\";\n TransactionStatus[\"failed\"] = \"failed\";\n TransactionStatus[\"waiting\"] = \"waiting_tx\";\n})(TransactionStatus || (TransactionStatus = {}));\n\nclass CompassRequestError extends Error {\n constructor(compassErrors) {\n super(`Error fetching Compass data: ${compassErrors.errors.map((error) => error.message).join(', ')}`);\n this.errors = compassErrors.errors;\n }\n}\n\nclass CompassMissingDataError extends Error {\n constructor() {\n super('Compass response is missing data');\n }\n}\n\nclass CompassBadRequestError extends Error {\n constructor() {\n super('Compass malformed request');\n }\n}\n\nclass CompassUnauthorizedError extends Error {\n constructor() {\n super('Unauthorized access, API key may be invalid or expired');\n }\n}\n\nclass MissingAuthenticationProviderError extends Error {\n constructor() {\n super(`An AuthenticationProvider is required for write operations`);\n }\n}\n\nconst DEFAULT_MOMENTS_BASE_URL = 'https://moments.poap.tech';\nclass PoapMomentsApi {\n constructor(params) {\n var _a;\n this.baseUrl = (_a = params.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_MOMENTS_BASE_URL;\n this.authenticationProvider = params.authenticationProvider;\n }\n async getSignedUrl() {\n const response = await axios.post(`${this.baseUrl}/moments/media-upload-url`, undefined, {\n headers: {\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n async uploadFile(fileBinary, signedUrl, fileType, onProgress) {\n await axios.put(signedUrl, fileBinary, {\n headers: {\n 'Content-Type': fileType,\n },\n onUploadProgress: (progressEvent) => {\n if (onProgress) {\n onProgress(progressEvent.progress || 0);\n }\n },\n });\n }\n async fetchMediaStatus(mediaKey) {\n var _a;\n try {\n const response = await axios.get(`${this.baseUrl}/media/${mediaKey}`);\n return response.data.status;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {\n return MediaStatus.IN_PROCESS;\n }\n throw error;\n }\n }\n async waitForMediaProcessing(mediaKey, timeOut = 60000) {\n const delay = 2000;\n const maxTries = timeOut / delay;\n const checkStatus = async (tries) => {\n if (tries >= maxTries) {\n throw new Error('Exceeded maximum number of tries to check media processing status.');\n }\n const status = await this.fetchMediaStatus(mediaKey);\n if (status === MediaStatus.PROCESSED) {\n return;\n }\n if (status === MediaStatus.INVALID) {\n throw new InvalidMediaError('status is invalid');\n }\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(tries + 1);\n };\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(0);\n }\n async createMoment(input) {\n var _a;\n try {\n const response = await axios.post(`${this.baseUrl}/moments`, input, {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 409) {\n throw new InvalidMediaError(error.response.data.message);\n }\n throw error;\n }\n }\n async patchMoment(id, input) {\n await fetch(`${this.baseUrl}/moments/${id}`, {\n method: 'PATCH',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new Error('An AuthenticationProvider is required for write operations');\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nconst DEFAULT_DROP_BASE_URL$1 = 'https://api.poap.tech';\nclass PoapDropApi {\n constructor(config) {\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl || DEFAULT_DROP_BASE_URL$1;\n }\n async createDrop(input) {\n const form = new FormData();\n for (const key in input) {\n if (Object.prototype.hasOwnProperty.call(input, key)) {\n if (key === 'image') {\n form.append(key, input[key]);\n }\n else {\n form.append(key, input[key] + '');\n }\n }\n }\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'POST',\n body: form,\n headers: {},\n });\n }\n async updateDrop(input) {\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'PUT',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n };\n const response = await fetch(url, {\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n });\n return await response.json();\n }\n}\n\nfunction getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\n/**\n * lodash (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors <https://jquery.org/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991,\n MAX_INTEGER = 1.7976931348623157e+308,\n NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n symbolTag = '[object Symbol]';\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeCeil = Math.ceil,\n nativeMax = Math.max;\n\n/**\n * The base implementation of `_.slice` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\nfunction baseSlice(array, start, end) {\n var index = -1,\n length = array.length;\n\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = end > length ? length : end;\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : ((end - start) >>> 0);\n start >>>= 0;\n\n var result = Array(length);\n while (++index < length) {\n result[index] = array[index + start];\n }\n return result;\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\n/**\n * Creates an array of elements split into groups the length of `size`.\n * If `array` can't be split evenly, the final chunk will be the remaining\n * elements.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to process.\n * @param {number} [size=1] The length of each chunk\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the new array of chunks.\n * @example\n *\n * _.chunk(['a', 'b', 'c', 'd'], 2);\n * // => [['a', 'b'], ['c', 'd']]\n *\n * _.chunk(['a', 'b', 'c', 'd'], 3);\n * // => [['a', 'b', 'c'], ['d']]\n */\nfunction chunk(array, size, guard) {\n if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {\n size = 1;\n } else {\n size = nativeMax(toInteger(size), 0);\n }\n var length = array ? array.length : 0;\n if (!length || size < 1) {\n return [];\n }\n var index = 0,\n resIndex = 0,\n result = Array(nativeCeil(length / size));\n\n while (index < length) {\n result[resIndex++] = baseSlice(array, index, (index += size));\n }\n return result;\n}\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\nfunction toFinite(value) {\n if (!value) {\n return value === 0 ? value : 0;\n }\n value = toNumber(value);\n if (value === INFINITY || value === -INFINITY) {\n var sign = (value < 0 ? -1 : 1);\n return sign * MAX_INTEGER;\n }\n return value === value ? value : 0;\n}\n\n/**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\nfunction toInteger(value) {\n var result = toFinite(value),\n remainder = result % 1;\n\n return result === result ? (remainder ? result - remainder : result) : 0;\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nvar lodash_chunk = chunk;\n\nvar chunk$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_chunk);\n\nconst DEFAULT_COMPASS_BASE_URL = 'https://public.compass.poap.tech/v1/graphql';\nclass PoapCompass {\n constructor(config) {\n var _a;\n this.batchSize = 5;\n this.apiKey = config.apiKey;\n this.baseUrl = (_a = config.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_COMPASS_BASE_URL;\n }\n async fetchGraphQL(query, variables, signal) {\n let response;\n try {\n response = await fetch(this.baseUrl, {\n signal,\n method: 'POST',\n body: JSON.stringify({\n query,\n variables,\n }),\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': this.apiKey,\n },\n });\n }\n catch (error) {\n throw new Error(`Network error, received error ${error}`);\n }\n this.handleResponseStatus(response);\n const body = await response.json();\n this.handleResponseErrors(body);\n return body;\n }\n handleResponseStatus(response) {\n switch (response.status) {\n case 400:\n throw new CompassBadRequestError();\n case 401:\n throw new CompassUnauthorizedError();\n case 200:\n return;\n default:\n throw new Error(`Response error, received status code ${response.status}`);\n }\n }\n handleResponseErrors(response) {\n if (this.isError(response)) {\n throw new CompassRequestError(response);\n }\n if (!this.hasData(response)) {\n throw new CompassMissingDataError();\n }\n }\n isError(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'errors' in response &&\n Array.isArray(response.errors) &&\n response.errors.every((error) => error != null &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'));\n }\n hasData(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'data' in response &&\n response.data != null &&\n typeof response.data === 'object');\n }\n async request(query, variables, signal) {\n return await this.fetchGraphQL(query, variables !== null && variables !== void 0 ? variables : {}, signal);\n }\n async batch(query, variables, signal) {\n const results = [];\n const chunks = chunk$1(variables, this.batchSize);\n for (const chunk of chunks) {\n const responses = await Promise.all(chunk.map((variables) => this.request(query, variables, signal)));\n results.push(...responses);\n }\n return results;\n }\n}\n\nconst DEFAULT_OAUTH_SERVER = 'auth.accounts.poap.xyz';\nclass AuthenticationProviderHttp {\n constructor(clientId, clientSecret, oAuthServerDomain) {\n this.clientId = clientId;\n this.clientSecret = clientSecret;\n this.oAuthServerDomain = oAuthServerDomain || DEFAULT_OAUTH_SERVER;\n }\n async getJWT(audience) {\n if (this.tokenData && !this.isTokenExpired()) {\n return this.tokenData.accessToken;\n }\n const response = await fetch(`https://${this.oAuthServerDomain}/oauth/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n client_id: this.clientId,\n client_secret: this.clientSecret,\n audience,\n grant_type: 'client_credentials',\n }),\n });\n if (!response.ok) {\n throw new Error(`Network response was not ok: ${response.statusText}`);\n }\n const responseData = await response.json();\n this.tokenData = {\n accessToken: responseData.access_token,\n expiresAt: Date.now() + responseData.expires_in * 1000,\n };\n return responseData.access_token;\n }\n isTokenExpired() {\n return !this.tokenData || this.tokenData.expiresAt < Date.now();\n }\n}\n\nconst DEFAULT_DROP_BASE_URL = 'https://api.poap.tech';\nclass PoapTokenApi {\n constructor({ apiKey, baseUrl = DEFAULT_DROP_BASE_URL, authenticationProvider, }) {\n this.apiKey = apiKey;\n this.baseUrl = baseUrl;\n this.authenticationProvider = authenticationProvider;\n }\n async getMintCode(code) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr?qr_hash=${code}`, {\n method: 'GET',\n headers: {},\n });\n }\n async postMintCode(input) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr`, {\n method: 'POST',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async getMintTransaction(qrHash) {\n const transactions = await this.secureFetch(`${this.baseUrl}/transactions?qr_hash=${qrHash}`, {\n method: 'GET',\n });\n if (transactions.total === 0) {\n return null;\n }\n const status = transactions.transactions[0].status;\n if (status === TransactionStatus.waiting) {\n return null;\n }\n return transactions.transactions[0];\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n Authorization: await this.getAuthorizationToken(),\n };\n const response = await fetch(url, {\n ...options,\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n signal: AbortSignal.timeout(10000),\n });\n return await response.json();\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new MissingAuthenticationProviderError();\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nexport { AuthenticationProviderHttp, CompassBadRequestError, CompassMissingDataError, CompassRequestError, CompassUnauthorizedError, InvalidMediaError, MediaStatus, MissingAuthenticationProviderError, PoapCompass, PoapDropApi, PoapMomentsApi, PoapTokenApi, TransactionStatus };\n//# sourceMappingURL=index.mjs.map\n","export class FinishedWithError extends Error {\n constructor(error: string, code: string) {\n super(\n `Code: '${code}', finished with error: '${error}', please try again later `,\n );\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\n\nconst MAX_RETRIES = 20;\nconst INITIAL_DELAY = 1000;\nconst BACKOFF_FACTOR = 1.2;\n\n/**\n * Abstract class representing a task that can be retried with an increasing delay.\n */\nexport abstract class RetryableTask {\n protected retries = 0;\n protected delay: number = INITIAL_DELAY;\n protected tokensApiProvider: TokensApiProvider;\n\n /**\n * Constructs a new RetryableTask instance.\n *\n * @param {TokensApiProvider} tokensApiProvider - The provider used to perform operations that might be retried.\n */\n constructor(tokensApiProvider: TokensApiProvider) {\n this.tokensApiProvider = tokensApiProvider;\n }\n\n /**\n * Attempts to perform a given task. If the task fails, it retries with an increasing delay until\n * maximum retries are reached.\n *\n * @protected\n * @template T - The type of value that the callback returns.\n * @param {() => Promise<T>} callback - The asynchronous function representing the task to be retried.\n * @returns {Promise<T>} A promise that resolves to the result of the task or rejects with an error.\n * @throws {Error} Throws an error if maximum retries are reached.\n */\n protected backoffAndRetry<T>(callback: () => Promise<T>): Promise<T> {\n if (this.retries >= MAX_RETRIES) {\n throw new Error('Max retries reached');\n }\n this.retries++;\n this.delay *= BACKOFF_FACTOR;\n\n return new Promise<T>((resolve, reject) => {\n setTimeout(() => {\n callback().then(resolve, reject);\n }, this.delay);\n });\n }\n}\n","import {\n TokensApiProvider,\n Transaction,\n TransactionStatus,\n} from '@poap-xyz/providers';\nimport { FinishedWithError } from '../errors/FinishedWithError';\nimport { RetryableTask } from './RetryableTask';\n\n/**\n * A utility class designed to continually check the status of a POAP token mint.\n * If a mint is still pending or in process, it implements a backoff retry mechanism.\n */\nexport class MintChecker extends RetryableTask {\n private mintCode: string;\n\n /**\n * Constructs a new instance of the MintChecker class.\n *\n * @param {string} mintCode - The unique code for the token mint.\n * @param {TokensApiProvider} tokensApiProvider - The provider to fetch the mint status.\n */\n constructor(tokensApiProvider: TokensApiProvider, mintCode: string) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Checks the current status of a token mint.\n * If the mint is still pending or in process, it will retry the check with an increased delay.\n *\n * @public\n * @returns {Promise<void>} A promise that resolves once the status has been checked.\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n public async checkMintStatus(): Promise<void> {\n try {\n const transaction = await this.tokensApiProvider.getMintTransaction(\n this.mintCode,\n );\n\n if (this.shouldRetry(transaction)) {\n await this.backoffAndRetry(() => this.checkMintStatus());\n } else {\n this.handleErrorStatus(transaction, this.mintCode);\n }\n } catch (e) {\n if (e instanceof FinishedWithError) {\n throw e;\n }\n\n await this.backoffAndRetry(() => this.checkMintStatus());\n }\n }\n\n /**\n * Determines if a retry should be performed based on the provided minting status.\n *\n * @private\n * @returns {boolean} Returns true if a retry should be performed, otherwise false.\n * @param transaction - The transaction to check for retry.\n */\n private shouldRetry(transaction: Transaction | null): boolean {\n return !transaction || transaction.status === TransactionStatus.pending;\n }\n\n /**\n * Handles any error statuses from the mint status response.\n * If the minting process finishes with an error, an exception will be thrown.\n *\n * @private\n * @param {Transaction} transaction - The transaction to check for errors.\n * @param mintCode\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n private handleErrorStatus(\n transaction: Transaction | null,\n mintCode: string,\n ): void {\n if (transaction?.status === TransactionStatus.failed) {\n throw new FinishedWithError(\n 'The Transaction associated with this mint failed',\n mintCode,\n );\n }\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\nimport { RetryableTask } from './RetryableTask';\nimport { PoapMintStatus } from '../types';\n\n/**\n * @class PoapIndexed\n * @extends {RetryableTask}\n *\n * Represents a utility class designed to periodically check if a POAP token is indexed on our database.\n * This class extends `RetryableTask` to utilize its backoff retry mechanism in case the token hasn't been indexed yet.\n */\nexport class PoapIndexed extends RetryableTask {\n private mintCode: string;\n\n /**\n * Creates an instance of the PoapIndexed class.\n *\n * @param {string} mintCode - A unique Mint Code representing the token.\n * @param {TokensApiProvider} tokensApiProvider - An instance of the TokensApiProvider used to check the indexing status of the token.\n */\n constructor(mintCode: string, tokensApiProvider: TokensApiProvider) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Periodically checks if the POAP token, represented by its Mint Code, is indexed on our database.\n * This method will continue retrying with an increasing delay until either the token is indexed or it reaches the maximum allowed retries.\n *\n * @returns {Promise<GetClaimCodeResponse>} A promise that either resolves with the indexed token's mint code response or rejects due to reaching the max retry limit.\n */\n public async waitPoapIndexed(): Promise<PoapMintStatus> {\n let response = await this.tokensApiProvider.getMintCode(this.mintCode);\n while (response.result == null) {\n response = await this.backoffAndRetry(() =>\n this.tokensApiProvider.getMintCode(this.mintCode),\n );\n }\n return {\n minted: response.claimed,\n isActive: response.is_active,\n secretCode: response.secret,\n poapId: response.result?.token,\n };\n }\n}\n","import {\n CompassProvider,\n TokensApiProvider,\n Transaction,\n} from '@poap-xyz/providers';\nimport { POAP } from './domain/Poap';\nimport { POAPReservation } from './domain/POAPReservation';\nimport {\n PAGINATED_POAPS_QUERY,\n PaginatedPoapsResponse,\n PaginatedPoapsVariables,\n} from './queries';\nimport {\n EmailReservationInput,\n FetchPoapsInput,\n PoapMintStatus,\n PoapsSortFields,\n WalletMintInput,\n} from './types';\nimport {\n createAddressFilter,\n createBetweenFilter,\n createEqFilter,\n createInFilter,\n createNotNullAddressFilter,\n createOrderBy,\n nextCursor,\n PaginatedResult,\n} from '@poap-xyz/utils';\nimport { CodeAlreadyMintedError } from './errors/CodeAlreadyMintedError';\nimport { CodeExpiredError } from './errors/CodeExpiredError';\nimport { MintChecker } from './utils/MintChecker';\nimport { PoapIndexed } from './utils/PoapIndexed';\n\n/**\n * Represents a client for interacting with POAPs .\n * @class\n */\nexport class PoapsClient {\n /**\n * Initializes a new instance of the PoapsClient.\n * @param {CompassProvider} compassProvider - The provider for the POAP compass API.\n * @param {TokensApiProvider} tokensApiProvider - The provider for the Tokens API.\n */\n constructor(\n private compassProvider: CompassProvider,\n private tokensApiProvider: TokensApiProvider,\n ) {}\n\n /**\n * Fetches a list of POAP tokens based on the given input criteria.\n * @async\n * @param {FetchPoapsInput} input - Criteria for fetching POAP tokens.\n * @returns {Promise<PaginatedResult<POAP>>} A paginated list of POAP tokens.\n */\n async fetch(input: FetchPoapsInput): Promise<PaginatedResult<POAP>> {\n const {\n limit,\n offset,\n chain,\n collectorAddress,\n mintedDateFrom,\n mintedDateTo,\n ids,\n dropId,\n sortField,\n sortDir,\n filterZeroAddress = true,\n filterDeadAddress = true,\n } = input;\n\n const variables: PaginatedPoapsVariables = {\n limit,\n offset,\n orderBy: createOrderBy<PoapsSortFields>(sortField, sortDir),\n where: {\n ...createAddressFilter('collector_address', collectorAddress),\n ...(collectorAddress == undefined\n ? createNotNullAddressFilter(\n 'collector_address',\n filterZeroAddress,\n filterDeadAddress,\n )\n : {}),\n ...createEqFilter('chain', chain),\n ...createEqFilter('drop_id', dropId),\n ...createBetweenFilter('minted_on', mintedDateFrom, mintedDateTo),\n ...createInFilter('id', ids),\n },\n };\n\n const { data } = await this.compassProvider.request<\n PaginatedPoapsResponse,\n PaginatedPoapsVariables\n >(PAGINATED_POAPS_QUERY, variables);\n\n const poaps = data.poaps.map((poap) => {\n const { drop } = poap;\n const mintedOn = new Date(0);\n mintedOn.setUTCSeconds(poap.minted_on);\n return new POAP({\n id: Number(poap.id),\n collectorAddress: poap.collector_address,\n transferCount: poap.transfer_count,\n mintedOn,\n dropId: Number(poap.drop_id),\n imageUrl: drop.image_url,\n city: drop.city,\n country: drop.country,\n description: drop.description,\n startDate: new Date(drop.start_date),\n name: drop.name,\n endDate: new Date(drop.end_date),\n });\n });\n\n return new PaginatedResult<POAP>(\n poaps,\n nextCursor(poaps.length, limit, offset),\n );\n }\n\n /**\n * Retrieves mint code details for a specific Mint Code.\n * @async\n * @param {string} mintCode - The Mint Code for which to get the mint code.\n * @returns {Promise<PoapMintStatus>} The Mint status.\n */\n async getMintCode(mintCode: string): Promise<PoapMintStatus> {\n const getMintCodeRaw = await this.tokensApiProvider.getMintCode(mintCode);\n return {\n minted: getMintCodeRaw.claimed,\n isActive: getMintCodeRaw.is_active,\n secretCode: getMintCodeRaw.secret,\n poapId: getMintCodeRaw.result?.token,\n };\n }\n\n /**\n * Gets the Transaction associated with the mint.\n * The Transaction could change in case of a bump.\n * It returns null if the mint has no transaction associated.\n *\n * @param {string} qrHash - The qrHash of the mint.\n * @returns {Promise<Transaction> | null} The Transaction associated with the mint. Null if no transaction is found.\n */\n public async getMintTransaction(qrHash: string): Promise<Transaction | null> {\n return await this.tokensApiProvider.getMintTransaction(qrHash);\n }\n\n /**\n * Awaits until we have a final Transaction status for a specific Mint Code.\n * @async\n * @returns {Promise<void>}\n * @param mintCode - The Mint Code\n */\n public async waitMintStatus(mintCode: string): Promise<void> {\n const checker = new MintChecker(this.tokensApiProvider, mintCode);\n await checker.checkMintStatus();\n }\n\n /**\n * Awaits until a specific POAP, identified by its Mint Code, is indexed on our database.\n * @async\n * @param {string} mintCode - The Mint Code identifying the POAP to be indexed.\n * @returns {Promise<PoapMintStatus>} - The status of the POAP mint.\n */\n public async waitPoapIndexed(mintCode: string): Promise<PoapMintStatus> {\n const checker = new PoapIndexed(mintCode, this.tokensApiProvider);\n return await checker.waitPoapIndexed();\n }\n\n /**\n * Begins an asynchronous mint process and provides a unique queue ID in return.\n * @async\n * @param {WalletMintInput} input - Details required for the mint.\n */\n public async mintAsync(input: WalletMintInput): Promise<void> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n await this.tokensApiProvider.postMintCode({\n address: input.address,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: false,\n });\n }\n\n /**\n * Starts a synchronous mint process. The method waits for the mint to be processed and then\n * fetches the associated POAP. It combines the asynchronous mint and subsequent status checking\n * into a synchronous process for ease of use.\n * @async\n * @param {WalletMintInput} input - Details needed for the mint.\n * @returns {Promise<POAP>} The associated POAP upon successful mint completion.\n * @throws {FinishedWithError} If there's an error concluding the mint process.\n */\n async mintSync(input: WalletMintInput): Promise<POAP> {\n await this.mintAsync(input);\n\n await this.waitMintStatus(input.mintCode);\n\n const getCodeResponse = await this.waitPoapIndexed(input.mintCode);\n\n return (\n await this.fetch({\n limit: 1,\n offset: 0,\n ids: [getCodeResponse.poapId],\n })\n ).items[0];\n }\n\n /**\n * Reserves a POAP to an email address and provides reservation details.\n * @async\n * @param {EmailReservationInput} input - Information for the reservation.\n * @returns {Promise<POAPReservation>} The reservation details of the POAP.\n */\n public async emailReservation(\n input: EmailReservationInput,\n ): Promise<POAPReservation> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n const response = await this.tokensApiProvider.postMintCode({\n address: input.email,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: input.sendEmail || true,\n });\n\n return new POAPReservation({\n email: input.email,\n dropId: response.event.id,\n imageUrl: response.event.image_url,\n city: response.event.city,\n country: response.event.country,\n description: response.event.description,\n startDate: new Date(response.event.start_date),\n endDate: new Date(response.event.end_date),\n name: response.event.name,\n });\n }\n\n /**\n * Retrieves the secret code associated with a POAP code.\n * @async\n * @param {string} mintCode - The POAP code for which to get the secret.\n * @returns {Promise<string>} The associated secret code.\n * @throws {CodeAlreadyMintedError} Thrown when the POAP code has already been minted.\n * @throws {CodeExpiredError} Thrown when the POAP code is expired.\n */\n private async getSecretCode(mintCode: string): Promise<string> {\n const getCodeResponse = await this.getMintCode(mintCode);\n\n if (getCodeResponse.minted) {\n throw new CodeAlreadyMintedError(mintCode);\n }\n if (!getCodeResponse.isActive) {\n throw new CodeExpiredError(mintCode);\n }\n\n return getCodeResponse.secretCode;\n }\n}\n"],"names":[],"mappings":";;IAQY,gBAKX;AALD,CAAA,UAAY,eAAe,EAAA;AAEzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,WAAsB,CAAA;AAEtB,IAAA,eAAA,CAAA,IAAA,CAAA,GAAA,IAAS,CAAA;AACX,CAAC,EALW,eAAe,KAAf,eAAe,GAK1B,EAAA,CAAA,CAAA;;MCZY,IAAI,CAAA;AAcf,IAAA,WAAA,CAAY,UAA0B,EAAA;AACpC,QAAA,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC;AACxB,QAAA,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC,gBAAgB,CAAC;AACpD,QAAA,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;AACpC,QAAA,IAAI,CAAC,MAA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{"version":3,"file":"index.mjs","sources":["../../src/types/PoapsSortFields.ts","../../../utils/dist/esm/index.mjs","../../src/domain/POAP.ts","../../src/domain/POAPReservation.ts","../../src/queries/PaginatedPoaps.ts","../../src/errors/CodeAlreadyMintedError.ts","../../src/errors/CodeExpiredError.ts","../../../providers/dist/esm/index.mjs","../../src/errors/FinishedWithError.ts","../../src/utils/RetryableTask.ts","../../src/utils/MintChecker.ts","../../src/utils/PoapIndexed.ts","../../src/PoapsClient.ts"],"sourcesContent":["/**\n * Enum to define available fields for sorting POAPs.\n *\n * @export\n * @enum {string}\n */\nexport enum PoapsSortFields {\n /** Represents sorting by the date when a POAP was minted. */\n MintedOn = 'minted_on',\n /** Represents sorting by the ID of a POAP. */\n Id = 'id',\n}\n","class PaginatedResult {\n constructor(items, nextCursor) {\n this.items = items;\n this.nextCursor = nextCursor;\n }\n}\n\nvar Order;\n(function (Order) {\n Order[\"ASC\"] = \"asc\";\n Order[\"DESC\"] = \"desc\";\n})(Order || (Order = {}));\n\nvar Chain;\n(function (Chain) {\n Chain[\"Ethereum\"] = \"mainnet\";\n Chain[\"Gnosis\"] = \"xdai\";\n})(Chain || (Chain = {}));\n\nvar TransactionRequestStatus;\n(function (TransactionRequestStatus) {\n TransactionRequestStatus[\"PENDING\"] = \"PENDING\";\n TransactionRequestStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n TransactionRequestStatus[\"FINISH\"] = \"FINISH\";\n TransactionRequestStatus[\"FINISH_WITH_ERROR\"] = \"FINISH_WITH_ERROR\";\n})(TransactionRequestStatus || (TransactionRequestStatus = {}));\n\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\nconst DEAD_ADDRESS = '0x000000000000000000000000000000000000dead';\n\nfunction nextCursor(length, limit, offset) {\n const endIndex = offset + length;\n return endIndex < offset + limit ? null : endIndex;\n}\n\nfunction createField(keys, value) {\n return keys.split('.').reduceRight((prev, key) => ({\n [key]: prev,\n }), value);\n}\n\nfunction createLikeFilter(key, value) {\n return value\n ? createField(key, { _ilike: `%${value}%` })\n : {};\n}\nfunction createEqFilter(key, value) {\n return value ? createField(key, { _eq: value }) : {};\n}\nfunction createNeqFilter(key, value) {\n return value ? createField(key, { _neq: value }) : {};\n}\nfunction createBoolFilter(key, value) {\n return typeof value === 'boolean'\n ? createField(key, {\n _eq: value ? 'true' : 'false',\n })\n : {};\n}\nfunction createAddressFilter(key, value) {\n return value\n ? createField(key, { _eq: value.toLowerCase() })\n : {};\n}\nfunction createNotNullAddressFilter(key, filterZeroAddress = true, filterDeadAddress = true) {\n if (filterZeroAddress && filterDeadAddress) {\n return createField(key, {\n _nin: [ZERO_ADDRESS, DEAD_ADDRESS],\n });\n }\n if (filterZeroAddress) {\n return createField(key, {\n _neq: ZERO_ADDRESS,\n });\n }\n if (filterDeadAddress) {\n return createField(key, {\n _neq: DEAD_ADDRESS,\n });\n }\n return {};\n}\nfunction createInFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _in: values })\n : {};\n}\nfunction createNinFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _nin: values })\n : {};\n}\nfunction createLtFilter(key, value) {\n return value ? createField(key, { _lt: value }) : {};\n}\nfunction createLteFilter(key, value) {\n return value ? createField(key, { _lte: value }) : {};\n}\nfunction createGtFilter(key, value) {\n return value ? createField(key, { _gt: value }) : {};\n}\nfunction createGteFilter(key, value) {\n return value ? createField(key, { _gte: value }) : {};\n}\nfunction createBetweenFilter(key, from, to) {\n const betweenFilter = {};\n if (from) {\n betweenFilter._gte = from;\n }\n if (to) {\n betweenFilter._lte = to;\n }\n return from || to\n ? createField(key, betweenFilter)\n : {};\n}\n\nfunction createOrderBy(key, value) {\n return key && value ? createField(key, value) : {};\n}\n\nfunction removeSpecialCharacters(str) {\n return str.replace(/[^a-zA-Z0-9 ]/g, '');\n}\n\nfunction isNumeric(value, allowNegative = false) {\n if (typeof value === 'string') {\n return (allowNegative ? /^-?\\d+$/ : /^\\d+$/).test(value);\n }\n if (typeof value === 'number') {\n return true;\n }\n return false;\n}\n\nexport { Chain, DEAD_ADDRESS, Order, PaginatedResult, TransactionRequestStatus, ZERO_ADDRESS, createAddressFilter, createBetweenFilter, createBoolFilter, createEqFilter, createGtFilter, createGteFilter, createInFilter, createLikeFilter, createLtFilter, createLteFilter, createNeqFilter, createNinFilter, createNotNullAddressFilter, createOrderBy, isNumeric, nextCursor, removeSpecialCharacters };\n//# sourceMappingURL=index.mjs.map\n","import { PoapsResponse } from '../queries/PaginatedPoaps';\n\nexport class POAP {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n public static fromCompass(response: PoapsResponse): POAP {\n const mintedOn = new Date(0);\n mintedOn.setUTCSeconds(response.minted_on);\n\n return new POAP({\n id: Number(response.id),\n collectorAddress: response.collector_address,\n transferCount: response.transfer_count,\n mintedOn,\n dropId: Number(response.drop_id),\n imageUrl: response.drop.image_url,\n city: response.drop.city,\n country: response.drop.country,\n description: response.drop.description,\n startDate: new Date(response.drop.start_date),\n endDate: new Date(response.drop.end_date),\n name: response.drop.name,\n });\n }\n\n // eslint-disable-next-line max-statements\n constructor(properties: PoapProperties) {\n this.id = properties.id;\n this.collectorAddress = properties.collectorAddress;\n this.mintedOn = properties.mintedOn;\n this.dropId = properties.dropId;\n this.transferCount = properties.transferCount;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\ninterface PoapProperties {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n}\n","export class POAPReservation {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n constructor(properties: POAPReservationProperties) {\n this.email = properties.email;\n this.dropId = properties.dropId;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\ninterface POAPReservationProperties {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n name: string;\n endDate: Date;\n}\n","import {\n FilterVariables,\n OrderByVariables,\n PaginatedVariables,\n} from '@poap-xyz/utils';\n\nexport const PAGINATED_POAPS_QUERY = `\n query PaginatedPoaps(\n $limit: Int!\n $offset: Int!\n $orderBy: [poaps_order_by!]\n $where: poaps_bool_exp\n ) {\n poaps(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) {\n chain\n collector_address\n drop_id\n id\n minted_on\n transfer_count\n drop {\n image_url\n city\n country\n description\n start_date\n end_date\n name\n }\n }\n }\n`;\n\nexport interface PoapsResponse {\n id: number;\n collector_address: string;\n transfer_count: number;\n minted_on: number;\n drop_id: number;\n drop: {\n image_url: string;\n city: string;\n country: string;\n description: string;\n start_date: string;\n end_date: string;\n name: string;\n };\n}\n\nexport interface PaginatedPoapsResponse {\n poaps: PoapsResponse[];\n}\n\nexport type PaginatedPoapsVariables = FilterVariables &\n OrderByVariables &\n PaginatedVariables;\n","export class CodeAlreadyMintedError extends Error {\n constructor(code: string) {\n super(`Code: '${code}' already minted `);\n }\n}\n","export class CodeExpiredError extends Error {\n constructor(code: string) {\n super(`Code: '${code}', has been expired`);\n }\n}\n","import axios, { AxiosError } from 'axios';\n\nclass InvalidMediaError extends Error {\n constructor(reason) {\n super(`There was an while creating Moment. Invalid media file. Reason: ${reason}`);\n this.name = InvalidMediaError.name;\n }\n}\n\nvar MediaStatus;\n(function (MediaStatus) {\n MediaStatus[\"INVALID\"] = \"INVALID\";\n MediaStatus[\"PROCESSED\"] = \"PROCESSED\";\n MediaStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n})(MediaStatus || (MediaStatus = {}));\n\nvar TransactionStatus;\n(function (TransactionStatus) {\n TransactionStatus[\"pending\"] = \"pending\";\n TransactionStatus[\"passed\"] = \"passed\";\n TransactionStatus[\"failed\"] = \"failed\";\n TransactionStatus[\"waiting\"] = \"waiting_tx\";\n})(TransactionStatus || (TransactionStatus = {}));\n\nclass CompassRequestError extends Error {\n constructor(compassErrors) {\n super(`Error fetching Compass data: ${compassErrors.errors.map((error) => error.message).join(', ')}`);\n this.errors = compassErrors.errors;\n }\n}\n\nclass CompassMissingDataError extends Error {\n constructor() {\n super('Compass response is missing data');\n }\n}\n\nclass CompassBadRequestError extends Error {\n constructor() {\n super('Compass malformed request');\n }\n}\n\nclass CompassUnauthorizedError extends Error {\n constructor() {\n super('Unauthorized access, API key may be invalid or expired');\n }\n}\n\nclass MissingAuthenticationProviderError extends Error {\n constructor() {\n super(`An AuthenticationProvider is required for write operations`);\n }\n}\n\nconst DEFAULT_MOMENTS_BASE_URL = 'https://moments.poap.tech';\nclass PoapMomentsApi {\n constructor(params) {\n var _a;\n this.baseUrl = (_a = params.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_MOMENTS_BASE_URL;\n this.authenticationProvider = params.authenticationProvider;\n }\n async getSignedUrl() {\n const response = await axios.post(`${this.baseUrl}/moments/media-upload-url`, undefined, {\n headers: {\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n async uploadFile(fileBinary, signedUrl, fileType, onProgress) {\n await axios.put(signedUrl, fileBinary, {\n headers: {\n 'Content-Type': fileType,\n },\n onUploadProgress: (progressEvent) => {\n if (onProgress) {\n onProgress(progressEvent.progress || 0);\n }\n },\n });\n }\n async fetchMediaStatus(mediaKey) {\n var _a;\n try {\n const response = await axios.get(`${this.baseUrl}/media/${mediaKey}`);\n return response.data.status;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {\n return MediaStatus.IN_PROCESS;\n }\n throw error;\n }\n }\n async waitForMediaProcessing(mediaKey, timeOut = 60000) {\n const delay = 2000;\n const maxTries = timeOut / delay;\n const checkStatus = async (tries) => {\n if (tries >= maxTries) {\n throw new Error('Exceeded maximum number of tries to check media processing status.');\n }\n const status = await this.fetchMediaStatus(mediaKey);\n if (status === MediaStatus.PROCESSED) {\n return;\n }\n if (status === MediaStatus.INVALID) {\n throw new InvalidMediaError('status is invalid');\n }\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(tries + 1);\n };\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(0);\n }\n async createMoment(input) {\n var _a;\n try {\n const response = await axios.post(`${this.baseUrl}/moments`, input, {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 409) {\n throw new InvalidMediaError(error.response.data.message);\n }\n throw error;\n }\n }\n async patchMoment(id, input) {\n await fetch(`${this.baseUrl}/moments/${id}`, {\n method: 'PATCH',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new Error('An AuthenticationProvider is required for write operations');\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nconst DEFAULT_DROP_BASE_URL$1 = 'https://api.poap.tech';\nclass PoapDropApi {\n constructor(config) {\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl || DEFAULT_DROP_BASE_URL$1;\n }\n async createDrop(input) {\n const form = new FormData();\n for (const key in input) {\n if (Object.prototype.hasOwnProperty.call(input, key)) {\n if (key === 'image') {\n form.append(key, input[key]);\n }\n else {\n form.append(key, input[key] + '');\n }\n }\n }\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'POST',\n body: form,\n headers: {},\n });\n }\n async updateDrop(input) {\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'PUT',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n };\n const response = await fetch(url, {\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n });\n return await response.json();\n }\n}\n\nfunction getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\n/**\n * lodash (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors <https://jquery.org/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991,\n MAX_INTEGER = 1.7976931348623157e+308,\n NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n symbolTag = '[object Symbol]';\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeCeil = Math.ceil,\n nativeMax = Math.max;\n\n/**\n * The base implementation of `_.slice` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\nfunction baseSlice(array, start, end) {\n var index = -1,\n length = array.length;\n\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = end > length ? length : end;\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : ((end - start) >>> 0);\n start >>>= 0;\n\n var result = Array(length);\n while (++index < length) {\n result[index] = array[index + start];\n }\n return result;\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\n/**\n * Creates an array of elements split into groups the length of `size`.\n * If `array` can't be split evenly, the final chunk will be the remaining\n * elements.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to process.\n * @param {number} [size=1] The length of each chunk\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the new array of chunks.\n * @example\n *\n * _.chunk(['a', 'b', 'c', 'd'], 2);\n * // => [['a', 'b'], ['c', 'd']]\n *\n * _.chunk(['a', 'b', 'c', 'd'], 3);\n * // => [['a', 'b', 'c'], ['d']]\n */\nfunction chunk(array, size, guard) {\n if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {\n size = 1;\n } else {\n size = nativeMax(toInteger(size), 0);\n }\n var length = array ? array.length : 0;\n if (!length || size < 1) {\n return [];\n }\n var index = 0,\n resIndex = 0,\n result = Array(nativeCeil(length / size));\n\n while (index < length) {\n result[resIndex++] = baseSlice(array, index, (index += size));\n }\n return result;\n}\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\nfunction toFinite(value) {\n if (!value) {\n return value === 0 ? value : 0;\n }\n value = toNumber(value);\n if (value === INFINITY || value === -INFINITY) {\n var sign = (value < 0 ? -1 : 1);\n return sign * MAX_INTEGER;\n }\n return value === value ? value : 0;\n}\n\n/**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\nfunction toInteger(value) {\n var result = toFinite(value),\n remainder = result % 1;\n\n return result === result ? (remainder ? result - remainder : result) : 0;\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nvar lodash_chunk = chunk;\n\nvar chunk$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_chunk);\n\nconst DEFAULT_COMPASS_BASE_URL = 'https://public.compass.poap.tech/v1/graphql';\nclass PoapCompass {\n constructor(config) {\n var _a;\n this.batchSize = 5;\n this.apiKey = config.apiKey;\n this.baseUrl = (_a = config.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_COMPASS_BASE_URL;\n }\n async fetchGraphQL(query, variables, signal) {\n let response;\n try {\n response = await fetch(this.baseUrl, {\n signal,\n method: 'POST',\n body: JSON.stringify({\n query,\n variables,\n }),\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': this.apiKey,\n },\n });\n }\n catch (error) {\n throw new Error(`Network error, received error ${error}`);\n }\n this.handleResponseStatus(response);\n const body = await response.json();\n this.handleResponseErrors(body);\n return body;\n }\n handleResponseStatus(response) {\n switch (response.status) {\n case 400:\n throw new CompassBadRequestError();\n case 401:\n throw new CompassUnauthorizedError();\n case 200:\n return;\n default:\n throw new Error(`Response error, received status code ${response.status}`);\n }\n }\n handleResponseErrors(response) {\n if (this.isError(response)) {\n throw new CompassRequestError(response);\n }\n if (!this.hasData(response)) {\n throw new CompassMissingDataError();\n }\n }\n isError(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'errors' in response &&\n Array.isArray(response.errors) &&\n response.errors.every((error) => error != null &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'));\n }\n hasData(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'data' in response &&\n response.data != null &&\n typeof response.data === 'object');\n }\n async request(query, variables, signal) {\n return await this.fetchGraphQL(query, variables !== null && variables !== void 0 ? variables : {}, signal);\n }\n async batch(query, variables, signal) {\n const results = [];\n const chunks = chunk$1(variables, this.batchSize);\n for (const chunk of chunks) {\n const responses = await Promise.all(chunk.map((variables) => this.request(query, variables, signal)));\n results.push(...responses);\n }\n return results;\n }\n}\n\nconst DEFAULT_OAUTH_SERVER = 'auth.accounts.poap.xyz';\nclass AuthenticationProviderHttp {\n constructor(clientId, clientSecret, oAuthServerDomain) {\n this.clientId = clientId;\n this.clientSecret = clientSecret;\n this.oAuthServerDomain = oAuthServerDomain || DEFAULT_OAUTH_SERVER;\n }\n async getJWT(audience) {\n if (this.tokenData && !this.isTokenExpired()) {\n return this.tokenData.accessToken;\n }\n const response = await fetch(`https://${this.oAuthServerDomain}/oauth/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n client_id: this.clientId,\n client_secret: this.clientSecret,\n audience,\n grant_type: 'client_credentials',\n }),\n });\n if (!response.ok) {\n throw new Error(`Network response was not ok: ${response.statusText}`);\n }\n const responseData = await response.json();\n this.tokenData = {\n accessToken: responseData.access_token,\n expiresAt: Date.now() + responseData.expires_in * 1000,\n };\n return responseData.access_token;\n }\n isTokenExpired() {\n return !this.tokenData || this.tokenData.expiresAt < Date.now();\n }\n}\n\nconst DEFAULT_DROP_BASE_URL = 'https://api.poap.tech';\nclass PoapTokenApi {\n constructor({ apiKey, baseUrl = DEFAULT_DROP_BASE_URL, authenticationProvider, }) {\n this.apiKey = apiKey;\n this.baseUrl = baseUrl;\n this.authenticationProvider = authenticationProvider;\n }\n async getMintCode(code) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr?qr_hash=${code}`, {\n method: 'GET',\n headers: {},\n });\n }\n async postMintCode(input) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr`, {\n method: 'POST',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async getMintTransaction(qrHash) {\n const transactions = await this.secureFetch(`${this.baseUrl}/transactions?qr_hash=${qrHash}`, {\n method: 'GET',\n });\n if (transactions.total === 0) {\n return null;\n }\n const status = transactions.transactions[0].status;\n if (status === TransactionStatus.waiting) {\n return null;\n }\n return transactions.transactions[0];\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n Authorization: await this.getAuthorizationToken(),\n };\n const response = await fetch(url, {\n ...options,\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n signal: AbortSignal.timeout(10000),\n });\n return await response.json();\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new MissingAuthenticationProviderError();\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nexport { AuthenticationProviderHttp, CompassBadRequestError, CompassMissingDataError, CompassRequestError, CompassUnauthorizedError, InvalidMediaError, MediaStatus, MissingAuthenticationProviderError, PoapCompass, PoapDropApi, PoapMomentsApi, PoapTokenApi, TransactionStatus };\n//# sourceMappingURL=index.mjs.map\n","export class FinishedWithError extends Error {\n constructor(error: string, code: string) {\n super(\n `Code: '${code}', finished with error: '${error}', please try again later `,\n );\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\n\nconst MAX_RETRIES = 20;\nconst INITIAL_DELAY = 1000;\nconst BACKOFF_FACTOR = 1.2;\n\n/**\n * Abstract class representing a task that can be retried with an increasing delay.\n */\nexport abstract class RetryableTask {\n protected retries = 0;\n protected delay: number = INITIAL_DELAY;\n protected tokensApiProvider: TokensApiProvider;\n\n /**\n * Constructs a new RetryableTask instance.\n *\n * @param {TokensApiProvider} tokensApiProvider - The provider used to perform operations that might be retried.\n */\n constructor(tokensApiProvider: TokensApiProvider) {\n this.tokensApiProvider = tokensApiProvider;\n }\n\n /**\n * Attempts to perform a given task. If the task fails, it retries with an increasing delay until\n * maximum retries are reached.\n *\n * @protected\n * @template T - The type of value that the callback returns.\n * @param {() => Promise<T>} callback - The asynchronous function representing the task to be retried.\n * @returns {Promise<T>} A promise that resolves to the result of the task or rejects with an error.\n * @throws {Error} Throws an error if maximum retries are reached.\n */\n protected backoffAndRetry<T>(callback: () => Promise<T>): Promise<T> {\n if (this.retries >= MAX_RETRIES) {\n throw new Error('Max retries reached');\n }\n this.retries++;\n this.delay *= BACKOFF_FACTOR;\n\n return new Promise<T>((resolve, reject) => {\n setTimeout(() => {\n callback().then(resolve, reject);\n }, this.delay);\n });\n }\n}\n","import {\n TokensApiProvider,\n Transaction,\n TransactionStatus,\n} from '@poap-xyz/providers';\nimport { FinishedWithError } from '../errors/FinishedWithError';\nimport { RetryableTask } from './RetryableTask';\n\n/**\n * A utility class designed to continually check the status of a POAP token mint.\n * If a mint is still pending or in process, it implements a backoff retry mechanism.\n */\nexport class MintChecker extends RetryableTask {\n private mintCode: string;\n\n /**\n * Constructs a new instance of the MintChecker class.\n *\n * @param {string} mintCode - The unique code for the token mint.\n * @param {TokensApiProvider} tokensApiProvider - The provider to fetch the mint status.\n */\n constructor(tokensApiProvider: TokensApiProvider, mintCode: string) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Checks the current status of a token mint.\n * If the mint is still pending or in process, it will retry the check with an increased delay.\n *\n * @public\n * @returns {Promise<void>} A promise that resolves once the status has been checked.\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n public async checkMintStatus(): Promise<void> {\n try {\n const transaction = await this.tokensApiProvider.getMintTransaction(\n this.mintCode,\n );\n\n if (this.shouldRetry(transaction)) {\n await this.backoffAndRetry(() => this.checkMintStatus());\n } else {\n this.handleErrorStatus(transaction, this.mintCode);\n }\n } catch (e) {\n if (e instanceof FinishedWithError) {\n throw e;\n }\n\n await this.backoffAndRetry(() => this.checkMintStatus());\n }\n }\n\n /**\n * Determines if a retry should be performed based on the provided minting status.\n *\n * @private\n * @returns {boolean} Returns true if a retry should be performed, otherwise false.\n * @param transaction - The transaction to check for retry.\n */\n private shouldRetry(transaction: Transaction | null): boolean {\n return !transaction || transaction.status === TransactionStatus.pending;\n }\n\n /**\n * Handles any error statuses from the mint status response.\n * If the minting process finishes with an error, an exception will be thrown.\n *\n * @private\n * @param {Transaction} transaction - The transaction to check for errors.\n * @param mintCode\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n private handleErrorStatus(\n transaction: Transaction | null,\n mintCode: string,\n ): void {\n if (transaction?.status === TransactionStatus.failed) {\n throw new FinishedWithError(\n 'The Transaction associated with this mint failed',\n mintCode,\n );\n }\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\nimport { RetryableTask } from './RetryableTask';\nimport { PoapMintStatus } from '../types/PoapMintStatus';\n\n/**\n * @class PoapIndexed\n * @extends {RetryableTask}\n *\n * Represents a utility class designed to periodically check if a POAP token is indexed on our database.\n * This class extends `RetryableTask` to utilize its backoff retry mechanism in case the token hasn't been indexed yet.\n */\nexport class PoapIndexed extends RetryableTask {\n private mintCode: string;\n\n /**\n * Creates an instance of the PoapIndexed class.\n *\n * @param {TokensApiProvider} tokensApiProvider - An instance of the TokensApiProvider used to check the indexing status of the token.\n * @param {string} mintCode - A unique Mint Code representing the token.\n */\n constructor(tokensApiProvider: TokensApiProvider, mintCode: string) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Periodically checks if the POAP token, represented by its Mint Code, is indexed on our database.\n * This method will continue retrying with an increasing delay until either the token is indexed or it reaches the maximum allowed retries.\n *\n * @returns {Promise<GetClaimCodeResponse>} A promise that either resolves with the indexed token's mint code response or rejects due to reaching the max retry limit.\n */\n public async waitPoapIndexed(): Promise<PoapMintStatus> {\n let response = await this.tokensApiProvider.getMintCode(this.mintCode);\n while (response.result == null) {\n response = await this.backoffAndRetry(() =>\n this.tokensApiProvider.getMintCode(this.mintCode),\n );\n }\n return {\n minted: response.claimed,\n isActive: response.is_active,\n secretCode: response.secret,\n poapId: response.result?.token,\n };\n }\n}\n","import {\n CompassProvider,\n TokensApiProvider,\n Transaction,\n} from '@poap-xyz/providers';\nimport {\n createAddressFilter,\n createBetweenFilter,\n createEqFilter,\n createInFilter,\n createNotNullAddressFilter,\n createOrderBy,\n nextCursor,\n PaginatedResult,\n} from '@poap-xyz/utils';\nimport { POAP } from './domain/POAP';\nimport { POAPReservation } from './domain/POAPReservation';\nimport {\n PAGINATED_POAPS_QUERY,\n PaginatedPoapsResponse,\n PaginatedPoapsVariables,\n} from './queries/PaginatedPoaps';\nimport { FetchPoapsInput } from './types/FetchPoapsInput';\nimport { PoapsSortFields } from './types/PoapsSortFields';\nimport { PoapMintStatus } from './types/PoapMintStatus';\nimport { WalletMintInput } from './types/WalletMintInput';\nimport { EmailReservationInput } from './types/EmailReservationInput';\nimport { CodeAlreadyMintedError } from './errors/CodeAlreadyMintedError';\nimport { CodeExpiredError } from './errors/CodeExpiredError';\nimport { MintChecker } from './utils/MintChecker';\nimport { PoapIndexed } from './utils/PoapIndexed';\n\n/**\n * Represents a client for interacting with POAPs.\n *\n * @class\n */\nexport class PoapsClient {\n /**\n * Initializes a new instance of the PoapsClient.\n *\n * @param {CompassProvider} compassProvider - The provider for the POAP compass API.\n * @param {TokensApiProvider} tokensApiProvider - The provider for the Tokens API.\n */\n constructor(\n private compassProvider: CompassProvider,\n private tokensApiProvider: TokensApiProvider,\n ) {}\n\n /**\n * Fetches a list of POAP tokens based on the given input criteria.\n *\n * @async\n * @param {FetchPoapsInput} input - Criteria for fetching POAP tokens.\n * @returns {Promise<PaginatedResult<POAP>>} A paginated list of POAP tokens.\n */\n async fetch(input: FetchPoapsInput): Promise<PaginatedResult<POAP>> {\n const {\n limit,\n offset,\n chain,\n collectorAddress,\n mintedDateFrom,\n mintedDateTo,\n ids,\n dropId,\n sortField,\n sortDir,\n filterZeroAddress = true,\n filterDeadAddress = true,\n } = input;\n\n const variables: PaginatedPoapsVariables = {\n limit,\n offset,\n orderBy: createOrderBy<PoapsSortFields>(sortField, sortDir),\n where: {\n ...createAddressFilter('collector_address', collectorAddress),\n ...(collectorAddress == undefined\n ? createNotNullAddressFilter(\n 'collector_address',\n filterZeroAddress,\n filterDeadAddress,\n )\n : {}),\n ...createEqFilter('chain', chain),\n ...createEqFilter('drop_id', dropId),\n ...createBetweenFilter('minted_on', mintedDateFrom, mintedDateTo),\n ...createInFilter('id', ids),\n },\n };\n\n const { data } = await this.compassProvider.request<\n PaginatedPoapsResponse,\n PaginatedPoapsVariables\n >(PAGINATED_POAPS_QUERY, variables);\n\n const poaps = data.poaps.map((poap) => POAP.fromCompass(poap));\n\n return new PaginatedResult<POAP>(\n poaps,\n nextCursor(poaps.length, limit, offset),\n );\n }\n\n /**\n * Retrieves mint code details for a specific Mint Code.\n *\n * @async\n * @param {string} mintCode - The Mint Code for which to get the mint code.\n * @returns {Promise<PoapMintStatus>} The Mint status.\n */\n async getMintCode(mintCode: string): Promise<PoapMintStatus> {\n const getMintCodeRaw = await this.tokensApiProvider.getMintCode(mintCode);\n return {\n minted: getMintCodeRaw.claimed,\n isActive: getMintCodeRaw.is_active,\n secretCode: getMintCodeRaw.secret,\n poapId: getMintCodeRaw.result?.token,\n };\n }\n\n /**\n * Gets the Transaction associated with the mint.\n * The Transaction could change in case of a bump.\n * It returns null if the mint has no transaction associated.\n *\n * @param {string} qrHash - The qrHash of the mint.\n * @returns {Promise<Transaction> | null} The Transaction associated with the mint. Null if no transaction is found.\n */\n public async getMintTransaction(qrHash: string): Promise<Transaction | null> {\n return await this.tokensApiProvider.getMintTransaction(qrHash);\n }\n\n /**\n * Awaits until we have a final Transaction status for a specific Mint Code.\n *\n * @async\n * @returns {Promise<void>}\n * @param mintCode - The Mint Code\n */\n public async waitMintStatus(mintCode: string): Promise<void> {\n const checker = new MintChecker(this.tokensApiProvider, mintCode);\n await checker.checkMintStatus();\n }\n\n /**\n * Awaits until a specific POAP, identified by its Mint Code, is indexed on our database.\n *\n * @async\n * @param {string} mintCode - The Mint Code identifying the POAP to be indexed.\n * @returns {Promise<PoapMintStatus>} - The status of the POAP mint.\n */\n public async waitPoapIndexed(mintCode: string): Promise<PoapMintStatus> {\n const checker = new PoapIndexed(this.tokensApiProvider, mintCode);\n return await checker.waitPoapIndexed();\n }\n\n /**\n * Begins an asynchronous mint process and provides a unique queue ID in return.\n *\n * @async\n * @param {WalletMintInput} input - Details required for the mint.\n */\n public async mintAsync(input: WalletMintInput): Promise<void> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n await this.tokensApiProvider.postMintCode({\n address: input.address,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: false,\n });\n }\n\n /**\n * Starts a synchronous mint process. The method waits for the mint to be processed and then\n * fetches the associated POAP. It combines the asynchronous mint and subsequent status checking\n * into a synchronous process for ease of use.\n *\n * @async\n * @param {WalletMintInput} input - Details needed for the mint.\n * @returns {Promise<POAP>} The associated POAP upon successful mint completion.\n * @throws {FinishedWithError} If there's an error concluding the mint process.\n */\n async mintSync(input: WalletMintInput): Promise<POAP> {\n await this.mintAsync(input);\n\n await this.waitMintStatus(input.mintCode);\n\n const getCodeResponse = await this.waitPoapIndexed(input.mintCode);\n\n return (\n await this.fetch({\n limit: 1,\n offset: 0,\n ids: [getCodeResponse.poapId],\n })\n ).items[0];\n }\n\n /**\n * Reserves a POAP to an email address and provides reservation details.\n *\n * @async\n * @param {EmailReservationInput} input - Information for the reservation.\n * @returns {Promise<POAPReservation>} The reservation details of the POAP.\n */\n public async emailReservation(\n input: EmailReservationInput,\n ): Promise<POAPReservation> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n const response = await this.tokensApiProvider.postMintCode({\n address: input.email,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: input.sendEmail || true,\n });\n\n return new POAPReservation({\n email: input.email,\n dropId: response.event.id,\n imageUrl: response.event.image_url,\n city: response.event.city,\n country: response.event.country,\n description: response.event.description,\n startDate: new Date(response.event.start_date),\n endDate: new Date(response.event.end_date),\n name: response.event.name,\n });\n }\n\n /**\n * Retrieves the secret code associated with a POAP code.\n *\n * @async\n * @param {string} mintCode - The POAP code for which to get the secret.\n * @returns {Promise<string>} The associated secret code.\n * @throws {CodeAlreadyMintedError} Thrown when the POAP code has already been minted.\n * @throws {CodeExpiredError} Thrown when the POAP code is expired.\n */\n private async getSecretCode(mintCode: string): Promise<string> {\n const getCodeResponse = await this.getMintCode(mintCode);\n\n if (getCodeResponse.minted) {\n throw new CodeAlreadyMintedError(mintCode);\n }\n if (!getCodeResponse.isActive) {\n throw new CodeExpiredError(mintCode);\n }\n\n return getCodeResponse.secretCode;\n }\n}\n"],"names":[],"mappings":";;IAMY,gBAKX;AALD,CAAA,UAAY,eAAe,EAAA;AAEzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,WAAsB,CAAA;AAEtB,IAAA,eAAA,CAAA,IAAA,CAAA,GAAA,IAAS,CAAA;AACX,CAAC,EALW,eAAe,KAAf,eAAe,GAK1B,EAAA,CAAA,CAAA;;ACXD,MAAM,eAAe,CAAC;AACtB,IAAI,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE;AACnC,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,QAAQ,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;AACrC,KAAK;AACL,CAAC;AACD;AACA,IAAI,KAAK,CAAC;AACV,CAAC,UAAU,KAAK,EAAE;AA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AQ,EAAE;AAC7B,YAAA,MAAM,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;SACtC;QAED,OAAO,eAAe,CAAC,UAAU,CAAC;KACnC;AACF;;;;"} |
| 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'; |
+79
-79
@@ -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 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../src/types/input.ts","../../src/domain/Poap.ts","../../src/domain/POAPReservation.ts","../../src/queries/PaginatedPoaps.ts","../../../utils/dist/esm/index.mjs","../../src/errors/CodeAlreadyMintedError.ts","../../src/errors/CodeExpiredError.ts","../../../providers/dist/esm/index.mjs","../../src/errors/FinishedWithError.ts","../../src/utils/RetryableTask.ts","../../src/utils/MintChecker.ts","../../src/utils/PoapIndexed.ts","../../src/PoapsClient.ts"],"sourcesContent":["import { Order, Chain, PaginationInput } from '@poap-xyz/utils';\n\n/**\n * Enum to define available fields for sorting POAPs.\n *\n * @export\n * @enum {string}\n */\nexport enum PoapsSortFields {\n /** Represents sorting by the date when a POAP was minted. */\n MintedOn = 'minted_on',\n /** Represents sorting by the ID of a POAP. */\n Id = 'id',\n}\n\n/**\n * Represents the input fields for fetching POAPs.\n * This interface extends `PaginationInput` to provide pagination capability.\n *\n * @export\n * @interface FetchPoapsInput\n * @extends {PaginationInput}\n */\nexport interface FetchPoapsInput extends PaginationInput {\n /** Optional filter for the name of a POAP. */\n name?: string;\n /** Optional filter for the blockchain chain of a POAP. */\n chain?: Chain;\n /** Optional filter for the start date when a POAP was minted. */\n mintedDateFrom?: string;\n /** Optional filter for the end date when a POAP was minted. */\n mintedDateTo?: string;\n /** Optional filter for specific POAP IDs. */\n ids?: number[];\n /** Optional filter for the collector's address. */\n collectorAddress?: string;\n /** Optional filter for a specific drop ID. */\n dropId?: number;\n /** Field by which to sort the results. */\n sortField?: PoapsSortFields;\n /** Direction in which to sort the results. */\n sortDir?: Order;\n /** Filter to include/exclude POAPs with zero addresses. */\n filterZeroAddress?: boolean;\n /** Filter out dead addresses? */\n filterDeadAddress?: boolean;\n}\n\n/**\n * Represents the input fields required to mint a POAP for a wallet.\n *\n * @export\n * @interface WalletMintInput\n */\nexport interface WalletMintInput {\n mintCode: string;\n address: string;\n}\n\n/**\n * Represents the input fields required to reserve a POAP via email.\n *\n * @export\n * @interface EmailReservationInput\n */\nexport interface EmailReservationInput {\n mintCode: string;\n email: string;\n sendEmail?: boolean;\n}\n","/* eslint-disable max-statements */\nexport class POAP {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n constructor(properties: PoapProperties) {\n this.id = properties.id;\n this.collectorAddress = properties.collectorAddress;\n this.mintedOn = properties.mintedOn;\n this.dropId = properties.dropId;\n this.transferCount = properties.transferCount;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\nexport interface PoapProperties {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n name: string;\n endDate: Date;\n}\n","/* eslint-disable max-statements */\nexport class POAPReservation {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n constructor(properties: POAPReservationProperties) {\n this.email = properties.email;\n this.dropId = properties.dropId;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\nexport interface POAPReservationProperties {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n name: string;\n endDate: Date;\n}\n","import {\n FilterVariables,\n OrderByVariables,\n PaginatedVariables,\n} from '@poap-xyz/utils';\n\nexport const PAGINATED_POAPS_QUERY = `\n query PaginatedPoaps(\n $limit: Int!\n $offset: Int!\n $orderBy: [poaps_order_by!]\n $where: poaps_bool_exp\n ) {\n poaps(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) {\n chain\n collector_address\n drop_id\n id\n minted_on\n transfer_count\n drop {\n image_url\n city\n country\n description\n start_date\n end_date\n name\n }\n }\n }\n`;\n\nexport interface PoapsResponse {\n id: number;\n collector_address: string;\n transfer_count: number;\n minted_on: number;\n drop_id: number;\n drop: {\n image_url: string;\n city: string;\n country: string;\n description: string;\n start_date: string;\n end_date: string;\n name: string;\n };\n}\n\nexport interface PaginatedPoapsResponse {\n poaps: PoapsResponse[];\n}\n\nexport type PaginatedPoapsVariables = FilterVariables &\n OrderByVariables &\n PaginatedVariables;\n","class PaginatedResult {\n constructor(items, nextCursor) {\n this.items = items;\n this.nextCursor = nextCursor;\n }\n}\n\nvar Order;\n(function (Order) {\n Order[\"ASC\"] = \"asc\";\n Order[\"DESC\"] = \"desc\";\n})(Order || (Order = {}));\n\nvar Chain;\n(function (Chain) {\n Chain[\"Ethereum\"] = \"mainnet\";\n Chain[\"Gnosis\"] = \"xdai\";\n})(Chain || (Chain = {}));\n\nvar TransactionRequestStatus;\n(function (TransactionRequestStatus) {\n TransactionRequestStatus[\"PENDING\"] = \"PENDING\";\n TransactionRequestStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n TransactionRequestStatus[\"FINISH\"] = \"FINISH\";\n TransactionRequestStatus[\"FINISH_WITH_ERROR\"] = \"FINISH_WITH_ERROR\";\n})(TransactionRequestStatus || (TransactionRequestStatus = {}));\n\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\nconst DEAD_ADDRESS = '0x000000000000000000000000000000000000dead';\n\nfunction nextCursor(length, limit, offset) {\n const endIndex = offset + length;\n return endIndex < offset + limit ? null : endIndex;\n}\n\nfunction createField(keys, value) {\n return keys.split('.').reduceRight((prev, key) => ({\n [key]: prev,\n }), value);\n}\n\nfunction createLikeFilter(key, value) {\n return value\n ? createField(key, { _ilike: `%${value}%` })\n : {};\n}\nfunction createEqFilter(key, value) {\n return value ? createField(key, { _eq: value }) : {};\n}\nfunction createNeqFilter(key, value) {\n return value ? createField(key, { _neq: value }) : {};\n}\nfunction createBoolFilter(key, value) {\n return typeof value === 'boolean'\n ? createField(key, {\n _eq: value ? 'true' : 'false',\n })\n : {};\n}\nfunction createAddressFilter(key, value) {\n return value\n ? createField(key, { _eq: value.toLowerCase() })\n : {};\n}\nfunction createNotNullAddressFilter(key, filterZeroAddress = true, filterDeadAddress = true) {\n if (filterZeroAddress && filterDeadAddress) {\n return createField(key, {\n _nin: [ZERO_ADDRESS, DEAD_ADDRESS],\n });\n }\n if (filterZeroAddress) {\n return createField(key, {\n _neq: ZERO_ADDRESS,\n });\n }\n if (filterDeadAddress) {\n return createField(key, {\n _neq: DEAD_ADDRESS,\n });\n }\n return {};\n}\nfunction createInFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _in: values })\n : {};\n}\nfunction createNinFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _nin: values })\n : {};\n}\nfunction createLtFilter(key, value) {\n return value ? createField(key, { _lt: value }) : {};\n}\nfunction createLteFilter(key, value) {\n return value ? createField(key, { _lte: value }) : {};\n}\nfunction createGtFilter(key, value) {\n return value ? createField(key, { _gt: value }) : {};\n}\nfunction createGteFilter(key, value) {\n return value ? createField(key, { _gte: value }) : {};\n}\nfunction createBetweenFilter(key, from, to) {\n const betweenFilter = {};\n if (from) {\n betweenFilter._gte = from;\n }\n if (to) {\n betweenFilter._lte = to;\n }\n return from || to\n ? createField(key, betweenFilter)\n : {};\n}\n\nfunction createOrderBy(key, value) {\n return key && value ? createField(key, value) : {};\n}\n\nfunction removeSpecialCharacters(str) {\n return str.replace(/[^a-zA-Z0-9 ]/g, '');\n}\n\nfunction isNumeric(value, allowNegative = false) {\n if (typeof value === 'string') {\n return (allowNegative ? /^-?\\d+$/ : /^\\d+$/).test(value);\n }\n if (typeof value === 'number') {\n return true;\n }\n return false;\n}\n\nexport { Chain, DEAD_ADDRESS, Order, PaginatedResult, TransactionRequestStatus, ZERO_ADDRESS, createAddressFilter, createBetweenFilter, createBoolFilter, createEqFilter, createGtFilter, createGteFilter, createInFilter, createLikeFilter, createLtFilter, createLteFilter, createNeqFilter, createNinFilter, createNotNullAddressFilter, createOrderBy, isNumeric, nextCursor, removeSpecialCharacters };\n//# sourceMappingURL=index.mjs.map\n","export class CodeAlreadyMintedError extends Error {\n constructor(code: string) {\n super(`Code: '${code}' already minted `);\n }\n}\n","export class CodeExpiredError extends Error {\n constructor(code: string) {\n super(`Code: '${code}', has been expired`);\n }\n}\n","import axios, { AxiosError } from 'axios';\n\nclass InvalidMediaError extends Error {\n constructor(reason) {\n super(`There was an while creating Moment. Invalid media file. Reason: ${reason}`);\n this.name = InvalidMediaError.name;\n }\n}\n\nvar MediaStatus;\n(function (MediaStatus) {\n MediaStatus[\"INVALID\"] = \"INVALID\";\n MediaStatus[\"PROCESSED\"] = \"PROCESSED\";\n MediaStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n})(MediaStatus || (MediaStatus = {}));\n\nvar TransactionStatus;\n(function (TransactionStatus) {\n TransactionStatus[\"pending\"] = \"pending\";\n TransactionStatus[\"passed\"] = \"passed\";\n TransactionStatus[\"failed\"] = \"failed\";\n TransactionStatus[\"waiting\"] = \"waiting_tx\";\n})(TransactionStatus || (TransactionStatus = {}));\n\nclass CompassRequestError extends Error {\n constructor(compassErrors) {\n super(`Error fetching Compass data: ${compassErrors.errors.map((error) => error.message).join(', ')}`);\n this.errors = compassErrors.errors;\n }\n}\n\nclass CompassMissingDataError extends Error {\n constructor() {\n super('Compass response is missing data');\n }\n}\n\nclass CompassBadRequestError extends Error {\n constructor() {\n super('Compass malformed request');\n }\n}\n\nclass CompassUnauthorizedError extends Error {\n constructor() {\n super('Unauthorized access, API key may be invalid or expired');\n }\n}\n\nclass MissingAuthenticationProviderError extends Error {\n constructor() {\n super(`An AuthenticationProvider is required for write operations`);\n }\n}\n\nconst DEFAULT_MOMENTS_BASE_URL = 'https://moments.poap.tech';\nclass PoapMomentsApi {\n constructor(params) {\n var _a;\n this.baseUrl = (_a = params.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_MOMENTS_BASE_URL;\n this.authenticationProvider = params.authenticationProvider;\n }\n async getSignedUrl() {\n const response = await axios.post(`${this.baseUrl}/moments/media-upload-url`, undefined, {\n headers: {\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n async uploadFile(fileBinary, signedUrl, fileType, onProgress) {\n await axios.put(signedUrl, fileBinary, {\n headers: {\n 'Content-Type': fileType,\n },\n onUploadProgress: (progressEvent) => {\n if (onProgress) {\n onProgress(progressEvent.progress || 0);\n }\n },\n });\n }\n async fetchMediaStatus(mediaKey) {\n var _a;\n try {\n const response = await axios.get(`${this.baseUrl}/media/${mediaKey}`);\n return response.data.status;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {\n return MediaStatus.IN_PROCESS;\n }\n throw error;\n }\n }\n async waitForMediaProcessing(mediaKey, timeOut = 60000) {\n const delay = 2000;\n const maxTries = timeOut / delay;\n const checkStatus = async (tries) => {\n if (tries >= maxTries) {\n throw new Error('Exceeded maximum number of tries to check media processing status.');\n }\n const status = await this.fetchMediaStatus(mediaKey);\n if (status === MediaStatus.PROCESSED) {\n return;\n }\n if (status === MediaStatus.INVALID) {\n throw new InvalidMediaError('status is invalid');\n }\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(tries + 1);\n };\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(0);\n }\n async createMoment(input) {\n var _a;\n try {\n const response = await axios.post(`${this.baseUrl}/moments`, input, {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 409) {\n throw new InvalidMediaError(error.response.data.message);\n }\n throw error;\n }\n }\n async patchMoment(id, input) {\n await fetch(`${this.baseUrl}/moments/${id}`, {\n method: 'PATCH',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new Error('An AuthenticationProvider is required for write operations');\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nconst DEFAULT_DROP_BASE_URL$1 = 'https://api.poap.tech';\nclass PoapDropApi {\n constructor(config) {\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl || DEFAULT_DROP_BASE_URL$1;\n }\n async createDrop(input) {\n const form = new FormData();\n for (const key in input) {\n if (Object.prototype.hasOwnProperty.call(input, key)) {\n if (key === 'image') {\n form.append(key, input[key]);\n }\n else {\n form.append(key, input[key] + '');\n }\n }\n }\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'POST',\n body: form,\n headers: {},\n });\n }\n async updateDrop(input) {\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'PUT',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n };\n const response = await fetch(url, {\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n });\n return await response.json();\n }\n}\n\nfunction getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\n/**\n * lodash (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors <https://jquery.org/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991,\n MAX_INTEGER = 1.7976931348623157e+308,\n NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n symbolTag = '[object Symbol]';\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeCeil = Math.ceil,\n nativeMax = Math.max;\n\n/**\n * The base implementation of `_.slice` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\nfunction baseSlice(array, start, end) {\n var index = -1,\n length = array.length;\n\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = end > length ? length : end;\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : ((end - start) >>> 0);\n start >>>= 0;\n\n var result = Array(length);\n while (++index < length) {\n result[index] = array[index + start];\n }\n return result;\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\n/**\n * Creates an array of elements split into groups the length of `size`.\n * If `array` can't be split evenly, the final chunk will be the remaining\n * elements.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to process.\n * @param {number} [size=1] The length of each chunk\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the new array of chunks.\n * @example\n *\n * _.chunk(['a', 'b', 'c', 'd'], 2);\n * // => [['a', 'b'], ['c', 'd']]\n *\n * _.chunk(['a', 'b', 'c', 'd'], 3);\n * // => [['a', 'b', 'c'], ['d']]\n */\nfunction chunk(array, size, guard) {\n if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {\n size = 1;\n } else {\n size = nativeMax(toInteger(size), 0);\n }\n var length = array ? array.length : 0;\n if (!length || size < 1) {\n return [];\n }\n var index = 0,\n resIndex = 0,\n result = Array(nativeCeil(length / size));\n\n while (index < length) {\n result[resIndex++] = baseSlice(array, index, (index += size));\n }\n return result;\n}\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\nfunction toFinite(value) {\n if (!value) {\n return value === 0 ? value : 0;\n }\n value = toNumber(value);\n if (value === INFINITY || value === -INFINITY) {\n var sign = (value < 0 ? -1 : 1);\n return sign * MAX_INTEGER;\n }\n return value === value ? value : 0;\n}\n\n/**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\nfunction toInteger(value) {\n var result = toFinite(value),\n remainder = result % 1;\n\n return result === result ? (remainder ? result - remainder : result) : 0;\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nvar lodash_chunk = chunk;\n\nvar chunk$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_chunk);\n\nconst DEFAULT_COMPASS_BASE_URL = 'https://public.compass.poap.tech/v1/graphql';\nclass PoapCompass {\n constructor(config) {\n var _a;\n this.batchSize = 5;\n this.apiKey = config.apiKey;\n this.baseUrl = (_a = config.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_COMPASS_BASE_URL;\n }\n async fetchGraphQL(query, variables, signal) {\n let response;\n try {\n response = await fetch(this.baseUrl, {\n signal,\n method: 'POST',\n body: JSON.stringify({\n query,\n variables,\n }),\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': this.apiKey,\n },\n });\n }\n catch (error) {\n throw new Error(`Network error, received error ${error}`);\n }\n this.handleResponseStatus(response);\n const body = await response.json();\n this.handleResponseErrors(body);\n return body;\n }\n handleResponseStatus(response) {\n switch (response.status) {\n case 400:\n throw new CompassBadRequestError();\n case 401:\n throw new CompassUnauthorizedError();\n case 200:\n return;\n default:\n throw new Error(`Response error, received status code ${response.status}`);\n }\n }\n handleResponseErrors(response) {\n if (this.isError(response)) {\n throw new CompassRequestError(response);\n }\n if (!this.hasData(response)) {\n throw new CompassMissingDataError();\n }\n }\n isError(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'errors' in response &&\n Array.isArray(response.errors) &&\n response.errors.every((error) => error != null &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'));\n }\n hasData(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'data' in response &&\n response.data != null &&\n typeof response.data === 'object');\n }\n async request(query, variables, signal) {\n return await this.fetchGraphQL(query, variables !== null && variables !== void 0 ? variables : {}, signal);\n }\n async batch(query, variables, signal) {\n const results = [];\n const chunks = chunk$1(variables, this.batchSize);\n for (const chunk of chunks) {\n const responses = await Promise.all(chunk.map((variables) => this.request(query, variables, signal)));\n results.push(...responses);\n }\n return results;\n }\n}\n\nconst DEFAULT_OAUTH_SERVER = 'auth.accounts.poap.xyz';\nclass AuthenticationProviderHttp {\n constructor(clientId, clientSecret, oAuthServerDomain) {\n this.clientId = clientId;\n this.clientSecret = clientSecret;\n this.oAuthServerDomain = oAuthServerDomain || DEFAULT_OAUTH_SERVER;\n }\n async getJWT(audience) {\n if (this.tokenData && !this.isTokenExpired()) {\n return this.tokenData.accessToken;\n }\n const response = await fetch(`https://${this.oAuthServerDomain}/oauth/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n client_id: this.clientId,\n client_secret: this.clientSecret,\n audience,\n grant_type: 'client_credentials',\n }),\n });\n if (!response.ok) {\n throw new Error(`Network response was not ok: ${response.statusText}`);\n }\n const responseData = await response.json();\n this.tokenData = {\n accessToken: responseData.access_token,\n expiresAt: Date.now() + responseData.expires_in * 1000,\n };\n return responseData.access_token;\n }\n isTokenExpired() {\n return !this.tokenData || this.tokenData.expiresAt < Date.now();\n }\n}\n\nconst DEFAULT_DROP_BASE_URL = 'https://api.poap.tech';\nclass PoapTokenApi {\n constructor({ apiKey, baseUrl = DEFAULT_DROP_BASE_URL, authenticationProvider, }) {\n this.apiKey = apiKey;\n this.baseUrl = baseUrl;\n this.authenticationProvider = authenticationProvider;\n }\n async getMintCode(code) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr?qr_hash=${code}`, {\n method: 'GET',\n headers: {},\n });\n }\n async postMintCode(input) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr`, {\n method: 'POST',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async getMintTransaction(qrHash) {\n const transactions = await this.secureFetch(`${this.baseUrl}/transactions?qr_hash=${qrHash}`, {\n method: 'GET',\n });\n if (transactions.total === 0) {\n return null;\n }\n const status = transactions.transactions[0].status;\n if (status === TransactionStatus.waiting) {\n return null;\n }\n return transactions.transactions[0];\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n Authorization: await this.getAuthorizationToken(),\n };\n const response = await fetch(url, {\n ...options,\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n signal: AbortSignal.timeout(10000),\n });\n return await response.json();\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new MissingAuthenticationProviderError();\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nexport { AuthenticationProviderHttp, CompassBadRequestError, CompassMissingDataError, CompassRequestError, CompassUnauthorizedError, InvalidMediaError, MediaStatus, MissingAuthenticationProviderError, PoapCompass, PoapDropApi, PoapMomentsApi, PoapTokenApi, TransactionStatus };\n//# sourceMappingURL=index.mjs.map\n","export class FinishedWithError extends Error {\n constructor(error: string, code: string) {\n super(\n `Code: '${code}', finished with error: '${error}', please try again later `,\n );\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\n\nconst MAX_RETRIES = 20;\nconst INITIAL_DELAY = 1000;\nconst BACKOFF_FACTOR = 1.2;\n\n/**\n * Abstract class representing a task that can be retried with an increasing delay.\n */\nexport abstract class RetryableTask {\n protected retries = 0;\n protected delay: number = INITIAL_DELAY;\n protected tokensApiProvider: TokensApiProvider;\n\n /**\n * Constructs a new RetryableTask instance.\n *\n * @param {TokensApiProvider} tokensApiProvider - The provider used to perform operations that might be retried.\n */\n constructor(tokensApiProvider: TokensApiProvider) {\n this.tokensApiProvider = tokensApiProvider;\n }\n\n /**\n * Attempts to perform a given task. If the task fails, it retries with an increasing delay until\n * maximum retries are reached.\n *\n * @protected\n * @template T - The type of value that the callback returns.\n * @param {() => Promise<T>} callback - The asynchronous function representing the task to be retried.\n * @returns {Promise<T>} A promise that resolves to the result of the task or rejects with an error.\n * @throws {Error} Throws an error if maximum retries are reached.\n */\n protected backoffAndRetry<T>(callback: () => Promise<T>): Promise<T> {\n if (this.retries >= MAX_RETRIES) {\n throw new Error('Max retries reached');\n }\n this.retries++;\n this.delay *= BACKOFF_FACTOR;\n\n return new Promise<T>((resolve, reject) => {\n setTimeout(() => {\n callback().then(resolve, reject);\n }, this.delay);\n });\n }\n}\n","import {\n TokensApiProvider,\n Transaction,\n TransactionStatus,\n} from '@poap-xyz/providers';\nimport { FinishedWithError } from '../errors/FinishedWithError';\nimport { RetryableTask } from './RetryableTask';\n\n/**\n * A utility class designed to continually check the status of a POAP token mint.\n * If a mint is still pending or in process, it implements a backoff retry mechanism.\n */\nexport class MintChecker extends RetryableTask {\n private mintCode: string;\n\n /**\n * Constructs a new instance of the MintChecker class.\n *\n * @param {string} mintCode - The unique code for the token mint.\n * @param {TokensApiProvider} tokensApiProvider - The provider to fetch the mint status.\n */\n constructor(tokensApiProvider: TokensApiProvider, mintCode: string) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Checks the current status of a token mint.\n * If the mint is still pending or in process, it will retry the check with an increased delay.\n *\n * @public\n * @returns {Promise<void>} A promise that resolves once the status has been checked.\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n public async checkMintStatus(): Promise<void> {\n try {\n const transaction = await this.tokensApiProvider.getMintTransaction(\n this.mintCode,\n );\n\n if (this.shouldRetry(transaction)) {\n await this.backoffAndRetry(() => this.checkMintStatus());\n } else {\n this.handleErrorStatus(transaction, this.mintCode);\n }\n } catch (e) {\n if (e instanceof FinishedWithError) {\n throw e;\n }\n\n await this.backoffAndRetry(() => this.checkMintStatus());\n }\n }\n\n /**\n * Determines if a retry should be performed based on the provided minting status.\n *\n * @private\n * @returns {boolean} Returns true if a retry should be performed, otherwise false.\n * @param transaction - The transaction to check for retry.\n */\n private shouldRetry(transaction: Transaction | null): boolean {\n return !transaction || transaction.status === TransactionStatus.pending;\n }\n\n /**\n * Handles any error statuses from the mint status response.\n * If the minting process finishes with an error, an exception will be thrown.\n *\n * @private\n * @param {Transaction} transaction - The transaction to check for errors.\n * @param mintCode\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n private handleErrorStatus(\n transaction: Transaction | null,\n mintCode: string,\n ): void {\n if (transaction?.status === TransactionStatus.failed) {\n throw new FinishedWithError(\n 'The Transaction associated with this mint failed',\n mintCode,\n );\n }\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\nimport { RetryableTask } from './RetryableTask';\nimport { PoapMintStatus } from '../types';\n\n/**\n * @class PoapIndexed\n * @extends {RetryableTask}\n *\n * Represents a utility class designed to periodically check if a POAP token is indexed on our database.\n * This class extends `RetryableTask` to utilize its backoff retry mechanism in case the token hasn't been indexed yet.\n */\nexport class PoapIndexed extends RetryableTask {\n private mintCode: string;\n\n /**\n * Creates an instance of the PoapIndexed class.\n *\n * @param {string} mintCode - A unique Mint Code representing the token.\n * @param {TokensApiProvider} tokensApiProvider - An instance of the TokensApiProvider used to check the indexing status of the token.\n */\n constructor(mintCode: string, tokensApiProvider: TokensApiProvider) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Periodically checks if the POAP token, represented by its Mint Code, is indexed on our database.\n * This method will continue retrying with an increasing delay until either the token is indexed or it reaches the maximum allowed retries.\n *\n * @returns {Promise<GetClaimCodeResponse>} A promise that either resolves with the indexed token's mint code response or rejects due to reaching the max retry limit.\n */\n public async waitPoapIndexed(): Promise<PoapMintStatus> {\n let response = await this.tokensApiProvider.getMintCode(this.mintCode);\n while (response.result == null) {\n response = await this.backoffAndRetry(() =>\n this.tokensApiProvider.getMintCode(this.mintCode),\n );\n }\n return {\n minted: response.claimed,\n isActive: response.is_active,\n secretCode: response.secret,\n poapId: response.result?.token,\n };\n }\n}\n","import {\n CompassProvider,\n TokensApiProvider,\n Transaction,\n} from '@poap-xyz/providers';\nimport { POAP } from './domain/Poap';\nimport { POAPReservation } from './domain/POAPReservation';\nimport {\n PAGINATED_POAPS_QUERY,\n PaginatedPoapsResponse,\n PaginatedPoapsVariables,\n} from './queries';\nimport {\n EmailReservationInput,\n FetchPoapsInput,\n PoapMintStatus,\n PoapsSortFields,\n WalletMintInput,\n} from './types';\nimport {\n createAddressFilter,\n createBetweenFilter,\n createEqFilter,\n createInFilter,\n createNotNullAddressFilter,\n createOrderBy,\n nextCursor,\n PaginatedResult,\n} from '@poap-xyz/utils';\nimport { CodeAlreadyMintedError } from './errors/CodeAlreadyMintedError';\nimport { CodeExpiredError } from './errors/CodeExpiredError';\nimport { MintChecker } from './utils/MintChecker';\nimport { PoapIndexed } from './utils/PoapIndexed';\n\n/**\n * Represents a client for interacting with POAPs .\n * @class\n */\nexport class PoapsClient {\n /**\n * Initializes a new instance of the PoapsClient.\n * @param {CompassProvider} compassProvider - The provider for the POAP compass API.\n * @param {TokensApiProvider} tokensApiProvider - The provider for the Tokens API.\n */\n constructor(\n private compassProvider: CompassProvider,\n private tokensApiProvider: TokensApiProvider,\n ) {}\n\n /**\n * Fetches a list of POAP tokens based on the given input criteria.\n * @async\n * @param {FetchPoapsInput} input - Criteria for fetching POAP tokens.\n * @returns {Promise<PaginatedResult<POAP>>} A paginated list of POAP tokens.\n */\n async fetch(input: FetchPoapsInput): Promise<PaginatedResult<POAP>> {\n const {\n limit,\n offset,\n chain,\n collectorAddress,\n mintedDateFrom,\n mintedDateTo,\n ids,\n dropId,\n sortField,\n sortDir,\n filterZeroAddress = true,\n filterDeadAddress = true,\n } = input;\n\n const variables: PaginatedPoapsVariables = {\n limit,\n offset,\n orderBy: createOrderBy<PoapsSortFields>(sortField, sortDir),\n where: {\n ...createAddressFilter('collector_address', collectorAddress),\n ...(collectorAddress == undefined\n ? createNotNullAddressFilter(\n 'collector_address',\n filterZeroAddress,\n filterDeadAddress,\n )\n : {}),\n ...createEqFilter('chain', chain),\n ...createEqFilter('drop_id', dropId),\n ...createBetweenFilter('minted_on', mintedDateFrom, mintedDateTo),\n ...createInFilter('id', ids),\n },\n };\n\n const { data } = await this.compassProvider.request<\n PaginatedPoapsResponse,\n PaginatedPoapsVariables\n >(PAGINATED_POAPS_QUERY, variables);\n\n const poaps = data.poaps.map((poap) => {\n const { drop } = poap;\n const mintedOn = new Date(0);\n mintedOn.setUTCSeconds(poap.minted_on);\n return new POAP({\n id: Number(poap.id),\n collectorAddress: poap.collector_address,\n transferCount: poap.transfer_count,\n mintedOn,\n dropId: Number(poap.drop_id),\n imageUrl: drop.image_url,\n city: drop.city,\n country: drop.country,\n description: drop.description,\n startDate: new Date(drop.start_date),\n name: drop.name,\n endDate: new Date(drop.end_date),\n });\n });\n\n return new PaginatedResult<POAP>(\n poaps,\n nextCursor(poaps.length, limit, offset),\n );\n }\n\n /**\n * Retrieves mint code details for a specific Mint Code.\n * @async\n * @param {string} mintCode - The Mint Code for which to get the mint code.\n * @returns {Promise<PoapMintStatus>} The Mint status.\n */\n async getMintCode(mintCode: string): Promise<PoapMintStatus> {\n const getMintCodeRaw = await this.tokensApiProvider.getMintCode(mintCode);\n return {\n minted: getMintCodeRaw.claimed,\n isActive: getMintCodeRaw.is_active,\n secretCode: getMintCodeRaw.secret,\n poapId: getMintCodeRaw.result?.token,\n };\n }\n\n /**\n * Gets the Transaction associated with the mint.\n * The Transaction could change in case of a bump.\n * It returns null if the mint has no transaction associated.\n *\n * @param {string} qrHash - The qrHash of the mint.\n * @returns {Promise<Transaction> | null} The Transaction associated with the mint. Null if no transaction is found.\n */\n public async getMintTransaction(qrHash: string): Promise<Transaction | null> {\n return await this.tokensApiProvider.getMintTransaction(qrHash);\n }\n\n /**\n * Awaits until we have a final Transaction status for a specific Mint Code.\n * @async\n * @returns {Promise<void>}\n * @param mintCode - The Mint Code\n */\n public async waitMintStatus(mintCode: string): Promise<void> {\n const checker = new MintChecker(this.tokensApiProvider, mintCode);\n await checker.checkMintStatus();\n }\n\n /**\n * Awaits until a specific POAP, identified by its Mint Code, is indexed on our database.\n * @async\n * @param {string} mintCode - The Mint Code identifying the POAP to be indexed.\n * @returns {Promise<PoapMintStatus>} - The status of the POAP mint.\n */\n public async waitPoapIndexed(mintCode: string): Promise<PoapMintStatus> {\n const checker = new PoapIndexed(mintCode, this.tokensApiProvider);\n return await checker.waitPoapIndexed();\n }\n\n /**\n * Begins an asynchronous mint process and provides a unique queue ID in return.\n * @async\n * @param {WalletMintInput} input - Details required for the mint.\n */\n public async mintAsync(input: WalletMintInput): Promise<void> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n await this.tokensApiProvider.postMintCode({\n address: input.address,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: false,\n });\n }\n\n /**\n * Starts a synchronous mint process. The method waits for the mint to be processed and then\n * fetches the associated POAP. It combines the asynchronous mint and subsequent status checking\n * into a synchronous process for ease of use.\n * @async\n * @param {WalletMintInput} input - Details needed for the mint.\n * @returns {Promise<POAP>} The associated POAP upon successful mint completion.\n * @throws {FinishedWithError} If there's an error concluding the mint process.\n */\n async mintSync(input: WalletMintInput): Promise<POAP> {\n await this.mintAsync(input);\n\n await this.waitMintStatus(input.mintCode);\n\n const getCodeResponse = await this.waitPoapIndexed(input.mintCode);\n\n return (\n await this.fetch({\n limit: 1,\n offset: 0,\n ids: [getCodeResponse.poapId],\n })\n ).items[0];\n }\n\n /**\n * Reserves a POAP to an email address and provides reservation details.\n * @async\n * @param {EmailReservationInput} input - Information for the reservation.\n * @returns {Promise<POAPReservation>} The reservation details of the POAP.\n */\n public async emailReservation(\n input: EmailReservationInput,\n ): Promise<POAPReservation> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n const response = await this.tokensApiProvider.postMintCode({\n address: input.email,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: input.sendEmail || true,\n });\n\n return new POAPReservation({\n email: input.email,\n dropId: response.event.id,\n imageUrl: response.event.image_url,\n city: response.event.city,\n country: response.event.country,\n description: response.event.description,\n startDate: new Date(response.event.start_date),\n endDate: new Date(response.event.end_date),\n name: response.event.name,\n });\n }\n\n /**\n * Retrieves the secret code associated with a POAP code.\n * @async\n * @param {string} mintCode - The POAP code for which to get the secret.\n * @returns {Promise<string>} The associated secret code.\n * @throws {CodeAlreadyMintedError} Thrown when the POAP code has already been minted.\n * @throws {CodeExpiredError} Thrown when the POAP code is expired.\n */\n private async getSecretCode(mintCode: string): Promise<string> {\n const getCodeResponse = await this.getMintCode(mintCode);\n\n if (getCodeResponse.minted) {\n throw new CodeAlreadyMintedError(mintCode);\n }\n if (!getCodeResponse.isActive) {\n throw new CodeExpiredError(mintCode);\n }\n\n return getCodeResponse.secretCode;\n }\n}\n"],"names":["PoapsSortFields"],"mappings":";;;;;;AAQYA,mCAKX;EALD,CAAA,UAAY,eAAe,EAAA;EAEzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,WAAsB,CAAA;EAEtB,IAAA,eAAA,CAAA,IAAA,CAAA,GAAA,IAAS,CAAA;EACX,CAAC,EALWA,uBAAe,KAAfA,uBAAe,GAK1B,EAAA,CAAA,CAAA;;QCZY,IAAI,CAAA;EAcf,IAAA,WAAA,CAAY,UAA0B,EAAA;EACpC,QAAA,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC;EACxB,QAAA,IAAI,CAA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AQ,EAAE;EAC7B,YAAA,MAAM,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;WACtC;UAED,OAAO,eAAe,CAAC,UAAU,CAAC;OACnC;EACF;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../src/types/PoapsSortFields.ts","../../../utils/dist/esm/index.mjs","../../src/domain/POAP.ts","../../src/domain/POAPReservation.ts","../../src/queries/PaginatedPoaps.ts","../../src/errors/CodeAlreadyMintedError.ts","../../src/errors/CodeExpiredError.ts","../../../providers/dist/esm/index.mjs","../../src/errors/FinishedWithError.ts","../../src/utils/RetryableTask.ts","../../src/utils/MintChecker.ts","../../src/utils/PoapIndexed.ts","../../src/PoapsClient.ts"],"sourcesContent":["/**\n * Enum to define available fields for sorting POAPs.\n *\n * @export\n * @enum {string}\n */\nexport enum PoapsSortFields {\n /** Represents sorting by the date when a POAP was minted. */\n MintedOn = 'minted_on',\n /** Represents sorting by the ID of a POAP. */\n Id = 'id',\n}\n","class PaginatedResult {\n constructor(items, nextCursor) {\n this.items = items;\n this.nextCursor = nextCursor;\n }\n}\n\nvar Order;\n(function (Order) {\n Order[\"ASC\"] = \"asc\";\n Order[\"DESC\"] = \"desc\";\n})(Order || (Order = {}));\n\nvar Chain;\n(function (Chain) {\n Chain[\"Ethereum\"] = \"mainnet\";\n Chain[\"Gnosis\"] = \"xdai\";\n})(Chain || (Chain = {}));\n\nvar TransactionRequestStatus;\n(function (TransactionRequestStatus) {\n TransactionRequestStatus[\"PENDING\"] = \"PENDING\";\n TransactionRequestStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n TransactionRequestStatus[\"FINISH\"] = \"FINISH\";\n TransactionRequestStatus[\"FINISH_WITH_ERROR\"] = \"FINISH_WITH_ERROR\";\n})(TransactionRequestStatus || (TransactionRequestStatus = {}));\n\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\nconst DEAD_ADDRESS = '0x000000000000000000000000000000000000dead';\n\nfunction nextCursor(length, limit, offset) {\n const endIndex = offset + length;\n return endIndex < offset + limit ? null : endIndex;\n}\n\nfunction createField(keys, value) {\n return keys.split('.').reduceRight((prev, key) => ({\n [key]: prev,\n }), value);\n}\n\nfunction createLikeFilter(key, value) {\n return value\n ? createField(key, { _ilike: `%${value}%` })\n : {};\n}\nfunction createEqFilter(key, value) {\n return value ? createField(key, { _eq: value }) : {};\n}\nfunction createNeqFilter(key, value) {\n return value ? createField(key, { _neq: value }) : {};\n}\nfunction createBoolFilter(key, value) {\n return typeof value === 'boolean'\n ? createField(key, {\n _eq: value ? 'true' : 'false',\n })\n : {};\n}\nfunction createAddressFilter(key, value) {\n return value\n ? createField(key, { _eq: value.toLowerCase() })\n : {};\n}\nfunction createNotNullAddressFilter(key, filterZeroAddress = true, filterDeadAddress = true) {\n if (filterZeroAddress && filterDeadAddress) {\n return createField(key, {\n _nin: [ZERO_ADDRESS, DEAD_ADDRESS],\n });\n }\n if (filterZeroAddress) {\n return createField(key, {\n _neq: ZERO_ADDRESS,\n });\n }\n if (filterDeadAddress) {\n return createField(key, {\n _neq: DEAD_ADDRESS,\n });\n }\n return {};\n}\nfunction createInFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _in: values })\n : {};\n}\nfunction createNinFilter(key, values) {\n return values && values.length > 0\n ? createField(key, { _nin: values })\n : {};\n}\nfunction createLtFilter(key, value) {\n return value ? createField(key, { _lt: value }) : {};\n}\nfunction createLteFilter(key, value) {\n return value ? createField(key, { _lte: value }) : {};\n}\nfunction createGtFilter(key, value) {\n return value ? createField(key, { _gt: value }) : {};\n}\nfunction createGteFilter(key, value) {\n return value ? createField(key, { _gte: value }) : {};\n}\nfunction createBetweenFilter(key, from, to) {\n const betweenFilter = {};\n if (from) {\n betweenFilter._gte = from;\n }\n if (to) {\n betweenFilter._lte = to;\n }\n return from || to\n ? createField(key, betweenFilter)\n : {};\n}\n\nfunction createOrderBy(key, value) {\n return key && value ? createField(key, value) : {};\n}\n\nfunction removeSpecialCharacters(str) {\n return str.replace(/[^a-zA-Z0-9 ]/g, '');\n}\n\nfunction isNumeric(value, allowNegative = false) {\n if (typeof value === 'string') {\n return (allowNegative ? /^-?\\d+$/ : /^\\d+$/).test(value);\n }\n if (typeof value === 'number') {\n return true;\n }\n return false;\n}\n\nexport { Chain, DEAD_ADDRESS, Order, PaginatedResult, TransactionRequestStatus, ZERO_ADDRESS, createAddressFilter, createBetweenFilter, createBoolFilter, createEqFilter, createGtFilter, createGteFilter, createInFilter, createLikeFilter, createLtFilter, createLteFilter, createNeqFilter, createNinFilter, createNotNullAddressFilter, createOrderBy, isNumeric, nextCursor, removeSpecialCharacters };\n//# sourceMappingURL=index.mjs.map\n","import { PoapsResponse } from '../queries/PaginatedPoaps';\n\nexport class POAP {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n public static fromCompass(response: PoapsResponse): POAP {\n const mintedOn = new Date(0);\n mintedOn.setUTCSeconds(response.minted_on);\n\n return new POAP({\n id: Number(response.id),\n collectorAddress: response.collector_address,\n transferCount: response.transfer_count,\n mintedOn,\n dropId: Number(response.drop_id),\n imageUrl: response.drop.image_url,\n city: response.drop.city,\n country: response.drop.country,\n description: response.drop.description,\n startDate: new Date(response.drop.start_date),\n endDate: new Date(response.drop.end_date),\n name: response.drop.name,\n });\n }\n\n // eslint-disable-next-line max-statements\n constructor(properties: PoapProperties) {\n this.id = properties.id;\n this.collectorAddress = properties.collectorAddress;\n this.mintedOn = properties.mintedOn;\n this.dropId = properties.dropId;\n this.transferCount = properties.transferCount;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\ninterface PoapProperties {\n id: number;\n collectorAddress: string;\n transferCount: number;\n mintedOn: Date;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n}\n","export class POAPReservation {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n endDate: Date;\n name: string;\n\n constructor(properties: POAPReservationProperties) {\n this.email = properties.email;\n this.dropId = properties.dropId;\n this.imageUrl = properties.imageUrl;\n this.city = properties.city;\n this.country = properties.country;\n this.description = properties.description;\n this.startDate = properties.startDate;\n this.endDate = properties.endDate;\n this.name = properties.name;\n }\n}\n\ninterface POAPReservationProperties {\n email: string;\n dropId: number;\n imageUrl: string;\n city: string;\n country: string;\n description: string;\n startDate: Date;\n name: string;\n endDate: Date;\n}\n","import {\n FilterVariables,\n OrderByVariables,\n PaginatedVariables,\n} from '@poap-xyz/utils';\n\nexport const PAGINATED_POAPS_QUERY = `\n query PaginatedPoaps(\n $limit: Int!\n $offset: Int!\n $orderBy: [poaps_order_by!]\n $where: poaps_bool_exp\n ) {\n poaps(limit: $limit, offset: $offset, order_by: $orderBy, where: $where) {\n chain\n collector_address\n drop_id\n id\n minted_on\n transfer_count\n drop {\n image_url\n city\n country\n description\n start_date\n end_date\n name\n }\n }\n }\n`;\n\nexport interface PoapsResponse {\n id: number;\n collector_address: string;\n transfer_count: number;\n minted_on: number;\n drop_id: number;\n drop: {\n image_url: string;\n city: string;\n country: string;\n description: string;\n start_date: string;\n end_date: string;\n name: string;\n };\n}\n\nexport interface PaginatedPoapsResponse {\n poaps: PoapsResponse[];\n}\n\nexport type PaginatedPoapsVariables = FilterVariables &\n OrderByVariables &\n PaginatedVariables;\n","export class CodeAlreadyMintedError extends Error {\n constructor(code: string) {\n super(`Code: '${code}' already minted `);\n }\n}\n","export class CodeExpiredError extends Error {\n constructor(code: string) {\n super(`Code: '${code}', has been expired`);\n }\n}\n","import axios, { AxiosError } from 'axios';\n\nclass InvalidMediaError extends Error {\n constructor(reason) {\n super(`There was an while creating Moment. Invalid media file. Reason: ${reason}`);\n this.name = InvalidMediaError.name;\n }\n}\n\nvar MediaStatus;\n(function (MediaStatus) {\n MediaStatus[\"INVALID\"] = \"INVALID\";\n MediaStatus[\"PROCESSED\"] = \"PROCESSED\";\n MediaStatus[\"IN_PROCESS\"] = \"IN_PROCESS\";\n})(MediaStatus || (MediaStatus = {}));\n\nvar TransactionStatus;\n(function (TransactionStatus) {\n TransactionStatus[\"pending\"] = \"pending\";\n TransactionStatus[\"passed\"] = \"passed\";\n TransactionStatus[\"failed\"] = \"failed\";\n TransactionStatus[\"waiting\"] = \"waiting_tx\";\n})(TransactionStatus || (TransactionStatus = {}));\n\nclass CompassRequestError extends Error {\n constructor(compassErrors) {\n super(`Error fetching Compass data: ${compassErrors.errors.map((error) => error.message).join(', ')}`);\n this.errors = compassErrors.errors;\n }\n}\n\nclass CompassMissingDataError extends Error {\n constructor() {\n super('Compass response is missing data');\n }\n}\n\nclass CompassBadRequestError extends Error {\n constructor() {\n super('Compass malformed request');\n }\n}\n\nclass CompassUnauthorizedError extends Error {\n constructor() {\n super('Unauthorized access, API key may be invalid or expired');\n }\n}\n\nclass MissingAuthenticationProviderError extends Error {\n constructor() {\n super(`An AuthenticationProvider is required for write operations`);\n }\n}\n\nconst DEFAULT_MOMENTS_BASE_URL = 'https://moments.poap.tech';\nclass PoapMomentsApi {\n constructor(params) {\n var _a;\n this.baseUrl = (_a = params.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_MOMENTS_BASE_URL;\n this.authenticationProvider = params.authenticationProvider;\n }\n async getSignedUrl() {\n const response = await axios.post(`${this.baseUrl}/moments/media-upload-url`, undefined, {\n headers: {\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n async uploadFile(fileBinary, signedUrl, fileType, onProgress) {\n await axios.put(signedUrl, fileBinary, {\n headers: {\n 'Content-Type': fileType,\n },\n onUploadProgress: (progressEvent) => {\n if (onProgress) {\n onProgress(progressEvent.progress || 0);\n }\n },\n });\n }\n async fetchMediaStatus(mediaKey) {\n var _a;\n try {\n const response = await axios.get(`${this.baseUrl}/media/${mediaKey}`);\n return response.data.status;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {\n return MediaStatus.IN_PROCESS;\n }\n throw error;\n }\n }\n async waitForMediaProcessing(mediaKey, timeOut = 60000) {\n const delay = 2000;\n const maxTries = timeOut / delay;\n const checkStatus = async (tries) => {\n if (tries >= maxTries) {\n throw new Error('Exceeded maximum number of tries to check media processing status.');\n }\n const status = await this.fetchMediaStatus(mediaKey);\n if (status === MediaStatus.PROCESSED) {\n return;\n }\n if (status === MediaStatus.INVALID) {\n throw new InvalidMediaError('status is invalid');\n }\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(tries + 1);\n };\n await new Promise((resolve) => setTimeout(resolve, delay));\n return checkStatus(0);\n }\n async createMoment(input) {\n var _a;\n try {\n const response = await axios.post(`${this.baseUrl}/moments`, input, {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n return response.data;\n }\n catch (error) {\n if (error instanceof AxiosError && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 409) {\n throw new InvalidMediaError(error.response.data.message);\n }\n throw error;\n }\n }\n async patchMoment(id, input) {\n await fetch(`${this.baseUrl}/moments/${id}`, {\n method: 'PATCH',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n Authorization: await this.getAuthorizationToken(),\n },\n });\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new Error('An AuthenticationProvider is required for write operations');\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nconst DEFAULT_DROP_BASE_URL$1 = 'https://api.poap.tech';\nclass PoapDropApi {\n constructor(config) {\n this.apiKey = config.apiKey;\n this.baseUrl = config.baseUrl || DEFAULT_DROP_BASE_URL$1;\n }\n async createDrop(input) {\n const form = new FormData();\n for (const key in input) {\n if (Object.prototype.hasOwnProperty.call(input, key)) {\n if (key === 'image') {\n form.append(key, input[key]);\n }\n else {\n form.append(key, input[key] + '');\n }\n }\n }\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'POST',\n body: form,\n headers: {},\n });\n }\n async updateDrop(input) {\n return await this.secureFetch(`${this.baseUrl}/events`, {\n method: 'PUT',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n };\n const response = await fetch(url, {\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n });\n return await response.json();\n }\n}\n\nfunction getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\n/**\n * lodash (Custom Build) <https://lodash.com/>\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors <https://jquery.org/>\n * Released under MIT license <https://lodash.com/license>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0,\n MAX_SAFE_INTEGER = 9007199254740991,\n MAX_INTEGER = 1.7976931348623157e+308,\n NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n symbolTag = '[object Symbol]';\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeCeil = Math.ceil,\n nativeMax = Math.max;\n\n/**\n * The base implementation of `_.slice` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\nfunction baseSlice(array, start, end) {\n var index = -1,\n length = array.length;\n\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = end > length ? length : end;\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : ((end - start) >>> 0);\n start >>>= 0;\n\n var result = Array(length);\n while (++index < length) {\n result[index] = array[index + start];\n }\n return result;\n}\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n length = length == null ? MAX_SAFE_INTEGER : length;\n return !!length &&\n (typeof value == 'number' || reIsUint.test(value)) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\n/**\n * Creates an array of elements split into groups the length of `size`.\n * If `array` can't be split evenly, the final chunk will be the remaining\n * elements.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Array\n * @param {Array} array The array to process.\n * @param {number} [size=1] The length of each chunk\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {Array} Returns the new array of chunks.\n * @example\n *\n * _.chunk(['a', 'b', 'c', 'd'], 2);\n * // => [['a', 'b'], ['c', 'd']]\n *\n * _.chunk(['a', 'b', 'c', 'd'], 3);\n * // => [['a', 'b', 'c'], ['d']]\n */\nfunction chunk(array, size, guard) {\n if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {\n size = 1;\n } else {\n size = nativeMax(toInteger(size), 0);\n }\n var length = array ? array.length : 0;\n if (!length || size < 1) {\n return [];\n }\n var index = 0,\n resIndex = 0,\n result = Array(nativeCeil(length / size));\n\n while (index < length) {\n result[resIndex++] = baseSlice(array, index, (index += size));\n }\n return result;\n}\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\nfunction toFinite(value) {\n if (!value) {\n return value === 0 ? value : 0;\n }\n value = toNumber(value);\n if (value === INFINITY || value === -INFINITY) {\n var sign = (value < 0 ? -1 : 1);\n return sign * MAX_INTEGER;\n }\n return value === value ? value : 0;\n}\n\n/**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\nfunction toInteger(value) {\n var result = toFinite(value),\n remainder = result % 1;\n\n return result === result ? (remainder ? result - remainder : result) : 0;\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nvar lodash_chunk = chunk;\n\nvar chunk$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_chunk);\n\nconst DEFAULT_COMPASS_BASE_URL = 'https://public.compass.poap.tech/v1/graphql';\nclass PoapCompass {\n constructor(config) {\n var _a;\n this.batchSize = 5;\n this.apiKey = config.apiKey;\n this.baseUrl = (_a = config.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_COMPASS_BASE_URL;\n }\n async fetchGraphQL(query, variables, signal) {\n let response;\n try {\n response = await fetch(this.baseUrl, {\n signal,\n method: 'POST',\n body: JSON.stringify({\n query,\n variables,\n }),\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': this.apiKey,\n },\n });\n }\n catch (error) {\n throw new Error(`Network error, received error ${error}`);\n }\n this.handleResponseStatus(response);\n const body = await response.json();\n this.handleResponseErrors(body);\n return body;\n }\n handleResponseStatus(response) {\n switch (response.status) {\n case 400:\n throw new CompassBadRequestError();\n case 401:\n throw new CompassUnauthorizedError();\n case 200:\n return;\n default:\n throw new Error(`Response error, received status code ${response.status}`);\n }\n }\n handleResponseErrors(response) {\n if (this.isError(response)) {\n throw new CompassRequestError(response);\n }\n if (!this.hasData(response)) {\n throw new CompassMissingDataError();\n }\n }\n isError(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'errors' in response &&\n Array.isArray(response.errors) &&\n response.errors.every((error) => error != null &&\n typeof error === 'object' &&\n 'message' in error &&\n typeof error.message === 'string'));\n }\n hasData(response) {\n return (response != null &&\n typeof response === 'object' &&\n 'data' in response &&\n response.data != null &&\n typeof response.data === 'object');\n }\n async request(query, variables, signal) {\n return await this.fetchGraphQL(query, variables !== null && variables !== void 0 ? variables : {}, signal);\n }\n async batch(query, variables, signal) {\n const results = [];\n const chunks = chunk$1(variables, this.batchSize);\n for (const chunk of chunks) {\n const responses = await Promise.all(chunk.map((variables) => this.request(query, variables, signal)));\n results.push(...responses);\n }\n return results;\n }\n}\n\nconst DEFAULT_OAUTH_SERVER = 'auth.accounts.poap.xyz';\nclass AuthenticationProviderHttp {\n constructor(clientId, clientSecret, oAuthServerDomain) {\n this.clientId = clientId;\n this.clientSecret = clientSecret;\n this.oAuthServerDomain = oAuthServerDomain || DEFAULT_OAUTH_SERVER;\n }\n async getJWT(audience) {\n if (this.tokenData && !this.isTokenExpired()) {\n return this.tokenData.accessToken;\n }\n const response = await fetch(`https://${this.oAuthServerDomain}/oauth/token`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n client_id: this.clientId,\n client_secret: this.clientSecret,\n audience,\n grant_type: 'client_credentials',\n }),\n });\n if (!response.ok) {\n throw new Error(`Network response was not ok: ${response.statusText}`);\n }\n const responseData = await response.json();\n this.tokenData = {\n accessToken: responseData.access_token,\n expiresAt: Date.now() + responseData.expires_in * 1000,\n };\n return responseData.access_token;\n }\n isTokenExpired() {\n return !this.tokenData || this.tokenData.expiresAt < Date.now();\n }\n}\n\nconst DEFAULT_DROP_BASE_URL = 'https://api.poap.tech';\nclass PoapTokenApi {\n constructor({ apiKey, baseUrl = DEFAULT_DROP_BASE_URL, authenticationProvider, }) {\n this.apiKey = apiKey;\n this.baseUrl = baseUrl;\n this.authenticationProvider = authenticationProvider;\n }\n async getMintCode(code) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr?qr_hash=${code}`, {\n method: 'GET',\n headers: {},\n });\n }\n async postMintCode(input) {\n return await this.secureFetch(`${this.baseUrl}/actions/claim-qr`, {\n method: 'POST',\n body: JSON.stringify(input),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n async getMintTransaction(qrHash) {\n const transactions = await this.secureFetch(`${this.baseUrl}/transactions?qr_hash=${qrHash}`, {\n method: 'GET',\n });\n if (transactions.total === 0) {\n return null;\n }\n const status = transactions.transactions[0].status;\n if (status === TransactionStatus.waiting) {\n return null;\n }\n return transactions.transactions[0];\n }\n async secureFetch(url, options) {\n const headersWithApiKey = {\n ...options.headers,\n 'x-api-key': this.apiKey,\n Authorization: await this.getAuthorizationToken(),\n };\n const response = await fetch(url, {\n ...options,\n method: options.method,\n body: options.body,\n headers: headersWithApiKey,\n signal: AbortSignal.timeout(10000),\n });\n return await response.json();\n }\n async getAuthorizationToken() {\n if (!this.authenticationProvider) {\n throw new MissingAuthenticationProviderError();\n }\n return `Bearer ${await this.authenticationProvider.getJWT(this.baseUrl)}`;\n }\n}\n\nexport { AuthenticationProviderHttp, CompassBadRequestError, CompassMissingDataError, CompassRequestError, CompassUnauthorizedError, InvalidMediaError, MediaStatus, MissingAuthenticationProviderError, PoapCompass, PoapDropApi, PoapMomentsApi, PoapTokenApi, TransactionStatus };\n//# sourceMappingURL=index.mjs.map\n","export class FinishedWithError extends Error {\n constructor(error: string, code: string) {\n super(\n `Code: '${code}', finished with error: '${error}', please try again later `,\n );\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\n\nconst MAX_RETRIES = 20;\nconst INITIAL_DELAY = 1000;\nconst BACKOFF_FACTOR = 1.2;\n\n/**\n * Abstract class representing a task that can be retried with an increasing delay.\n */\nexport abstract class RetryableTask {\n protected retries = 0;\n protected delay: number = INITIAL_DELAY;\n protected tokensApiProvider: TokensApiProvider;\n\n /**\n * Constructs a new RetryableTask instance.\n *\n * @param {TokensApiProvider} tokensApiProvider - The provider used to perform operations that might be retried.\n */\n constructor(tokensApiProvider: TokensApiProvider) {\n this.tokensApiProvider = tokensApiProvider;\n }\n\n /**\n * Attempts to perform a given task. If the task fails, it retries with an increasing delay until\n * maximum retries are reached.\n *\n * @protected\n * @template T - The type of value that the callback returns.\n * @param {() => Promise<T>} callback - The asynchronous function representing the task to be retried.\n * @returns {Promise<T>} A promise that resolves to the result of the task or rejects with an error.\n * @throws {Error} Throws an error if maximum retries are reached.\n */\n protected backoffAndRetry<T>(callback: () => Promise<T>): Promise<T> {\n if (this.retries >= MAX_RETRIES) {\n throw new Error('Max retries reached');\n }\n this.retries++;\n this.delay *= BACKOFF_FACTOR;\n\n return new Promise<T>((resolve, reject) => {\n setTimeout(() => {\n callback().then(resolve, reject);\n }, this.delay);\n });\n }\n}\n","import {\n TokensApiProvider,\n Transaction,\n TransactionStatus,\n} from '@poap-xyz/providers';\nimport { FinishedWithError } from '../errors/FinishedWithError';\nimport { RetryableTask } from './RetryableTask';\n\n/**\n * A utility class designed to continually check the status of a POAP token mint.\n * If a mint is still pending or in process, it implements a backoff retry mechanism.\n */\nexport class MintChecker extends RetryableTask {\n private mintCode: string;\n\n /**\n * Constructs a new instance of the MintChecker class.\n *\n * @param {string} mintCode - The unique code for the token mint.\n * @param {TokensApiProvider} tokensApiProvider - The provider to fetch the mint status.\n */\n constructor(tokensApiProvider: TokensApiProvider, mintCode: string) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Checks the current status of a token mint.\n * If the mint is still pending or in process, it will retry the check with an increased delay.\n *\n * @public\n * @returns {Promise<void>} A promise that resolves once the status has been checked.\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n public async checkMintStatus(): Promise<void> {\n try {\n const transaction = await this.tokensApiProvider.getMintTransaction(\n this.mintCode,\n );\n\n if (this.shouldRetry(transaction)) {\n await this.backoffAndRetry(() => this.checkMintStatus());\n } else {\n this.handleErrorStatus(transaction, this.mintCode);\n }\n } catch (e) {\n if (e instanceof FinishedWithError) {\n throw e;\n }\n\n await this.backoffAndRetry(() => this.checkMintStatus());\n }\n }\n\n /**\n * Determines if a retry should be performed based on the provided minting status.\n *\n * @private\n * @returns {boolean} Returns true if a retry should be performed, otherwise false.\n * @param transaction - The transaction to check for retry.\n */\n private shouldRetry(transaction: Transaction | null): boolean {\n return !transaction || transaction.status === TransactionStatus.pending;\n }\n\n /**\n * Handles any error statuses from the mint status response.\n * If the minting process finishes with an error, an exception will be thrown.\n *\n * @private\n * @param {Transaction} transaction - The transaction to check for errors.\n * @param mintCode\n * @throws {FinishedWithError} Throws an error if the minting process finished with an error.\n */\n private handleErrorStatus(\n transaction: Transaction | null,\n mintCode: string,\n ): void {\n if (transaction?.status === TransactionStatus.failed) {\n throw new FinishedWithError(\n 'The Transaction associated with this mint failed',\n mintCode,\n );\n }\n }\n}\n","import { TokensApiProvider } from '@poap-xyz/providers';\nimport { RetryableTask } from './RetryableTask';\nimport { PoapMintStatus } from '../types/PoapMintStatus';\n\n/**\n * @class PoapIndexed\n * @extends {RetryableTask}\n *\n * Represents a utility class designed to periodically check if a POAP token is indexed on our database.\n * This class extends `RetryableTask` to utilize its backoff retry mechanism in case the token hasn't been indexed yet.\n */\nexport class PoapIndexed extends RetryableTask {\n private mintCode: string;\n\n /**\n * Creates an instance of the PoapIndexed class.\n *\n * @param {TokensApiProvider} tokensApiProvider - An instance of the TokensApiProvider used to check the indexing status of the token.\n * @param {string} mintCode - A unique Mint Code representing the token.\n */\n constructor(tokensApiProvider: TokensApiProvider, mintCode: string) {\n super(tokensApiProvider);\n this.mintCode = mintCode;\n }\n\n /**\n * Periodically checks if the POAP token, represented by its Mint Code, is indexed on our database.\n * This method will continue retrying with an increasing delay until either the token is indexed or it reaches the maximum allowed retries.\n *\n * @returns {Promise<GetClaimCodeResponse>} A promise that either resolves with the indexed token's mint code response or rejects due to reaching the max retry limit.\n */\n public async waitPoapIndexed(): Promise<PoapMintStatus> {\n let response = await this.tokensApiProvider.getMintCode(this.mintCode);\n while (response.result == null) {\n response = await this.backoffAndRetry(() =>\n this.tokensApiProvider.getMintCode(this.mintCode),\n );\n }\n return {\n minted: response.claimed,\n isActive: response.is_active,\n secretCode: response.secret,\n poapId: response.result?.token,\n };\n }\n}\n","import {\n CompassProvider,\n TokensApiProvider,\n Transaction,\n} from '@poap-xyz/providers';\nimport {\n createAddressFilter,\n createBetweenFilter,\n createEqFilter,\n createInFilter,\n createNotNullAddressFilter,\n createOrderBy,\n nextCursor,\n PaginatedResult,\n} from '@poap-xyz/utils';\nimport { POAP } from './domain/POAP';\nimport { POAPReservation } from './domain/POAPReservation';\nimport {\n PAGINATED_POAPS_QUERY,\n PaginatedPoapsResponse,\n PaginatedPoapsVariables,\n} from './queries/PaginatedPoaps';\nimport { FetchPoapsInput } from './types/FetchPoapsInput';\nimport { PoapsSortFields } from './types/PoapsSortFields';\nimport { PoapMintStatus } from './types/PoapMintStatus';\nimport { WalletMintInput } from './types/WalletMintInput';\nimport { EmailReservationInput } from './types/EmailReservationInput';\nimport { CodeAlreadyMintedError } from './errors/CodeAlreadyMintedError';\nimport { CodeExpiredError } from './errors/CodeExpiredError';\nimport { MintChecker } from './utils/MintChecker';\nimport { PoapIndexed } from './utils/PoapIndexed';\n\n/**\n * Represents a client for interacting with POAPs.\n *\n * @class\n */\nexport class PoapsClient {\n /**\n * Initializes a new instance of the PoapsClient.\n *\n * @param {CompassProvider} compassProvider - The provider for the POAP compass API.\n * @param {TokensApiProvider} tokensApiProvider - The provider for the Tokens API.\n */\n constructor(\n private compassProvider: CompassProvider,\n private tokensApiProvider: TokensApiProvider,\n ) {}\n\n /**\n * Fetches a list of POAP tokens based on the given input criteria.\n *\n * @async\n * @param {FetchPoapsInput} input - Criteria for fetching POAP tokens.\n * @returns {Promise<PaginatedResult<POAP>>} A paginated list of POAP tokens.\n */\n async fetch(input: FetchPoapsInput): Promise<PaginatedResult<POAP>> {\n const {\n limit,\n offset,\n chain,\n collectorAddress,\n mintedDateFrom,\n mintedDateTo,\n ids,\n dropId,\n sortField,\n sortDir,\n filterZeroAddress = true,\n filterDeadAddress = true,\n } = input;\n\n const variables: PaginatedPoapsVariables = {\n limit,\n offset,\n orderBy: createOrderBy<PoapsSortFields>(sortField, sortDir),\n where: {\n ...createAddressFilter('collector_address', collectorAddress),\n ...(collectorAddress == undefined\n ? createNotNullAddressFilter(\n 'collector_address',\n filterZeroAddress,\n filterDeadAddress,\n )\n : {}),\n ...createEqFilter('chain', chain),\n ...createEqFilter('drop_id', dropId),\n ...createBetweenFilter('minted_on', mintedDateFrom, mintedDateTo),\n ...createInFilter('id', ids),\n },\n };\n\n const { data } = await this.compassProvider.request<\n PaginatedPoapsResponse,\n PaginatedPoapsVariables\n >(PAGINATED_POAPS_QUERY, variables);\n\n const poaps = data.poaps.map((poap) => POAP.fromCompass(poap));\n\n return new PaginatedResult<POAP>(\n poaps,\n nextCursor(poaps.length, limit, offset),\n );\n }\n\n /**\n * Retrieves mint code details for a specific Mint Code.\n *\n * @async\n * @param {string} mintCode - The Mint Code for which to get the mint code.\n * @returns {Promise<PoapMintStatus>} The Mint status.\n */\n async getMintCode(mintCode: string): Promise<PoapMintStatus> {\n const getMintCodeRaw = await this.tokensApiProvider.getMintCode(mintCode);\n return {\n minted: getMintCodeRaw.claimed,\n isActive: getMintCodeRaw.is_active,\n secretCode: getMintCodeRaw.secret,\n poapId: getMintCodeRaw.result?.token,\n };\n }\n\n /**\n * Gets the Transaction associated with the mint.\n * The Transaction could change in case of a bump.\n * It returns null if the mint has no transaction associated.\n *\n * @param {string} qrHash - The qrHash of the mint.\n * @returns {Promise<Transaction> | null} The Transaction associated with the mint. Null if no transaction is found.\n */\n public async getMintTransaction(qrHash: string): Promise<Transaction | null> {\n return await this.tokensApiProvider.getMintTransaction(qrHash);\n }\n\n /**\n * Awaits until we have a final Transaction status for a specific Mint Code.\n *\n * @async\n * @returns {Promise<void>}\n * @param mintCode - The Mint Code\n */\n public async waitMintStatus(mintCode: string): Promise<void> {\n const checker = new MintChecker(this.tokensApiProvider, mintCode);\n await checker.checkMintStatus();\n }\n\n /**\n * Awaits until a specific POAP, identified by its Mint Code, is indexed on our database.\n *\n * @async\n * @param {string} mintCode - The Mint Code identifying the POAP to be indexed.\n * @returns {Promise<PoapMintStatus>} - The status of the POAP mint.\n */\n public async waitPoapIndexed(mintCode: string): Promise<PoapMintStatus> {\n const checker = new PoapIndexed(this.tokensApiProvider, mintCode);\n return await checker.waitPoapIndexed();\n }\n\n /**\n * Begins an asynchronous mint process and provides a unique queue ID in return.\n *\n * @async\n * @param {WalletMintInput} input - Details required for the mint.\n */\n public async mintAsync(input: WalletMintInput): Promise<void> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n await this.tokensApiProvider.postMintCode({\n address: input.address,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: false,\n });\n }\n\n /**\n * Starts a synchronous mint process. The method waits for the mint to be processed and then\n * fetches the associated POAP. It combines the asynchronous mint and subsequent status checking\n * into a synchronous process for ease of use.\n *\n * @async\n * @param {WalletMintInput} input - Details needed for the mint.\n * @returns {Promise<POAP>} The associated POAP upon successful mint completion.\n * @throws {FinishedWithError} If there's an error concluding the mint process.\n */\n async mintSync(input: WalletMintInput): Promise<POAP> {\n await this.mintAsync(input);\n\n await this.waitMintStatus(input.mintCode);\n\n const getCodeResponse = await this.waitPoapIndexed(input.mintCode);\n\n return (\n await this.fetch({\n limit: 1,\n offset: 0,\n ids: [getCodeResponse.poapId],\n })\n ).items[0];\n }\n\n /**\n * Reserves a POAP to an email address and provides reservation details.\n *\n * @async\n * @param {EmailReservationInput} input - Information for the reservation.\n * @returns {Promise<POAPReservation>} The reservation details of the POAP.\n */\n public async emailReservation(\n input: EmailReservationInput,\n ): Promise<POAPReservation> {\n const secretCode = await this.getSecretCode(input.mintCode);\n\n const response = await this.tokensApiProvider.postMintCode({\n address: input.email,\n qr_hash: input.mintCode,\n secret: secretCode,\n sendEmail: input.sendEmail || true,\n });\n\n return new POAPReservation({\n email: input.email,\n dropId: response.event.id,\n imageUrl: response.event.image_url,\n city: response.event.city,\n country: response.event.country,\n description: response.event.description,\n startDate: new Date(response.event.start_date),\n endDate: new Date(response.event.end_date),\n name: response.event.name,\n });\n }\n\n /**\n * Retrieves the secret code associated with a POAP code.\n *\n * @async\n * @param {string} mintCode - The POAP code for which to get the secret.\n * @returns {Promise<string>} The associated secret code.\n * @throws {CodeAlreadyMintedError} Thrown when the POAP code has already been minted.\n * @throws {CodeExpiredError} Thrown when the POAP code is expired.\n */\n private async getSecretCode(mintCode: string): Promise<string> {\n const getCodeResponse = await this.getMintCode(mintCode);\n\n if (getCodeResponse.minted) {\n throw new CodeAlreadyMintedError(mintCode);\n }\n if (!getCodeResponse.isActive) {\n throw new CodeExpiredError(mintCode);\n }\n\n return getCodeResponse.secretCode;\n }\n}\n"],"names":["PoapsSortFields"],"mappings":";;;;;;AAMYA,mCAKX;EALD,CAAA,UAAY,eAAe,EAAA;EAEzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,WAAsB,CAAA;EAEtB,IAAA,eAAA,CAAA,IAAA,CAAA,GAAA,IAAS,CAAA;EACX,CAAC,EALWA,uBAAe,KAAfA,uBAAe,GAK1B,EAAA,CAAA,CAAA;;ECXD,MAAM,eAAe,CAAC;EACtB,IAAI,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE;EACnC,QAAQ,IAAI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AQ,CAAC,CAAC;EAEzD,QAAA,IAAI,eAAe,CAAC,MAAM,EAAE;EAC1B,YAAA,MAAM,IAAI,sBAAsB,CAAC,QAAQ,CAAC,CAAC;WAC5C;EACD,QAAA,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;EAC7B,YAAA,MAAM,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;WACtC;UAED,OAAO,eAAe,CAAC,UAAU,CAAC;OACnC;EACF;;;;;;;;;;;;;"} |
| 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>; | ||
| } |
+3
-3
| { | ||
| "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": { |
| export declare class POAP { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| endDate: Date; | ||
| name: string; | ||
| constructor(properties: PoapProperties); | ||
| } | ||
| export interface PoapProperties { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| name: string; | ||
| endDate: Date; | ||
| } |
| export * from './PaginatedPoaps'; |
| export * from './input'; | ||
| export * from './response'; |
| import { Order, Chain, PaginationInput } from '@poap-xyz/utils'; | ||
| export declare enum PoapsSortFields { | ||
| MintedOn = "minted_on", | ||
| Id = "id" | ||
| } | ||
| export interface FetchPoapsInput extends PaginationInput { | ||
| name?: string; | ||
| chain?: Chain; | ||
| mintedDateFrom?: string; | ||
| mintedDateTo?: string; | ||
| ids?: number[]; | ||
| collectorAddress?: string; | ||
| dropId?: number; | ||
| sortField?: PoapsSortFields; | ||
| sortDir?: Order; | ||
| filterZeroAddress?: boolean; | ||
| filterDeadAddress?: boolean; | ||
| } | ||
| export interface WalletMintInput { | ||
| mintCode: string; | ||
| address: string; | ||
| } | ||
| export interface EmailReservationInput { | ||
| mintCode: string; | ||
| email: string; | ||
| sendEmail?: boolean; | ||
| } |
| export interface PoapMintStatus { | ||
| minted: boolean; | ||
| isActive: boolean; | ||
| secretCode: string; | ||
| poapId: number; | ||
| } |
| export declare class POAP { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| endDate: Date; | ||
| name: string; | ||
| constructor(properties: PoapProperties); | ||
| } | ||
| export interface PoapProperties { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| name: string; | ||
| endDate: Date; | ||
| } |
| export * from './PaginatedPoaps'; |
| export * from './input'; | ||
| export * from './response'; |
| import { Order, Chain, PaginationInput } from '@poap-xyz/utils'; | ||
| export declare enum PoapsSortFields { | ||
| MintedOn = "minted_on", | ||
| Id = "id" | ||
| } | ||
| export interface FetchPoapsInput extends PaginationInput { | ||
| name?: string; | ||
| chain?: Chain; | ||
| mintedDateFrom?: string; | ||
| mintedDateTo?: string; | ||
| ids?: number[]; | ||
| collectorAddress?: string; | ||
| dropId?: number; | ||
| sortField?: PoapsSortFields; | ||
| sortDir?: Order; | ||
| filterZeroAddress?: boolean; | ||
| filterDeadAddress?: boolean; | ||
| } | ||
| export interface WalletMintInput { | ||
| mintCode: string; | ||
| address: string; | ||
| } | ||
| export interface EmailReservationInput { | ||
| mintCode: string; | ||
| email: string; | ||
| sendEmail?: boolean; | ||
| } |
| export interface PoapMintStatus { | ||
| minted: boolean; | ||
| isActive: boolean; | ||
| secretCode: string; | ||
| poapId: number; | ||
| } |
| export declare class POAP { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| endDate: Date; | ||
| name: string; | ||
| constructor(properties: PoapProperties); | ||
| } | ||
| export interface PoapProperties { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| name: string; | ||
| endDate: Date; | ||
| } |
| export * from './PaginatedPoaps'; |
| export * from './input'; | ||
| export * from './response'; |
| import { Order, Chain, PaginationInput } from '@poap-xyz/utils'; | ||
| export declare enum PoapsSortFields { | ||
| MintedOn = "minted_on", | ||
| Id = "id" | ||
| } | ||
| export interface FetchPoapsInput extends PaginationInput { | ||
| name?: string; | ||
| chain?: Chain; | ||
| mintedDateFrom?: string; | ||
| mintedDateTo?: string; | ||
| ids?: number[]; | ||
| collectorAddress?: string; | ||
| dropId?: number; | ||
| sortField?: PoapsSortFields; | ||
| sortDir?: Order; | ||
| filterZeroAddress?: boolean; | ||
| filterDeadAddress?: boolean; | ||
| } | ||
| export interface WalletMintInput { | ||
| mintCode: string; | ||
| address: string; | ||
| } | ||
| export interface EmailReservationInput { | ||
| mintCode: string; | ||
| email: string; | ||
| sendEmail?: boolean; | ||
| } |
| export interface PoapMintStatus { | ||
| minted: boolean; | ||
| isActive: boolean; | ||
| secretCode: string; | ||
| poapId: number; | ||
| } |
-141
| # Error Handling Documentation | ||
| This section documents the custom error classes defined for handling specific error scenarios while interacting with POAP tokens. | ||
| ## CodeAlreadyMintedError | ||
| The `CodeAlreadyMintedError` class is thrown when an attempt is made to mint a POAP token using a mint code that has already been used. | ||
| ```typescript | ||
| export class CodeAlreadyMintedError extends Error { | ||
| constructor(code: string) { | ||
| super(`Code: '${code}' already minted `); | ||
| } | ||
| } | ||
| ``` | ||
| ## CodeExpiredError | ||
| The `CodeExpiredError` class is thrown when an attempt is made to use a mint code that has expired. | ||
| ```typescript | ||
| export class CodeExpiredError extends Error { | ||
| constructor(code: string) { | ||
| super(`Code: '${code}', has been expired`); | ||
| } | ||
| } | ||
| ``` | ||
| ## FinishedWithError | ||
| The `FinishedWithError` class is thrown when a minting operation encounters an error. | ||
| ```typescript | ||
| export class FinishedWithError extends Error { | ||
| constructor(error: string, code: string) { | ||
| super( | ||
| `Code: '${code}', finished with error: '${error}', please try again later `, | ||
| ); | ||
| } | ||
| } | ||
| ``` | ||
| ## Usage | ||
| These custom error classes allow for more precise error handling and better debugging, by providing specific error messages based on the type of error encountered. They extend the native JavaScript `Error` class and can be used in a similar manner, with the added benefit of POAP-specific error messages. | ||
| ### Example Usage | ||
| Below are examples demonstrating how one might use the `PoapsClient` class along with the custom error handling. | ||
| ```typescript | ||
| // Importing necessary classes and error types | ||
| import { | ||
| PoapsClient, | ||
| WalletMintInput, | ||
| EmailReservationInput, | ||
| } from '@poap-xyz/poap-client'; | ||
| import { | ||
| CodeAlreadyMintedError, | ||
| CodeExpiredError, | ||
| FinishedWithError, | ||
| } from '@poap-xyz/poap-errors'; | ||
| // Initializing the PoapsClient with providers | ||
| const poapsClient = new PoapsClient(compassProvider, tokensApiProvider); | ||
| // Defining the WalletMintInput | ||
| const walletMintInput: WalletMintInput = { | ||
| mintCode: 'some-mint-code', | ||
| address: '0x1234567890abcdef1234567890abcdef12345678', | ||
| }; | ||
| // Defining the EmailReservationInput | ||
| const emailReservationInput: EmailReservationInput = { | ||
| mintCode: 'some-other-mint-code', | ||
| email: 'example@example.com', | ||
| }; | ||
| // Attempting to mint a POAP token synchronously | ||
| async function mintPoap() { | ||
| try { | ||
| const poap = await poapsClient.mintSync(walletMintInput); | ||
| console.log('POAP minted successfully:', poap); | ||
| } catch (error) { | ||
| if (error instanceof FinishedWithError) { | ||
| console.error('Error concluding the mint process:', error.message); | ||
| // Action: Notify the user about the error and suggest retrying later. | ||
| } else { | ||
| console.error('An unknown error occurred:', error.message); | ||
| // Action: Log the error and notify the user of a general error. | ||
| } | ||
| } | ||
| } | ||
| // Attempting to get the secret code for a mint code | ||
| async function getSecret() { | ||
| try { | ||
| const secretCode = await poapsClient.getSecretCode( | ||
| walletMintInput.mintCode, | ||
| ); | ||
| console.log('Secret code retrieved:', secretCode); | ||
| } catch (error) { | ||
| if (error instanceof CodeAlreadyMintedError) { | ||
| console.error('This mint code has already been used:', error.message); | ||
| // Action: Notify the user that the mint code has already been used. | ||
| } else if (error instanceof CodeExpiredError) { | ||
| console.error('This mint code has expired:', error.message); | ||
| // Action: Notify the user that the mint code has expired. | ||
| } else { | ||
| console.error('An unknown error occurred:', error.message); | ||
| // Action: Log the error and notify the user of a general error. | ||
| } | ||
| } | ||
| } | ||
| // Attempting to reserve a POAP via email | ||
| async function reservePoap() { | ||
| try { | ||
| const reservation = await poapsClient.emailReservation( | ||
| emailReservationInput, | ||
| ); | ||
| console.log('POAP reserved successfully:', reservation); | ||
| } catch (error) { | ||
| if (error instanceof CodeAlreadyMintedError) { | ||
| console.error('This mint code has already been used:', error.message); | ||
| // Action: Notify the user that the mint code has already been used. | ||
| } else if (error instanceof CodeExpiredError) { | ||
| console.error('This mint code has expired:', error.message); | ||
| // Action: Notify the user that the mint code has expired. | ||
| } else { | ||
| console.error('An unknown error occurred:', error.message); | ||
| // Action: Log the error and notify the user of a general error. | ||
| } | ||
| } | ||
| } | ||
| // Executing the mintPoap, getSecret, and reservePoap functions | ||
| mintPoap(); | ||
| getSecret(); | ||
| reservePoap(); | ||
| ``` |
| # Input Types Documentation | ||
| This section documents the input types used to fetch and manage POAPs . | ||
| ## PoapsSortFields | ||
| The `PoapsSortFields` enumeration defines the available fields by which POAPs can be sorted. | ||
| | Property | Value | Description | | ||
| | ---------- | ----------- | ------------------------------------------------------ | | ||
| | `MintedOn` | `minted_on` | Represents sorting by the date when a POAP was minted. | | ||
| | `Id` | `id` | Represents sorting by the ID of a POAP. | | ||
| ```typescript | ||
| export enum PoapsSortFields { | ||
| MintedOn = 'minted_on', | ||
| Id = 'id', | ||
| } | ||
| ``` | ||
| ## FetchPoapsInput | ||
| The `FetchPoapsInput` interface represents the input fields for fetching POAPs and extends `PaginationInput` to provide pagination capability. | ||
| | Property | Type | Description | | ||
| | --------------------- | ------------------ | ---------------------------------------------------------- | | ||
| | `name` | `string?` | Optional filter for the name of a POAP. | | ||
| | `chain` | `Chain?` | Optional filter for the blockchain chain of a POAP. | | ||
| | `mintedDateFrom` | `string?` | Optional filter for the start date when a POAP was minted. | | ||
| | `mintedDateTo` | `string?` | Optional filter for the end date when a POAP was minted. | | ||
| | `ids` | `number[]?` | Optional filter for specific POAP IDs. | | ||
| | `collectorAddress` | `string?` | Optional filter for the collector's address. | | ||
| | `dropId` | `number?` | Optional filter for a specific drop ID. | | ||
| | `sortField` | `PoapsSortFields?` | Field by which to sort the results. | | ||
| | `sortDir` | `Order?` | Direction in which to sort the results. | | ||
| | `filterByZeroAddress` | `boolean?` | Filter to include/exclude POAPs with zero addresses. | | ||
| ```typescript | ||
| export interface FetchPoapsInput extends PaginationInput { | ||
| name?: string; | ||
| chain?: Chain; | ||
| mintedDateFrom?: string; | ||
| mintedDateTo?: string; | ||
| ids?: number[]; | ||
| collectorAddress?: string; | ||
| dropId?: number; | ||
| sortField?: PoapsSortFields; | ||
| sortDir?: Order; | ||
| filterByZeroAddress?: boolean; | ||
| } | ||
| ``` | ||
| ## WalletMintInput | ||
| The `WalletMintInput` interface represents the input fields required to mint a POAP for an Ethereum wallet address. | ||
| | Property | Type | Description | | ||
| | ---------- | -------- | ---------------------------------------------- | | ||
| | `mintCode` | `string` | The mint code for the POAP. | | ||
| | `address` | `string` | The address of the wallet to mint the POAP to. | | ||
| ```typescript | ||
| export interface WalletMintInput { | ||
| mintCode: string; | ||
| address: string; | ||
| ``` | ||
| ## EmailReservationInput | ||
| The `EmailReservationInput` interface represents the input fields required to reserve a POAP via email. | ||
| | Property | Type | Description | | ||
| | ----------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | `mintCode` | `string` | The mint code for the POAP, essential for identifying the specific POAP being reserved. | | ||
| | `email` | `string` | The email address for reserving the POAP, where the reservation confirmation and next steps will be sent. | | ||
| | `sendEmail` | `boolean?` | Optional field to specify whether to send an email notification. If set to true or omitted, an email containing the next steps will be sent to the provided email address. If set to false, no email will be sent, although the POAP is still reserved. | | ||
| ```typescript | ||
| export interface EmailReservationInput { | ||
| mintCode: string; | ||
| email: string; | ||
| sendEmail?: boolean; | ||
| } | ||
| ``` |
-57
| # POAP | ||
| ## Description | ||
| The `POAP` class represents a POAP token with various attributes pertaining to the token itself, the drop it's associated with, and its ownership details. | ||
| ## Constructor | ||
| ```typescript | ||
| constructor(properties: PoapProperties) | ||
| ``` | ||
| Creates a new instance of the `POAP` class with specified properties. | ||
| ### Parameters | ||
| - `properties` (`PoapProperties`): An object containing all necessary properties to initialize the `POAP` instance. | ||
| ## Properties | ||
| | Property | Type | Description | | ||
| | ------------------ | -------- | ------------------------------------------------------------------------ | | ||
| | `id` | `number` | The unique identifier of the POAP token. | | ||
| | `collectorAddress` | `string` | The address of the collector owning the POAP token. | | ||
| | `transferCount` | `number` | The number of times the POAP token has been transferred. | | ||
| | `mintedOn` | `Date` | The date and time when the POAP token was minted. | | ||
| | `dropId` | `number` | The identifier of the drop associated with the POAP token. | | ||
| | `imageUrl` | `string` | The URL of the image representing the POAP token or the associated drop. | | ||
| | `city` | `string` | The city where the associated drop took place. | | ||
| | `country` | `string` | The country where the associated drop took place. | | ||
| | `description` | `string` | A description of the associated drop or the POAP token. | | ||
| | `startDate` | `Date` | The start date of the associated drop. | | ||
| | `endDate` | `Date` | The end date of the associated drop. | | ||
| | `name` | `string` | The name of the associated drop. | | ||
| ## PoapProperties Interface | ||
| The `PoapProperties` interface defines the shape of the object required by the constructor of the `POAP` class. | ||
| ```typescript | ||
| interface PoapProperties { | ||
| id: number; | ||
| collectorAddress: string; | ||
| transferCount: number; | ||
| mintedOn: Date; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| name: string; | ||
| endDate: Date; | ||
| } | ||
| ``` | ||
| Each property in the `PoapProperties` interface corresponds to a property in the `POAP` class, and their descriptions are as mentioned above in the Properties section. |
| # POAPReservation | ||
| ## Description | ||
| The `POAPReservation` class represents a reservation of a POAP token associated with an email address. This class encapsulates details about the event for which the POAP token is reserved. | ||
| ## Constructor | ||
| ```typescript | ||
| constructor(properties: POAPReservationProperties) | ||
| ``` | ||
| Creates a new instance of the `POAPReservation` class with the specified properties. | ||
| ### Parameters | ||
| - `properties` (`POAPReservationProperties`): An object containing all necessary properties to initialize the `POAPReservation` instance. | ||
| ## Properties | ||
| | Property | Type | Description | | ||
| | ------------- | -------- | ------------------------------------------------------------------------------- | | ||
| | `email` | `string` | The email address where the POAP token is reserved. | | ||
| | `dropId` | `number` | The identifier of the drop associated with the POAP reservation. | | ||
| | `imageUrl` | `string` | The URL of the image representing the POAP reservation or the associated event. | | ||
| | `city` | `string` | The city where the associated event took place. | | ||
| | `country` | `string` | The country where the associated event took place. | | ||
| | `description` | `string` | A description of the associated event or the POAP reservation. | | ||
| | `startDate` | `Date` | The start date of the associated event. | | ||
| | `endDate` | `Date` | The end date of the associated event. | | ||
| | `name` | `string` | The name of the associated event or the POAP reservation. | | ||
| ## POAPReservationProperties Interface | ||
| The `POAPReservationProperties` interface defines the shape of the object required by the constructor of the `POAPReservation` class. | ||
| ```typescript | ||
| interface POAPReservationProperties { | ||
| email: string; | ||
| dropId: number; | ||
| imageUrl: string; | ||
| city: string; | ||
| country: string; | ||
| description: string; | ||
| startDate: Date; | ||
| name: string; | ||
| endDate: Date; | ||
| } | ||
| ``` | ||
| Each property in the `POAPReservationProperties` interface corresponds to a property in the `POAPReservation` class, and their descriptions are as mentioned above in the Properties section. |
| # PoapsClient | ||
| ## Description | ||
| `PoapsClient` is a class representing a client for interacting with POAPs . | ||
| ## Constructor | ||
| ```typescript | ||
| constructor( | ||
| private compassProvider: CompassProvider, | ||
| private tokensApiProvider: TokensApiProvider | ||
| ) | ||
| ``` | ||
| - `compassProvider` (`CompassProvider`): The provider for the POAP compass API. | ||
| - `tokensApiProvider` (`TokensApiProvider`): The provider for the Tokens API. | ||
| ## Methods | ||
| ### `fetch` | ||
| ```typescript | ||
| async fetch(input: FetchPoapsInput): Promise<PaginatedResult<POAP>> | ||
| ``` | ||
| Fetches a list of [`POAP`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/POAP.md) tokens based on the given input criteria. | ||
| #### Parameters | ||
| - `input` ([`FetchPoapsInput`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/inputs.md/FetchPoapsInput)): Criteria for fetching POAP tokens. | ||
| #### Returns | ||
| A promise that resolves to a paginated list of [`POAP`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/POAP.md) tokens. | ||
| ### `getSecretCode` | ||
| ```typescript | ||
| private async getSecretCode(mintCode: string): Promise<string> | ||
| ``` | ||
| Retrieves the secret code associated with a POAP code. | ||
| #### Parameters | ||
| - `mintCode` (`string`): The POAP code for which to get the secret. | ||
| #### Returns | ||
| A promise that resolves to the associated secret code. | ||
| #### Throws | ||
| - [`CodeAlreadyMintedError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/CodeAlreadyMintedError): Thrown when the POAP code has already been minted. | ||
| - [`CodeExpiredError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/CodeExpiredError): Thrown when the POAP code is expired. | ||
| ### `getMintCode` | ||
| ```typescript | ||
| async getMintCode(mintCode: string): Promise<PoapMintStatus> | ||
| ``` | ||
| Retrieves mint code details for a specific Mint Code. | ||
| #### Parameters | ||
| - `mintCode` (`string`): The Mint Code for which to get the mint code. | ||
| #### Returns | ||
| A promise that resolves to the mint code details, [`PoapMintStatus`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/responses.md/PoapMintStatus). | ||
| ### `getMintStatus` | ||
| ```typescript | ||
| async getMintStatus(queueUid: string): Promise<MintingStatus> | ||
| ``` | ||
| Fetches the current status of a mint based on its unique ID. | ||
| #### Parameters | ||
| - `queueUid` (`string`): The unique ID of the mint. | ||
| #### Returns | ||
| A promise that resolves to the current status of the mint. | ||
| ### `waitMintStatus` | ||
| ```typescript | ||
| async waitMintStatus(queueUid: string, mintCode: string): Promise<void> | ||
| ``` | ||
| Awaits until the mint's status changes from 'IN_PROCESS' or 'PENDING'. | ||
| #### Parameters | ||
| - `queueUid` (`string`): The unique ID of the mint. | ||
| - `mintCode` (`string`): The Mint Code for the mint. | ||
| #### Returns | ||
| A promise that resolves when the mint's status changes. | ||
| ### `waitPoapIndexed` | ||
| ```typescript | ||
| async waitPoapIndexed(mintCode: string): Promise<PoapMintStatus> | ||
| ``` | ||
| Awaits until a specific POAP, identified by its Mint Code, is indexed on our database. | ||
| #### Parameters | ||
| - `mintCode` (`string`): The Mint Code identifying the POAP to be indexed. | ||
| #### Returns | ||
| A promise that resolves to details of the indexed POAP, [`PoapMintStatus`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/responses.md/PoapMintStatus). | ||
| ### `mintAsync` | ||
| ```typescript | ||
| async mintAsync(input: WalletMintInput): Promise<string> | ||
| ``` | ||
| Begins an asynchronous mint process and provides a unique queue ID in return. | ||
| #### Parameters | ||
| - `input` ([`WalletMintInput`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/inputs.md/WalletMintInput)): Details required for the mint. | ||
| #### Returns | ||
| A promise that resolves to a unique queue ID for the initiated mint. | ||
| #### Throws | ||
| - [`CodeAlreadyMintedError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/CodeAlreadyMintedError): Thrown when the POAP code has already been minted. | ||
| - [`CodeExpiredError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/CodeExpiredError): Thrown when the POAP code is expired. | ||
| ### `mintSync` | ||
| ```typescript | ||
| async mintSync(input: WalletMintInput): Promise<POAP> | ||
| ``` | ||
| Starts a synchronous mint process. | ||
| #### Parameters | ||
| - `input` ([`WalletMintInput`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/inputs.md/WalletMintInput)): Details needed for the mint. | ||
| #### Returns | ||
| A promise that resolves to the associated [`POAP`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/POAP.md) upon successful mint completion. | ||
| #### Throws | ||
| - [`CodeAlreadyMintedError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/CodeAlreadyMintedError): Thrown when the POAP code has already been minted. | ||
| - [`CodeExpiredError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/CodeExpiredError): Thrown when the POAP code is expired. | ||
| - [`FinishedWithError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/FinishedWithError): Thrown when a minting operation encounters an error. | ||
| ### `emailReservation` | ||
| ```typescript | ||
| async emailReservation( | ||
| input: EmailReservationInput | ||
| ): Promise<POAPReservation> | ||
| ``` | ||
| Reserves a POAP to an email address and provides reservation details. | ||
| #### Parameters | ||
| - `input` ([`EmailReservationInput`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/inputs.md/EmailReservationInput)): Information for the reservation. | ||
| #### Returns | ||
| A promise that resolves to the reservation details of the [`POAPReservation`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/POAPReservation.md). | ||
| #### Throws | ||
| - [`CodeAlreadyMintedError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/CodeAlreadyMintedError): Thrown when the POAP code has already been minted. | ||
| - [`CodeExpiredError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/CodeExpiredError): Thrown when the POAP code is expired. | ||
| ## Related Types | ||
| - [`PoapsClient`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/PoapsClient.md) | ||
| - [`POAP`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/POAP.md) | ||
| - [`POAPReservation`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/POAPReservation.md) | ||
| - [`FetchPoapsInput`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/inputs.md/FetchPoapsInput) | ||
| - [`WalletMintInput`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/inputs.md/WalletMintInput) | ||
| - [`EmailReservationInput`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/inputs.md/EmailReservationInput) | ||
| - [`PoapMintStatus`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/responses.md/PoapMintStatus) | ||
| - [`PoapsSortFields`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/inputs.md/PoapsSortFields) | ||
| - [`CodeAlreadyMintedError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/CodeAlreadyMintedError) | ||
| - [`CodeExpiredError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/CodeExpiredError) | ||
| - [`FinishedWithError`](https://github.com/poap-xyz/poap.js/tree/main/packages/poaps/docs/errors.md/FinishedWithError) |
| # Responses Documentation | ||
| This section documents the response types defined for managing and interacting with POAPs . | ||
| ## PoapMintStatus | ||
| The `PoapMintStatus` interface represents the status of a minting operation for a POAP token. | ||
| ```typescript | ||
| export interface PoapMintStatus { | ||
| minted: boolean; | ||
| isActive: boolean; | ||
| secretCode: string; | ||
| poapId: number; | ||
| } | ||
| ``` | ||
| ### Properties | ||
| | Property | Type | Description | | ||
| | ------------ | --------- | --------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | `minted` | `boolean` | Indicates whether the POAP token has been minted. | | ||
| | `isActive` | `boolean` | Indicates whether the mint code is active. | | ||
| | `secretCode` | `string` | The secret code associated with the minting operation. This code is required to mint a POAP token to a wallet. | | ||
| | `poapId` | `number` | The identifier of the minted POAP token. This ID is unique to each POAP token and can be used to fetch further details about the token. | | ||
| The `PoapMintStatus` interface is crucial for understanding the result of a minting operation, providing essential information about the mint status, and the details of the minted POAP token. |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
1621
0.93%271262
-8.61%58
-4.92%Updated
Updated