-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflow_functions.py
44 lines (34 loc) · 1.39 KB
/
flow_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from mint import *
from ipfs import ipfs_upload
# Testnet account name
acc_name = "web3hacks"
# Testnet account address
acc_address = "0x429b022e4a4860c5"
# Flow config path
config_path = "./flow/flow.json"
def mint_file(uploaded_file, description="This is a test file", type="Patent", acc_address="0x429b022e4a4860c5", receiver_address="0x429b022e4a4860c5", acc_name=acc_name):
ipfs_hash, ipfs_link = ipfs_upload(uploaded_file)
data = {
"name": uploaded_file.name,
"ipfsLink": ipfs_link,
"ipfsHash": ipfs_hash,
"description": description,
"type": type
}
MintClass = MintNFT(acc_address, receiver_address, data)
# Replace with streamlit spinner?
print("Minting NFT...")
transaction_id = asyncio.run(MintClass.run(ctx = Config(config_path, acc_name)))
print("NFT minted successfully!")
return [transaction_id,ipfs_link]
def nft_data(acc_address, acc_name, id):
MetaDataClass = RetrieveMetadata(acc_address, id)
data = asyncio.run(MetaDataClass.run(ctx = Config(config_path, acc_name)))
return data
def all_nfts(acc_address=acc_address, acc_name=acc_name):
RetrieveNFTClass = RetrieveAllNFTs(acc_address)
ids = asyncio.run(RetrieveNFTClass.run(ctx = Config(config_path, acc_name)))
all_data = {}
for id in ids:
all_data[id] = nft_data(acc_address, acc_name, id)
return all_data