UNPKG

@lyncworld/fuel-marketplace

Version:

Marketplace NPM SDK on Fuel blockchain. Powered by LYNC, it allows anyone to create their own decentralized marketplace which includes listing and buying of Non-fungible tokens (NFTs) and Semi-fungible tokens (SFTs) in a few lines of code.

37 lines (29 loc) 1.18 kB
import { bn } from 'fuels'; import { NftMarketplace } from '@/contracts/marketplace'; import { MarketplaceServices } from '@/interfaces'; import { checkArguments } from '@/utils'; export class CancelListingService extends MarketplaceServices { private readonly contract: NftMarketplace | undefined = undefined; private listingId: `0x${string}` = '0x'; constructor(contract: NftMarketplace) { super(); checkArguments([contract], 'arguments'); this.contract = contract; } setProperties(listingId: `0x${string}`) { checkArguments([listingId], 'arguments'); this.listingId = listingId; return this; } async execute() { checkArguments([this.contract, this.listingId], 'properties'); try { const transactionAwaited = await this.contract!.functions.cancel_listing(bn(this.listingId)).call(); const finalTransaction = await transactionAwaited.waitForResult(); return { success: true, data: finalTransaction }; } catch (error: unknown) { console.error('Error Log: Error executing cancel listing transaction: ', { error }); return { success: false, error }; } } }