From 17e0fd3dc9a14cc6421a0489a57e6ad9f96258e7 Mon Sep 17 00:00:00 2001 From: Oleg Baranov Date: Thu, 27 Oct 2022 11:50:40 +0300 Subject: [PATCH 1/3] NFT empty content support --- ton/nft/content.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ton/nft/content.go b/ton/nft/content.go index e3736bf7..a325a09e 100644 --- a/ton/nft/content.go +++ b/ton/nft/content.go @@ -2,7 +2,6 @@ package nft import ( "crypto/sha256" - "errors" "fmt" "github.com/xssnick/tonutils-go/tvm/cell" @@ -36,7 +35,7 @@ func ContentFromCell(c *cell.Cell) (ContentAny, error) { func ContentFromSlice(s *cell.Slice) (ContentAny, error) { if s.BitsLeft() < 8 { if s.RefsNum() == 0 { - return nil, errors.New("invalid content") + return &ContentOffchain{}, nil } s = s.MustLoadRef() } From 220546e16698675ef70b11b60186bff79fba45c4 Mon Sep 17 00:00:00 2001 From: Oleg Baranov Date: Thu, 27 Oct 2022 12:08:14 +0300 Subject: [PATCH 2/3] Fixed 257 bit int loading --- tvm/cell/slice.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tvm/cell/slice.go b/tvm/cell/slice.go index a7c84efa..1c6ac754 100644 --- a/tvm/cell/slice.go +++ b/tvm/cell/slice.go @@ -167,9 +167,13 @@ func (c *Slice) MustLoadBigUInt(sz uint) *big.Int { func (c *Slice) LoadBigUInt(sz uint) (*big.Int, error) { if sz > 256 { - return nil, ErrTooBigValue + return nil, ErrTooBigSize } + return c.loadBigNumber(sz) +} + +func (c *Slice) loadBigNumber(sz uint) (*big.Int, error) { b, err := c.LoadSlice(sz) if err != nil { return nil, err @@ -190,7 +194,11 @@ func (c *Slice) LoadBigUInt(sz uint) (*big.Int, error) { } func (c *Slice) LoadBigInt(sz uint) (*big.Int, error) { - u, err := c.LoadBigUInt(sz) + if sz > 257 { + return nil, ErrTooBigSize + } + + u, err := c.loadBigNumber(sz) if err != nil { return nil, err } From 72353be86aa99748640dbac7ef2ed080a39af882 Mon Sep 17 00:00:00 2001 From: Coverage Date: Thu, 27 Oct 2022 09:55:40 +0000 Subject: [PATCH 3/3] Updated coverage badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89a911b1..60d578ef 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Based on TON][ton-svg]][ton] -![Coverage](https://img.shields.io/badge/Coverage-70.6%25-brightgreen) +![Coverage](https://img.shields.io/badge/Coverage-70.5%25-brightgreen) Golang library for interacting with TON blockchain.