Skip to content

Commit 3a089ec

Browse files
authored
chore:updated running_examples.md and changelog entry (#463)
Signed-off-by: Arnav <arnav.1plz@gmail.com>
1 parent 3276871 commit 3a089ec

File tree

2 files changed

+50
-49
lines changed

2 files changed

+50
-49
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
3232
- Added checksum validation for TokenId
3333
- Refactor examples/token_cancel_airdrop
3434
- Refactor token creation examples for modularity and consistency
35+
- Rearranged running_examples.md to be alphabetical
3536

3637
### Changed
3738

docs/sdk_users/running_examples.md

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ You can choose either syntax or even mix both styles in your projects.
1111
## Table of Contents
1212

1313
- [Account Transactions](#account-transactions)
14-
- [Creating an Account](#creating-an-account)
15-
- [Updating an Account](#updating-an-account)
1614
- [Querying Account Balance](#querying-account-balance)
17-
- [Querying Account Info](#querying-account-info)
15+
- [Creating an Account](#creating-an-account)
1816
- [Deleting an Account](#deleting-an-account)
19-
- [Creating a Token](#creating-a-token)
17+
- [Querying Account Info](#querying-account-info)
18+
- [Updating an Account](#updating-an-account)
2019
- [Allowance Approve Transaction](#allowance-approve-transaction)
2120
- [Allowance Delete Transaction](#allowance-delete-transaction)
2221
- [Token Transactions](#token-transactions)
22+
- [Creating a Token](#creating-a-token)
2323
- [Minting a Fungible Token](#minting-a-fungible-token)
2424
- [Minting a Non-Fungible Token](#minting-a-non-fungible-token)
2525
- [Associating a Token](#associating-a-token)
@@ -85,6 +85,18 @@ You can choose either syntax or even mix both styles in your projects.
8585

8686
## Account Transactions
8787

88+
### Querying Account Balance
89+
90+
#### Pythonic Syntax:
91+
```
92+
balance = CryptoGetAccountBalanceQuery(account_id=some_account_id).execute(client) print(f"Account balance: {balance.hbars} hbars")
93+
```
94+
95+
#### Method Chaining:
96+
```
97+
balance = ( CryptoGetAccountBalanceQuery() .set_account_id(some_account_id) .execute(client) ) print(f"Account balance: {balance.hbars} hbars")
98+
```
99+
88100
### Creating an Account
89101

90102
#### Pythonic Syntax:
@@ -112,53 +124,30 @@ transaction = (
112124
transaction.execute(client)
113125
```
114126

115-
### Updating an Account
127+
### Deleting an Account
116128

117129
#### Pythonic Syntax:
118-
```python
119-
transaction = AccountUpdateTransaction(
120-
account_params=AccountUpdateParams(
121-
account_id=account_id,
122-
key=new_public_key,
123-
account_memo=memo,
124-
receiver_signature_required=receiver_sig_required,
125-
auto_renew_period=Duration(seconds),
126-
expiration_time=future_expiration
127-
)
130+
```
131+
transaction = AccountDeleteTransaction(
132+
account_id=account_id,
133+
transfer_account_id=transfer_account_id # Account to receive remaining balance
128134
).freeze_with(client)
129135
130-
transaction.sign(old_private_key) # Sign with old key
131-
transaction.sign(new_private_key) # Sign with new key
136+
transaction.sign(account_private_key) # Account being deleted must sign
132137
transaction.execute(client)
133138
```
134139

135140
#### Method Chaining:
136-
```python
141+
```
137142
transaction = (
138-
AccountUpdateTransaction()
143+
AccountDeleteTransaction()
139144
.set_account_id(account_id)
140-
.set_key(new_public_key)
141-
.set_account_memo(memo)
142-
.set_receiver_signature_required(receiver_sig_required)
143-
.set_auto_renew_period(Duration(seconds))
144-
.set_expiration_time(future_expiration)
145+
.set_transfer_account_id(transfer_account_id) # Account to receive remaining balance
145146
.freeze_with(client)
146147
)
147-
transaction.sign(old_private_key) # Sign with old key
148-
transaction.sign(new_private_key) # Sign with new key
149-
transaction.execute(client)
150-
```
151148
152-
### Querying Account Balance
153-
154-
#### Pythonic Syntax:
155-
```
156-
balance = CryptoGetAccountBalanceQuery(account_id=some_account_id).execute(client) print(f"Account balance: {balance.hbars} hbars")
157-
```
158-
159-
#### Method Chaining:
160-
```
161-
balance = ( CryptoGetAccountBalanceQuery() .set_account_id(some_account_id) .execute(client) ) print(f"Account balance: {balance.hbars} hbars")
149+
transaction.sign(account_private_key) # Account being deleted must sign
150+
transaction.execute(client)
162151
```
163152

164153
### Querying Account Info
@@ -189,29 +178,40 @@ print(f"Owned NFTs: {info.owned_nfts}")
189178
print(f"Token Relationships: {info.token_relationships}")
190179
```
191180

192-
### Deleting an Account
181+
### Updating an Account
193182

194183
#### Pythonic Syntax:
195-
```
196-
transaction = AccountDeleteTransaction(
197-
account_id=account_id,
198-
transfer_account_id=transfer_account_id # Account to receive remaining balance
184+
```python
185+
transaction = AccountUpdateTransaction(
186+
account_params=AccountUpdateParams(
187+
account_id=account_id,
188+
key=new_public_key,
189+
account_memo=memo,
190+
receiver_signature_required=receiver_sig_required,
191+
auto_renew_period=Duration(seconds),
192+
expiration_time=future_expiration
193+
)
199194
).freeze_with(client)
200195

201-
transaction.sign(account_private_key) # Account being deleted must sign
196+
transaction.sign(old_private_key) # Sign with old key
197+
transaction.sign(new_private_key) # Sign with new key
202198
transaction.execute(client)
203199
```
204200

205201
#### Method Chaining:
206-
```
202+
```python
207203
transaction = (
208-
AccountDeleteTransaction()
204+
AccountUpdateTransaction()
209205
.set_account_id(account_id)
210-
.set_transfer_account_id(transfer_account_id) # Account to receive remaining balance
206+
.set_key(new_public_key)
207+
.set_account_memo(memo)
208+
.set_receiver_signature_required(receiver_sig_required)
209+
.set_auto_renew_period(Duration(seconds))
210+
.set_expiration_time(future_expiration)
211211
.freeze_with(client)
212212
)
213-
214-
transaction.sign(account_private_key) # Account being deleted must sign
213+
transaction.sign(old_private_key) # Sign with old key
214+
transaction.sign(new_private_key) # Sign with new key
215215
transaction.execute(client)
216216
```
217217

0 commit comments

Comments
 (0)