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
20 changes: 10 additions & 10 deletions src/story_protocol_python_sdk/resources/Group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_integration_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
10 changes: 5 additions & 5 deletions tests/integration/test_integration_ip_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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=[
{
Expand Down
22 changes: 11 additions & 11 deletions tests/integration/test_integration_nft_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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"""
Expand Down