Skip to content

Commit

Permalink
Uncomment, fix imports and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed Feb 14, 2024
1 parent 84bfebf commit 89da3d2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
32 changes: 15 additions & 17 deletions bindings/python/examples/wallet/transaction_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,24 @@

# This example sends a transaction with a tagged data payload.

TaggedDataPayload(PayloadType.TaggedData,
utf8_to_hex("tag"), utf8_to_hex("data"))
# wallet = Wallet(os.environ['WALLET_DB_PATH'])
wallet = Wallet(os.environ['WALLET_DB_PATH'])

# account = wallet.get_account('Alice')
account = wallet.get_account('Alice')

# # Sync account with the node
# response = account.sync()
# Sync account with the node
response = account.sync()

# if 'STRONGHOLD_PASSWORD' not in os.environ:
# raise Exception(".env STRONGHOLD_PASSWORD is undefined, see .env.example")
if 'STRONGHOLD_PASSWORD' not in os.environ:
raise Exception(".env STRONGHOLD_PASSWORD is undefined, see .env.example")

# wallet.set_stronghold_password(os.environ["STRONGHOLD_PASSWORD"])
wallet.set_stronghold_password(os.environ["STRONGHOLD_PASSWORD"])

# params = [{
# "address": "rms1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluaw60xu",
# "amount": "1000000",
# }]
params = [{
"address": "rms1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluaw60xu",
"amount": "1000000",
}]

# transaction = account.send_with_params(params, TransactionOptions(remainder_value_strategy=RemainderValueStrategy.ReuseAddress,
# note="my first tx", tagged_data_payload=TaggedDataPayload(PayloadType.TaggedData, utf8_to_hex("tag"), utf8_to_hex("data"))))
# print(transaction)
# print(f'Block sent: {os.environ["EXPLORER_URL"]}/block/{transaction.blockId}')
transaction = account.send_with_params(params, TransactionOptions(remainder_value_strategy=RemainderValueStrategy.ReuseAddress,
note="my first tx", tagged_data_payload=TaggedDataPayload(PayloadType.TaggedData, utf8_to_hex("tag"), utf8_to_hex("data"))))
print(transaction)
print(f'Block sent: {os.environ["EXPLORER_URL"]}/block/{transaction.blockId}')
9 changes: 4 additions & 5 deletions bindings/python/iota_sdk/types/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations
import dacite
from dataclasses import dataclass, field
from enum import IntEnum
from typing import Any, Dict, Optional, List, Union
from typing import Any, Optional, List, Union
import dacite
from dacite import from_dict
from iota_sdk.types.common import HexStr
from iota_sdk.types.output import BasicOutput, AliasOutput, FoundryOutput, NftOutput
Expand Down Expand Up @@ -155,9 +155,8 @@ class TaggedDataPayload(Payload):
def __post_init__(self):
if self.type != int(
PayloadType.TaggedData):
return dacite.UnionMatchError("invalid TaggedDataPayload type")
self.type = int(
PayloadType.TaggedData)
return dacite.UnionMatchError("invalid TaggedDataPayload type", self)
return self


@dataclass
Expand Down

0 comments on commit 89da3d2

Please sign in to comment.