UNPKG

@unchainedshop/plugins

Version:

Official plugin collection for the Unchained Engine with payment, delivery, and pricing adapters

27 lines (26 loc) 1.05 kB
import { WorkerEventTypes } from '@unchainedshop/core-worker'; import { WorkerAdapter, WorkerDirector, } from '@unchainedshop/core'; import { subscribe } from '@unchainedshop/events'; export const ExportTokenWorker = { ...WorkerAdapter, key: 'shop.unchained.worker-plugin.export-token', label: 'External worker to hold the state of the minting/export process of tokens', version: '1.0.0', type: 'EXPORT_TOKEN', external: true, async doWork() { throw new Error('Cannot do work for external workers'); }, }; export const configureExportToken = (unchainedAPI) => { subscribe(WorkerEventTypes.FINISHED, async ({ payload: work }) => { if (work.type === 'EXPORT_TOKEN' && work.success) { await unchainedAPI.modules.warehousing.updateTokenOwnership({ tokenId: work.input.token._id, walletAddress: work.input.recipientWalletAddress, }); } }); }; export default configureExportToken; WorkerDirector.registerAdapter(ExportTokenWorker);