Skip to content

Commit fc52077

Browse files
Add token transfer with memo tx signing test
1 parent c5755f1 commit fc52077

11 files changed

Lines changed: 3378 additions & 3 deletions

File tree

scripts/split_tx_util.py

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def split_transaction(json_file: str) -> tuple[bytes, list[bytes], bytes, list[b
3030
json_tx = json.load(file)
3131

3232
# Determine if the JSON is a full PrepareSubmissionResponse or just a PreparedTransaction
33-
prepared_transaction = json_tx.get("prepared_transaction") or json_tx.get("preparedTransaction")
33+
prepared_transaction = json_tx.get("prepared_transaction") or json_tx.get("preparedTransaction") or json_tx.get("json")
3434
if not prepared_transaction:
3535
prepared_transaction = json_tx
3636

src/transaction/canonical_hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ static void encode_metadata(HashWriter *hw, const Metadata *m) {
617617
(EncodeFn) encode_int64_by_ptr,
618618
&m->max_ledger_effective_time);
619619

620-
encode_int64(hw, m->submission_time);
620+
encode_int64(hw, m->preparation_time);
621621
encode_int32(hw, m->input_contracts_count);
622622
}
623623

tests/application_client/canton_transaction.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ def from_bytes(cls, hexa: Union[bytes, BytesIO]):
8787
def get_hash_from_json(cls, json_file: str) -> bytes:
8888
with open(json_file, "r", encoding="utf-8") as file:
8989
data = json.load(file)
90-
return base64.b64decode(data["prepared_transaction_hash"])
90+
91+
tx_hash = data.get("prepared_transaction_hash") or data.get("hash")
92+
# Detect if base64 or hex encoding
93+
if tx_hash:
94+
try:
95+
return bytes.fromhex(tx_hash)
96+
except ValueError:
97+
return base64.b64decode(tx_hash)
98+
raise TransactionError("No hash found in JSON file")
9199

92100
@classmethod
93101
def serialize_from_json_into_tx_parts(cls, json_file: str) -> tuple[bytes, list[bytes], bytes, list[bytes]]:
11.7 KB
Loading
17.2 KB
Loading
15.5 KB
Loading
12.3 KB
Loading
6.21 KB
Loading
11.6 KB
Loading

tests/test_sign_cmd.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ def test_sign_token_transfer(
131131
custom_screen_text="Sign transaction to",
132132
)
133133

134+
def test_sign_token_transfer_with_memo(
135+
backend: BackendInterface, scenario_navigator: NavigateWithScenario
136+
) -> None:
137+
_sign_and_verify_prepared_transaction(
138+
backend,
139+
scenario_navigator,
140+
tx_json="tests/tx_examples/token_transfer_with_memo.json",
141+
custom_screen_text="Sign transaction to",
142+
)
143+
134144
def test_sign_preapproval_proposal(
135145
backend: BackendInterface, scenario_navigator: NavigateWithScenario
136146
) -> None:

0 commit comments

Comments
 (0)