-
Notifications
You must be signed in to change notification settings - Fork 411
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 auto-gzip contracts in cli when uploading #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
The utils could be simplified a bit.
And it seems like the ci is demanding a test case for utils.go
Otherwise, nice work. Happy to merge when cleaned up
x/wasm/client/utils/utils.go
Outdated
return false | ||
} | ||
|
||
in := io.LimitReader(bytes.NewReader(input), maxSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alex does this to maintain a stream for his reader functionality. You can just do a bytes.Equal(input[:3], gzipIdent)
The function is correct and nice code organization btw. Just could be simpler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and compare on maxSize as well I guess
x/wasm/client/utils/utils.go
Outdated
// IsWasm checks if the file contents are of wasm binary | ||
func IsWasm(input []byte) bool { | ||
if len(input) < 3 { | ||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. Function looks good, but could be simpler.
|
||
// GzipIt compresses the input ([]byte) | ||
func GzipIt(input []byte) ([]byte, error) { | ||
// Create gzip writer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
@@ -57,6 +59,17 @@ func StoreCodeCmd(cdc *codec.Codec) *cobra.Command { | |||
return err | |||
} | |||
|
|||
// gzip the wasm file | |||
if wasmUtils.IsWasm(wasm) { | |||
wasm, err = wasmUtils.GzipIt(wasm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
@ethanfrey updated all the changes. It is r4r |
Codecov Report
@@ Coverage Diff @@
## master #19 +/- ##
==========================================
+ Coverage 59.2% 59.38% +0.18%
==========================================
Files 11 12 +1
Lines 929 943 +14
==========================================
+ Hits 550 560 +10
- Misses 329 331 +2
- Partials 50 52 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for cleanup and adding tests
} | ||
|
||
// IsWasm checks if the file contents are of wasm binary | ||
func IsWasm(input []byte) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the cleanup, so simple
Closes: #17 Depends on: cosmos/cosmos-sdk#4470
Fixes: #18
Targeted PR against correct branch (see CONTRIBUTING.md)
Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
Wrote tests
Updated relevant documentation (
docs/
)Added a relevant changelog entry to the
Unreleased
section inCHANGELOG.md
Reviewed
Files changed
in the github PR explorerFor Admin Use: