Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "rubix-py"
version = "0.5.1"
version = "0.6.0"
description = "Rubix Client SDK for Python"
requires-python = ">=3.10"
license = { text = "MIT" }
Expand Down
38 changes: 29 additions & 9 deletions rubix/signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .crypto.secp256k1 import Secp256k1Keypair
from .did import create_did
from .crypto.account import save_account_to_file, load_account_from_file
from .utils.validate import validate_asset_address

CONFIG_ACCOUNTS_DIR = "account"

Expand Down Expand Up @@ -451,18 +452,20 @@ def execute_smart_contract(self, contract_address: str, smart_contract_data: str
# Return the final response
return tx_response

def deploy_nft(self, artifact_file: str, metadata_file: str, nft_data: str, nft_value: float,
nft_metadata_info: str = "", nft_file_name: str = ""):
def deploy_nft(self, nft_data: str, nft_value: float, artifact_file: str = "", metadata_file: str = "",
nft_metadata_info: str = "", nft_file_name: str = "", nft_id: str = ""):
"""
Deploys an NFT

Args:
artifact_file (str): Path to the artifact file.
metadata_file (str): (To be Deprecated) Path to the metadata file.
artifact_file (str, optional): Path to the artifact file.
metadata_file (str, optional): (To be Deprecated) Path to the metadata file.
nft_data (str): Arbitrary data for the NFT.
nft_value (float): The value of the NFT.
nft_metadata_info (str, optional): Additional metadata information for the NFT. Defaults to "".
nft_file_name (str, optional): Name of the NFT file. Defaults to "".
nft_id (str, optional): Pre-computed IPFS CID v0. If this is passed, then `metadata_file` and
and `artifact_file` are ignored

Returns:
Transaction response from the Rubix node.
Expand All @@ -471,12 +474,29 @@ def deploy_nft(self, artifact_file: str, metadata_file: str, nft_data: str, nft_
Exception: If the NFT deployment fails.
"""
deployer_did = self.did

# Either nft_id or both artifact_file and metadata_file should be passed.
# Passing all of them or none of them would result in an error
if nft_id != "" and artifact_file != "" and metadata_file != "":
raise AttributeError("values for `nft_id`, `artifact_file` and `metadata_file` have been passed. " \
" Either pass `nft_id` or both `artifact_file` and `metadata_file`")

nft_address = self.__generate_nft_address(
user_did=deployer_did,
artifact_file=artifact_file,
metadata_file=metadata_file
)
if nft_id == "" and artifact_file == "" and metadata_file == "":
raise AttributeError("`nft_id`, `artifact_file` and `metadata_file` are empty. " \
" Either pass `nft_id` or both `artifact_file` and `metadata_file`")

if nft_id == "":
nft_address = self.__generate_nft_address(
user_did=deployer_did,
artifact_file=artifact_file,
metadata_file=metadata_file
)
else:
# validate nft_id
if not validate_asset_address(nft_id):
raise ValueError(f"nft_id passed is not in a valid format, value: {nft_id}")

nft_address = nft_id

tx_body = {
"did": deployer_did,
Expand Down