diff --git a/src/story_protocol_python_sdk/resources/Group.py b/src/story_protocol_python_sdk/resources/Group.py index 079d894..b64626c 100644 --- a/src/story_protocol_python_sdk/resources/Group.py +++ b/src/story_protocol_python_sdk/resources/Group.py @@ -472,7 +472,7 @@ def collect_and_distribute_group_royalties( member_ip_ids, tx_options=tx_options ) - + # Parse events to get collected royalties collected_royalties = self._parse_tx_collected_royalties_to_group_pool_event(response['tx_receipt']) royalties_distributed = self._parse_tx_royalty_paid_event(response['tx_receipt']) @@ -607,14 +607,14 @@ def _parse_tx_collected_royalties_to_group_pool_event(self, tx_receipt: dict) -> :param tx_receipt dict: The transaction receipt. :return list: List of collected royalties. """ - event_signature = self.web3.keccak(text="CollectedRoyaltiesToGroupPool(address,uint256,address)").hex() + event_signature = self.web3.keccak(text="CollectedRoyaltiesToGroupPool(address,address,address,uint256)").hex() collected_royalties = [] - + for log in tx_receipt['logs']: if log['topics'][0].hex() == event_signature: group_id = '0x' + log['topics'][1].hex()[24:] - amount = int(log['data'][:66], 16) - token = '0x' + log['data'][90:130] + amount = int(log['data'][:66].hex(), 16) + token = '0x' + log['topics'][2].hex()[24:] collected_royalties.append({ 'group_id': self.web3.to_checksum_address(group_id), @@ -631,16 +631,16 @@ def _parse_tx_royalty_paid_event(self, tx_receipt: dict) -> list: :param tx_receipt dict: The transaction receipt. :return list: List of royalties distributed. """ - event_signature = self.web3.keccak(text="RoyaltyPaid(address,uint256,address,uint256)").hex() + event_signature = self.web3.keccak(text="RoyaltyPaid(address,address,address,address,uint256,uint256)").hex() royalties_distributed = [] for log in tx_receipt['logs']: if log['topics'][0].hex() == event_signature: - receiver_ip_id = '0x' + log['topics'][1].hex()[24:] + receiver_ip_id = '0x' + log['topics'][0].hex()[24:] data = log['data'] - amount = int(data[:66], 16) - token = '0x' + data[90:130] - amount_after_fee = int(data[154:], 16) + amount = int(data[128:160].hex(), 16) + token = '0x' + data[108:128].hex() + amount_after_fee = int(data[160:].hex(), 16) royalties_distributed.append({ 'ip_id': self.web3.to_checksum_address(receiver_ip_id), diff --git a/tests/integration/test_integration_group.py b/tests/integration/test_integration_group.py index c5aee36..0aa10b3 100644 --- a/tests/integration/test_integration_group.py +++ b/tests/integration/test_integration_group.py @@ -500,7 +500,7 @@ def setup_royalty_collection(self, story_client, nft_collection): ancestor_ip_id=group_ip_id, token=MockERC20 ) - + return { 'group_ip_id': group_ip_id, 'ip_ids': ip_ids @@ -523,6 +523,7 @@ def test_collect_and_distribute_group_royalties(self, story_client, setup_royalt assert len(response['tx_hash']) > 0 assert 'collected_royalties' in response + assert len(response['collected_royalties']) > 0 assert response['collected_royalties'][0]['amount'] == 20 diff --git a/tests/integration/test_integration_ip_account.py b/tests/integration/test_integration_ip_account.py index b15c47d..9f0c42d 100644 --- a/tests/integration/test_integration_ip_account.py +++ b/tests/integration/test_integration_ip_account.py @@ -420,10 +420,10 @@ def test_execute_with_sig_wrong_signer(self, story_client): nft_contract=MockERC721, token_id=token_id ) - ip_id = register_response['ipId'] + ip_id = register_response['ip_id'] deadline = get_block_timestamp(web3) + 100 - state = story_client.IPAccount.getIpAccountNonce(ip_id) + state = story_client.IPAccount.get_ip_account_nonce(ip_id) data = "0x" execute_data = story_client.IPAccount.ip_account_client.contract.encode_abi( @@ -472,7 +472,7 @@ def test_execute_with_sig_wrong_signer(self, story_client): wrong_signer = "0x1234567890123456789012345678901234567890" with pytest.raises(Exception) as exc_info: - story_client.IPAccount.executeWithSig( + story_client.IPAccount.execute_with_sig( ip_id=ip_id, to=story_client.IPAccount.access_controller_client.contract.address, value=0, @@ -509,10 +509,10 @@ def test_transfer_erc20_invalid_token_params(self, story_client): nft_contract=MockERC721, token_id=token_id ) - ip_id = register_response['ipId'] + ip_id = register_response['ip_id'] with pytest.raises(ValueError) as exc_info: - story_client.IPAccount.transferERC20( + story_client.IPAccount.transfer_erc20( ip_id=ip_id, tokens=[ { diff --git a/tests/integration/test_integration_nft_client.py b/tests/integration/test_integration_nft_client.py index 02f13c6..fa5a1e8 100644 --- a/tests/integration/test_integration_nft_client.py +++ b/tests/integration/test_integration_nft_client.py @@ -113,7 +113,7 @@ def test_invalid_recipient_address(self, story_client): def test_invalid_mint_fee_values(self, story_client): """Test with invalid mint fee values""" with pytest.raises(ValueError) as exc_info: - story_client.NFTClient.createNFTCollection( + story_client.NFTClient.create_nft_collection( name="test-collection", symbol="TEST", is_public_minting=True, @@ -127,7 +127,7 @@ def test_invalid_mint_fee_values(self, story_client): try: huge_mint_fee = 2**256 - 1 # Max uint256 value - story_client.NFTClient.createNFTCollection( + story_client.NFTClient.create_nft_collection( name="test-collection", symbol="TEST", is_public_minting=True, @@ -145,7 +145,7 @@ def test_parameter_omission(self, story_client): """Test omitting required parameters""" with pytest.raises(TypeError) as exc_info: - story_client.NFTClient.createNFTCollection( + story_client.NFTClient.create_nft_collection( # name is omitted symbol="TEST", is_public_minting=True, @@ -155,7 +155,7 @@ def test_parameter_omission(self, story_client): ) with pytest.raises(TypeError) as exc_info: - story_client.NFTClient.createNFTCollection( + story_client.NFTClient.create_nft_collection( name="test-collection", # symbol is omitted is_public_minting=True, @@ -165,7 +165,7 @@ def test_parameter_omission(self, story_client): ) with pytest.raises(TypeError) as exc_info: - story_client.NFTClient.createNFTCollection( + story_client.NFTClient.create_nft_collection( name="test-collection", symbol="TEST", # is_public_minting is omitted @@ -175,7 +175,7 @@ def test_parameter_omission(self, story_client): ) with pytest.raises(TypeError) as exc_info: - story_client.NFTClient.createNFTCollection( + story_client.NFTClient.create_nft_collection( name="test-collection", symbol="TEST", is_public_minting=True, @@ -185,7 +185,7 @@ def test_parameter_omission(self, story_client): ) with pytest.raises(TypeError) as exc_info: - story_client.NFTClient.createNFTCollection( + story_client.NFTClient.create_nft_collection( name="test-collection", symbol="TEST", is_public_minting=True, @@ -195,7 +195,7 @@ def test_parameter_omission(self, story_client): ) with pytest.raises(TypeError) as exc_info: - story_client.NFTClient.createNFTCollection( + story_client.NFTClient.create_nft_collection( name="test-collection", symbol="TEST", is_public_minting=True, @@ -209,7 +209,7 @@ def test_authorization_errors(self, story_client): different_owner = "0x1234567890123456789012345678901234567890" - response = story_client.NFTClient.createNFTCollection( + response = story_client.NFTClient.create_nft_collection( name="test-collection", symbol="TEST", is_public_minting=True, @@ -220,8 +220,8 @@ def test_authorization_errors(self, story_client): ) assert response is not None - assert 'nftContract' in response - assert Web3.is_address(response['nftContract']) + assert 'nft_contract' in response + assert Web3.is_address(response['nft_contract']) class TestMintFee: """Tests for mint fee functionality in NFT collections"""