Export Token Worker
An external worker placeholder for managing NFT/token minting and export processes.
Installation
import '@unchainedshop/plugins/worker/export-token';
Purpose
The Export Token Worker:
- Acts as a placeholder for external token minting systems
- Tracks the state of token export/minting processes
- Automatically updates token ownership when work completes successfully
- Listens for work completion events to trigger ownership updates
Configuration
To enable automatic ownership updates, configure the worker in your platform setup:
import { configureExportToken } from '@unchainedshop/plugins/worker/export-token';
// Pass the unchained API to enable event listeners
configureExportToken(unchainedAPI);
How It Works
- Create Export Work: External system creates work with token details
- External Processing: The minting/export happens outside Unchained
- Complete Work: External system marks work as finished via GraphQL
- Ownership Update: Worker automatically updates token ownership in the database
Usage
Create Export Work (from external system)
mutation CreateExportWork {
createWork(
type: "EXPORT_TOKEN"
input: {
token: {
_id: "token-id",
contractAddress: "0x...",
tokenId: "123"
},
recipientWalletAddress: "0xRecipientAddress..."
}
) {
_id
status
}
}
Complete Export Work (from external system)
mutation CompleteExport {
finishWork(
workId: "work-id"
success: true
result: {
transactionHash: "0x...",
blockNumber: 12345
}
) {
_id
status
}
}
Event Handling
When a work item of type EXPORT_TOKEN completes successfully, the worker:
- Extracts the token ID from
work.input.token._id - Extracts the wallet address from
work.input.recipientWalletAddress - Updates the token ownership in the warehousing module
Adapter Details
| Property | Value |
|---|---|
| Key | shop.unchained.worker-plugin.export-token |
| Type | EXPORT_TOKEN |
| External | true |
| Source | worker/export-token.ts |