Skip to content

Commit fa8e920

Browse files
committed
Revert "Merge pull request hiero-ledger#32 from exploreriii/TokenDissociateTransaction"
This reverts commit 8c61874, reversing changes made to d2f2ce3.
1 parent 8c61874 commit fa8e920

File tree

5 files changed

+18
-348
lines changed

5 files changed

+18
-348
lines changed

README.md

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a Python SDK for interacting with the Hedera Hashgraph platform. It allows developers to:
44

5-
- Manage Token Transactions like Create, Associate, Dissociate, Transfer & Delete
5+
- Manage Token Transactions like Create, Associate, Transfer & Delete
66
- Manage Consensus Transactions like Topic Create, Update, Delete
77
- Submit Topic Messages
88
- Query Account Balance, Transaction Receipts, Topic Infos and Messages
@@ -17,7 +17,6 @@ This is a Python SDK for interacting with the Hedera Hashgraph platform. It allo
1717
- [Querying Account Balance](#querying-account-balance)
1818
- [Creating a Token](#creating-a-token)
1919
- [Associating a Token](#associating-a-token)
20-
- [Dissociating a Token](#dissociating-a-token)
2120
- [Transferring Tokens](#transferring-tokens)
2221
- [Deleting a Token](#deleting-a-token)
2322
- [Transferring HBAR](#transferring-hbar)
@@ -108,7 +107,6 @@ New Account Private Key: 228a06c363b0eb328434d51xxx...
108107
New Account Public Key: 8f444e36e8926def492adxxx...
109108
Token creation successful. Token ID: 0.0.5025xxx
110109
Token association successful.
111-
Token dissociation successful.
112110
Token transfer successful.
113111
Token deletion successful.
114112
Topic creation successful.
@@ -231,31 +229,6 @@ transaction = (
231229
transaction.execute(client)
232230
```
233231

234-
### Dissociating a Token
235-
236-
#### Pythonic Syntax:
237-
```
238-
transaction = TokenDissociateTransaction(
239-
account_id=recipient_id,
240-
token_ids=[token_id]
241-
).freeze_with(client)
242-
243-
transaction.sign(recipient_key)
244-
transaction.execute(client)
245-
```
246-
#### Method Chaining:
247-
```
248-
transaction = (
249-
TokenDissociateTransaction()
250-
.set_account_id(recipient_id)
251-
.add_token_id(token_id)
252-
.freeze_with(client)
253-
.sign(recipient_key)
254-
)
255-
256-
transaction.execute(client)
257-
```
258-
259232
### Transferring Tokens
260233

261234
#### Pythonic Syntax:

examples/token_dissociate.py

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/hedera_sdk_python/tokens/token_dissociate_transaction.py

Lines changed: 0 additions & 101 deletions
This file was deleted.

test.py

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from hedera_sdk_python.crypto.private_key import PrivateKey
99
from hedera_sdk_python.tokens.token_create_transaction import TokenCreateTransaction
1010
from hedera_sdk_python.tokens.token_associate_transaction import TokenAssociateTransaction
11-
from hedera_sdk_python.tokens.token_dissociate_transaction import TokenDissociateTransaction
1211
from hedera_sdk_python.transaction.transfer_transaction import TransferTransaction
1312
from hedera_sdk_python.tokens.token_delete_transaction import TokenDeleteTransaction
1413
from hedera_sdk_python.response_code import ResponseCode
@@ -19,6 +18,7 @@
1918
from hedera_sdk_python.consensus.topic_id import TopicId
2019
from hedera_sdk_python.query.topic_info_query import TopicInfoQuery
2120
from hedera_sdk_python.query.account_balance_query import CryptoGetAccountBalanceQuery
21+
2222
load_dotenv()
2323

2424
def load_operator_credentials():
@@ -90,10 +90,10 @@ def create_token(client, operator_id, admin_key):
9090
print(f"Token creation successful. Token ID: {token_id}")
9191
return token_id
9292

93-
def associate_token(client, recipient_id, recipient_private_key, token_ids):
93+
def associate_token(client, recipient_id, recipient_private_key, token_id):
9494
transaction = TokenAssociateTransaction(
9595
account_id=recipient_id,
96-
token_ids=token_ids
96+
token_ids=[token_id]
9797
)
9898
transaction.freeze_with(client)
9999
transaction.sign(client.operator_private_key)
@@ -109,34 +109,16 @@ def associate_token(client, recipient_id, recipient_private_key, token_ids):
109109
print(f"Token association failed: {str(e)}")
110110
sys.exit(1)
111111

112-
def dissociate_token(client, recipient_id, recipient_private_key, token_id):
113-
"""Dissociate the specified token with the recipient account."""
114-
transaction = TokenDissociateTransaction(
115-
account_id = recipient_id,
116-
token_ids = token_id)
117-
transaction.freeze_with(client)
118-
transaction.sign(client.operator_private_key)
119-
transaction.sign(recipient_private_key)
120-
121-
try:
122-
receipt = transaction.execute(client)
123-
if receipt.status != ResponseCode.SUCCESS:
124-
status_message = ResponseCode.get_name(receipt.status)
125-
raise Exception(f"Token dissociation failed with status: {status_message}")
126-
print("Token dissociation successful.")
127-
except Exception as e:
128-
print(f"Token dissociation failed: {str(e)}")
129-
sys.exit(1)
130-
131-
def transfer_token(client, source_id, source_private_key, recipient_id, token_id):
132-
"""Transfer the specified token to the recipient account."""
133-
transaction = (
134-
TransferTransaction()
135-
.add_token_transfer(token_id, source_id, -1)
136-
.add_token_transfer(token_id, recipient_id, 1)
137-
.freeze_with(client)
138-
)
139-
transaction.sign(source_private_key)
112+
def transfer_token(client, recipient_id, token_id):
113+
transaction = TransferTransaction(
114+
token_transfers={
115+
token_id: {
116+
client.operator_account_id: -1,
117+
recipient_id: 1,
118+
}
119+
}
120+
).freeze_with(client)
121+
transaction.sign(client.operator_private_key)
140122

141123
try:
142124
receipt = transaction.execute(client)
@@ -266,13 +248,10 @@ def main():
266248
recipient_id, recipient_private_key = create_new_account(client)
267249
query_balance(client, recipient_id)
268250

269-
token_id_1 = create_token(client, operator_id, admin_key)
270-
token_id_2 = create_token(client, operator_id, admin_key)
271-
272-
associate_token(client, recipient_id, recipient_private_key, [token_id_1, token_id_2])
273-
transfer_token(client, operator_id, operator_key, recipient_id, token_id_1)
274-
dissociate_token(client, recipient_id, recipient_private_key, [token_id_2])
275-
delete_token(client, token_id_1, admin_key)
251+
token_id = create_token(client, operator_id, admin_key)
252+
associate_token(client, recipient_id, recipient_private_key, token_id)
253+
transfer_token(client, recipient_id, token_id)
254+
delete_token(client, token_id, admin_key)
276255

277256
topic_id = create_topic(client)
278257
submit_message(client, topic_id)

0 commit comments

Comments
 (0)