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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
- Rename test files across the repository to ensure they consistently end with _test.py (#1055)
- Cleaned up `token_airdrop_claim_signature_required` example for pylint compliance (no functional changes). (#1080)
- Rename the file 'test_token_fee_schedule_update_transaction_e2e.py' to make it ends with _test.py as all other test files.(#1117)
- Format token examples with Black for consistent code style and improved readability (#1119)
- Format token examples with Black for consistent code style and improved readability (#1119)
- Replaced `ResponseCode.get_name(receipt.status)` with the `ResponseCode(receipt.status).name` across examples and integration tests for consistency. (#1136)



### Fixed
Expand Down
2 changes: 1 addition & 1 deletion examples/query/payment_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def create_fungible_token(client, operator_id, operator_key):

if receipt.status != ResponseCode.SUCCESS:
print(
f"Fungible token creation failed with status: {ResponseCode.get_name(receipt.status)}"
f"Fungible token creation failed with status: {ResponseCode(receipt.status).name}"
)
sys.exit(1)

Expand Down
8 changes: 4 additions & 4 deletions examples/tokens/token_revoke_kyc_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def associate_token(client, token_id, account_id, account_private_key):

if receipt.status != ResponseCode.SUCCESS:
print(
f"Token association failed with status: {ResponseCode.get_name(receipt.status)}"
f"Token association failed with status: {ResponseCode(receipt.status).name}"
)
sys.exit(1)

Expand All @@ -118,7 +118,7 @@ def create_test_account(client):
# Check if account creation was successful
if receipt.status != ResponseCode.SUCCESS:
print(
f"Account creation failed with status: {ResponseCode.get_name(receipt.status)}"
f"Account creation failed with status: {ResponseCode(receipt.status).name}"
)
sys.exit(1)

Expand All @@ -142,7 +142,7 @@ def grant_kyc(client, token_id, account_id, kyc_private_key):

if receipt.status != ResponseCode.SUCCESS:
print(
f"Token grant KYC failed with status: {ResponseCode.get_name(receipt.status)}"
f"Token grant KYC failed with status: {ResponseCode(receipt.status).name}"
)
sys.exit(1)

Expand Down Expand Up @@ -189,7 +189,7 @@ def token_revoke_kyc():
# Check if the transaction was successful
if receipt.status != ResponseCode.SUCCESS:
print(
f"Token revoke KYC failed with status: {ResponseCode.get_name(receipt.status)}"
f"Token revoke KYC failed with status: {ResponseCode(receipt.status).name}"
)
sys.exit(1)

Expand Down
4 changes: 2 additions & 2 deletions examples/tokens/token_update_transaction_fungible.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def create_fungible_token(client, operator_id, operator_key, metadata_key):
# Check if token creation was successful
if receipt.status != ResponseCode.SUCCESS:
print(
f"Fungible token creation failed with status: {ResponseCode.get_name(receipt.status)}"
f"Fungible token creation failed with status: {ResponseCode(receipt.status).name}"
)
sys.exit(1)

Expand Down Expand Up @@ -109,7 +109,7 @@ def update_token_data(

if receipt.status != ResponseCode.SUCCESS:
print(
f"Token metadata update failed with status: {ResponseCode.get_name(receipt.status)}"
f"Token metadata update failed with status: {ResponseCode(receipt.status).name}"
)
sys.exit(1)

Expand Down
4 changes: 2 additions & 2 deletions examples/tokens/token_update_transaction_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def create_fungible_token(client, operator_id, admin_key, wipe_key):
# Check if token creation was successful
if receipt.status != ResponseCode.SUCCESS:
print(
f"Fungible token creation failed with status: {ResponseCode.get_name(receipt.status)}"
f"Fungible token creation failed with status: {ResponseCode(receipt.status).name}"
)
sys.exit(1)

Expand Down Expand Up @@ -106,7 +106,7 @@ def update_wipe_key_full_validation(client, token_id, old_wipe_key):

if receipt.status != ResponseCode.SUCCESS:
print(
f"Token update failed with status: {ResponseCode.get_name(receipt.status)}"
f"Token update failed with status: {ResponseCode(receipt.status).name}"
)
sys.exit(1)

Expand Down
4 changes: 2 additions & 2 deletions examples/tokens/token_update_transaction_nft.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def create_nft(client, operator_id, operator_key, metadata_key):
# Check if nft creation was successful
if receipt.status != ResponseCode.SUCCESS:
print(
f"NFT creation failed with status: {ResponseCode.get_name(receipt.status)}"
f"NFT creation failed with status: {ResponseCode(receipt.status).name}"
)
sys.exit(1)

Expand Down Expand Up @@ -109,7 +109,7 @@ def update_nft_data(

if receipt.status != ResponseCode.SUCCESS:
print(
f"NFT data update failed with status: {ResponseCode.get_name(receipt.status)}"
f"NFT data update failed with status: {ResponseCode(receipt.status).name}"
)
sys.exit(1)

Expand Down
8 changes: 4 additions & 4 deletions tests/integration/file_update_transaction_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_integration_file_update_transaction_can_execute(env):
)
assert (
receipt.status == ResponseCode.SUCCESS
), f"File creation failed with status: {ResponseCode.get_name(receipt.status)}"
), f"File creation failed with status: {ResponseCode(receipt.status).name}"

file_id = receipt.file_id
assert file_id is not None, "File ID should not be None"
Expand All @@ -53,7 +53,7 @@ def test_integration_file_update_transaction_can_execute(env):
)
assert (
receipt.status == ResponseCode.SUCCESS
), f"File update failed with status: {ResponseCode.get_name(receipt.status)}"
), f"File update failed with status: {ResponseCode(receipt.status).name}"

# Query file info and check if everything is updated
info = FileInfoQuery().set_file_id(file_id).execute(env.client)
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_integration_file_update_transaction_cannot_update_immutable_file(env):
receipt = FileCreateTransaction().set_contents("Immutable file").execute(env.client)
assert (
receipt.status == ResponseCode.SUCCESS
), f"File creation failed with status: {ResponseCode.get_name(receipt.status)}"
), f"File creation failed with status: {ResponseCode(receipt.status).name}"

file_id = receipt.file_id
assert file_id is not None, "File ID should not be None"
Expand Down Expand Up @@ -121,7 +121,7 @@ def test_integration_file_update_transaction_fails_when_key_is_invalid(env):
)
assert (
receipt.status == ResponseCode.SUCCESS
), f"File creation failed with status: {ResponseCode.get_name(receipt.status)}"
), f"File creation failed with status: {ResponseCode(receipt.status).name}"

file_id = receipt.file_id
assert file_id is not None, "File ID should not be None"
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/token_revoke_kyc_transaction_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_token_revoke_kyc_transaction_can_execute():
.set_initial_balance(Hbar(2))
.execute(env.client)
)
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode.get_name(receipt.status)}"
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode(receipt.status).name}"
account_id = receipt.account_id

