From eb289bc19dc01c9a127e5c7eb510344bfaa7f99c Mon Sep 17 00:00:00 2001 From: Benjamin Fuentes Date: Tue, 26 Sep 2023 16:48:26 +0200 Subject: [PATCH] fixed --- solution/_esy/default/bin/node | 4 - solution/_esy/default/installation.json | 4 - solution/_esy/default/pnp.js | 925 ------------------ solution/_ligo/ligo/installation.json | 1 + solution/artifacts/nft.default_storage.tz | 18 +- solution/artifacts/nft.tz | 1044 ++++++++------------- solution/contracts/nft.jsligo | 92 +- solution/contracts/nft.storageList.jsligo | 45 +- solution/esy.json | 1 - solution/esy.lock/.gitattributes | 3 - solution/esy.lock/.gitignore | 3 - solution/esy.lock/index.json | 29 - solution/ligo.esy.lock/index.json | 1 + solution/ligo.json | 1 + 14 files changed, 469 insertions(+), 1702 deletions(-) delete mode 100755 solution/_esy/default/bin/node delete mode 100644 solution/_esy/default/installation.json delete mode 100644 solution/_esy/default/pnp.js create mode 100644 solution/_ligo/ligo/installation.json delete mode 100644 solution/esy.json delete mode 100644 solution/esy.lock/.gitattributes delete mode 100644 solution/esy.lock/.gitignore delete mode 100644 solution/esy.lock/index.json create mode 100644 solution/ligo.esy.lock/index.json create mode 100644 solution/ligo.json diff --git a/solution/_esy/default/bin/node b/solution/_esy/default/bin/node deleted file mode 100755 index 2600722..0000000 --- a/solution/_esy/default/bin/node +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -export ESY__NODE_BIN_PATH='/project/_esy/default/bin' -exec '/usr/bin/node' -r '/project/_esy/default/pnp.js' "$@" - \ No newline at end of file diff --git a/solution/_esy/default/installation.json b/solution/_esy/default/installation.json deleted file mode 100644 index 853af2a..0000000 --- a/solution/_esy/default/installation.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "project@link-dev:./esy.json": "/project", - "@ligo/fa@1.0.5@d41d8cd9": "./.ligo/source/i/ligo__s__fa__1.0.5__03096c62" -} \ No newline at end of file diff --git a/solution/_esy/default/pnp.js b/solution/_esy/default/pnp.js deleted file mode 100644 index d3eb0f3..0000000 --- a/solution/_esy/default/pnp.js +++ /dev/null @@ -1,925 +0,0 @@ -#!/usr/bin/env node - -/* eslint-disable max-len, flowtype/require-valid-file-annotation, flowtype/require-return-type */ -/* global packageInformationStores, null, $$SETUP_STATIC_TABLES */ - -// Used for the resolveUnqualified part of the resolution (ie resolving folder/index.js & file extensions) -// Deconstructed so that they aren't affected by any fs monkeypatching occuring later during the execution -const {statSync, lstatSync, readlinkSync, readFileSync, existsSync, realpathSync} = require('fs'); - -const Module = require('module'); -const path = require('path'); -const StringDecoder = require('string_decoder'); - -const ignorePattern = null ? new RegExp(null) : null; - -const pnpFile = path.resolve(__dirname, __filename); -const builtinModules = new Set(Module.builtinModules || Object.keys(process.binding('natives'))); - -const topLevelLocator = {name: null, reference: null}; -const blacklistedLocator = {name: NaN, reference: NaN}; - -// Used for compatibility purposes - cf setupCompatibilityLayer -const patchedModules = []; -const fallbackLocators = [topLevelLocator]; - -// Matches backslashes of Windows paths -const backwardSlashRegExp = /\\/g; - -// Matches if the path must point to a directory (ie ends with /) -const isDirRegExp = /\/$/; - -// Matches if the path starts with a valid path qualifier (./, ../, /) -// eslint-disable-next-line no-unused-vars -const isStrictRegExp = /^\.{0,2}\//; - -// Splits a require request into its components, or return null if the request is a file path -const pathRegExp = /^(?![a-zA-Z]:[\\\/]|\\\\|\.{0,2}(?:\/|$))((?:@[^\/]+\/)?[^\/]+)\/?(.*|)$/; - -// Keep a reference around ("module" is a common name in this context, so better rename it to something more significant) -const pnpModule = module; - -/** - * Used to disable the resolution hooks (for when we want to fallback to the previous resolution - we then need - * a way to "reset" the environment temporarily) - */ - -let enableNativeHooks = true; - -/** - * Simple helper function that assign an error code to an error, so that it can more easily be caught and used - * by third-parties. - */ - -function makeError(code, message, data = {}) { - const error = new Error(message); - return Object.assign(error, {code, data}); -} - -/** - * Ensures that the returned locator isn't a blacklisted one. - * - * Blacklisted packages are packages that cannot be used because their dependencies cannot be deduced. This only - * happens with peer dependencies, which effectively have different sets of dependencies depending on their parents. - * - * In order to deambiguate those different sets of dependencies, the Yarn implementation of PnP will generate a - * symlink for each combination of // it will find, and will - * blacklist the target of those symlinks. By doing this, we ensure that files loaded through a specific path - * will always have the same set of dependencies, provided the symlinks are correctly preserved. - * - * Unfortunately, some tools do not preserve them, and when it happens PnP isn't able anymore to deduce the set of - * dependencies based on the path of the file that makes the require calls. But since we've blacklisted those paths, - * we're able to print a more helpful error message that points out that a third-party package is doing something - * incompatible! - */ - -// eslint-disable-next-line no-unused-vars -function blacklistCheck(locator) { - if (locator === blacklistedLocator) { - throw makeError( - `BLACKLISTED`, - [ - `A package has been resolved through a blacklisted path - this is usually caused by one of your tools calling`, - `"realpath" on the return value of "require.resolve". Since the returned values use symlinks to disambiguate`, - `peer dependencies, they must be passed untransformed to "require".`, - ].join(` `) - ); - } - - return locator; -} - -let packageInformationStores = new Map([ -["@ligo/fa", -new Map([["1.0.5", - { - packageLocation: "./.ligo/source/i/ligo__s__fa__1.0.5__03096c62/", - packageDependencies: new Map([["@ligo/fa", "1.0.5"]])}]])], - [null, - new Map([[null, - { - packageLocation: "/project/", - packageDependencies: new Map([["@ligo/fa", "1.0.5"]])}]])]]); - -let topLevelLocatorPath = "../../"; - -let locatorsByLocations = new Map([ -["../../", topLevelLocator], - ["./.ligo/source/i/ligo__s__fa__1.0.5__03096c62/", - { - name: "@ligo/fa", - reference: "1.0.5"}]]); - - - exports.findPackageLocator = function findPackageLocator(location) { - let relativeLocation = normalizePath(path.relative(__dirname, location)); - - if (!relativeLocation.match(isStrictRegExp)) - relativeLocation = `./${relativeLocation}`; - - if (location.match(isDirRegExp) && relativeLocation.charAt(relativeLocation.length - 1) !== '/') - relativeLocation = `${relativeLocation}/`; - - let match; - - - if (relativeLocation.length >= 46 && relativeLocation[45] === '/') - if (match = locatorsByLocations.get(relativeLocation.substr(0, 46))) - return blacklistCheck(match); - - - if (relativeLocation.length >= 6 && relativeLocation[5] === '/') - if (match = locatorsByLocations.get(relativeLocation.substr(0, 6))) - return blacklistCheck(match); - - - /* - this can only happen if inside the _esy - as any other path will implies the opposite - - topLevelLocatorPath = ../../ - - | folder | relativeLocation | - | ------------------- | ---------------- | - | /workspace/app | ../../ | - | /workspace | ../../../ | - | /workspace/app/x | ../../x/ | - | /workspace/app/_esy | ../ | - - */ - if (!relativeLocation.startsWith(topLevelLocatorPath)) { - return topLevelLocator; - } - return null; - }; - - - -/** - * Returns the module that should be used to resolve require calls. It's usually the direct parent, except if we're - * inside an eval expression. - */ - -function getIssuerModule(parent) { - let issuer = parent; - - while (issuer && (issuer.id === '[eval]' || issuer.id === '' || !issuer.filename)) { - issuer = issuer.parent; - } - - return issuer; -} - -/** - * Returns information about a package in a safe way (will throw if they cannot be retrieved) - */ - -function getPackageInformationSafe(packageLocator) { - const packageInformation = exports.getPackageInformation(packageLocator); - - if (!packageInformation) { - throw makeError( - `INTERNAL`, - `Couldn't find a matching entry in the dependency tree for the specified parent (this is probably an internal error)` - ); - } - - return packageInformation; -} - -/** - * Implements the node resolution for folder access and extension selection - */ - -function applyNodeExtensionResolution(unqualifiedPath, {extensions}) { - // We use this "infinite while" so that we can restart the process as long as we hit package folders - while (true) { - let stat; - - try { - stat = statSync(unqualifiedPath); - } catch (error) {} - - // If the file exists and is a file, we can stop right there - - if (stat && !stat.isDirectory()) { - // If the very last component of the resolved path is a symlink to a file, we then resolve it to a file. We only - // do this first the last component, and not the rest of the path! This allows us to support the case of bin - // symlinks, where a symlink in "/xyz/pkg-name/.bin/bin-name" will point somewhere else (like "/xyz/pkg-name/index.js"). - // In such a case, we want relative requires to be resolved relative to "/xyz/pkg-name/" rather than "/xyz/pkg-name/.bin/". - // - // Also note that the reason we must use readlink on the last component (instead of realpath on the whole path) - // is that we must preserve the other symlinks, in particular those used by pnp to deambiguate packages using - // peer dependencies. For example, "/xyz/.pnp/local/pnp-01234569/.bin/bin-name" should see its relative requires - // be resolved relative to "/xyz/.pnp/local/pnp-0123456789/" rather than "/xyz/pkg-with-peers/", because otherwise - // we would lose the information that would tell us what are the dependencies of pkg-with-peers relative to its - // ancestors. - - if (lstatSync(unqualifiedPath).isSymbolicLink()) { - unqualifiedPath = path.normalize(path.resolve(path.dirname(unqualifiedPath), readlinkSync(unqualifiedPath))); - } - - return unqualifiedPath; - } - - // If the file is a directory, we must check if it contains a package.json with a "main" entry - - if (stat && stat.isDirectory()) { - let pkgJson; - - try { - pkgJson = JSON.parse(readFileSync(`${unqualifiedPath}/package.json`, 'utf-8')); - } catch (error) {} - - let nextUnqualifiedPath; - - if (pkgJson && pkgJson.main) { - nextUnqualifiedPath = path.resolve(unqualifiedPath, pkgJson.main); - } - - // If the "main" field changed the path, we start again from this new location - - if (nextUnqualifiedPath && nextUnqualifiedPath !== unqualifiedPath) { - const resolution = applyNodeExtensionResolution(nextUnqualifiedPath, {extensions}); - - if (resolution !== null) { - return resolution; - } - } - } - - // Otherwise we check if we find a file that match one of the supported extensions - - const qualifiedPath = extensions - .map(extension => { - return `${unqualifiedPath}${extension}`; - }) - .find(candidateFile => { - return existsSync(candidateFile); - }); - - if (qualifiedPath) { - return qualifiedPath; - } - - // Otherwise, we check if the path is a folder - in such a case, we try to use its index - - if (stat && stat.isDirectory()) { - const indexPath = extensions - .map(extension => { - return `${unqualifiedPath}/index${extension}`; - }) - .find(candidateFile => { - return existsSync(candidateFile); - }); - - if (indexPath) { - return indexPath; - } - } - - // Otherwise there's nothing else we can do :( - - return null; - } -} - -/** - * This function creates fake modules that can be used with the _resolveFilename function. - * Ideally it would be nice to be able to avoid this, since it causes useless allocations - * and cannot be cached efficiently (we recompute the nodeModulePaths every time). - * - * Fortunately, this should only affect the fallback, and there hopefully shouldn't be a - * lot of them. - */ - -function makeFakeModule(path) { - const fakeModule = new Module(path, false); - fakeModule.filename = path; - fakeModule.paths = Module._nodeModulePaths(path); - return fakeModule; -} - -/** - * Normalize path to posix format. - */ - -function normalizePath(fsPath) { - fsPath = path.normalize(fsPath); - - if (process.platform === 'win32') { - fsPath = fsPath.replace(backwardSlashRegExp, '/'); - } - - return fsPath; -} - -/** - * Forward the resolution to the next resolver (usually the native one) - */ - -function callNativeResolution(request, issuer) { - if (issuer.endsWith('/')) { - issuer += 'internal.js'; - } - - try { - enableNativeHooks = false; - - // Since we would need to create a fake module anyway (to call _resolveLookupPath that - // would give us the paths to give to _resolveFilename), we can as well not use - // the {paths} option at all, since it internally makes _resolveFilename create another - // fake module anyway. - return Module._resolveFilename(request, makeFakeModule(issuer), false); - } finally { - enableNativeHooks = true; - } -} - -/** - * This key indicates which version of the standard is implemented by this resolver. The `std` key is the - * Plug'n'Play standard, and any other key are third-party extensions. Third-party extensions are not allowed - * to override the standard, and can only offer new methods. - * - * If an new version of the Plug'n'Play standard is released and some extensions conflict with newly added - * functions, they'll just have to fix the conflicts and bump their own version number. - */ - -exports.VERSIONS = {std: 1}; - -/** - * Useful when used together with getPackageInformation to fetch information about the top-level package. - */ - -exports.topLevel = {name: null, reference: null}; - -/** - * Gets the package information for a given locator. Returns null if they cannot be retrieved. - */ - -exports.getPackageInformation = function getPackageInformation({name, reference}) { - const packageInformationStore = packageInformationStores.get(name); - - if (!packageInformationStore) { - return null; - } - - const packageInformation = packageInformationStore.get(reference); - - if (!packageInformation) { - return null; - } - - return packageInformation; -}; - -/** - * Transforms a request (what's typically passed as argument to the require function) into an unqualified path. - * This path is called "unqualified" because it only changes the package name to the package location on the disk, - * which means that the end result still cannot be directly accessed (for example, it doesn't try to resolve the - * file extension, or to resolve directories to their "index.js" content). Use the "resolveUnqualified" function - * to convert them to fully-qualified paths, or just use "resolveRequest" that do both operations in one go. - * - * Note that it is extremely important that the `issuer` path ends with a forward slash if the issuer is to be - * treated as a folder (ie. "/tmp/foo/" rather than "/tmp/foo" if "foo" is a directory). Otherwise relative - * imports won't be computed correctly (they'll get resolved relative to "/tmp/" instead of "/tmp/foo/"). - */ - -exports.resolveToUnqualified = function resolveToUnqualified(request, issuer, {considerBuiltins = true} = {}) { - // The 'pnpapi' request is reserved and will always return the path to the PnP file, from everywhere - - if (request === `pnpapi`) { - return pnpFile; - } - - // Bailout if the request is a native module - - if (considerBuiltins && builtinModules.has(request)) { - return null; - } - - // We allow disabling the pnp resolution for some subpaths. This is because some projects, often legacy, - // contain multiple levels of dependencies (ie. a yarn.lock inside a subfolder of a yarn.lock). This is - // typically solved using workspaces, but not all of them have been converted already. - - if (ignorePattern && ignorePattern.test(normalizePath(issuer))) { - const result = callNativeResolution(request, issuer); - - if (result === false) { - throw makeError( - `BUILTIN_NODE_RESOLUTION_FAIL`, - `The builtin node resolution algorithm was unable to resolve the module referenced by "${request}" and requested from "${issuer}" (it didn't go through the pnp resolver because the issuer was explicitely ignored by the regexp "null")`, - { - request, - issuer, - } - ); - } - - return result; - } - - let unqualifiedPath; - - // If the request is a relative or absolute path, we just return it normalized - - const dependencyNameMatch = request.match(pathRegExp); - - if (!dependencyNameMatch) { - if (path.isAbsolute(request)) { - unqualifiedPath = path.normalize(request); - } else if (issuer.match(isDirRegExp)) { - unqualifiedPath = path.normalize(path.resolve(issuer, request)); - } else { - unqualifiedPath = path.normalize(path.resolve(path.dirname(issuer), request)); - } - } - - // Things are more hairy if it's a package require - we then need to figure out which package is needed, and in - // particular the exact version for the given location on the dependency tree - - if (dependencyNameMatch) { - const [, dependencyName, subPath] = dependencyNameMatch; - - const issuerLocator = exports.findPackageLocator(issuer); - - // If the issuer file doesn't seem to be owned by a package managed through pnp, then we resort to using the next - // resolution algorithm in the chain, usually the native Node resolution one - - if (!issuerLocator) { - const result = callNativeResolution(request, issuer); - - if (result === false) { - throw makeError( - `BUILTIN_NODE_RESOLUTION_FAIL`, - `The builtin node resolution algorithm was unable to resolve the module referenced by "${request}" and requested from "${issuer}" (it didn't go through the pnp resolver because the issuer doesn't seem to be part of the Yarn-managed dependency tree)`, - { - request, - issuer, - } - ); - } - - return result; - } - - const issuerInformation = getPackageInformationSafe(issuerLocator); - - // We obtain the dependency reference in regard to the package that request it - - let dependencyReference = issuerInformation.packageDependencies.get(dependencyName); - - // If we can't find it, we check if we can potentially load it from the packages that have been defined as potential fallbacks. - // It's a bit of a hack, but it improves compatibility with the existing Node ecosystem. Hopefully we should eventually be able - // to kill this logic and become stricter once pnp gets enough traction and the affected packages fix themselves. - - if (issuerLocator !== topLevelLocator) { - for (let t = 0, T = fallbackLocators.length; dependencyReference === undefined && t < T; ++t) { - const fallbackInformation = getPackageInformationSafe(fallbackLocators[t]); - dependencyReference = fallbackInformation.packageDependencies.get(dependencyName); - } - } - - // If we can't find the path, and if the package making the request is the top-level, we can offer nicer error messages - - if (!dependencyReference) { - if (dependencyReference === null) { - if (issuerLocator === topLevelLocator) { - throw makeError( - `MISSING_PEER_DEPENDENCY`, - `You seem to be requiring a peer dependency ("${dependencyName}"), but it is not installed (which might be because you're the top-level package)`, - {request, issuer, dependencyName} - ); - } else { - throw makeError( - `MISSING_PEER_DEPENDENCY`, - `Package "${issuerLocator.name}@${issuerLocator.reference}" is trying to access a peer dependency ("${dependencyName}") that should be provided by its direct ancestor but isn't`, - {request, issuer, issuerLocator: Object.assign({}, issuerLocator), dependencyName} - ); - } - } else { - if (issuerLocator === topLevelLocator) { - throw makeError( - `UNDECLARED_DEPENDENCY`, - `You cannot require a package ("${dependencyName}") that is not declared in your dependencies (via "${issuer}")`, - {request, issuer, dependencyName} - ); - } else { - const candidates = Array.from(issuerInformation.packageDependencies.keys()); - throw makeError( - `UNDECLARED_DEPENDENCY`, - `Package "${issuerLocator.name}@${issuerLocator.reference}" (via "${issuer}") is trying to require the package "${dependencyName}" (via "${request}") without it being listed in its dependencies (${candidates.join( - `, ` - )})`, - {request, issuer, issuerLocator: Object.assign({}, issuerLocator), dependencyName, candidates} - ); - } - } - } - - // We need to check that the package exists on the filesystem, because it might not have been installed - - const dependencyLocator = {name: dependencyName, reference: dependencyReference}; - const dependencyInformation = exports.getPackageInformation(dependencyLocator); - const dependencyLocation = path.resolve(__dirname, dependencyInformation.packageLocation); - - if (!dependencyLocation) { - throw makeError( - `MISSING_DEPENDENCY`, - `Package "${dependencyLocator.name}@${dependencyLocator.reference}" is a valid dependency, but hasn't been installed and thus cannot be required (it might be caused if you install a partial tree, such as on production environments)`, - {request, issuer, dependencyLocator: Object.assign({}, dependencyLocator)} - ); - } - - // Now that we know which package we should resolve to, we only have to find out the file location - - if (subPath) { - unqualifiedPath = path.resolve(dependencyLocation, subPath); - } else { - unqualifiedPath = dependencyLocation; - } - } - - return path.normalize(unqualifiedPath); -}; - -/** - * Transforms an unqualified path into a qualified path by using the Node resolution algorithm (which automatically - * appends ".js" / ".json", and transforms directory accesses into "index.js"). - */ - -exports.resolveUnqualified = function resolveUnqualified( - unqualifiedPath, - {extensions = Object.keys(Module._extensions)} = {} -) { - const qualifiedPath = applyNodeExtensionResolution(unqualifiedPath, {extensions}); - - if (qualifiedPath) { - return path.normalize(qualifiedPath); - } else { - throw makeError( - `QUALIFIED_PATH_RESOLUTION_FAILED`, - `Couldn't find a suitable Node resolution for unqualified path "${unqualifiedPath}"`, - {unqualifiedPath} - ); - } -}; - -/** - * Transforms a request into a fully qualified path. - * - * Note that it is extremely important that the `issuer` path ends with a forward slash if the issuer is to be - * treated as a folder (ie. "/tmp/foo/" rather than "/tmp/foo" if "foo" is a directory). Otherwise relative - * imports won't be computed correctly (they'll get resolved relative to "/tmp/" instead of "/tmp/foo/"). - */ - -exports.resolveRequest = function resolveRequest(request, issuer, {considerBuiltins, extensions} = {}) { - let unqualifiedPath; - - try { - unqualifiedPath = exports.resolveToUnqualified(request, issuer, {considerBuiltins}); - } catch (originalError) { - // If we get a BUILTIN_NODE_RESOLUTION_FAIL error there, it means that we've had to use the builtin node - // resolution, which usually shouldn't happen. It might be because the user is trying to require something - // from a path loaded through a symlink (which is not possible, because we need something normalized to - // figure out which package is making the require call), so we try to make the same request using a fully - // resolved issuer and throws a better and more actionable error if it works. - if (originalError.code === `BUILTIN_NODE_RESOLUTION_FAIL`) { - let realIssuer; - - try { - realIssuer = realpathSync(issuer); - } catch (error) {} - - if (realIssuer) { - if (issuer.endsWith(`/`)) { - realIssuer = realIssuer.replace(/\/?$/, `/`); - } - - try { - exports.resolveToUnqualified(request, realIssuer, {considerBuiltins}); - } catch (error) { - // If an error was thrown, the problem doesn't seem to come from a path not being normalized, so we - // can just throw the original error which was legit. - throw originalError; - } - - // If we reach this stage, it means that resolveToUnqualified didn't fail when using the fully resolved - // file path, which is very likely caused by a module being invoked through Node with a path not being - // correctly normalized (ie you should use "node $(realpath script.js)" instead of "node script.js"). - throw makeError( - `SYMLINKED_PATH_DETECTED`, - `A pnp module ("${request}") has been required from what seems to be a symlinked path ("${issuer}"). This is not possible, you must ensure that your modules are invoked through their fully resolved path on the filesystem (in this case "${realIssuer}").`, - { - request, - issuer, - realIssuer, - } - ); - } - } - throw originalError; - } - - if (unqualifiedPath === null) { - return null; - } - - try { - return exports.resolveUnqualified(unqualifiedPath, {extensions}); - } catch (resolutionError) { - if (resolutionError.code === 'QUALIFIED_PATH_RESOLUTION_FAILED') { - Object.assign(resolutionError.data, {request, issuer}); - } - throw resolutionError; - } -}; - -/** - * Setups the hook into the Node environment. - * - * From this point on, any call to `require()` will go through the "resolveRequest" function, and the result will - * be used as path of the file to load. - */ - -exports.setup = function setup() { - // A small note: we don't replace the cache here (and instead use the native one). This is an effort to not - // break code similar to "delete require.cache[require.resolve(FOO)]", where FOO is a package located outside - // of the Yarn dependency tree. In this case, we defer the load to the native loader. If we were to replace the - // cache by our own, the native loader would populate its own cache, which wouldn't be exposed anymore, so the - // delete call would be broken. - - const originalModuleLoad = Module._load; - - Module._load = function(request, parent, isMain) { - if (!enableNativeHooks) { - return originalModuleLoad.call(Module, request, parent, isMain); - } - - // Builtins are managed by the regular Node loader - - if (builtinModules.has(request)) { - try { - enableNativeHooks = false; - return originalModuleLoad.call(Module, request, parent, isMain); - } finally { - enableNativeHooks = true; - } - } - - // The 'pnpapi' name is reserved to return the PnP api currently in use by the program - - if (request === `pnpapi`) { - return pnpModule.exports; - } - - // Request `Module._resolveFilename` (ie. `resolveRequest`) to tell us which file we should load - - const modulePath = Module._resolveFilename(request, parent, isMain); - - // Check if the module has already been created for the given file - - const cacheEntry = Module._cache[modulePath]; - - if (cacheEntry) { - return cacheEntry.exports; - } - - // Create a new module and store it into the cache - - const module = new Module(modulePath, parent); - Module._cache[modulePath] = module; - - // The main module is exposed as global variable - - if (isMain) { - process.mainModule = module; - module.id = '.'; - } - - // Try to load the module, and remove it from the cache if it fails - - let hasThrown = true; - - try { - module.load(modulePath); - hasThrown = false; - } finally { - if (hasThrown) { - delete Module._cache[modulePath]; - } - } - - // Some modules might have to be patched for compatibility purposes - - for (const [filter, patchFn] of patchedModules) { - if (filter.test(request)) { - module.exports = patchFn(exports.findPackageLocator(parent.filename), module.exports); - } - } - - return module.exports; - }; - - const originalModuleResolveFilename = Module._resolveFilename; - - Module._resolveFilename = function(request, parent, isMain, options) { - if (!enableNativeHooks) { - return originalModuleResolveFilename.call(Module, request, parent, isMain, options); - } - - let issuers; - - if (options) { - const optionNames = new Set(Object.keys(options)); - optionNames.delete('paths'); - - if (optionNames.size > 0) { - throw makeError( - `UNSUPPORTED`, - `Some options passed to require() aren't supported by PnP yet (${Array.from(optionNames).join(', ')})` - ); - } - - if (options.paths) { - issuers = options.paths.map(entry => `${path.normalize(entry)}/`); - } - } - - if (!issuers) { - const issuerModule = getIssuerModule(parent); - const issuer = issuerModule ? issuerModule.filename : `${process.cwd()}/`; - - issuers = [issuer]; - } - - let firstError; - - for (const issuer of issuers) { - let resolution; - - try { - resolution = exports.resolveRequest(request, issuer); - } catch (error) { - firstError = firstError || error; - continue; - } - - return resolution !== null ? resolution : request; - } - - throw firstError; - }; - - const originalFindPath = Module._findPath; - - Module._findPath = function(request, paths, isMain) { - if (!enableNativeHooks) { - return originalFindPath.call(Module, request, paths, isMain); - } - - for (const path of paths || []) { - let resolution; - - try { - resolution = exports.resolveRequest(request, path); - } catch (error) { - continue; - } - - if (resolution) { - return resolution; - } - } - - return false; - }; - - process.versions.pnp = String(exports.VERSIONS.std); -}; - -exports.setupCompatibilityLayer = () => { - // ESLint currently doesn't have any portable way for shared configs to specify their own - // plugins that should be used (https://github.com/eslint/eslint/issues/10125). This will - // likely get fixed at some point, but it'll take time and in the meantime we'll just add - // additional fallback entries for common shared configs. - - for (const name of [`react-scripts`]) { - const packageInformationStore = packageInformationStores.get(name); - if (packageInformationStore) { - for (const reference of packageInformationStore.keys()) { - fallbackLocators.push({name, reference}); - } - } - } - - // Modern versions of `resolve` support a specific entry point that custom resolvers can use - // to inject a specific resolution logic without having to patch the whole package. - // - // Cf: https://github.com/browserify/resolve/pull/174 - - patchedModules.push([ - /^\.\/normalize-options\.js$/, - (issuer, normalizeOptions) => { - if (!issuer || issuer.name !== 'resolve') { - return normalizeOptions; - } - - return (request, opts) => { - opts = opts || {}; - - if (opts.forceNodeResolution) { - return opts; - } - - opts.preserveSymlinks = true; - opts.paths = function(request, basedir, getNodeModulesDir, opts) { - // Extract the name of the package being requested (1=full name, 2=scope name, 3=local name) - const parts = request.match(/^((?:(@[^\/]+)\/)?([^\/]+))/); - - // make sure that basedir ends with a slash - if (basedir.charAt(basedir.length - 1) !== '/') { - basedir = path.join(basedir, '/'); - } - // This is guaranteed to return the path to the "package.json" file from the given package - const manifestPath = exports.resolveToUnqualified(`${parts[1]}/package.json`, basedir); - - // The first dirname strips the package.json, the second strips the local named folder - let nodeModules = path.dirname(path.dirname(manifestPath)); - - // Strips the scope named folder if needed - if (parts[2]) { - nodeModules = path.dirname(nodeModules); - } - - return [nodeModules]; - }; - - return opts; - }; - }, - ]); -}; - -if (module.parent && module.parent.id === 'internal/preload') { - exports.setupCompatibilityLayer(); - - exports.setup(); -} - -if (process.mainModule === module) { - exports.setupCompatibilityLayer(); - - const reportError = (code, message, data) => { - process.stdout.write(`${JSON.stringify([{code, message, data}, null])}\n`); - }; - - const reportSuccess = resolution => { - process.stdout.write(`${JSON.stringify([null, resolution])}\n`); - }; - - const processResolution = (request, issuer) => { - try { - reportSuccess(exports.resolveRequest(request, issuer)); - } catch (error) { - reportError(error.code, error.message, error.data); - } - }; - - const processRequest = data => { - try { - const [request, issuer] = JSON.parse(data); - processResolution(request, issuer); - } catch (error) { - reportError(`INVALID_JSON`, error.message, error.data); - } - }; - - if (process.argv.length > 2) { - if (process.argv.length !== 4) { - process.stderr.write(`Usage: ${process.argv[0]} ${process.argv[1]} \n`); - process.exitCode = 64; /* EX_USAGE */ - } else { - processResolution(process.argv[2], process.argv[3]); - } - } else { - let buffer = ''; - const decoder = new StringDecoder.StringDecoder(); - - process.stdin.on('data', chunk => { - buffer += decoder.write(chunk); - - do { - const index = buffer.indexOf('\n'); - if (index === -1) { - break; - } - - const line = buffer.slice(0, index); - buffer = buffer.slice(index + 1); - - processRequest(line); - } while (true); - }); - } - } diff --git a/solution/_ligo/ligo/installation.json b/solution/_ligo/ligo/installation.json new file mode 100644 index 0000000..960b5e2 --- /dev/null +++ b/solution/_ligo/ligo/installation.json @@ -0,0 +1 @@ +{"app@link-dev:./ligo.json":"/home/zamrokk/training-nft-3/solution","@ligo/fa@1.0.6@ffffffff":"./.ligo/source/i/ligo__s__fa__1.0.6__ffffffff"} \ No newline at end of file diff --git a/solution/artifacts/nft.default_storage.tz b/solution/artifacts/nft.default_storage.tz index 48ab34f..bece3af 100644 --- a/solution/artifacts/nft.default_storage.tz +++ b/solution/artifacts/nft.default_storage.tz @@ -1,9 +1,11 @@ -(Pair (Pair (Pair { "tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb" } {}) - { Elt "" 0x74657a6f732d73746f726167653a64617461 ; - Elt "data" - 0x7b0a202020202020226e616d65223a22464132204e4654204d61726b6574706c616365222c0a202020202020226465736372697074696f6e223a224578616d706c65206f662046413220696d706c656d656e746174696f6e222c0a2020202020202276657273696f6e223a22302e302e31222c0a202020202020226c6963656e7365223a7b226e616d65223a224d4954227d2c0a20202020202022617574686f7273223a5b224d617269676f6c643c636f6e74616374406d617269676f6c642e6465763e225d2c0a20202020202022686f6d6570616765223a2268747470733a2f2f6d617269676f6c642e646576222c0a20202020202022736f75726365223a7b0a202020202020202022746f6f6c73223a5b224c69676f225d2c0a2020202020202020226c6f636174696f6e223a2268747470733a2f2f6769746875622e636f6d2f6c69676f6c616e672f636f6e74726163742d636174616c6f6775652f747265652f6d61696e2f6c69622f666132227d2c0a20202020202022696e7465726661636573223a5b22545a49502d303132225d2c0a202020202020226572726f7273223a205b5d2c0a202020202020227669657773223a205b5d0a2020202020207d } - {}) - (Pair {} {}) - {} - 0) +(Pair { "tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb" } + 0 + {} + {} + { Elt "" 0x74657a6f732d73746f726167653a64617461 ; + Elt "data" + 0x7b0a202020202020226e616d65223a22464132204e4654204d61726b6574706c616365222c0a202020202020226465736372697074696f6e223a224578616d706c65206f662046413220696d706c656d656e746174696f6e222c0a2020202020202276657273696f6e223a22302e302e31222c0a202020202020226c6963656e7365223a7b226e616d65223a224d4954227d2c0a20202020202022617574686f7273223a5b224d617269676f6c643c636f6e74616374406d617269676f6c642e6465763e225d2c0a20202020202022686f6d6570616765223a2268747470733a2f2f6d617269676f6c642e646576222c0a20202020202022736f75726365223a7b0a202020202020202022746f6f6c73223a5b224c69676f225d2c0a2020202020202020226c6f636174696f6e223a2268747470733a2f2f6769746875622e636f6d2f6c69676f6c616e672f636f6e74726163742d636174616c6f6775652f747265652f6d61696e2f6c69622f666132227d2c0a20202020202022696e7465726661636573223a5b22545a49502d303132225d2c0a202020202020226572726f7273223a205b5d2c0a202020202020227669657773223a205b5d0a2020202020207d } + {} + {} + {}) diff --git a/solution/artifacts/nft.tz b/solution/artifacts/nft.tz index 28052d0..973719d 100644 --- a/solution/artifacts/nft.tz +++ b/solution/artifacts/nft.tz @@ -1,22 +1,25 @@ { parameter - (or (or (or (pair %balance_of - (list %requests (pair (address %owner) (nat %token_id))) - (contract %callback - (list (pair (pair %request (address %owner) (nat %token_id)) (nat %balance))))) - (pair %buy nat address)) - (or (pair %mint (pair (pair nat bytes) bytes bytes) bytes) (pair %sell nat nat))) - (or (list %transfer - (pair (address %from_) (list %txs (pair (address %to_) (nat %token_id) (nat %amount))))) - (list %update_operators - (or (pair %add_operator (address %owner) (address %operator) (nat %token_id)) - (pair %remove_operator (address %owner) (address %operator) (nat %token_id)))))) ; + (or (pair %buy nat address) + (or (pair %sell nat nat) + (or (pair %mint nat bytes bytes bytes bytes) + (or (list %update_operators + (or (pair %add_operator (address %owner) (address %operator) (nat %token_id)) + (pair %remove_operator (address %owner) (address %operator) (nat %token_id)))) + (or (pair %balance_of + (list %requests (pair (address %owner) (nat %token_id))) + (contract %callback + (list (pair (pair %request (address %owner) (nat %token_id)) (nat %balance))))) + (list %transfer + (pair (address %from_) (list %txs (pair (address %to_) (nat %token_id) (nat %amount)))))))))) ; storage - (pair (pair (pair (set %administrators address) (big_map %ledger address nat)) - (big_map %metadata string bytes) - (map %offers address (pair (nat %price) (nat %quantity)))) - (pair (big_map %operators address (set address)) (set %owners address)) + (pair (set %administrators address) + (nat %totalSupply) + (map %offers address (pair (nat %quantity) (nat %price))) + (big_map %ledger address nat) + (big_map %metadata string bytes) (big_map %token_metadata nat (pair (nat %token_id) (map %token_info string bytes))) - (nat %totalSupply)) ; + (big_map %operators address (set address)) + (set %owners address)) ; code { LAMBDA address unit @@ -123,13 +126,14 @@ DROP ; LAMBDA (pair (lambda (pair (big_map address nat) address) nat) - (pair (pair (pair (pair (big_map address nat) (big_map string bytes)) - (big_map address (set address)) - (set address)) - (big_map nat (pair nat (map string bytes)))) + (pair (pair (big_map address nat) + (big_map address (set address)) + (big_map nat (pair nat (map string bytes))) + (big_map string bytes) + (set address)) address)) nat - { UNPAIR ; SWAP ; UNPAIR ; CAR ; CAR ; CAR ; PAIR ; EXEC } ; + { UNPAIR ; SWAP ; UNPAIR ; CAR ; PAIR ; EXEC } ; DUP 4 ; APPLY ; DIG 3 ; @@ -137,284 +141,177 @@ DIG 5 ; UNPAIR ; IF_LEFT - { DIG 6 ; - DROP ; - IF_LEFT - { DIG 5 ; - DROP ; - IF_LEFT - { DIG 3 ; - DIG 4 ; - DROP 2 ; - DUP 2 ; - CDR ; - CDR ; - CAR ; - DUP 3 ; - CDR ; - CAR ; - CDR ; - DUP 4 ; - CDR ; - CAR ; - CAR ; - PAIR ; - DUP 4 ; - CAR ; - CDR ; - CAR ; - DUP 5 ; - CAR ; - CAR ; - CDR ; - PAIR ; - PAIR ; - PAIR ; - SWAP ; - UNPAIR ; - MAP { DUP ; CAR ; DUP 4 ; PAIR ; DUP 6 ; SWAP ; EXEC ; SWAP ; PAIR } ; - DIG 4 ; - DROP ; - SWAP ; - PUSH mutez 0 ; - DIG 2 ; - TRANSFER_TOKENS ; - SWAP ; - NIL operation ; - DIG 2 ; - CONS ; - PAIR ; - DUP 2 ; - DIG 2 ; - CAR ; - DUP ; - CAR ; - DUP 4 ; - CDR ; - CAR ; - CAR ; - CAR ; - UPDATE 2 ; - UPDATE 1 ; - UPDATE 1 ; - DUP ; - CAR ; - DUP ; - CDR ; - DUP 4 ; - CDR ; - CAR ; - CAR ; - CDR ; - UPDATE 1 ; - UPDATE 2 ; - UPDATE 1 ; - DUP ; - CDR ; - DUP ; - CDR ; - DUP 4 ; - CDR ; - CDR ; - UPDATE 1 ; - UPDATE 2 ; - UPDATE 2 ; - DUP ; - CDR ; - DUP ; - CAR ; - DUP 4 ; - CDR ; - CAR ; - CDR ; - CAR ; - UPDATE 1 ; - UPDATE 1 ; - UPDATE 2 ; - DUP ; - CDR ; - DUP ; - CAR ; - DUP 4 ; - CDR ; - CAR ; - CDR ; - CDR ; - UPDATE 2 ; - UPDATE 1 ; - UPDATE 2 ; - SWAP ; - CAR ; - PAIR } - { DIG 2 ; - DROP ; - UNPAIR ; - DUP 3 ; - CAR ; - CDR ; - CDR ; - DUP 3 ; - GET ; - IF_NONE - { DROP 5 ; PUSH string "3" ; FAILWITH } - { DUP ; - CDR ; - DUP 3 ; - COMPARE ; - GT ; - IF { DROP 6 ; PUSH string "4" ; FAILWITH } - { PUSH mutez 1 ; - DUP 3 ; - DUP 3 ; - CAR ; - MUL ; - MUL ; - AMOUNT ; - COMPARE ; - LT ; - IF { DROP 6 ; PUSH string "5" ; FAILWITH } - { DUP 3 ; - CONTRACT unit ; - IF_NONE { PUSH string "6" ; FAILWITH } {} ; - PUSH mutez 1 ; - DUP 4 ; - DUP 4 ; - CAR ; - MUL ; - MUL ; - UNIT ; - TRANSFER_TOKENS ; - DUP 3 ; - DUP 5 ; - DUP 7 ; - CAR ; - CAR ; - CDR ; - PAIR 3 ; - DIG 7 ; - SWAP ; - EXEC ; - DUP 4 ; - SOURCE ; - DIG 2 ; - PAIR 3 ; - DIG 6 ; - SWAP ; - EXEC ; - DUP 3 ; - DIG 4 ; - DIG 4 ; - CDR ; - SUB ; - ABS ; - UPDATE 2 ; - DUP 5 ; - DUP 6 ; - CAR ; - DUP ; - CDR ; - DUP 8 ; - CAR ; - CDR ; - CDR ; - DIG 4 ; - SOME ; - DIG 7 ; - UPDATE ; - UPDATE 2 ; - UPDATE 2 ; - UPDATE 1 ; - DUP ; - CAR ; - DUP ; - CAR ; - DIG 3 ; - UPDATE 2 ; - UPDATE 1 ; - UPDATE 1 ; - DUP ; - CDR ; - DUP ; - CAR ; - DIG 4 ; - CDR ; - CAR ; - CDR ; - SOURCE ; - PUSH bool True ; - SWAP ; - UPDATE ; - UPDATE 2 ; - UPDATE 1 ; - UPDATE 2 ; - NIL operation ; - DIG 2 ; - CONS ; - PAIR } } } } } + { DIG 2 ; + DIG 5 ; + DIG 6 ; + DROP 3 ; + UNPAIR ; + DUP 3 ; + GET 5 ; + DUP 3 ; + GET ; + IF_NONE + { DROP 5 ; PUSH string "3" ; FAILWITH } + { DUP ; + CAR ; + DUP 3 ; + COMPARE ; + GT ; + IF { DROP 6 ; PUSH string "4" ; FAILWITH } + { PUSH mutez 1 ; + DUP 3 ; + DUP 3 ; + CDR ; + MUL ; + MUL ; + AMOUNT ; + COMPARE ; + LT ; + IF { DROP 6 ; PUSH string "5" ; FAILWITH } + { DUP 3 ; + CONTRACT unit ; + IF_NONE { PUSH string "6" ; FAILWITH } {} ; + PUSH mutez 1 ; + DUP 4 ; + DUP 4 ; + CDR ; + MUL ; + MUL ; + UNIT ; + TRANSFER_TOKENS ; + DUP 3 ; + DUP 5 ; + DUP 7 ; + GET 7 ; + PAIR 3 ; + DIG 7 ; + SWAP ; + EXEC ; + DUP 4 ; + SOURCE ; + DIG 2 ; + PAIR 3 ; + DIG 6 ; + SWAP ; + EXEC ; + DUP 3 ; + DIG 4 ; + DIG 4 ; + CAR ; + SUB ; + ABS ; + UPDATE 1 ; + DUP 5 ; + DUP 6 ; + GET 5 ; + DIG 2 ; + SOME ; + DIG 5 ; + UPDATE ; + UPDATE 5 ; + SWAP ; + UPDATE 7 ; + DIG 2 ; + GET 14 ; + SOURCE ; + PUSH bool True ; + SWAP ; + UPDATE ; + UPDATE 14 ; + NIL operation ; + DIG 2 ; + CONS ; + PAIR } } } } + { IF_LEFT { DIG 3 ; DIG 4 ; - DROP 2 ; - IF_LEFT + DIG 6 ; + DROP 3 ; + UNPAIR ; + SOURCE ; + DUP 4 ; + GET 14 ; + DUP 5 ; + GET 9 ; + DUP 6 ; + GET 11 ; + DUP 7 ; + GET 13 ; + DUP 8 ; + GET 7 ; + PAIR 5 ; + PAIR ; + DIG 4 ; + SWAP ; + EXEC ; + DUP 2 ; + COMPARE ; + GT ; + IF { DROP 4 ; PUSH string "2" ; FAILWITH } + { SELF_ADDRESS ; + SOURCE ; + DUP 5 ; + GET 13 ; + PAIR 3 ; + DIG 4 ; + SWAP ; + EXEC ; + DUP 4 ; + DIG 4 ; + GET 5 ; + DIG 4 ; + DIG 4 ; + PAIR ; + SOURCE ; + SWAP ; + SOME ; + SWAP ; + UPDATE ; + UPDATE 5 ; + SWAP ; + UPDATE 13 ; + NIL operation ; + PAIR } } + { IF_LEFT { DIG 2 ; DIG 3 ; - DROP 2 ; - UNPAIR ; - UNPAIR ; - UNPAIR ; - DIG 2 ; - UNPAIR ; + DIG 4 ; + DIG 5 ; + DIG 6 ; + DROP 5 ; + UNPAIR 5 ; PUSH nat 0 ; - DUP 4 ; + DUP 2 ; COMPARE ; LE ; IF { DROP 6 ; PUSH string "0" ; FAILWITH } { DUP 6 ; - CAR ; - CAR ; CAR ; SENDER ; MEM ; NOT ; IF { DROP 6 ; PUSH string "1" ; FAILWITH } { DUP 6 ; - DUP 7 ; - CDR ; - DUP ; - CDR ; - DUP 6 ; - UPDATE 2 ; - UPDATE 2 ; - UPDATE 2 ; - DUP ; - CAR ; - DUP ; - CAR ; + DUP 2 ; + UPDATE 3 ; EMPTY_BIG_MAP address nat ; - DIG 6 ; + DIG 2 ; SOME ; SENDER ; UPDATE ; - UPDATE 2 ; - UPDATE 1 ; - UPDATE 1 ; - DUP ; - CDR ; - DUP ; - CDR ; - DUP 8 ; - CDR ; - CDR ; - CAR ; + UPDATE 7 ; + DUP 6 ; + GET 11 ; EMPTY_MAP string bytes ; PUSH bytes 0x30 ; SOME ; PUSH string "decimals" ; UPDATE ; - DIG 6 ; + DIG 5 ; SOME ; PUSH string "symbol" ; UPDATE ; - DIG 7 ; + DIG 5 ; SOME ; PUSH string "thumbnailUri" ; UPDATE ; @@ -422,11 +319,11 @@ SOME ; PUSH string "interfaces" ; UPDATE ; - DIG 5 ; + DIG 4 ; SOME ; PUSH string "description" ; UPDATE ; - DIG 5 ; + DIG 3 ; SOME ; PUSH string "name" ; UPDATE ; @@ -435,393 +332,232 @@ SOME ; PUSH nat 0 ; UPDATE ; - UPDATE 1 ; - UPDATE 2 ; - UPDATE 2 ; - DUP ; - CDR ; - DUP ; - CAR ; + UPDATE 11 ; EMPTY_BIG_MAP address (set address) ; - UPDATE 1 ; - UPDATE 1 ; - UPDATE 2 ; - DUP ; - CDR ; - DUP ; - CAR ; - DIG 3 ; - CDR ; - CAR ; - CDR ; + UPDATE 13 ; + SWAP ; + GET 14 ; SENDER ; PUSH bool True ; SWAP ; UPDATE ; - UPDATE 2 ; - UPDATE 1 ; - UPDATE 2 ; + UPDATE 14 ; NIL operation ; PAIR } } } - { UNPAIR ; - SOURCE ; - DUP 4 ; - CDR ; - CDR ; - CAR ; - DUP 5 ; - CDR ; - CAR ; - CDR ; - DUP 6 ; - CDR ; - CAR ; - CAR ; - PAIR ; - DUP 6 ; - CAR ; - CDR ; - CAR ; - DUP 7 ; - CAR ; - CAR ; - CDR ; - PAIR ; - PAIR ; - PAIR ; - PAIR ; - DIG 4 ; - SWAP ; - EXEC ; - DUP 2 ; - COMPARE ; - GT ; - IF { DROP 4 ; PUSH string "2" ; FAILWITH } - { SELF_ADDRESS ; - SOURCE ; - DUP 5 ; - CDR ; - CAR ; - CAR ; - PAIR 3 ; - DIG 4 ; - SWAP ; - EXEC ; - DUP 4 ; - DUP 5 ; - CAR ; - DUP ; - CDR ; - DIG 6 ; - CAR ; - CDR ; - CDR ; - DIG 5 ; - DIG 6 ; - PAIR ; - SOURCE ; - SWAP ; - SOME ; - SWAP ; - UPDATE ; - UPDATE 2 ; - UPDATE 2 ; - UPDATE 1 ; - DUP ; - CDR ; - DUP ; - CAR ; - DIG 3 ; - UPDATE 1 ; - UPDATE 1 ; - UPDATE 2 ; - NIL operation ; - PAIR } } } } - { DIG 2 ; - DROP ; - IF_LEFT - { DIG 4 ; - DIG 5 ; - DROP 2 ; - DUP 2 ; - CDR ; - CDR ; - CAR ; - DUP 3 ; - CDR ; - CAR ; - CDR ; - DUP 4 ; - CDR ; - CAR ; - CAR ; - PAIR ; - DUP 4 ; - CAR ; - CDR ; - CAR ; - DUP 5 ; - CAR ; - CAR ; - CDR ; - PAIR ; - PAIR ; - PAIR ; - DUP ; - CAR ; - CAR ; - CAR ; - DIG 2 ; - ITER { UNPAIR ; - DUG 2 ; - ITER { UNPAIR 3 ; - SWAP ; - DROP ; - SENDER ; - DUP 5 ; - DUP 2 ; - COMPARE ; - EQ ; - IF { DROP } - { DUP 6 ; - CAR ; - CDR ; + { IF_LEFT + { DIG 2 ; + DIG 3 ; + DIG 4 ; + DROP 3 ; + DUP 2 ; + GET 14 ; + DUP 3 ; + GET 9 ; + DUP 4 ; + GET 11 ; + DUP 5 ; + GET 13 ; + DUP 6 ; + GET 7 ; + PAIR 5 ; + DUP ; + GET 3 ; + DIG 2 ; + ITER { IF_LEFT + { DUP ; GET 3 ; SWAP ; CAR ; DIG 2 ; PAIR 3 ; DUP 4 ; SWAP ; EXEC } + { DUP ; + GET 3 ; + SWAP ; CAR ; - DUP 6 ; - GET ; - IF_NONE { EMPTY_SET address } {} ; + DUP 2 ; + DUP 2 ; + COMPARE ; + EQ ; + IF { DROP 2 } + { DUP ; + DUP 8 ; + SWAP ; + EXEC ; + DROP ; + DUP 3 ; + DIG 3 ; + DUP 3 ; + GET ; + IF_NONE + { DIG 2 ; DROP ; NONE (set address) } + { PUSH nat 0 ; + DUP 2 ; + DUP 6 ; + PUSH bool False ; + SWAP ; + UPDATE ; + SIZE ; + COMPARE ; + EQ ; + IF { DIG 3 ; DROP 2 ; NONE (set address) } + { DIG 3 ; PUSH bool False ; SWAP ; UPDATE ; SOME } } ; + DIG 2 ; + UPDATE } } } ; + DIG 3 ; + DIG 4 ; + DROP 2 ; + UPDATE 3 ; + NIL operation ; + PAIR ; + SWAP ; + DUP 2 ; + CDR ; + CAR ; + UPDATE 7 ; + DUP 2 ; + CDR ; + GET 7 ; + UPDATE 9 ; + DUP 2 ; + CDR ; + GET 5 ; + UPDATE 11 ; + DUP 2 ; + CDR ; + GET 3 ; + UPDATE 13 ; + DUP 2 ; + CDR ; + GET 8 ; + UPDATE 14 ; + SWAP ; + CAR } + { DIG 5 ; + DIG 6 ; + DROP 2 ; + IF_LEFT + { DIG 3 ; + DIG 4 ; + DROP 2 ; + DUP 2 ; + GET 14 ; + DUP 3 ; + GET 9 ; + DUP 4 ; + GET 11 ; + DUP 5 ; + GET 13 ; + DUP 6 ; + GET 7 ; + PAIR 5 ; + SWAP ; + UNPAIR ; + MAP { DUP ; CAR ; DUP 4 ; PAIR ; DUP 6 ; SWAP ; EXEC ; SWAP ; PAIR } ; + DIG 4 ; + DROP ; + SWAP ; + PUSH mutez 0 ; + DIG 2 ; + TRANSFER_TOKENS ; + SWAP ; + NIL operation ; + DIG 2 ; + CONS ; + PAIR ; + SWAP ; + DUP 2 ; + CDR ; + CAR ; + UPDATE 7 ; + DUP 2 ; + CDR ; + GET 7 ; + UPDATE 9 ; + DUP 2 ; + CDR ; + GET 5 ; + UPDATE 11 ; + DUP 2 ; + CDR ; + GET 3 ; + UPDATE 13 ; + DUP 2 ; + CDR ; + GET 8 ; + UPDATE 14 ; + SWAP ; + CAR } + { DIG 2 ; + DROP ; + DUP 2 ; + GET 14 ; + DUP 3 ; + GET 9 ; + DUP 4 ; + GET 11 ; + DUP 5 ; + GET 13 ; + DUP 6 ; + GET 7 ; + PAIR 5 ; + DUP ; + CAR ; + DIG 2 ; + ITER { UNPAIR ; + DUG 2 ; + ITER { UNPAIR 3 ; + SWAP ; + DROP ; + SENDER ; + DUP 5 ; + DUP 2 ; + COMPARE ; + EQ ; + IF { DROP } + { DUP 6 ; + GET 3 ; + DUP 6 ; + GET ; + IF_NONE { EMPTY_SET address } {} ; + SWAP ; + MEM ; + IF {} { PUSH string "FA2_NOT_OPERATOR" ; FAILWITH } } ; + DUP 2 ; + DUP 5 ; + DIG 4 ; + PAIR 3 ; + DUP 8 ; + SWAP ; + EXEC ; + PAIR 3 ; + DUP 5 ; + SWAP ; + EXEC } ; SWAP ; - MEM ; - IF {} { PUSH string "FA2_NOT_OPERATOR" ; FAILWITH } } ; - DUP 2 ; - DUP 5 ; - DIG 4 ; - PAIR 3 ; - DUP 8 ; - SWAP ; - EXEC ; - PAIR 3 ; - DUP 5 ; - SWAP ; - EXEC } ; - SWAP ; - DROP } ; - DIG 3 ; - DIG 4 ; - DROP 2 ; - DUP 2 ; - DIG 2 ; - CAR ; - DUP ; - CAR ; - DIG 3 ; - UPDATE 1 ; - UPDATE 1 ; - UPDATE 1 ; - NIL operation ; - PAIR ; - DUP 2 ; - DIG 2 ; - CAR ; - DUP ; - CAR ; - DUP 4 ; - CDR ; - CAR ; - CAR ; - CAR ; - UPDATE 2 ; - UPDATE 1 ; - UPDATE 1 ; - DUP ; - CAR ; - DUP ; - CDR ; - DUP 4 ; - CDR ; - CAR ; - CAR ; - CDR ; - UPDATE 1 ; - UPDATE 2 ; - UPDATE 1 ; - DUP ; - CDR ; - DUP ; - CDR ; - DUP 4 ; - CDR ; - CDR ; - UPDATE 1 ; - UPDATE 2 ; - UPDATE 2 ; - DUP ; - CDR ; - DUP ; - CAR ; - DUP 4 ; - CDR ; - CAR ; - CDR ; - CAR ; - UPDATE 1 ; - UPDATE 1 ; - UPDATE 2 ; - DUP ; - CDR ; - DUP ; - CAR ; - DUP 4 ; - CDR ; - CAR ; - CDR ; - CDR ; - UPDATE 2 ; - UPDATE 1 ; - UPDATE 2 ; - SWAP ; - CAR } - { DIG 2 ; - DIG 3 ; - DROP 2 ; - DUP 2 ; - CDR ; - CDR ; - CAR ; - DUP 3 ; - CDR ; - CAR ; - CDR ; - DUP 4 ; - CDR ; - CAR ; - CAR ; - PAIR ; - DUP 4 ; - CAR ; - CDR ; - CAR ; - DUP 5 ; - CAR ; - CAR ; - CDR ; - PAIR ; - PAIR ; - PAIR ; - DUP ; - CAR ; - CDR ; - CAR ; - DIG 2 ; - ITER { IF_LEFT - { DUP ; GET 3 ; SWAP ; CAR ; DIG 2 ; PAIR 3 ; DUP 4 ; SWAP ; EXEC } - { DUP ; - GET 3 ; - SWAP ; - CAR ; - DUP 2 ; - DUP 2 ; - COMPARE ; - EQ ; - IF { DROP 2 } - { DUP ; - DUP 8 ; - SWAP ; - EXEC ; - DROP ; - DUP 3 ; - DIG 3 ; - DUP 3 ; - GET ; - IF_NONE - { DIG 2 ; DROP ; NONE (set address) } - { PUSH nat 0 ; - DUP 2 ; - DUP 6 ; - PUSH bool False ; - SWAP ; - UPDATE ; - SIZE ; - COMPARE ; - EQ ; - IF { DIG 3 ; DROP 2 ; NONE (set address) } - { DIG 3 ; PUSH bool False ; SWAP ; UPDATE ; SOME } } ; - DIG 2 ; - UPDATE } } } ; - DIG 3 ; - DIG 4 ; - DROP 2 ; - DUP 2 ; - DIG 2 ; - CAR ; - DUP ; - CDR ; - DIG 3 ; - UPDATE 1 ; - UPDATE 2 ; - UPDATE 1 ; - NIL operation ; - PAIR ; - DUP 2 ; - DIG 2 ; - CAR ; - DUP ; - CAR ; - DUP 4 ; - CDR ; - CAR ; - CAR ; - CAR ; - UPDATE 2 ; - UPDATE 1 ; - UPDATE 1 ; - DUP ; - CAR ; - DUP ; - CDR ; - DUP 4 ; - CDR ; - CAR ; - CAR ; - CDR ; - UPDATE 1 ; - UPDATE 2 ; - UPDATE 1 ; - DUP ; - CDR ; - DUP ; - CDR ; - DUP 4 ; - CDR ; - CDR ; - UPDATE 1 ; - UPDATE 2 ; - UPDATE 2 ; - DUP ; - CDR ; - DUP ; - CAR ; - DUP 4 ; - CDR ; - CAR ; - CDR ; - CAR ; - UPDATE 1 ; - UPDATE 1 ; - UPDATE 2 ; - DUP ; - CDR ; - DUP ; - CAR ; - DUP 4 ; - CDR ; - CAR ; - CDR ; - CDR ; - UPDATE 2 ; - UPDATE 1 ; - UPDATE 2 ; - SWAP ; - CAR } ; - PAIR } } } + DROP } ; + DIG 3 ; + DIG 4 ; + DROP 2 ; + UPDATE 1 ; + NIL operation ; + PAIR ; + SWAP ; + DUP 2 ; + CDR ; + CAR ; + UPDATE 7 ; + DUP 2 ; + CDR ; + GET 7 ; + UPDATE 9 ; + DUP 2 ; + CDR ; + GET 5 ; + UPDATE 11 ; + DUP 2 ; + CDR ; + GET 3 ; + UPDATE 13 ; + DUP 2 ; + CDR ; + GET 8 ; + UPDATE 14 ; + SWAP ; + CAR } } ; + PAIR } } } } } diff --git a/solution/contracts/nft.jsligo b/solution/contracts/nft.jsligo index b933c30..00f2e25 100644 --- a/solution/contracts/nft.jsligo +++ b/solution/contracts/nft.jsligo @@ -1,4 +1,5 @@ #import "@ligo/fa/lib/fa2/asset/single_asset.jsligo" "SINGLEASSET" + /* ERROR MAP FOR UI DISPLAY or TESTS const errorMap : map = Map.literal(list([ ["0", "Enter a positive and not null amount"], @@ -11,12 +12,9 @@ ])); */ -type offer = { - quantity: nat, - price: nat -}; +export type offer = { quantity: nat, price: nat }; -type storage = { +export type storage = { administrators: set
, totalSupply: nat, offers: map, //user sells an offer @@ -33,16 +31,14 @@ type ret = [list, storage]; const transfer = (p: SINGLEASSET.transfer, s: storage): ret => { const ret2: [list, SINGLEASSET.storage] = SINGLEASSET.transfer( - [ - p, - { - ledger: s.ledger, - metadata: s.metadata, - token_metadata: s.token_metadata, - operators: s.operators, - owners: s.owners - } - ] + p, + { + ledger: s.ledger, + metadata: s.metadata, + token_metadata: s.token_metadata, + operators: s.operators, + owners: s.owners + } ); return [ ret2[0], @@ -61,16 +57,14 @@ const transfer = (p: SINGLEASSET.transfer, s: storage): ret => { const balance_of = (p: SINGLEASSET.balance_of, s: storage): ret => { const ret2: [list, SINGLEASSET.storage] = SINGLEASSET.balance_of( - [ - p, - { - ledger: s.ledger, - metadata: s.metadata, - token_metadata: s.token_metadata, - operators: s.operators, - owners: s.owners - } - ] + p, + { + ledger: s.ledger, + metadata: s.metadata, + token_metadata: s.token_metadata, + operators: s.operators, + owners: s.owners + } ); return [ ret2[0], @@ -88,17 +82,15 @@ const balance_of = (p: SINGLEASSET.balance_of, s: storage): ret => { @entry const update_operators = (p: SINGLEASSET.update_operators, s: storage): ret => { const ret2: [list, SINGLEASSET.storage] = - SINGLEASSET.update_ops( - [ - p, - { - ledger: s.ledger, - metadata: s.metadata, - token_metadata: s.token_metadata, - operators: s.operators, - owners: s.owners - } - ] + SINGLEASSET.update_operators( + p, + { + ledger: s.ledger, + metadata: s.metadata, + token_metadata: s.token_metadata, + operators: s.operators, + owners: s.owners + } ); return [ ret2[0], @@ -115,12 +107,17 @@ const update_operators = (p: SINGLEASSET.update_operators, s: storage): ret => { @entry const mint = ( - [quantity, name, description, symbol, ipfsUrl] - : [nat, bytes, bytes, bytes, bytes], + [quantity, name, description, symbol, ipfsUrl]: [ + nat, + bytes, + bytes, + bytes, + bytes + ], s: storage ): ret => { if (quantity <= (0 as nat)) return failwith("0"); - if (!Set.mem(Tezos.get_sender(), s.administrators)) return failwith("1"); + if (! Set.mem(Tezos.get_sender(), s.administrators)) return failwith("1"); const token_info: map = Map.literal( list( @@ -193,11 +190,11 @@ const sell = ([quantity, price]: [nat, nat], s: storage): ret => { const buy = ([quantity, seller]: [nat, address], s: storage): ret => { //search for the offer - return match( - Map.find_opt(seller, s.offers), - { - None: () => failwith("3"), - Some: (offer: offer) => { + return match(Map.find_opt(seller, s.offers)) { + when (None()): + failwith("3") + when (Some(offer)): + do { //check if quantity is enough if (quantity > offer.quantity) return failwith("4"); @@ -220,8 +217,8 @@ const buy = ([quantity, seller]: [nat, address], s: storage): ret => { SINGLEASSET.Ledger.decrease_token_amount_for_user(s.ledger)(seller)( quantity ); - ledger = - SINGLEASSET.Ledger.increase_token_amount_for_user(ledger)( + ledger + = SINGLEASSET.Ledger.increase_token_amount_for_user(ledger)( Tezos.get_source() )(quantity); //update new offer @@ -237,6 +234,5 @@ const buy = ([quantity, seller]: [nat, address], s: storage): ret => { } ] } - } - ) + } }; diff --git a/solution/contracts/nft.storageList.jsligo b/solution/contracts/nft.storageList.jsligo index 1f857a3..c19310e 100644 --- a/solution/contracts/nft.storageList.jsligo +++ b/solution/contracts/nft.storageList.jsligo @@ -1,21 +1,20 @@ #import "nft.jsligo" "Contract" -#import "@ligo/fa/lib/fa2/asset/single_asset.jsligo" "SINGLEASSET" -const default_storage = - { - administrators: Set.literal( - list(["tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb" as address]) - ) as set
, - totalSupply: 0 as nat, - offers: Map.empty as map, - ledger: Big_map.empty as SINGLEASSET.Ledger.t, - metadata: Big_map.literal( - list( + +const default_storage = { + administrators: Set.literal( + list(["tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb" as address]) + ) as set
, + totalSupply: 0 as nat, + offers: Map.empty as map, + ledger: Big_map.empty as Contract.SINGLEASSET.Ledger.t, + metadata: Big_map.literal( + list( + [ + ["", bytes `tezos-storage:data`], [ - ["", bytes `tezos-storage:data`], - [ - "data", - bytes - `{ + "data", + bytes + `{ "name":"FA2 NFT Marketplace", "description":"Example of FA2 implementation", "version":"0.0.1", @@ -29,11 +28,11 @@ const default_storage = "errors": [], "views": [] }` - ] ] - ) - ) as SINGLEASSET.Metadata.t, - token_metadata: Big_map.empty as SINGLEASSET.TokenMetadata.t, - operators: Big_map.empty as SINGLEASSET.Operators.t, - owners: Set.empty as set - }; + ] + ) + ) as Contract.SINGLEASSET.Metadata.t, + token_metadata: Big_map.empty as Contract.SINGLEASSET.TokenMetadata.t, + operators: Big_map.empty as Contract.SINGLEASSET.Operators.t, + owners: Set.empty as set +}; diff --git a/solution/esy.json b/solution/esy.json deleted file mode 100644 index 60d39dc..0000000 --- a/solution/esy.json +++ /dev/null @@ -1 +0,0 @@ -{ "dependencies": { "@ligo/fa": "^1.0.5" } } \ No newline at end of file diff --git a/solution/esy.lock/.gitattributes b/solution/esy.lock/.gitattributes deleted file mode 100644 index e0b4e26..0000000 --- a/solution/esy.lock/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ - -# Set eol to LF so files aren't converted to CRLF-eol on Windows. -* text eol=lf linguist-generated diff --git a/solution/esy.lock/.gitignore b/solution/esy.lock/.gitignore deleted file mode 100644 index a221be2..0000000 --- a/solution/esy.lock/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# Reset any possible .gitignore, we want all esy.lock to be un-ignored. -!* diff --git a/solution/esy.lock/index.json b/solution/esy.lock/index.json deleted file mode 100644 index 256ca5b..0000000 --- a/solution/esy.lock/index.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "checksum": "899f0e4782096ccf045b6c9794276e2c", - "root": "project@link-dev:./esy.json", - "node": { - "project@link-dev:./esy.json": { - "id": "project@link-dev:./esy.json", - "name": "project", - "version": "link-dev:./esy.json", - "source": { "type": "link-dev", "path": ".", "manifest": "esy.json" }, - "overrides": [], - "dependencies": [ "@ligo/fa@1.0.5@d41d8cd9" ], - "devDependencies": [] - }, - "@ligo/fa@1.0.5@d41d8cd9": { - "id": "@ligo/fa@1.0.5@d41d8cd9", - "name": "@ligo/fa", - "version": "1.0.5", - "source": { - "type": "install", - "source": [ - "archive:https://packages.ligolang.org/-/api/@ligo/fa/-/@ligo/fa-1.0.5.tgz#sha1:24fdfc2a513f67e0a3b2707984ae67b58cecfb3d" - ] - }, - "overrides": [], - "dependencies": [], - "devDependencies": [] - } - } -} \ No newline at end of file diff --git a/solution/ligo.esy.lock/index.json b/solution/ligo.esy.lock/index.json new file mode 100644 index 0000000..ed57381 --- /dev/null +++ b/solution/ligo.esy.lock/index.json @@ -0,0 +1 @@ +{"checksum":"bf569f71ba430eeb160dc22d65f22669ae857112","root":"app@link-dev:./ligo.json","node":{"@ligo/fa@1.0.6@ffffffff":{"id":"@ligo/fa@1.0.6@ffffffff","name":"@ligo/fa","version":"1.0.6","source":{"type":"library","source":["archive:https://packages.ligolang.org/-/api/@ligo/fa/-/@ligo/fa-1.0.6.tgz#sha1:94927de94317e20b350e51ecfa90a647c322e665"]},"overrides":[],"dependencies":[],"devDependencies":[]},"app@link-dev:./ligo.json":{"id":"app@link-dev:./ligo.json","name":"app","version":"link-dev:./ligo.json","source":{"type":"link-dev","path":".","manifest":"ligo.json"},"overrides":[],"dependencies":["@ligo/fa@1.0.6@ffffffff"],"devDependencies":[]}}} \ No newline at end of file diff --git a/solution/ligo.json b/solution/ligo.json new file mode 100644 index 0000000..4aa79e9 --- /dev/null +++ b/solution/ligo.json @@ -0,0 +1 @@ +{ "name": "app", "dependencies": { "@ligo/fa": "^1.0.6" } } \ No newline at end of file