diff --git a/src/story_protocol_python_sdk/abi/SPGNFTImpl/SPGNFTImpl_client.py b/src/story_protocol_python_sdk/abi/SPGNFTImpl/SPGNFTImpl_client.py new file mode 100644 index 0000000..020bb05 --- /dev/null +++ b/src/story_protocol_python_sdk/abi/SPGNFTImpl/SPGNFTImpl_client.py @@ -0,0 +1,23 @@ + +import json +import os +from web3 import Web3 + +class SPGNFTImplClient: + def __init__(self, web3: Web3, contract_address=None): + self.web3 = web3 + abi_path = os.path.join(os.path.dirname(__file__), '..', '..', 'abi', 'jsons', 'SPGNFTImpl.json') + with open(abi_path, 'r') as abi_file: + abi = json.load(abi_file) + self.contract = self.web3.eth.contract(address=contract_address, abi=abi) + + def mintFee(self, ): + + return self.contract.functions.mintFee().call() + + + def mintFeeToken(self, ): + + return self.contract.functions.mintFeeToken().call() + + \ No newline at end of file diff --git a/src/story_protocol_python_sdk/abi/jsons/SPGNFTImpl.json b/src/story_protocol_python_sdk/abi/jsons/SPGNFTImpl.json new file mode 100644 index 0000000..74820d5 --- /dev/null +++ b/src/story_protocol_python_sdk/abi/jsons/SPGNFTImpl.json @@ -0,0 +1,1235 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "derivativeWorkflows", + "type": "address" + }, + { + "internalType": "address", + "name": "groupingWorkflows", + "type": "address" + }, + { + "internalType": "address", + "name": "licenseAttachmentWorkflows", + "type": "address" + }, + { + "internalType": "address", + "name": "registrationWorkflows", + "type": "address" + }, + { + "internalType": "address", + "name": "royaltyTokenDistributionWorkflows", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AccessControlBadConfirmation", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "neededRole", + "type": "bytes32" + } + ], + "name": "AccessControlUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "ERC721IncorrectOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ERC721InsufficientApproval", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC721InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "ERC721InvalidOperator", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "ERC721InvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC721InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC721InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ERC721NonexistentToken", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "inputs": [], + "name": "SPGNFT__CallerNotFeeRecipientOrAdmin", + "type": "error" + }, + { + "inputs": [], + "name": "SPGNFT__CallerNotPeripheryContract", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spgNftContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "nftMetadataHash", + "type": "bytes32" + } + ], + "name": "SPGNFT__DuplicatedNFTMetadataHash", + "type": "error" + }, + { + "inputs": [], + "name": "SPGNFT__MaxSupplyReached", + "type": "error" + }, + { + "inputs": [], + "name": "SPGNFT__MintingClosed", + "type": "error" + }, + { + "inputs": [], + "name": "SPGNFT__MintingDenied", + "type": "error" + }, + { + "inputs": [], + "name": "SPGNFT__ZeroAddressParam", + "type": "error" + }, + { + "inputs": [], + "name": "SPGNFT__ZeroMaxSupply", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "approved", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_fromTokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_toTokenId", + "type": "uint256" + } + ], + "name": "BatchMetadataUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "ContractURIUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "version", + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + } + ], + "name": "MetadataUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DERIVATIVE_WORKFLOWS_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GROUPING_WORKFLOWS_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LICENSE_ATTACHMENT_WORKFLOWS_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "REGISTRATION_WORKFLOWS_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ROYALTY_TOKEN_DISTRIBUTION_WORKFLOWS_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "baseURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "contractURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getApproved", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "nftMetadataHash", + "type": "bytes32" + } + ], + "name": "getTokenIdByMetadataHash", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "string", + "name": "baseURI", + "type": "string" + }, + { + "internalType": "string", + "name": "contractURI", + "type": "string" + }, + { + "internalType": "uint32", + "name": "maxSupply", + "type": "uint32" + }, + { + "internalType": "uint256", + "name": "mintFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "mintFeeToken", + "type": "address" + }, + { + "internalType": "address", + "name": "mintFeeRecipient", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "bool", + "name": "mintOpen", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isPublicMinting", + "type": "bool" + } + ], + "internalType": "struct ISPGNFT.InitParams", + "name": "initParams", + "type": "tuple" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "string", + "name": "nftMetadataURI", + "type": "string" + }, + { + "internalType": "bytes32", + "name": "nftMetadataHash", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "allowDuplicates", + "type": "bool" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "internalType": "string", + "name": "nftMetadataURI", + "type": "string" + }, + { + "internalType": "bytes32", + "name": "nftMetadataHash", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "allowDuplicates", + "type": "bool" + } + ], + "name": "mintByPeriphery", + "outputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "mintFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "mintFeeRecipient", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "mintFeeToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "mintOpen", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "publicMinting", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "callerConfirmation", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "baseURI", + "type": "string" + } + ], + "name": "setBaseURI", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "contractURI", + "type": "string" + } + ], + "name": "setContractURI", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "name": "setMintFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newFeeRecipient", + "type": "address" + } + ], + "name": "setMintFeeRecipient", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "setMintFeeToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "mintOpen", + "type": "bool" + } + ], + "name": "setMintOpen", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "isPublicMinting", + "type": "bool" + } + ], + "name": "setPublicMinting", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "tokenURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "withdrawToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] \ No newline at end of file diff --git a/src/story_protocol_python_sdk/resources/NFTClient.py b/src/story_protocol_python_sdk/resources/NFTClient.py index 1fa6108..2452233 100644 --- a/src/story_protocol_python_sdk/resources/NFTClient.py +++ b/src/story_protocol_python_sdk/resources/NFTClient.py @@ -3,6 +3,7 @@ from web3 import Web3 from story_protocol_python_sdk.abi.RegistrationWorkflows.RegistrationWorkflows_client import RegistrationWorkflowsClient +from story_protocol_python_sdk.abi.SPGNFTImpl.SPGNFTImpl_client import SPGNFTImplClient from story_protocol_python_sdk.utils.transaction_utils import build_and_send_transaction @@ -94,4 +95,34 @@ def _parse_tx_collection_created_event(self, tx_receipt: dict) -> int: if log['topics'][0].hex() == event_signature: return self.web3.to_checksum_address('0x' + log['topics'][1].hex()[-40:]) - return None \ No newline at end of file + return None + + def getMintFeeToken(self, nft_contract: str) -> str: + """ + Returns the current mint fee token of the collection. + + :param nft_contract str: The address of the NFT contract. + :return str: The address of the mint fee token. + """ + try: + nft_contract = self.web3.to_checksum_address(nft_contract) + spg_nft_client = SPGNFTImplClient(self.web3, contract_address=nft_contract) + + return spg_nft_client.mintFeeToken() + except Exception as e: + raise ValueError(f"Failed to get mint fee token: {str(e)}") + + def getMintFee(self, nft_contract: str) -> int: + """ + Returns the current mint fee of the collection. + + :param nft_contract str: The address of the NFT contract. + :return int: The mint fee amount. + """ + try: + nft_contract = self.web3.to_checksum_address(nft_contract) + spg_nft_client = SPGNFTImplClient(self.web3, contract_address=nft_contract) + + return spg_nft_client.mintFee() + except Exception as e: + raise ValueError(f"Failed to get mint fee: {str(e)}") diff --git a/src/story_protocol_python_sdk/resources/Royalty.py b/src/story_protocol_python_sdk/resources/Royalty.py index 44a132d..757f2e5 100644 --- a/src/story_protocol_python_sdk/resources/Royalty.py +++ b/src/story_protocol_python_sdk/resources/Royalty.py @@ -6,7 +6,6 @@ from story_protocol_python_sdk.abi.IpRoyaltyVaultImpl.IpRoyaltyVaultImpl_client import IpRoyaltyVaultImplClient from story_protocol_python_sdk.abi.RoyaltyPolicyLAP.RoyaltyPolicyLAP_client import RoyaltyPolicyLAPClient from story_protocol_python_sdk.abi.RoyaltyModule.RoyaltyModule_client import RoyaltyModuleClient -from story_protocol_python_sdk.abi.IpRoyaltyVaultImpl.IpRoyaltyVaultImpl_client import IpRoyaltyVaultImplClient from story_protocol_python_sdk.abi.RoyaltyWorkflows.RoyaltyWorkflows_client import RoyaltyWorkflowsClient from story_protocol_python_sdk.abi.IPAccountImpl.IPAccountImpl_client import IPAccountImplClient from story_protocol_python_sdk.abi.MockERC20.MockERC20_client import MockERC20Client diff --git a/src/story_protocol_python_sdk/scripts/config.json b/src/story_protocol_python_sdk/scripts/config.json index 9b1b5fd..6dbd1d5 100644 --- a/src/story_protocol_python_sdk/scripts/config.json +++ b/src/story_protocol_python_sdk/scripts/config.json @@ -240,6 +240,14 @@ "transfer", "transferFrom" ] + }, + { + "contract_name": "SPGNFTImpl", + "contract_address": "0xc09e3788Fdfbd3dd8CDaa2aa481B52CcFAb74a42", + "functions": [ + "mintFeeToken", + "mintFee" + ] } ] } diff --git a/tests/integration/test_integration_nft_client.py b/tests/integration/test_integration_nft_client.py index faa8854..e890058 100644 --- a/tests/integration/test_integration_nft_client.py +++ b/tests/integration/test_integration_nft_client.py @@ -1,48 +1,13 @@ # tests/integration/test_integration_nft_client.py -import os -import sys import pytest from web3 import Web3 -from dotenv import load_dotenv - -# Ensure the src directory is in the Python path -current_dir = os.path.dirname(__file__) -src_path = os.path.abspath(os.path.join(current_dir, '..', '..')) -if src_path not in sys.path: - sys.path.append(src_path) - -from utils import get_story_client_in_devnet - -# Load environment variables at module level -load_dotenv(override=True) - -def get_web3_instance(): - """Get Web3 instance with proper error handling""" - rpc_url = os.getenv('RPC_PROVIDER_URL') - if not rpc_url: - pytest.skip("RPC_PROVIDER_URL not found in environment") - - web3 = Web3(Web3.HTTPProvider(rpc_url)) - if not web3.is_connected(): - pytest.skip("Failed to connect to Web3 provider") - - return web3 - -@pytest.fixture(scope="session") -def web3(): - return get_web3_instance() - -@pytest.fixture(scope="session") -def account(web3): - private_key = os.getenv('WALLET_PRIVATE_KEY') - if not private_key: - pytest.skip("WALLET_PRIVATE_KEY not found in environment") - return web3.eth.account.from_key(private_key) - -@pytest.fixture(scope="function") -def story_client(web3, account): - return get_story_client_in_devnet(web3, account) + +from setup_for_integration import ( + story_client, + MockERC721, + MockERC20, +) class TestNFTCollectionOperations: """Tests for NFT collection creation and management""" @@ -91,7 +56,7 @@ def test_create_collection_with_mint_fee(self, story_client): contract_uri="test-uri", mint_fee_recipient=story_client.account.address, mint_fee=1000, - mint_fee_token=story_client.account.address # Using account address as mock token + mint_fee_token=MockERC20 ) assert response is not None @@ -143,4 +108,33 @@ def test_invalid_recipient_address(self, story_client): contract_uri="test-uri", mint_fee_recipient="0xinvalid" ) - assert "when sending a str, it must be a hex string. got: '0xinvalid'" in str(exc_info.value).lower() \ No newline at end of file + assert "when sending a str, it must be a hex string. got: '0xinvalid'" in str(exc_info.value).lower() + +class TestMintFee: + """Tests for mint fee functionality in NFT collections""" + + @pytest.fixture(scope="module") + def nft_contract(self, story_client): + response = story_client.NFTClient.createNFTCollection( + name="paid-collection", + symbol="PAID", + is_public_minting=True, + mint_open=True, + contract_uri="test-uri", + max_supply=100, + mint_fee_recipient=story_client.account.address, + mint_fee=1000, + mint_fee_token=MockERC20, + ) + + return response['nftContract'] + + def test_get_mint_fee_token(self, story_client, nft_contract): + """Test successfully getting mint fee token""" + mint_fee_token = story_client.NFTClient.getMintFeeToken(nft_contract) + assert mint_fee_token == MockERC20 + + def test_get_mint_fee(self, story_client, nft_contract): + """Test successfully getting mint fee""" + mint_fee = story_client.NFTClient.getMintFee(nft_contract) + assert mint_fee == 1000