replace CIDFromJSONBytes #97

Merged
0xmuralik merged 3 commits from murali/CIDFromJSONBytes into main 2023-03-14 05:51:23 +00:00
4 changed files with 6 additions and 6 deletions
Showing only changes of commit db2c3afef1 - Show all commits

View File

@ -33,7 +33,7 @@ func GenerateHash(json map[string]interface{}) (string, []byte, error) {
return "", nil, err
}
cidString, err := CIDFromJSONBytesUsingIpldPrime(content)
cidString, err := CIDFromJSONBytes(content)
if err != nil {
return "", nil, err
}
@ -54,10 +54,10 @@ func GetAttributeAsString(obj map[string]interface{}, attr string) (string, erro
return "", errors.New("attribute not found")
}
// CIDFromJSONBytesUsingIpldPrime returns CID (dagcbor) for json (as bytes).
// CIDFromJSONBytes returns CID (dagcbor) for json (as bytes).
Review

Maybe we should shorten the name of this to CIDFromJSONBytes now that the name is available.

Maybe we should shorten the name of this to `CIDFromJSONBytes` now that the name is available.
// This is combination of samples for unmarshalling and linking
// see: https://pkg.go.dev/github.com/ipld/go-ipld-prime
func CIDFromJSONBytesUsingIpldPrime(content []byte) (string, error) {
func CIDFromJSONBytes(content []byte) (string, error) {
if len(content) == 0 {
return "", nil
}

View File

@ -26,7 +26,7 @@ func TestAndValidateCIDGeneration(t *testing.T) {
}
for _, tc := range testCases {
newImpl, err := CIDFromJSONBytesUsingIpldPrime([]byte(tc.content))
newImpl, err := CIDFromJSONBytes([]byte(tc.content))
require.NoError(t, err)
require.Equal(t, tc.expected, newImpl)
}

View File

@ -417,7 +417,7 @@ func (k Keeper) RevealBid(ctx sdk.Context, msg types.MsgRevealBid) (*types.Aucti
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal string.")
}
cid, err := wnsUtils.CIDFromJSONBytesUsingIpldPrime(revealBytes)
cid, err := wnsUtils.CIDFromJSONBytes(revealBytes)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal JSON.")
}

View File

@ -70,7 +70,7 @@ func UnMarshalMapFromJSONBytes(bytes []byte) map[string]interface{} {
// GetCid gets the content ID.
func GetCid(content []byte) (string, error) {
return wnsUtils.CIDFromJSONBytesUsingIpldPrime(content)
return wnsUtils.CIDFromJSONBytes(content)
}
// BytesToBase64 encodes a byte array as a base64 string.