Skip to content

Commit

Permalink
updated linting
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickAlphaC committed Apr 10, 2021
1 parent 0468459 commit ba0b3ec
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
25 changes: 13 additions & 12 deletions scripts/advanced_collectible/create_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@
load_dotenv()

breed_to_image_uri = {
'PUG': "https://ipfs.io/ipfs/QmSsYRx3LpDAb1GZQm7zZ1AuHZjfbPkD6J7s9r41xu1mf8?filename=pug.png",
'SHIBA_INU': "https://ipfs.io/ipfs/QmYx6GsYAKnNzZ9A6NvEKV9nf1VaDzJrqDR23Y8YSkebLU?filename=shiba-inu.png",
'ST_BERNARD': "https://ipfs.io/ipfs/QmUPjADFGEKmfohdTaNcWhp7VGk26h5jXDA7v3VtTnTLcW?filename=st-bernard.png"
"PUG": "https://ipfs.io/ipfs/QmSsYRx3LpDAb1GZQm7zZ1AuHZjfbPkD6J7s9r41xu1mf8?filename=pug.png",
"SHIBA_INU": "https://ipfs.io/ipfs/QmYx6GsYAKnNzZ9A6NvEKV9nf1VaDzJrqDR23Y8YSkebLU?filename=shiba-inu.png",
"ST_BERNARD": "https://ipfs.io/ipfs/QmUPjADFGEKmfohdTaNcWhp7VGk26h5jXDA7v3VtTnTLcW?filename=st-bernard.png",
}


def main():
print("Working on " + network.show_active())
advanced_collectible = AdvancedCollectible[len(AdvancedCollectible) - 1]
number_of_advanced_collectibles = advanced_collectible.tokenCounter()
print("The number of tokens you've deployed is: " +
str(number_of_advanced_collectibles))
print(
"The number of tokens you've deployed is: "
+ str(number_of_advanced_collectibles)
)
write_metadata(number_of_advanced_collectibles, advanced_collectible)


Expand All @@ -39,8 +41,7 @@ def write_metadata(token_ids, nft_contract):
)
if Path(metadata_file_name).exists():
print(
"{} already found, delete it to overwrite!".format(
metadata_file_name)
"{} already found, delete it to overwrite!".format(metadata_file_name)
)
else:
print("Creating Metadata file: " + metadata_file_name)
Expand All @@ -53,7 +54,9 @@ def write_metadata(token_ids, nft_contract):
image_to_upload = None
if os.getenv("UPLOAD_IPFS") == "true":
image_to_upload = upload_nft()
image_to_upload = breed_to_image_uri[breed] if not image_to_upload else image_to_upload
image_to_upload = (
breed_to_image_uri[breed] if not image_to_upload else image_to_upload
)
collectible_metadata["image"] = image_to_upload
file = open(metadata_file_name, "w")
json.dump(collectible_metadata, file)
Expand All @@ -67,11 +70,9 @@ def upload_nft(image_path="./img/pug.png"):
if os.getenv("IPFS_URL")
else "https://ipfs.infura.io:5001/"
)
response = requests.post(ipfs_url + "/api/v0/add",
files={"file": image_binary})
response = requests.post(ipfs_url + "/api/v0/add", files={"file": image_binary})
ipfs_hash = response.json()["Hash"]
filename = image_path.split("/")[-1:][0]
image_uri = "https://ipfs.io/ipfs/{}?filename={}".format(
ipfs_hash, filename)
image_uri = "https://ipfs.io/ipfs/{}?filename={}".format(ipfs_hash, filename)
print(image_uri)
return image_uri
15 changes: 8 additions & 7 deletions scripts/advanced_collectible/set_tokenuri.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@


dog_metadata_dic = {
'PUG': "https://ipfs.io/ipfs/Qmd9MCGtdVz2miNumBHDbvj8bigSgTwnr4SbyH6DNnpWdt?filename=0-PUG.json",
'SHIBA_INU': "https://ipfs.io/ipfs/QmQbvDdVXKc5FyTaiYaCsvHAzroF7d6Fa8fGtEBYvPMtrk?filename=1-SHIBA_INU.json",
'ST_BERNARD': "https://ipfs.io/ipfs/QmbBnUjyHHN7Ytq9xDsYF9sucZdDJLRkWz7vnZfrjMXMxs?filename=2-ST_BERNARD.json"
"PUG": "https://ipfs.io/ipfs/Qmd9MCGtdVz2miNumBHDbvj8bigSgTwnr4SbyH6DNnpWdt?filename=0-PUG.json",
"SHIBA_INU": "https://ipfs.io/ipfs/QmQbvDdVXKc5FyTaiYaCsvHAzroF7d6Fa8fGtEBYvPMtrk?filename=1-SHIBA_INU.json",
"ST_BERNARD": "https://ipfs.io/ipfs/QmbBnUjyHHN7Ytq9xDsYF9sucZdDJLRkWz7vnZfrjMXMxs?filename=2-ST_BERNARD.json",
}
OPENSEA_FORMAT = "https://testnets.opensea.io/assets/{}/{}"

Expand All @@ -16,14 +16,15 @@ def main():
print("Working on " + network.show_active())
advanced_collectible = AdvancedCollectible[len(AdvancedCollectible) - 1]
number_of_advanced_collectibles = advanced_collectible.tokenCounter()
print("The number of tokens you've deployed is: " +
str(number_of_advanced_collectibles))
print(
"The number of tokens you've deployed is: "
+ str(number_of_advanced_collectibles)
)
for token_id in range(number_of_advanced_collectibles):
breed = get_breed(advanced_collectible.tokenIdToBreed(token_id))
if not advanced_collectible.tokenURI(token_id).startswith("https://"):
print("Setting tokenURI of {}".format(token_id))
set_tokenURI(token_id, advanced_collectible,
dog_metadata_dic[breed])
set_tokenURI(token_id, advanced_collectible, dog_metadata_dic[breed])
else:
print("Skipping {}, we already set that tokenURI!".format(token_id))

Expand Down
3 changes: 1 addition & 2 deletions scripts/helpful_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ def fund_advanced_collectible(nft_contract):
interface.LinkTokenInterface(
config["networks"][network.show_active()]["link_token"]
).transfer(
nft_contract, config["networks"][network.show_active()]["fee"], {
"from": dev}
nft_contract, config["networks"][network.show_active()]["fee"], {"from": dev}
)

0 comments on commit ba0b3ec

Please sign in to comment.