rename func
This commit is contained in:
parent
8932d69f36
commit
db2c3afef1
@ -33,7 +33,7 @@ func GenerateHash(json map[string]interface{}) (string, []byte, error) {
|
|||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cidString, err := CIDFromJSONBytesUsingIpldPrime(content)
|
cidString, err := CIDFromJSONBytes(content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
@ -54,10 +54,10 @@ func GetAttributeAsString(obj map[string]interface{}, attr string) (string, erro
|
|||||||
return "", errors.New("attribute not found")
|
return "", errors.New("attribute not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// CIDFromJSONBytesUsingIpldPrime returns CID (dagcbor) for json (as bytes).
|
// CIDFromJSONBytes returns CID (dagcbor) for json (as bytes).
|
||||||
// This is combination of samples for unmarshalling and linking
|
// This is combination of samples for unmarshalling and linking
|
||||||
// see: https://pkg.go.dev/github.com/ipld/go-ipld-prime
|
// 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 {
|
if len(content) == 0 {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ func TestAndValidateCIDGeneration(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
newImpl, err := CIDFromJSONBytesUsingIpldPrime([]byte(tc.content))
|
newImpl, err := CIDFromJSONBytes([]byte(tc.content))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, tc.expected, newImpl)
|
require.Equal(t, tc.expected, newImpl)
|
||||||
}
|
}
|
||||||
|
@ -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.")
|
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal string.")
|
||||||
}
|
}
|
||||||
|
|
||||||
cid, err := wnsUtils.CIDFromJSONBytesUsingIpldPrime(revealBytes)
|
cid, err := wnsUtils.CIDFromJSONBytes(revealBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal JSON.")
|
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal JSON.")
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,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) {
|
||||||
return wnsUtils.CIDFromJSONBytesUsingIpldPrime(content)
|
return wnsUtils.CIDFromJSONBytes(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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