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

Automatically sort maps to match Soroban environment expectations #759

Merged
merged 6 commits into from
Jun 28, 2024

Conversation

Shaptic
Copy link
Contributor

@Shaptic Shaptic commented Jun 27, 2024

Closes stellar/js-stellar-sdk#996 and stellar/js-stellar-sdk#966.

Note that test changes just involve changing the order of the map fields to be sorted accordingly in the "expected output" portion of the test.

Also, the diff is simpler if you turn whitespace off.

Copy link

Size Change: +1.74 kB (+0.05%)

Total Size: 3.21 MB

Filename Size Change
dist/stellar-base.js 2.35 MB +1.42 kB (+0.06%)
dist/stellar-base.min.js 855 kB +318 B (+0.04%)

compressed-size-action

@Shaptic Shaptic requested review from sreuland, psheth9, a team and kalepail June 27, 2024 23:11
src/scval.js Show resolved Hide resolved
@@ -182,12 +182,12 @@ describe('parsing and building ScVals', function () {
scv = nativeToScVal(
{
hello: 'world',
goodbye: [1, 2, 3]
there: [1, 2, 3]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's tough to grasp how expectations are validating the new sorting of keys from this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the main test for order was the earlier one. This test was evaluating that type was being used correctly, and there are some assertions about scv[0] and scv[1] that become out of order since goodbye comes before hello lexicographically, so instead of modifying the assertion checks I just changed the key name so it'd stay in the same order as before.

Copy link
Contributor

@sreuland sreuland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a minor comment for consideration.

@re1ro
Copy link

re1ro commented Jun 28, 2024

Thank you for the expedited solution! 😄

@Shaptic Shaptic merged commit 9abd8bd into master Jun 28, 2024
8 checks passed
@Shaptic Shaptic deleted the sorted-maps branch June 28, 2024 19:10
@Shaptic Shaptic mentioned this pull request Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Struct encoding fails based on entries order
3 participants