chore: release v0.4.1
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// Code generated by apigen. DO NOT EDIT.
|
||||
|
||||
package abi
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// DataHash is the canonical hash of a manifest primitives block. The generated data package bakes
|
||||
// it in and an upload whose manifest does not match it is rejected, so a manifest edited without a
|
||||
// regenerate never runs against stale generated types. Key order and whitespace do not matter.
|
||||
// A module with no primitives hashes to the empty string.
|
||||
func DataHash(primitives json.RawMessage) string {
|
||||
var decoded any
|
||||
if err := json.Unmarshal(primitives, &decoded); err != nil || decoded == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
encoded, err := json.Marshal(decoded)
|
||||
if err != nil || string(encoded) == "{}" {
|
||||
return ""
|
||||
}
|
||||
|
||||
sum := sha256.Sum256(encoded)
|
||||
|
||||
return hex.EncodeToString(sum[:])
|
||||
}
|
||||
Reference in New Issue
Block a user