From f5eb5f18e5f19f65bc9f1c77e8f6162100dffe67 Mon Sep 17 00:00:00 2001 From: "pc@zrch.com" Date: Mon, 1 Nov 2021 14:10:46 +0700 Subject: [PATCH 1/3] Fix Issue-8 --- .gitignore | 138 +++++++++++ Test NFT.ipynb | 638 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 776 insertions(+) create mode 100644 .gitignore create mode 100644 Test NFT.ipynb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5391d87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,138 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ \ No newline at end of file diff --git a/Test NFT.ipynb b/Test NFT.ipynb new file mode 100644 index 0000000..9bc80e2 --- /dev/null +++ b/Test NFT.ipynb @@ -0,0 +1,638 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "a2d73a00", + "metadata": {}, + "source": [ + "# Installation" + ] + }, + { + "cell_type": "markdown", + "id": "0a2333b8", + "metadata": {}, + "source": [ + "## arweave" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "70eb11f2", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[K\u001b[?25h \u001b[27m⸩ ⠧ reify:arweave-deploy: \u001b[7msill\u001b[0m \u001b[35maudit\u001b[0m bulk request { 'arweave\u001b[0m\u001b[Kve\u001b[0m\u001b[K\n", + "changed 1 package, and audited 2 packages in 2s\n", + "\n", + "found \u001b[32m\u001b[1m0\u001b[22m\u001b[39m vulnerabilities\n" + ] + } + ], + "source": [ + "!npm install -g arweave-deploy" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "a36ef2a2", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[K\u001b[?25h \u001b[27m⸩ ⠧ reify:arweave-deploy: \u001b[7msill\u001b[0m \u001b[35maudit\u001b[0m bulk request { 'arweave\u001b[0m\u001b[Kve\u001b[0m\u001b[K\n", + "changed 1 package, and audited 2 packages in 1s\n", + "\n", + "found \u001b[32m\u001b[1m0\u001b[22m\u001b[39m vulnerabilities\n" + ] + } + ], + "source": [ + "!npm update -g arweave-deploy" + ] + }, + { + "cell_type": "markdown", + "id": "3be82ab6", + "metadata": {}, + "source": [ + "# Test arweave" + ] + }, + { + "cell_type": "markdown", + "id": "c0a5b166", + "metadata": {}, + "source": [ + "## Create arweave-key" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "5680da0e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[96mYour new wallet address: iNGwggkWVwJYJ5RbUO8MvBvA5Cs-mwHGIyYCsx_peGM\u001b[39m\r\n", + "\u001b[96m\u001b[39m\r\n", + "\r\n", + "Successfully saved key to new-arweave-key.json\r\n", + "Set this wallet as your default by using 'arweave key-save new-arweave-key.json'\r\n" + ] + } + ], + "source": [ + "!arweave key-create new-arweave-key.json" + ] + }, + { + "cell_type": "markdown", + "id": "3b90beb6", + "metadata": {}, + "source": [ + "## Upload a file to arweave" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "489389be", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\r\n", + "File\r\n", + "\r\n", + "Path: test-nft-files/prem.jpg\r\n", + "Size: 60.20 kB\r\n", + "\r\n", + "Transaction\r\n", + "\r\n", + "ID: BS3R0KIJrE1FNhsnqMnbRrWckiqMoBfky1mVd-47pPU\r\n", + "Price: 0.000027395596 AR\r\n", + "\r\n", + "Tags:\r\n", + "\r\n", + " - Content-Type:image/jpeg\r\n", + " - User-Agent:ArweaveDeploy/1.9.1\r\n", + "\r\n", + "Wallet\r\n", + "\r\n", + "Address: WaOHUDviIky6vGSLKwoLCQ13Mr7NhjcujIoMyCf36sM\r\n", + "Current balance: 0.000000000000 AR\r\n", + "Balance after uploading: -0.000027395596 AR\r\n", + "\r\n", + "\u001b[91mInsufficient balance: balance 0.000000000000 AR, fee: 0.000027395596 AR\u001b[39m\r\n" + ] + } + ], + "source": [ + "!arweave deploy test-nft-files/prem.jpg --key-file arweave-key-WaOHUDviIky6vGSLKwoLCQ13Mr7NhjcujIoMyCf36sM.json" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "0a9f0e7a", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "\n", + "metadata = {\n", + " \"name\": \"Prem\",\n", + " \"symbol\": \"Pre\",\n", + " \"description\": \"Prem is nice.\",\n", + " \"seller_fee_basis_points\": 700, \n", + " \"image\": \"https://ipfs.io/ipfs/QmSDeXSuZ6o6j84TiriuRxZuZcDeYCLyennD5FAtbZFPq3?filename=2370694-kg%20(1).jpeg\", \n", + " \"attributes\": [\n", + " {\n", + " \"trait_type\": \"handsome\",\n", + " \"value\": \"Yes\"\n", + " }\n", + " ],\n", + " \"collection\": {\n", + " \"name\": \"Prem\",\n", + " \"family\": \"test\"\n", + " },\n", + " \"properties\": {\n", + " \"category\": \"image\",\n", + " \"creators\": [\n", + " {\n", + " \"address\": \"AvFLeGBFDthzdoct5mHpbUE8ZJdYD4oZXpksoRiws8AG\",\n", + " \"share\": 100\n", + " }\n", + " ]\n", + " }\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "d4c353ce", + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "\n", + "with open(\"prem-metadata.json\", \"w\") as f:\n", + " json.dump(metadata, f)" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "2bbbc9a1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2370694-kg (1).jpeg\r\n", + "LICENSE\r\n", + "README-gitpod.md\r\n", + "README-installation-notes.md\r\n", + "README.md\r\n", + "README_ZH_CN.md\r\n", + "README_ZH_TW.md\r\n", + "Test NFT.ipynb\r\n", + "Untitled.ipynb\r\n", + "Untitled2.ipynb\r\n", + "arweave-key-WaOHUDviIky6vGSLKwoLCQ13Mr7NhjcujIoMyCf36sM.json\r\n", + "arweave-key-_CvOv_ZmFl2fKRhV00Z3npcoZSMi0i8w3zz5_UMMSbg.json\r\n", + "cluster-devnet.env\r\n", + "cluster-mainnet-beta.env\r\n", + "cluster-testnet.env\r\n", + "\u001b[34mdist\u001b[m\u001b[m\r\n", + "new-arweave-key.json\r\n", + "new-keypair.json\r\n", + "\u001b[34mnode_modules\u001b[m\u001b[m\r\n", + "package-lock.json\r\n", + "package.json\r\n", + "prem-metadata.json\r\n", + "\u001b[34msrc\u001b[m\u001b[m\r\n", + "\u001b[34mtest-nft-files\u001b[m\u001b[m\r\n", + "tsconfig.json\r\n" + ] + } + ], + "source": [ + "!ls" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "9093f06b", + "metadata": {}, + "outputs": [], + "source": [ + "metadata_url = \"https://ipfs.io/ipfs/QmQiaCacuZgS5qpQrmFacxyXAtmqYSYWfAARtXXCdwbjoA?filename=prem-metadata.json\"" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "198d3d6b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "README.md api.py \u001b[34mtest\u001b[m\u001b[m\r\n", + "Test NFT.ipynb \u001b[34mmetaplex\u001b[m\u001b[m \u001b[34mutils\u001b[m\u001b[m\r\n", + "\u001b[34mapi\u001b[m\u001b[m requirements.txt \u001b[34mvenv\u001b[m\u001b[m\r\n" + ] + } + ], + "source": [ + "!ls" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "1fa46526", + "metadata": {}, + "outputs": [], + "source": [ + "from api.metaplex_api import MetaplexAPI" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "1896831b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\"status\": 400}\n" + ] + }, + { + "ename": "TypeError", + "evalue": "'NoneType' object is not subscriptable", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/var/folders/hk/rw64djnx2cz613ykv0bjxpr80000gn/T/ipykernel_34682/3645243428.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[0mcontract_key\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;31m# conduct a mint, and send to a recipient, e.g. wallet_2\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 29\u001b[0;31m \u001b[0mmint_res\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mapi\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mapi_endpoint\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcontract_key\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mTEST_PUBLIC_KEY\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdivinity_json_file\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/Documents/nft/solana/python-api/api/metaplex_api.py\u001b[0m in \u001b[0;36mmint\u001b[0;34m(self, api_endpoint, contract_key, dest_key, link, max_retries, skip_confirmation, max_timeout, target, finalized, supply)\u001b[0m\n\u001b[1;32m 75\u001b[0m \u001b[0mMints\u001b[0m \u001b[0man\u001b[0m \u001b[0mNFT\u001b[0m \u001b[0mto\u001b[0m \u001b[0man\u001b[0m \u001b[0maccount\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mupdates\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mmetadata\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mcreates\u001b[0m \u001b[0ma\u001b[0m \u001b[0mmaster\u001b[0m \u001b[0medition\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 76\u001b[0m \"\"\"\n\u001b[0;32m---> 77\u001b[0;31m \u001b[0mtx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msigners\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mapi_endpoint\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maccount\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcontract_key\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdest_key\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlink\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msupply\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msupply\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 78\u001b[0m resp = execute(\n\u001b[1;32m 79\u001b[0m \u001b[0mapi_endpoint\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Documents/nft/solana/python-api/metaplex/transactions.py\u001b[0m in \u001b[0;36mmint\u001b[0;34m(api_endpoint, source_account, contract_key, dest_key, link, supply)\u001b[0m\n\u001b[1;32m 184\u001b[0m )\n\u001b[1;32m 185\u001b[0m \u001b[0mtx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmint_to_ix\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 186\u001b[0;31m \u001b[0mmetadata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_metadata\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclient\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmint_account\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 187\u001b[0m update_metadata_data = update_metadata_instruction_data(\n\u001b[1;32m 188\u001b[0m \u001b[0mmetadata\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'name'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Documents/nft/solana/python-api/metaplex/metadata.py\u001b[0m in \u001b[0;36mget_metadata\u001b[0;34m(client, mint_key)\u001b[0m\n\u001b[1;32m 179\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mget_metadata\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclient\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmint_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 180\u001b[0m \u001b[0mmetadata_account\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_metadata_account\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmint_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 181\u001b[0;31m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbase64\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mb64decode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclient\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_account_info\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmetadata_account\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'result'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'value'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 182\u001b[0m \u001b[0mmetadata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0munpack_metadata_account\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 183\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mmetadata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: 'NoneType' object is not subscriptable" + ] + } + ], + "source": [ + "import base58\n", + "import json\n", + "import os\n", + "from api import metaplex_api\n", + "from cryptography.fernet import Fernet\n", + "SERVER_DECRYPTION_KEY = Fernet.generate_key().decode(\"ascii\")\n", + "TEST_PRIVATE_KEY = \"4ANm6NEpE87PVyujRH2VoVwuPfMfw1Jp1hBwk31suKpc1rkEL9tjHSr8hvymQJQ6SHCPndaGC9qjJ26PY6sTZY3F\"\n", + "TEST_PUBLIC_KEY = \"6DF6tVFx3ASNoSrKc7RfpE5k6MdJFoyQ2Gf8WesAmT2m\"\n", + "\n", + "account = metaplex_api.Account(\n", + " list(base58.b58decode(TEST_PRIVATE_KEY))[:32]\n", + ")\n", + "cfg = {\n", + " \"PRIVATE_KEY\": base58.b58encode(account.secret_key()).decode(\"ascii\"),\n", + " \"PUBLIC_KEY\": str(account.public_key()),\n", + " \"DECRYPTION_KEY\": Fernet.generate_key().decode(\"ascii\")\n", + "}\n", + "api = metaplex_api.MetaplexAPI(cfg)\n", + "\n", + "api_endpoint = \"https://api.devnet.solana.com/\"\n", + "\n", + "# requires a JSON file with metadata. best to publish on Arweave\n", + "divinity_json_file = metadata_url\n", + "# deploy a contract. will return a contract key.\n", + "result = api.deploy(api_endpoint, \"Prem\", \"Pre\")\n", + "print(result)\n", + "contract_key = \"cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ\"\n", + "# conduct a mint, and send to a recipient, e.g. wallet_2\n", + "mint_res = api.mint(api_endpoint, contract_key, TEST_PUBLIC_KEY, divinity_json_file)" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "5a18ed99", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6DF6tVFx3ASNoSrKc7RfpE5k6MdJFoyQ2Gf8WesAmT2m" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "account.public_key()" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "c5b9b4d8", + "metadata": {}, + "outputs": [], + "source": [ + "api = metaplex_api.MetaplexAPI(cfg)" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "770c7e7c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "account" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "ec6ece61", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "api.account" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "id": "4bd611bf", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "create_metadata_instruction_data() missing 1 required positional argument: 'creators'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/var/folders/hk/rw64djnx2cz613ykv0bjxpr80000gn/T/ipykernel_40317/395278561.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mapi_endpoint\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"https://api.devnet.solana.com/\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;31m# Client(api_endpoint).request_airdrop(account.public_key(), int(1e10))\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0mmetaplex_api\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdeploy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mapi_endpoint\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"A\"\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;36m32\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0msymbol\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"A\"\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msource_account\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0maccount\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/Documents/nft/solana/python-api/metaplex/transactions.py\u001b[0m in \u001b[0;36mdeploy\u001b[0;34m(api_endpoint, source_account, name, symbol)\u001b[0m\n\u001b[1;32m 62\u001b[0m \u001b[0;31m# Create Token Metadata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 63\u001b[0m create_metadata_ix = create_metadata_instruction(\n\u001b[0;32m---> 64\u001b[0;31m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcreate_metadata_instruction_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msymbol\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msource_account\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpublic_key\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 65\u001b[0m \u001b[0mupdate_authority\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msource_account\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpublic_key\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 66\u001b[0m \u001b[0mmint_key\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmint_account\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpublic_key\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: create_metadata_instruction_data() missing 1 required positional argument: 'creators'" + ] + } + ], + "source": [ + "from api import metaplex_api\n", + "\n", + "account = metaplex_api.Account(\n", + " list(base58.b58decode(TEST_PRIVATE_KEY))[:32]\n", + ")\n", + "cfg = {\"PRIVATE_KEY\": base58.b58encode(account.secret_key()).decode(\"ascii\"), \"PUBLIC_KEY\": str(account.public_key()), \"DECRYPTION_KEY\": Fernet.generate_key().decode(\"ascii\")}\n", + "api_endpoint = \"https://api.devnet.solana.com/\"\n", + "# Client(api_endpoint).request_airdrop(account.public_key(), int(1e10))\n", + "metaplex_api.deploy(api_endpoint, name=\"A\"*32,symbol=\"A\"*10, source_account=account)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "8eed3780", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: attrs==21.2.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (21.2.0)\n", + "Requirement already satisfied: base58==2.1.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (2.1.0)\n", + "Collecting certifi==2021.5.30\n", + " Using cached certifi-2021.5.30-py2.py3-none-any.whl (145 kB)\n", + "Collecting cffi==1.14.5\n", + " Using cached cffi-1.14.5-cp38-cp38-macosx_10_9_x86_64.whl (176 kB)\n", + "Requirement already satisfied: chardet==4.0.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (4.0.0)\n", + "Collecting cheroot==8.5.2\n", + " Using cached cheroot-8.5.2-py2.py3-none-any.whl (97 kB)\n", + "Collecting CherryPy==18.6.0\n", + " Using cached CherryPy-18.6.0-py2.py3-none-any.whl (419 kB)\n", + "Requirement already satisfied: construct==2.10.67 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 8)) (2.10.67)\n", + "Collecting cryptography==3.4.7\n", + " Using cached cryptography-3.4.7-cp36-abi3-macosx_10_10_x86_64.whl (2.0 MB)\n", + "Collecting ed25519==1.5\n", + " Using cached ed25519-1.5-cp38-cp38-macosx_10_9_x86_64.whl\n", + "Collecting idna==2.10\n", + " Using cached idna-2.10-py2.py3-none-any.whl (58 kB)\n", + "Requirement already satisfied: iniconfig==1.1.1 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 12)) (1.1.1)\n", + "Collecting jaraco.classes==3.2.1\n", + " Using cached jaraco.classes-3.2.1-py3-none-any.whl (5.6 kB)\n", + "Collecting jaraco.collections==3.3.0\n", + " Using cached jaraco.collections-3.3.0-py3-none-any.whl (9.9 kB)\n", + "Collecting jaraco.functools==3.3.0\n", + " Using cached jaraco.functools-3.3.0-py3-none-any.whl (6.8 kB)\n", + "Collecting jaraco.text==3.5.0\n", + " Using cached jaraco.text-3.5.0-py3-none-any.whl (8.1 kB)\n", + "Collecting more-itertools==8.8.0\n", + " Using cached more_itertools-8.8.0-py3-none-any.whl (48 kB)\n", + "Collecting packaging==20.9\n", + " Using cached packaging-20.9-py2.py3-none-any.whl (40 kB)\n", + "Collecting pluggy==0.13.1\n", + " Using cached pluggy-0.13.1-py2.py3-none-any.whl (18 kB)\n", + "Collecting portend==2.7.1\n", + " Using cached portend-2.7.1-py3-none-any.whl (5.3 kB)\n", + "Requirement already satisfied: py==1.10.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 21)) (1.10.0)\n", + "Requirement already satisfied: pycparser==2.20 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 22)) (2.20)\n", + "Requirement already satisfied: PyNaCl==1.4.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 23)) (1.4.0)\n", + "Requirement already satisfied: pyparsing==2.4.7 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 24)) (2.4.7)\n", + "Collecting pytest==6.2.4\n", + " Using cached pytest-6.2.4-py3-none-any.whl (280 kB)\n", + "Collecting pytz==2021.1\n", + " Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)\n", + "Collecting requests==2.25.1\n", + " Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)\n", + "Requirement already satisfied: six==1.16.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 28)) (1.16.0)\n", + "Collecting solana==0.9.2\n", + " Using cached solana-0.9.2-py3-none-any.whl (49 kB)\n", + "Collecting tempora==4.1.1\n", + " Using cached tempora-4.1.1-py3-none-any.whl (15 kB)\n", + "Requirement already satisfied: toml==0.10.2 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 31)) (0.10.2)\n", + "Collecting typing-extensions==3.10.0.0\n", + " Using cached typing_extensions-3.10.0.0-py3-none-any.whl (26 kB)\n", + "Collecting urllib3==1.26.6\n", + " Using cached urllib3-1.26.6-py2.py3-none-any.whl (138 kB)\n", + "Requirement already satisfied: websockets==9.1 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 34)) (9.1)\n", + "Collecting zc.lockfile==2.0\n", + " Using cached zc.lockfile-2.0-py2.py3-none-any.whl (9.7 kB)\n", + "Requirement already satisfied: setuptools in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from zc.lockfile==2.0->-r requirements.txt (line 35)) (58.0.4)\n", + "Installing collected packages: more-itertools, pytz, jaraco.functools, urllib3, tempora, jaraco.text, jaraco.classes, idna, cffi, certifi, zc.lockfile, typing-extensions, requests, portend, pluggy, packaging, jaraco.collections, cheroot, solana, pytest, ed25519, cryptography, CherryPy\n", + " Attempting uninstall: pytz\n", + " Found existing installation: pytz 2021.3\n", + " Uninstalling pytz-2021.3:\n", + " Successfully uninstalled pytz-2021.3\n", + " Attempting uninstall: urllib3\n", + " Found existing installation: urllib3 1.26.7\n", + " Uninstalling urllib3-1.26.7:\n", + " Successfully uninstalled urllib3-1.26.7\n", + " Attempting uninstall: idna\n", + " Found existing installation: idna 3.2\n", + " Uninstalling idna-3.2:\n", + " Successfully uninstalled idna-3.2\n", + " Attempting uninstall: cffi\n", + " Found existing installation: cffi 1.15.0\n", + " Uninstalling cffi-1.15.0:\n", + " Successfully uninstalled cffi-1.15.0\n", + " Attempting uninstall: certifi\n", + " Found existing installation: certifi 2021.10.8\n", + " Uninstalling certifi-2021.10.8:\n", + " Successfully uninstalled certifi-2021.10.8\n", + " Attempting uninstall: typing-extensions\n", + " Found existing installation: typing-extensions 3.10.0.2\n", + " Uninstalling typing-extensions-3.10.0.2:\n", + " Successfully uninstalled typing-extensions-3.10.0.2\n", + " Attempting uninstall: requests\n", + " Found existing installation: requests 2.26.0\n", + " Uninstalling requests-2.26.0:\n", + " Successfully uninstalled requests-2.26.0\n", + " Attempting uninstall: pluggy\n", + " Found existing installation: pluggy 1.0.0\n", + " Uninstalling pluggy-1.0.0:\n", + " Successfully uninstalled pluggy-1.0.0\n", + " Attempting uninstall: packaging\n", + " Found existing installation: packaging 21.0\n", + " Uninstalling packaging-21.0:\n", + " Successfully uninstalled packaging-21.0\n", + " Attempting uninstall: solana\n", + " Found existing installation: solana 0.18.1\n", + " Uninstalling solana-0.18.1:\n", + " Successfully uninstalled solana-0.18.1\n", + " Attempting uninstall: pytest\n", + " Found existing installation: pytest 6.2.5\n", + " Uninstalling pytest-6.2.5:\n", + " Successfully uninstalled pytest-6.2.5\n", + "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", + "eth-brownie 1.17.0 requires certifi==2021.10.8, but you have certifi 2021.5.30 which is incompatible.\n", + "eth-brownie 1.17.0 requires idna==3.2, but you have idna 2.10 which is incompatible.\n", + "eth-brownie 1.17.0 requires packaging==21.0, but you have packaging 20.9 which is incompatible.\n", + "eth-brownie 1.17.0 requires pluggy==1.0.0, but you have pluggy 0.13.1 which is incompatible.\n", + "eth-brownie 1.17.0 requires pytest==6.2.5, but you have pytest 6.2.4 which is incompatible.\n", + "eth-brownie 1.17.0 requires requests==2.26.0, but you have requests 2.25.1 which is incompatible.\n", + "eth-brownie 1.17.0 requires typing-extensions==3.10.0.2, but you have typing-extensions 3.10.0.0 which is incompatible.\n", + "eth-brownie 1.17.0 requires urllib3==1.26.7, but you have urllib3 1.26.6 which is incompatible.\u001b[0m\n", + "Successfully installed CherryPy-18.6.0 certifi-2021.5.30 cffi-1.14.5 cheroot-8.5.2 cryptography-3.4.7 ed25519-1.5 idna-2.10 jaraco.classes-3.2.1 jaraco.collections-3.3.0 jaraco.functools-3.3.0 jaraco.text-3.5.0 more-itertools-8.8.0 packaging-20.9 pluggy-0.13.1 portend-2.7.1 pytest-6.2.4 pytz-2021.1 requests-2.25.1 solana-0.9.2 tempora-4.1.1 typing-extensions-3.10.0.0 urllib3-1.26.6 zc.lockfile-2.0\n" + ] + } + ], + "source": [ + "!pip install -r requirements.txt" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3 copy" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.12" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false + }, + "varInspector": { + "cols": { + "lenName": 16, + "lenType": 16, + "lenVar": 40 + }, + "kernels_config": { + "python": { + "delete_cmd_postfix": "", + "delete_cmd_prefix": "del ", + "library": "var_list.py", + "varRefreshCmd": "print(var_dic_list())" + }, + "r": { + "delete_cmd_postfix": ") ", + "delete_cmd_prefix": "rm(", + "library": "var_list.r", + "varRefreshCmd": "cat(var_dic_list()) " + } + }, + "types_to_exclude": [ + "module", + "function", + "builtin_function_or_method", + "instance", + "_Feature" + ], + "window_display": false + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 0de8694d38cfd07cb438c797af05c6c0ec3c7467 Mon Sep 17 00:00:00 2001 From: "pc@zrch.com" Date: Mon, 1 Nov 2021 14:14:17 +0700 Subject: [PATCH 2/3] Fix None type error when minting --- Test NFT.ipynb | 638 ------------------------------------------- api.py | 1 + metaplex/metadata.py | 4 +- 3 files changed, 4 insertions(+), 639 deletions(-) delete mode 100644 Test NFT.ipynb diff --git a/Test NFT.ipynb b/Test NFT.ipynb deleted file mode 100644 index 9bc80e2..0000000 --- a/Test NFT.ipynb +++ /dev/null @@ -1,638 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "a2d73a00", - "metadata": {}, - "source": [ - "# Installation" - ] - }, - { - "cell_type": "markdown", - "id": "0a2333b8", - "metadata": {}, - "source": [ - "## arweave" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "70eb11f2", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[K\u001b[?25h \u001b[27m⸩ ⠧ reify:arweave-deploy: \u001b[7msill\u001b[0m \u001b[35maudit\u001b[0m bulk request { 'arweave\u001b[0m\u001b[Kve\u001b[0m\u001b[K\n", - "changed 1 package, and audited 2 packages in 2s\n", - "\n", - "found \u001b[32m\u001b[1m0\u001b[22m\u001b[39m vulnerabilities\n" - ] - } - ], - "source": [ - "!npm install -g arweave-deploy" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "a36ef2a2", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[K\u001b[?25h \u001b[27m⸩ ⠧ reify:arweave-deploy: \u001b[7msill\u001b[0m \u001b[35maudit\u001b[0m bulk request { 'arweave\u001b[0m\u001b[Kve\u001b[0m\u001b[K\n", - "changed 1 package, and audited 2 packages in 1s\n", - "\n", - "found \u001b[32m\u001b[1m0\u001b[22m\u001b[39m vulnerabilities\n" - ] - } - ], - "source": [ - "!npm update -g arweave-deploy" - ] - }, - { - "cell_type": "markdown", - "id": "3be82ab6", - "metadata": {}, - "source": [ - "# Test arweave" - ] - }, - { - "cell_type": "markdown", - "id": "c0a5b166", - "metadata": {}, - "source": [ - "## Create arweave-key" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "id": "5680da0e", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[96mYour new wallet address: iNGwggkWVwJYJ5RbUO8MvBvA5Cs-mwHGIyYCsx_peGM\u001b[39m\r\n", - "\u001b[96m\u001b[39m\r\n", - "\r\n", - "Successfully saved key to new-arweave-key.json\r\n", - "Set this wallet as your default by using 'arweave key-save new-arweave-key.json'\r\n" - ] - } - ], - "source": [ - "!arweave key-create new-arweave-key.json" - ] - }, - { - "cell_type": "markdown", - "id": "3b90beb6", - "metadata": {}, - "source": [ - "## Upload a file to arweave" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "id": "489389be", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\r\n", - "File\r\n", - "\r\n", - "Path: test-nft-files/prem.jpg\r\n", - "Size: 60.20 kB\r\n", - "\r\n", - "Transaction\r\n", - "\r\n", - "ID: BS3R0KIJrE1FNhsnqMnbRrWckiqMoBfky1mVd-47pPU\r\n", - "Price: 0.000027395596 AR\r\n", - "\r\n", - "Tags:\r\n", - "\r\n", - " - Content-Type:image/jpeg\r\n", - " - User-Agent:ArweaveDeploy/1.9.1\r\n", - "\r\n", - "Wallet\r\n", - "\r\n", - "Address: WaOHUDviIky6vGSLKwoLCQ13Mr7NhjcujIoMyCf36sM\r\n", - "Current balance: 0.000000000000 AR\r\n", - "Balance after uploading: -0.000027395596 AR\r\n", - "\r\n", - "\u001b[91mInsufficient balance: balance 0.000000000000 AR, fee: 0.000027395596 AR\u001b[39m\r\n" - ] - } - ], - "source": [ - "!arweave deploy test-nft-files/prem.jpg --key-file arweave-key-WaOHUDviIky6vGSLKwoLCQ13Mr7NhjcujIoMyCf36sM.json" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "0a9f0e7a", - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "\n", - "metadata = {\n", - " \"name\": \"Prem\",\n", - " \"symbol\": \"Pre\",\n", - " \"description\": \"Prem is nice.\",\n", - " \"seller_fee_basis_points\": 700, \n", - " \"image\": \"https://ipfs.io/ipfs/QmSDeXSuZ6o6j84TiriuRxZuZcDeYCLyennD5FAtbZFPq3?filename=2370694-kg%20(1).jpeg\", \n", - " \"attributes\": [\n", - " {\n", - " \"trait_type\": \"handsome\",\n", - " \"value\": \"Yes\"\n", - " }\n", - " ],\n", - " \"collection\": {\n", - " \"name\": \"Prem\",\n", - " \"family\": \"test\"\n", - " },\n", - " \"properties\": {\n", - " \"category\": \"image\",\n", - " \"creators\": [\n", - " {\n", - " \"address\": \"AvFLeGBFDthzdoct5mHpbUE8ZJdYD4oZXpksoRiws8AG\",\n", - " \"share\": 100\n", - " }\n", - " ]\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "id": "d4c353ce", - "metadata": {}, - "outputs": [], - "source": [ - "import json\n", - "\n", - "with open(\"prem-metadata.json\", \"w\") as f:\n", - " json.dump(metadata, f)" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "2bbbc9a1", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2370694-kg (1).jpeg\r\n", - "LICENSE\r\n", - "README-gitpod.md\r\n", - "README-installation-notes.md\r\n", - "README.md\r\n", - "README_ZH_CN.md\r\n", - "README_ZH_TW.md\r\n", - "Test NFT.ipynb\r\n", - "Untitled.ipynb\r\n", - "Untitled2.ipynb\r\n", - "arweave-key-WaOHUDviIky6vGSLKwoLCQ13Mr7NhjcujIoMyCf36sM.json\r\n", - "arweave-key-_CvOv_ZmFl2fKRhV00Z3npcoZSMi0i8w3zz5_UMMSbg.json\r\n", - "cluster-devnet.env\r\n", - "cluster-mainnet-beta.env\r\n", - "cluster-testnet.env\r\n", - "\u001b[34mdist\u001b[m\u001b[m\r\n", - "new-arweave-key.json\r\n", - "new-keypair.json\r\n", - "\u001b[34mnode_modules\u001b[m\u001b[m\r\n", - "package-lock.json\r\n", - "package.json\r\n", - "prem-metadata.json\r\n", - "\u001b[34msrc\u001b[m\u001b[m\r\n", - "\u001b[34mtest-nft-files\u001b[m\u001b[m\r\n", - "tsconfig.json\r\n" - ] - } - ], - "source": [ - "!ls" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "9093f06b", - "metadata": {}, - "outputs": [], - "source": [ - "metadata_url = \"https://ipfs.io/ipfs/QmQiaCacuZgS5qpQrmFacxyXAtmqYSYWfAARtXXCdwbjoA?filename=prem-metadata.json\"" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "198d3d6b", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "README.md api.py \u001b[34mtest\u001b[m\u001b[m\r\n", - "Test NFT.ipynb \u001b[34mmetaplex\u001b[m\u001b[m \u001b[34mutils\u001b[m\u001b[m\r\n", - "\u001b[34mapi\u001b[m\u001b[m requirements.txt \u001b[34mvenv\u001b[m\u001b[m\r\n" - ] - } - ], - "source": [ - "!ls" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "1fa46526", - "metadata": {}, - "outputs": [], - "source": [ - "from api.metaplex_api import MetaplexAPI" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "1896831b", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\"status\": 400}\n" - ] - }, - { - "ename": "TypeError", - "evalue": "'NoneType' object is not subscriptable", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/var/folders/hk/rw64djnx2cz613ykv0bjxpr80000gn/T/ipykernel_34682/3645243428.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[0mcontract_key\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;31m# conduct a mint, and send to a recipient, e.g. wallet_2\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 29\u001b[0;31m \u001b[0mmint_res\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mapi\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mapi_endpoint\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcontract_key\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mTEST_PUBLIC_KEY\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdivinity_json_file\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m~/Documents/nft/solana/python-api/api/metaplex_api.py\u001b[0m in \u001b[0;36mmint\u001b[0;34m(self, api_endpoint, contract_key, dest_key, link, max_retries, skip_confirmation, max_timeout, target, finalized, supply)\u001b[0m\n\u001b[1;32m 75\u001b[0m \u001b[0mMints\u001b[0m \u001b[0man\u001b[0m \u001b[0mNFT\u001b[0m \u001b[0mto\u001b[0m \u001b[0man\u001b[0m \u001b[0maccount\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mupdates\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mmetadata\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mcreates\u001b[0m \u001b[0ma\u001b[0m \u001b[0mmaster\u001b[0m \u001b[0medition\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 76\u001b[0m \"\"\"\n\u001b[0;32m---> 77\u001b[0;31m \u001b[0mtx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msigners\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mapi_endpoint\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maccount\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcontract_key\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdest_key\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlink\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msupply\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msupply\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 78\u001b[0m resp = execute(\n\u001b[1;32m 79\u001b[0m \u001b[0mapi_endpoint\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Documents/nft/solana/python-api/metaplex/transactions.py\u001b[0m in \u001b[0;36mmint\u001b[0;34m(api_endpoint, source_account, contract_key, dest_key, link, supply)\u001b[0m\n\u001b[1;32m 184\u001b[0m )\n\u001b[1;32m 185\u001b[0m \u001b[0mtx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmint_to_ix\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 186\u001b[0;31m \u001b[0mmetadata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_metadata\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclient\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmint_account\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 187\u001b[0m update_metadata_data = update_metadata_instruction_data(\n\u001b[1;32m 188\u001b[0m \u001b[0mmetadata\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'name'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Documents/nft/solana/python-api/metaplex/metadata.py\u001b[0m in \u001b[0;36mget_metadata\u001b[0;34m(client, mint_key)\u001b[0m\n\u001b[1;32m 179\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mget_metadata\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclient\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmint_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 180\u001b[0m \u001b[0mmetadata_account\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_metadata_account\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmint_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 181\u001b[0;31m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbase64\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mb64decode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclient\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_account_info\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmetadata_account\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'result'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'value'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'data'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 182\u001b[0m \u001b[0mmetadata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0munpack_metadata_account\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 183\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mmetadata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mTypeError\u001b[0m: 'NoneType' object is not subscriptable" - ] - } - ], - "source": [ - "import base58\n", - "import json\n", - "import os\n", - "from api import metaplex_api\n", - "from cryptography.fernet import Fernet\n", - "SERVER_DECRYPTION_KEY = Fernet.generate_key().decode(\"ascii\")\n", - "TEST_PRIVATE_KEY = \"4ANm6NEpE87PVyujRH2VoVwuPfMfw1Jp1hBwk31suKpc1rkEL9tjHSr8hvymQJQ6SHCPndaGC9qjJ26PY6sTZY3F\"\n", - "TEST_PUBLIC_KEY = \"6DF6tVFx3ASNoSrKc7RfpE5k6MdJFoyQ2Gf8WesAmT2m\"\n", - "\n", - "account = metaplex_api.Account(\n", - " list(base58.b58decode(TEST_PRIVATE_KEY))[:32]\n", - ")\n", - "cfg = {\n", - " \"PRIVATE_KEY\": base58.b58encode(account.secret_key()).decode(\"ascii\"),\n", - " \"PUBLIC_KEY\": str(account.public_key()),\n", - " \"DECRYPTION_KEY\": Fernet.generate_key().decode(\"ascii\")\n", - "}\n", - "api = metaplex_api.MetaplexAPI(cfg)\n", - "\n", - "api_endpoint = \"https://api.devnet.solana.com/\"\n", - "\n", - "# requires a JSON file with metadata. best to publish on Arweave\n", - "divinity_json_file = metadata_url\n", - "# deploy a contract. will return a contract key.\n", - "result = api.deploy(api_endpoint, \"Prem\", \"Pre\")\n", - "print(result)\n", - "contract_key = \"cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ\"\n", - "# conduct a mint, and send to a recipient, e.g. wallet_2\n", - "mint_res = api.mint(api_endpoint, contract_key, TEST_PUBLIC_KEY, divinity_json_file)" - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "id": "5a18ed99", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "6DF6tVFx3ASNoSrKc7RfpE5k6MdJFoyQ2Gf8WesAmT2m" - ] - }, - "execution_count": 49, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "account.public_key()" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "id": "c5b9b4d8", - "metadata": {}, - "outputs": [], - "source": [ - "api = metaplex_api.MetaplexAPI(cfg)" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "id": "770c7e7c", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 31, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "account" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "id": "ec6ece61", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "api.account" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "id": "4bd611bf", - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "create_metadata_instruction_data() missing 1 required positional argument: 'creators'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/var/folders/hk/rw64djnx2cz613ykv0bjxpr80000gn/T/ipykernel_40317/395278561.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mapi_endpoint\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"https://api.devnet.solana.com/\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;31m# Client(api_endpoint).request_airdrop(account.public_key(), int(1e10))\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0mmetaplex_api\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdeploy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mapi_endpoint\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"A\"\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;36m32\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0msymbol\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"A\"\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msource_account\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0maccount\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m~/Documents/nft/solana/python-api/metaplex/transactions.py\u001b[0m in \u001b[0;36mdeploy\u001b[0;34m(api_endpoint, source_account, name, symbol)\u001b[0m\n\u001b[1;32m 62\u001b[0m \u001b[0;31m# Create Token Metadata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 63\u001b[0m create_metadata_ix = create_metadata_instruction(\n\u001b[0;32m---> 64\u001b[0;31m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcreate_metadata_instruction_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msymbol\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msource_account\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpublic_key\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 65\u001b[0m \u001b[0mupdate_authority\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msource_account\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpublic_key\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 66\u001b[0m \u001b[0mmint_key\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmint_account\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpublic_key\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mTypeError\u001b[0m: create_metadata_instruction_data() missing 1 required positional argument: 'creators'" - ] - } - ], - "source": [ - "from api import metaplex_api\n", - "\n", - "account = metaplex_api.Account(\n", - " list(base58.b58decode(TEST_PRIVATE_KEY))[:32]\n", - ")\n", - "cfg = {\"PRIVATE_KEY\": base58.b58encode(account.secret_key()).decode(\"ascii\"), \"PUBLIC_KEY\": str(account.public_key()), \"DECRYPTION_KEY\": Fernet.generate_key().decode(\"ascii\")}\n", - "api_endpoint = \"https://api.devnet.solana.com/\"\n", - "# Client(api_endpoint).request_airdrop(account.public_key(), int(1e10))\n", - "metaplex_api.deploy(api_endpoint, name=\"A\"*32,symbol=\"A\"*10, source_account=account)" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "id": "8eed3780", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: attrs==21.2.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (21.2.0)\n", - "Requirement already satisfied: base58==2.1.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (2.1.0)\n", - "Collecting certifi==2021.5.30\n", - " Using cached certifi-2021.5.30-py2.py3-none-any.whl (145 kB)\n", - "Collecting cffi==1.14.5\n", - " Using cached cffi-1.14.5-cp38-cp38-macosx_10_9_x86_64.whl (176 kB)\n", - "Requirement already satisfied: chardet==4.0.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (4.0.0)\n", - "Collecting cheroot==8.5.2\n", - " Using cached cheroot-8.5.2-py2.py3-none-any.whl (97 kB)\n", - "Collecting CherryPy==18.6.0\n", - " Using cached CherryPy-18.6.0-py2.py3-none-any.whl (419 kB)\n", - "Requirement already satisfied: construct==2.10.67 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 8)) (2.10.67)\n", - "Collecting cryptography==3.4.7\n", - " Using cached cryptography-3.4.7-cp36-abi3-macosx_10_10_x86_64.whl (2.0 MB)\n", - "Collecting ed25519==1.5\n", - " Using cached ed25519-1.5-cp38-cp38-macosx_10_9_x86_64.whl\n", - "Collecting idna==2.10\n", - " Using cached idna-2.10-py2.py3-none-any.whl (58 kB)\n", - "Requirement already satisfied: iniconfig==1.1.1 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 12)) (1.1.1)\n", - "Collecting jaraco.classes==3.2.1\n", - " Using cached jaraco.classes-3.2.1-py3-none-any.whl (5.6 kB)\n", - "Collecting jaraco.collections==3.3.0\n", - " Using cached jaraco.collections-3.3.0-py3-none-any.whl (9.9 kB)\n", - "Collecting jaraco.functools==3.3.0\n", - " Using cached jaraco.functools-3.3.0-py3-none-any.whl (6.8 kB)\n", - "Collecting jaraco.text==3.5.0\n", - " Using cached jaraco.text-3.5.0-py3-none-any.whl (8.1 kB)\n", - "Collecting more-itertools==8.8.0\n", - " Using cached more_itertools-8.8.0-py3-none-any.whl (48 kB)\n", - "Collecting packaging==20.9\n", - " Using cached packaging-20.9-py2.py3-none-any.whl (40 kB)\n", - "Collecting pluggy==0.13.1\n", - " Using cached pluggy-0.13.1-py2.py3-none-any.whl (18 kB)\n", - "Collecting portend==2.7.1\n", - " Using cached portend-2.7.1-py3-none-any.whl (5.3 kB)\n", - "Requirement already satisfied: py==1.10.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 21)) (1.10.0)\n", - "Requirement already satisfied: pycparser==2.20 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 22)) (2.20)\n", - "Requirement already satisfied: PyNaCl==1.4.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 23)) (1.4.0)\n", - "Requirement already satisfied: pyparsing==2.4.7 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 24)) (2.4.7)\n", - "Collecting pytest==6.2.4\n", - " Using cached pytest-6.2.4-py3-none-any.whl (280 kB)\n", - "Collecting pytz==2021.1\n", - " Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)\n", - "Collecting requests==2.25.1\n", - " Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)\n", - "Requirement already satisfied: six==1.16.0 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 28)) (1.16.0)\n", - "Collecting solana==0.9.2\n", - " Using cached solana-0.9.2-py3-none-any.whl (49 kB)\n", - "Collecting tempora==4.1.1\n", - " Using cached tempora-4.1.1-py3-none-any.whl (15 kB)\n", - "Requirement already satisfied: toml==0.10.2 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 31)) (0.10.2)\n", - "Collecting typing-extensions==3.10.0.0\n", - " Using cached typing_extensions-3.10.0.0-py3-none-any.whl (26 kB)\n", - "Collecting urllib3==1.26.6\n", - " Using cached urllib3-1.26.6-py2.py3-none-any.whl (138 kB)\n", - "Requirement already satisfied: websockets==9.1 in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from -r requirements.txt (line 34)) (9.1)\n", - "Collecting zc.lockfile==2.0\n", - " Using cached zc.lockfile-2.0-py2.py3-none-any.whl (9.7 kB)\n", - "Requirement already satisfied: setuptools in /Users/batprem/miniconda3/envs/nft/lib/python3.8/site-packages (from zc.lockfile==2.0->-r requirements.txt (line 35)) (58.0.4)\n", - "Installing collected packages: more-itertools, pytz, jaraco.functools, urllib3, tempora, jaraco.text, jaraco.classes, idna, cffi, certifi, zc.lockfile, typing-extensions, requests, portend, pluggy, packaging, jaraco.collections, cheroot, solana, pytest, ed25519, cryptography, CherryPy\n", - " Attempting uninstall: pytz\n", - " Found existing installation: pytz 2021.3\n", - " Uninstalling pytz-2021.3:\n", - " Successfully uninstalled pytz-2021.3\n", - " Attempting uninstall: urllib3\n", - " Found existing installation: urllib3 1.26.7\n", - " Uninstalling urllib3-1.26.7:\n", - " Successfully uninstalled urllib3-1.26.7\n", - " Attempting uninstall: idna\n", - " Found existing installation: idna 3.2\n", - " Uninstalling idna-3.2:\n", - " Successfully uninstalled idna-3.2\n", - " Attempting uninstall: cffi\n", - " Found existing installation: cffi 1.15.0\n", - " Uninstalling cffi-1.15.0:\n", - " Successfully uninstalled cffi-1.15.0\n", - " Attempting uninstall: certifi\n", - " Found existing installation: certifi 2021.10.8\n", - " Uninstalling certifi-2021.10.8:\n", - " Successfully uninstalled certifi-2021.10.8\n", - " Attempting uninstall: typing-extensions\n", - " Found existing installation: typing-extensions 3.10.0.2\n", - " Uninstalling typing-extensions-3.10.0.2:\n", - " Successfully uninstalled typing-extensions-3.10.0.2\n", - " Attempting uninstall: requests\n", - " Found existing installation: requests 2.26.0\n", - " Uninstalling requests-2.26.0:\n", - " Successfully uninstalled requests-2.26.0\n", - " Attempting uninstall: pluggy\n", - " Found existing installation: pluggy 1.0.0\n", - " Uninstalling pluggy-1.0.0:\n", - " Successfully uninstalled pluggy-1.0.0\n", - " Attempting uninstall: packaging\n", - " Found existing installation: packaging 21.0\n", - " Uninstalling packaging-21.0:\n", - " Successfully uninstalled packaging-21.0\n", - " Attempting uninstall: solana\n", - " Found existing installation: solana 0.18.1\n", - " Uninstalling solana-0.18.1:\n", - " Successfully uninstalled solana-0.18.1\n", - " Attempting uninstall: pytest\n", - " Found existing installation: pytest 6.2.5\n", - " Uninstalling pytest-6.2.5:\n", - " Successfully uninstalled pytest-6.2.5\n", - "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", - "eth-brownie 1.17.0 requires certifi==2021.10.8, but you have certifi 2021.5.30 which is incompatible.\n", - "eth-brownie 1.17.0 requires idna==3.2, but you have idna 2.10 which is incompatible.\n", - "eth-brownie 1.17.0 requires packaging==21.0, but you have packaging 20.9 which is incompatible.\n", - "eth-brownie 1.17.0 requires pluggy==1.0.0, but you have pluggy 0.13.1 which is incompatible.\n", - "eth-brownie 1.17.0 requires pytest==6.2.5, but you have pytest 6.2.4 which is incompatible.\n", - "eth-brownie 1.17.0 requires requests==2.26.0, but you have requests 2.25.1 which is incompatible.\n", - "eth-brownie 1.17.0 requires typing-extensions==3.10.0.2, but you have typing-extensions 3.10.0.0 which is incompatible.\n", - "eth-brownie 1.17.0 requires urllib3==1.26.7, but you have urllib3 1.26.6 which is incompatible.\u001b[0m\n", - "Successfully installed CherryPy-18.6.0 certifi-2021.5.30 cffi-1.14.5 cheroot-8.5.2 cryptography-3.4.7 ed25519-1.5 idna-2.10 jaraco.classes-3.2.1 jaraco.collections-3.3.0 jaraco.functools-3.3.0 jaraco.text-3.5.0 more-itertools-8.8.0 packaging-20.9 pluggy-0.13.1 portend-2.7.1 pytest-6.2.4 pytz-2021.1 requests-2.25.1 solana-0.9.2 tempora-4.1.1 typing-extensions-3.10.0.0 urllib3-1.26.6 zc.lockfile-2.0\n" - ] - } - ], - "source": [ - "!pip install -r requirements.txt" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3 copy" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.12" - }, - "toc": { - "base_numbering": 1, - "nav_menu": {}, - "number_sections": true, - "sideBar": true, - "skip_h1_title": false, - "title_cell": "Table of Contents", - "title_sidebar": "Contents", - "toc_cell": false, - "toc_position": {}, - "toc_section_display": true, - "toc_window_display": false - }, - "varInspector": { - "cols": { - "lenName": 16, - "lenType": 16, - "lenVar": 40 - }, - "kernels_config": { - "python": { - "delete_cmd_postfix": "", - "delete_cmd_prefix": "del ", - "library": "var_list.py", - "varRefreshCmd": "print(var_dic_list())" - }, - "r": { - "delete_cmd_postfix": ") ", - "delete_cmd_prefix": "rm(", - "library": "var_list.r", - "varRefreshCmd": "cat(var_dic_list()) " - } - }, - "types_to_exclude": [ - "module", - "function", - "builtin_function_or_method", - "instance", - "_Feature" - ], - "window_display": false - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/api.py b/api.py index cd96c4c..d121c9f 100644 --- a/api.py +++ b/api.py @@ -1 +1,2 @@ +from api import metaplex_api from api.metaplex_api import MetaplexAPI diff --git a/metaplex/metadata.py b/metaplex/metadata.py index c0d3d42..2bbaa71 100644 --- a/metaplex/metadata.py +++ b/metaplex/metadata.py @@ -177,7 +177,9 @@ def unpack_metadata_account(data): def get_metadata(client, mint_key): metadata_account = get_metadata_account(mint_key) - data = base64.b64decode(client.get_account_info(metadata_account)['result']['value']['data'][0]) + print("Test") + client_metadata_account = dict(client.get_account_info(metadata_account)) + data = base64.b64decode(client_metadata_account['result']['value']['data'][0]) metadata = unpack_metadata_account(data) return metadata From 6cce5c61a615abe32322bf85bdc63c2c40be57a2 Mon Sep 17 00:00:00 2001 From: "pc@zrch.com" Date: Mon, 1 Nov 2021 14:20:24 +0700 Subject: [PATCH 3/3] Delete printing and commit .gitignore --- .gitignore | 4 +++- metaplex/metadata.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 5391d87..9228659 100644 --- a/.gitignore +++ b/.gitignore @@ -135,4 +135,6 @@ dmypy.json .pytype/ # Cython debug symbols -cython_debug/ \ No newline at end of file +cython_debug/ + +*__pycache__/* \ No newline at end of file diff --git a/metaplex/metadata.py b/metaplex/metadata.py index 2bbaa71..f4f9d21 100644 --- a/metaplex/metadata.py +++ b/metaplex/metadata.py @@ -177,7 +177,6 @@ def unpack_metadata_account(data): def get_metadata(client, mint_key): metadata_account = get_metadata_account(mint_key) - print("Test") client_metadata_account = dict(client.get_account_info(metadata_account)) data = base64.b64decode(client_metadata_account['result']['value']['data'][0]) metadata = unpack_metadata_account(data)