Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sdk/python] Metadata - provide util to calculate delta (xor) value and delta length #298

Closed
cryptoBeliever opened this issue Jul 5, 2022 · 2 comments · Fixed by #299
Closed
Assignees
Labels
sdk-python Related to the Python SDK. Status: WIP This issue or PR is a work in progress.

Comments

@cryptoBeliever
Copy link
Contributor

Current Behaviour

Previous SDK when constructing Metadata (Namespace/Mosaic/Account) Transaction automatically calculated delta value and length based on on-chain metadata value fetched during Transaction creation.

New SDK is not doing network communication but would be nice to provide a helper or other way (additional field?) to provide previous value (which the user has to manually fetch from the network) and new value. It would calculate the correct delta value and delta length to put into the transaction.

Expected Behaviour

Provide util/helper or a way to pass previous value during Metadata Transaction creation. Based on that we could calculate:

  • value (delta)
  • value size
  • value size delta

JS issue: #297

@cryptoBeliever cryptoBeliever added Status: WIP This issue or PR is a work in progress. sdk-python Related to the Python SDK. labels Jul 5, 2022
Jaguar0625 added a commit that referenced this issue Jul 7, 2022
 problem: user manually has to do XOR
solution: add metadata_update_value to simplify
   issue: #298
Jaguar0625 added a commit that referenced this issue Jul 8, 2022
 problem: user manually has to do XOR
solution: add metadata_update_value to simplify
   issue: #298
Jaguar0625 added a commit that referenced this issue Jul 27, 2022
 problem: user manually has to do XOR
solution: add metadata_update_value to simplify
   issue: #298
Jaguar0625 added a commit that referenced this issue Aug 2, 2022
 problem: user manually has to do XOR
solution: add metadata_update_value to simplify
   issue: #298
Jaguar0625 added a commit that referenced this issue Aug 2, 2022
 problem: user manually has to do XOR
solution: add metadata_update_value to simplify
   issue: #298
Jaguar0625 added a commit that referenced this issue Aug 19, 2022
 problem: user manually has to do XOR
solution: add metadata_update_value to simplify
   issue: #298
Jaguar0625 added a commit that referenced this issue Aug 19, 2022
 problem: user manually has to do XOR
solution: add metadata_update_value to simplify
   issue: #298
Jaguar0625 added a commit that referenced this issue Sep 9, 2022
 problem: user manually has to do XOR
solution: add metadata_update_value to simplify
   issue: #298
@gimre-xymcity
Copy link
Member

part of py sdk 3.0.4

@cryptoBeliever
Copy link
Contributor Author

cryptoBeliever commented Apr 9, 2023

Works correctly. Tried on dev branch ✔️ :

old_value = b'test value'
new_value = b'test value _ 123 :)'
value_delta = metadata_update_value(old_value, new_value)

embedded_transactions = []

metadata = facade.transaction_factory.create_embedded({
	'type': 'account_metadata_transaction_v1',
	'signer_public_key': alicePubkey,
	'target_address': aliceAddress,
	'scoped_metadata_key': 2,
	'value': value_delta,
	'value_size_delta': len(new_value) - len(old_value)
})

embedded_transactions.append(metadata)
merkle_hash = facade.hash_embedded_transactions(embedded_transactions)

aggregate_transaction = facade.transaction_factory.create({
	'type': 'aggregate_complete_transaction_v2',
	'signer_public_key': alicePubkey,
	'fee': 100000,
	'deadline': deadline,
	'transactions_hash': merkle_hash,
	'transactions': embedded_transactions
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdk-python Related to the Python SDK. Status: WIP This issue or PR is a work in progress.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants