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

Add CreateArray and CreateMap to Helper #2145

Merged
merged 2 commits into from
Dec 12, 2020
Merged

Add CreateArray and CreateMap to Helper #2145

merged 2 commits into from
Dec 12, 2020

Conversation

erikzhang
Copy link
Member

Close #2143

@erikzhang
Copy link
Member Author

@lock9

@lock9
Copy link
Contributor

lock9 commented Dec 11, 2020

CODING MACHINE
Thanks man, let me check

@lock9
Copy link
Contributor

lock9 commented Dec 11, 2020

image

The code looks good, but I think some UT is recommended. Thanks a lot for the super speed Erik!

return sb.Emit(OpCode.PACK);
}

public static ScriptBuilder CreateMap<TKey, TValue>(this ScriptBuilder sb, IReadOnlyDictionary<TKey, TValue> map = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we keep the naming "Emit" or "Push"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it does not directly push the map, it actually creates a new map.

@erikzhang erikzhang merged commit d3f51ec into master Dec 12, 2020
@erikzhang erikzhang deleted the push-map branch December 12, 2020 11:52
@lock9
Copy link
Contributor

lock9 commented Dec 12, 2020

Hello @shargon and @erikzhang , if we don't add these instructions to the EmitPush method, we create a situation where you can use the EmitPush method, but it will fail with an exception. In a few words: it compiles but fails in runtime:

image

@shargon
Copy link
Member

shargon commented Dec 13, 2020

@lock9 but ContractParameter is not a IReadOnlyDictionary or IReadOnlyList. Could you provide an example?

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.

How to push a ContractParameterType of type 'Map' using the script builder?
3 participants