-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package boc | ||
|
||
import ( | ||
"encoding/base64" | ||
"encoding/hex" | ||
"fmt" | ||
) | ||
|
||
func DeserializeSingleRootBoc(boc []byte) (*Cell, error) { | ||
cells, err := DeserializeBoc(boc) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(cells) != 1 { | ||
return nil, fmt.Errorf("invalid boc roots number %v", len(cells)) | ||
} | ||
return cells[0], nil | ||
} | ||
|
||
func DeserializeBocBase64(boc string) ([]*Cell, error) { | ||
bocData, err := base64.StdEncoding.DecodeString(boc) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return DeserializeBoc(bocData) | ||
} | ||
|
||
func DeserializeSinglRootBase64(boc string) (*Cell, error) { | ||
cells, err := DeserializeBocBase64(boc) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(cells) != 1 { | ||
return nil, fmt.Errorf("invalid boc roots number %v", len(cells)) | ||
} | ||
return cells[0], nil | ||
} | ||
|
||
func DeserializeBocHex(boc string) ([]*Cell, error) { | ||
bocData, err := hex.DecodeString(boc) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return DeserializeBoc(bocData) | ||
} | ||
|
||
func DeserializeSinglRootHex(boc string) (*Cell, error) { | ||
cells, err := DeserializeBocHex(boc) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(cells) != 1 { | ||
return nil, fmt.Errorf("invalid boc roots number %v", len(cells)) | ||
} | ||
return cells[0], nil | ||
} | ||
|
||
func MustDeserializeSinglRootHex(boc string) *Cell { | ||
c, err := DeserializeSinglRootHex(boc) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return c | ||
} | ||
|
||
func MustDeserializeSinglRootBase64(boc string) *Cell { | ||
c, err := DeserializeSinglRootBase64(boc) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return c | ||
} | ||
|
||
func MustBitStringFromFiftHex(hexRepr string) *BitString { | ||
bs, err := BitStringFromFiftHex(hexRepr) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return bs | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters