Skip to content

Commit e01c5b9

Browse files
authored
Merge pull request #26 from nadineloepfe/solo-actions
Solo actions
2 parents bd9b53e + 2d87524 commit e01c5b9

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ OPERATOR_ID=<YOUR_OPERATOR_ID>
22
OPERATOR_KEY=<YOUR_PRIVATE_KEY>
33
RECIPIENT_ID=<RECIPIENT_ID>
44
RECIPIENT_KEY=<RECIPIENT_KEY>
5+
ADMIN_KEY=<ADMIN_KEY>
56
TOKEN_ID=<TOKEN_ID>
67
TOKEN_NAME=<TOKEN_NAME>
7-
TOKEN_SYMBOL=<TOKEN_SYMBOL>
8+
TOKEN_SYMBOL=<TOKEN_SYMBOL>
9+
NETWORK=<NETWORK>

.github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
run: |
3131
echo "OPERATOR_ID=${{ steps.solo.outputs.accountId }}"
3232
echo "OPERATOR_KEY=${{ steps.solo.outputs.privateKey }}"
33+
echo "ADMIN_KEY=${{ steps.solo.outputs.privateKey }}"
3334
echo "PUBLIC_KEY=${{ steps.solo.outputs.publicKey }}"
3435
3536
- name: Install your package
@@ -39,6 +40,8 @@ jobs:
3940
env:
4041
OPERATOR_ID: ${{ steps.solo.outputs.accountId }}
4142
OPERATOR_KEY: ${{ steps.solo.outputs.privateKey }}
43+
ADMIN_KEY: ${{ steps.solo.outputs.privateKey }}
4244
PUBLIC_KEY: ${{ steps.solo.outputs.publicKey }}
43-
NETWORK:
44-
run: python test.py
45+
NETWORK: solo
46+
run: |
47+
python test.py

test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import os
22
import sys
3+
from dotenv import load_dotenv
34
from src.client.network import Network
45
from src.client.client import Client
56
from src.account.account_id import AccountId
67
from src.account.account_create_transaction import AccountCreateTransaction
78
from src.crypto.private_key import PrivateKey
89
from src.tokens.token_create_transaction import TokenCreateTransaction
910
from src.tokens.token_associate_transaction import TokenAssociateTransaction
11+
from src.tokens.token_id import TokenId
1012
from src.transaction.transfer_transaction import TransferTransaction
1113
from src.response_code import ResponseCode
1214

15+
load_dotenv()
1316

1417
def load_operator_credentials():
1518
"""Load operator credentials from environment variables."""
@@ -54,6 +57,7 @@ def create_new_account(client, initial_balance=100000000):
5457

5558
def create_token(client, operator_id):
5659
"""Create a new token and return its TokenId instance."""
60+
5761
transaction = (
5862
TokenCreateTransaction()
5963
.set_token_name("ExampleToken")
@@ -63,6 +67,7 @@ def create_token(client, operator_id):
6367
.set_treasury_account_id(operator_id)
6468
.freeze_with(client)
6569
)
70+
6671
transaction.sign(client.operator_private_key)
6772

6873
try:
@@ -89,7 +94,7 @@ def associate_token(client, recipient_id, recipient_private_key, token_id):
8994
.freeze_with(client)
9095
)
9196
transaction.sign(client.operator_private_key) # sign with operator's key (payer)
92-
transaction.sign(recipient_private_key) # sign with newly created accounts key (recipient)
97+
transaction.sign(recipient_private_key) # sign with newly created account's key (recipient)
9398

9499
try:
95100
receipt = transaction.execute(client)
@@ -124,7 +129,9 @@ def transfer_token(client, recipient_id, token_id):
124129
def main():
125130
operator_id, operator_key = load_operator_credentials()
126131

127-
network = Network(node_address='localhost:50211', node_account_id=AccountId(0, 0, 3))
132+
network_type = os.getenv('NETWORK')
133+
network = Network(network=network_type)
134+
128135
client = Client(network)
129136
client.set_operator(operator_id, operator_key)
130137

@@ -134,4 +141,4 @@ def main():
134141
transfer_token(client, recipient_id, token_id)
135142

136143
if __name__ == "__main__":
137-
main()
144+
main()

0 commit comments

Comments
 (0)