local w=require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\078\101\118\101\114\109\111\114\101"))local z=game:GetService("\077\097\114\107\101\116\112\108\097\099\101\083\101\114\118\105\099\101")local g=w("\080\114\111\109\105\115\101")local H={}function H.PromisePlayerOwnsAsset(w,H)assert(typeof(w)=="\073\110\115\116\097\110\099\101")assert(type(H)=="\110\117\109\098\101\114")return g.spawn(function(g,C)local x local Q,h=pcall(function()x=z:PlayerOwnsAsset(w,H)end)if not Q then return C(h)end if type(x)~="\098\111\111\108\101\097\110"then return C("\066\097\100 \114\101\115\117\108\116 \116\121\112\101")end return g(x)end)end function H.PromiseUserOwnsGamePass(w,H)assert(typeof(w)=="\073\110\115\116\097\110\099\101")assert(type(H)=="\110\117\109\098\101\114")return g.spawn(function(g,C)local x local Q,h=pcall(function()x=z:UserOwnsGamePassAsync(w,H)end)if not Q then return C(h)end if type(x)~="\098\111\111\108\101\097\110"then return C("\066\097\100 \114\101\115\117\108\116 \116\121\112\101")end return g(x)end)end return H
--- Provides utility methods for MarketplaceService
-- @module MarketplaceUtil

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Nevermore"))

local MarketplaceService = game:GetService("MarketplaceService")

local Promise = require("Promise")

local MarketplaceUtil = {}

function MarketplaceUtil.PromisePlayerOwnsAsset(player, assetId)
	assert(typeof(player) == "Instance")
	assert(type(assetId) == "number")

	return Promise.spawn(function(resolve, reject)
		local result
		local ok, err = pcall(function()
			result = MarketplaceService:PlayerOwnsAsset(player, assetId)
		end)
		if not ok then
			return reject(err)
		end
		if type(result) ~= "boolean" then
			return reject("Bad result type")
		end
		return resolve(result)
	end)
end

function MarketplaceUtil.PromiseUserOwnsGamePass(player, gamePassId)
	assert(typeof(player) == "Instance")
	assert(type(gamePassId) == "number")

	return Promise.spawn(function(resolve, reject)
		local result
		local ok, err = pcall(function()
			result = MarketplaceService:UserOwnsGamePassAsync(player, gamePassId)
		end)
		if not ok then
			return reject(err)
		end
		if type(result) ~= "boolean" then
			return reject("Bad result type")
		end
		return resolve(result)
	end)
end

return MarketplaceUtil
