From 41c6626be86eb9fdb0969992d695d9f3c0e3c130 Mon Sep 17 00:00:00 2001 From: Oleg Baranov Date: Tue, 10 Sep 2024 12:51:27 +0400 Subject: [PATCH] Attached processing fees for HW3 + Fixed Retrier + Deprecated attr fields for onchain content --- example/nft-info/main.go | 4 ++-- ton/nft/content.go | 12 ++++++++---- ton/retrier.go | 4 ++-- ton/wallet/highloadv3.go | 4 ++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/example/nft-info/main.go b/example/nft-info/main.go index ecef810c..5ff3254c 100644 --- a/example/nft-info/main.go +++ b/example/nft-info/main.go @@ -44,7 +44,7 @@ func main() { case *nft.ContentOffchain: fmt.Println(" content offchain :", content.URI) case *nft.ContentOnchain: - fmt.Println(" content onchain :", content.Name) + fmt.Println(" content onchain :", content.GetAttribute("name")) } fmt.Println(" owner :", collectionData.OwnerAddress.String()) fmt.Println(" minted items num :", collectionData.NextItemIndex) @@ -69,7 +69,7 @@ func main() { fmt.Println(" full content :", nftContent.(*nft.ContentOffchain).URI) } case *nft.ContentOnchain: - fmt.Println(" content name :", content.Name) + fmt.Println(" content name :", content.GetAttribute("name")) } } else { fmt.Println(" empty content") diff --git a/ton/nft/content.go b/ton/nft/content.go index a325a09e..ca13e30b 100644 --- a/ton/nft/content.go +++ b/ton/nft/content.go @@ -16,11 +16,15 @@ type ContentOffchain struct { } type ContentOnchain struct { - Name string + // Deprecated: use GetAttribute("name") + Name string + // Deprecated: use GetAttribute("description") Description string - Image string - ImageData []byte - attributes *cell.Dictionary + // Deprecated: use GetAttribute("image") + Image string + // Deprecated: use GetAttributeBinary("image_data") + ImageData []byte + attributes *cell.Dictionary } type ContentSemichain struct { diff --git a/ton/retrier.go b/ton/retrier.go index 70e17be5..752f12fa 100644 --- a/ton/retrier.go +++ b/ton/retrier.go @@ -16,10 +16,10 @@ type retryClient struct { } func (w *retryClient) QueryLiteserver(ctx context.Context, payload tl.Serializable, result tl.Serializable) error { - tries := w.maxRetries + tries := 0 for { err := w.original.QueryLiteserver(ctx, payload, result) - if w.maxRetries > 0 && tries == w.maxRetries { + if w.maxRetries > 0 && tries >= w.maxRetries { return err } tries++ diff --git a/ton/wallet/highloadv3.go b/ton/wallet/highloadv3.go index e158de38..821bf034 100644 --- a/ton/wallet/highloadv3.go +++ b/ton/wallet/highloadv3.go @@ -123,6 +123,10 @@ func (s *SpecHighloadV3) packActions(queryId uint64, messages []*Message) (_ *Me list = cell.BeginCell().MustStoreRef(list).MustStoreBuilder(msg).EndCell() } + // attach some coins for internal message processing gas fees + fees := new(big.Int).Add(new(big.Int).Mul(tlb.MustFromTON("0.007").Nano(), big.NewInt(int64(len(messages)))), tlb.MustFromTON("0.01").Nano()) + amt = new(big.Int).Add(amt, fees) + return &Message{ Mode: PayGasSeparately + IgnoreErrors, InternalMessage: &tlb.InternalMessage{