Skip to content
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

Fix/object chanage #25

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion models/read_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,28 @@ type SuiObjectResponseError struct {
Digest string `json:"digest"`
}

type ObjectOwner struct {
func (o *ObjectOwner) UnmarshalJSON(data []byte) error {
res := gjson.ParseBytes(data)
if !res.IsObject() {
o.ObjectType = res.String()
return nil
}
o.AddressOwner = res.Get("AddressOwner").String()
o.ObjectOwner = res.Get("ObjectOwner").String()
shard := res.Get("Shared").String()
if shard != "" {
var objectShare ObjectShare
err := json.Unmarshal([]byte(shard), &objectShare)
if err != nil {
return err
}
o.Shared = objectShare
}
return nil
}

type ObjectOwner struct { //This struct has its own UnmarshalJSON method !!!
ObjectType string `json:"ObjectType"` //if Immutable return Immutable
// the owner's Sui address
AddressOwner string `json:"AddressOwner"`
ObjectOwner string `json:"ObjectOwner"`
Expand Down
Loading