Merge pull request #60 from vulcanize/murali/to_ipld_prime
feat: use ipld-prime in helpers
This commit is contained in:
commit
17480f2716
@ -7,9 +7,9 @@ import (
|
|||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
set "github.com/deckarep/golang-set"
|
set "github.com/deckarep/golang-set"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
wnsUtils "github.com/tharsis/ethermint/utils"
|
||||||
mh "github.com/multiformats/go-multihash"
|
|
||||||
|
|
||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
@ -72,12 +72,7 @@ func UnMarshalMapFromJSONBytes(bytes []byte) map[string]interface{} {
|
|||||||
|
|
||||||
// GetCid gets the content ID.
|
// GetCid gets the content ID.
|
||||||
func GetCid(content []byte) (string, error) {
|
func GetCid(content []byte) (string, error) {
|
||||||
node, err := cbor.FromJSON(bytes.NewReader(content), mh.SHA2_256, -1)
|
return wnsUtils.CIDFromJSONBytesUsingIpldPrime(content)
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return node.Cid().String(), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BytesToBase64 encodes a byte array as a base64 string.
|
// BytesToBase64 encodes a byte array as a base64 string.
|
||||||
|
Loading…
Reference in New Issue
Block a user