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] sending transaction - error for unordered mosaics array #205

Closed
cryptoBeliever opened this issue May 6, 2022 · 2 comments · Fixed by #295
Closed

[sdk/python] sending transaction - error for unordered mosaics array #205

cryptoBeliever opened this issue May 6, 2022 · 2 comments · Fixed by #295
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

cryptoBeliever commented May 6, 2022

When a mosaic array is not ordered by mosaic_id when constructing a transaction we get the error: "array passed to write array is not sorted". SDK should handle sorting and not require to sort it by the developer which is using SDK.

Example code causing the error:

facade = SymbolFacade('mainnet')
transaction = facade.transaction_factory.create({
        "type":"transfer_transaction",
        "signer_public_key":key_pair.public_key,
        "deadline":get_deadline(),
        "recipient_address":to_address,
        "mosaics":[
            {'mosaic_id': 0x6BED913FA20223F8, 'amount': 1},
            {'mosaic_id': 0x394832C219D2B952, 'amount': 2} 
        ]
})
transaction.fee.value = transaction.size * 100
signature = sign_transaction(facade,key_pair,transaction)

Result:
Error: array passed to write array is not sorted

Expected result:
SDK should handle sorting of mosaic array internally (if it's required to serialize sorted).

Used SDK version: 3.0.3

The corresponding issue for JS SDK: #206

@cryptoBeliever cryptoBeliever added Status: WIP This issue or PR is a work in progress. sdk-python Related to the Python SDK. labels May 6, 2022
@cryptoBeliever cryptoBeliever changed the title [sdk/python] error for unordered mosaics array [sdk/python] sending transaction - error for unordered mosaics array May 6, 2022
Jaguar0625 added a commit that referenced this issue Jul 7, 2022
 problem: currently user is expected to manually sort all ordered arrays in transaction descriptors
solution: provide autosort option on create (the default) to automatically sort the arrays during creation
   issue: #205
Jaguar0625 added a commit that referenced this issue Jul 8, 2022
 problem: currently user is expected to manually sort all ordered arrays in transaction descriptors
solution: provide autosort option on create (the default) to automatically sort the arrays during creation
   issue: #205
Jaguar0625 added a commit that referenced this issue Jul 27, 2022
 problem: currently user is expected to manually sort all ordered arrays in transaction descriptors
solution: provide autosort option on create (the default) to automatically sort the arrays during creation
   issue: #205
Jaguar0625 added a commit that referenced this issue Aug 2, 2022
 problem: currently user is expected to manually sort all ordered arrays in transaction descriptors
solution: provide autosort option on create (the default) to automatically sort the arrays during creation
   issue: #205
Jaguar0625 added a commit that referenced this issue Aug 2, 2022
 problem: currently user is expected to manually sort all ordered arrays in transaction descriptors
solution: provide autosort option on create (the default) to automatically sort the arrays during creation
   issue: #205
Jaguar0625 added a commit that referenced this issue Aug 19, 2022
 problem: currently user is expected to manually sort all ordered arrays in transaction descriptors
solution: provide autosort option on create (the default) to automatically sort the arrays during creation
   issue: #205
Jaguar0625 added a commit that referenced this issue Aug 19, 2022
 problem: currently user is expected to manually sort all ordered arrays in transaction descriptors
solution: provide autosort option on create (the default) to automatically sort the arrays during creation
   issue: #205
Jaguar0625 added a commit that referenced this issue Aug 19, 2022
 problem: currently user is expected to manually sort all ordered arrays in transaction descriptors
solution: provide autosort option on create (the default) to automatically sort the arrays during creation
   issue: #205
Jaguar0625 added a commit that referenced this issue Aug 19, 2022
 problem: currently user is expected to manually sort all ordered arrays in transaction descriptors
solution: provide autosort option on create (the default) to automatically sort the arrays during creation
   issue: #205
Jaguar0625 added a commit that referenced this issue Sep 9, 2022
 problem: currently user is expected to manually sort all ordered arrays in transaction descriptors
solution: provide autosort option on create (the default) to automatically sort the arrays during creation
   issue: #205
@gimre-xymcity
Copy link
Member

auto-sorting for create() is now default behavior, py sdk 3.0.4

@cryptoBeliever
Copy link
Contributor Author

It was tested on the dev branch. Works correctly. Example transaction:

transfer = facade.transaction_factory.create({
	'type': 'transfer_transaction_v1',
	'signer_public_key': alicePubkey,
	'recipient_address': bobAddress,
	'deadline': deadline,
	'fee': 100000,
	'mosaics': [
		{
          'mosaic_id': 0x3B6C1884BB157E22,
          'amount': 100
        },
        {
          'mosaic_id': 0x11A883250997A39A,
          'amount': 100
        }
	]
})

https://testnet.symbol.fyi/transactions/6702A3E6BA6F440B3F8016D81CD2FB4A8381615D2B0C9D15F6C82E8BD8BD98DD

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