# Create a new token and set the kyc key to be the operator's key
Expand All @@ -39,7 +39,7 @@ def test_token_revoke_kyc_transaction_can_execute():
.sign(new_account_private_key)
.execute(env.client)
)
assert receipt.status == ResponseCode.SUCCESS, f"Token association failed with status: {ResponseCode.get_name(receipt.status)}"
assert receipt.status == ResponseCode.SUCCESS, f"Token association failed with status: {ResponseCode(receipt.status).name}"

# Grant KYC to the new account first
receipt = (
Expand All @@ -48,7 +48,7 @@ def test_token_revoke_kyc_transaction_can_execute():
.set_token_id(token_id)
.execute(env.client)
)
assert receipt.status == ResponseCode.SUCCESS, f"Token grant KYC failed with status: {ResponseCode.get_name(receipt.status)}"
assert receipt.status == ResponseCode.SUCCESS, f"Token grant KYC failed with status: {ResponseCode(receipt.status).name}"

# Revoke KYC from the new account
receipt = (
Expand All @@ -57,7 +57,7 @@ def test_token_revoke_kyc_transaction_can_execute():
.set_token_id(token_id)
.execute(env.client)
)
assert receipt.status == ResponseCode.SUCCESS, f"Token revoke KYC failed with status: {ResponseCode.get_name(receipt.status)}"
assert receipt.status == ResponseCode.SUCCESS, f"Token revoke KYC failed with status: {ResponseCode(receipt.status).name}"
finally:
env.close()

Expand All @@ -76,7 +76,7 @@ def test_token_revoke_kyc_transaction_fails_with_no_kyc_key():
.set_initial_balance(Hbar(2))
.execute(env.client)
)
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode.get_name(receipt.status)}"
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode(receipt.status).name}"
account_id = receipt.account_id

# Create a new token without KYC key
Expand All @@ -91,7 +91,7 @@ def test_token_revoke_kyc_transaction_fails_with_no_kyc_key():
.sign(new_account_private_key)
.execute(env.client)
)
assert receipt.status == ResponseCode.SUCCESS, f"Token association failed with status: {ResponseCode.get_name(receipt.status)}"
assert receipt.status == ResponseCode.SUCCESS, f"Token association failed with status: {ResponseCode(receipt.status).name}"

# Try to revoke KYC for token without KYC key - should fail with TOKEN_HAS_NO_KYC_KEY
receipt = (
Expand All @@ -100,7 +100,7 @@ def test_token_revoke_kyc_transaction_fails_with_no_kyc_key():
.set_token_id(token_id)
.execute(env.client)
)
assert receipt.status == ResponseCode.TOKEN_HAS_NO_KYC_KEY, f"Token revoke KYC should have failed with TOKEN_HAS_NO_KYC_KEY status but got: {ResponseCode.get_name(receipt.status)}"
assert receipt.status == ResponseCode.TOKEN_HAS_NO_KYC_KEY, f"Token revoke KYC should have failed with TOKEN_HAS_NO_KYC_KEY status but got: {ResponseCode(receipt.status).name}"

# Try to revoke KYC with non-KYC key - should fail with TOKEN_HAS_NO_KYC_KEY
receipt = (
Expand All @@ -109,7 +109,7 @@ def test_token_revoke_kyc_transaction_fails_with_no_kyc_key():
.set_token_id(token_id)
.execute(env.client)
)
assert receipt.status == ResponseCode.TOKEN_HAS_NO_KYC_KEY, f"Token revoke KYC should have failed with TOKEN_HAS_NO_KYC_KEY status but got: {ResponseCode.get_name(receipt.status)}"
assert receipt.status == ResponseCode.TOKEN_HAS_NO_KYC_KEY, f"Token revoke KYC should have failed with TOKEN_HAS_NO_KYC_KEY status but got: {ResponseCode(receipt.status).name}"
finally:
env.close()

Expand All @@ -128,7 +128,7 @@ def test_token_revoke_kyc_transaction_fails_when_account_not_associated():
.set_initial_balance(Hbar(2))
.execute(env.client)
)
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode.get_name(receipt.status)}"
assert receipt.status == ResponseCode.SUCCESS, f"Account creation failed with status: {ResponseCode(receipt.status).name}"
account_id = receipt.account_id

# Create a new token and set the kyc key to be the operator's key
Expand All @@ -141,6 +141,6 @@ def test_token_revoke_kyc_transaction_fails_when_account_not_associated():
.set_token_id(token_id)
.execute(env.client)
)
assert receipt.status == ResponseCode.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT, f"Token revoke KYC should have failed with TOKEN_NOT_ASSOCIATED_TO_ACCOUNT status but got: {ResponseCode.get_name(receipt.status)}"
assert receipt.status == ResponseCode.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT, f"Token revoke KYC should have failed with TOKEN_NOT_ASSOCIATED_TO_ACCOUNT status but got: {ResponseCode(receipt.status).name}"
finally:
env.close()
Loading
Loading