From 10bca54912930089add6054c4078eab4a2cd725e Mon Sep 17 00:00:00 2001 From: Alexey Kostenko Date: Mon, 16 Sep 2024 19:16:22 +0300 Subject: [PATCH 1/2] check proof for not active account --- ton/getstate.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ton/getstate.go b/ton/getstate.go index b4d5edc..358613f 100644 --- a/ton/getstate.go +++ b/ton/getstate.go @@ -3,6 +3,7 @@ package ton import ( "bytes" "context" + "errors" "fmt" "github.com/xssnick/tonutils-go/address" "github.com/xssnick/tonutils-go/tl" @@ -58,12 +59,6 @@ func (c *APIClient) GetAccount(ctx context.Context, block *BlockIDExt, addr *add return nil, fmt.Errorf("response with incorrect master block") } - if t.State == nil { - return &tlb.Account{ - IsActive: false, - }, nil - } - if t.Proof == nil { return nil, fmt.Errorf("no proof") } @@ -87,9 +82,17 @@ func (c *APIClient) GetAccount(ctx context.Context, block *BlockIDExt, addr *add } shardAcc, balanceInfo, err := CheckAccountStateProof(addr, block, t.Proof, t.ShardProof, shardHash, c.proofCheckPolicy == ProofCheckPolicyUnsafe) + if errors.Is(err, ErrNoAddrInProof) && t.State == nil { + return &tlb.Account{ + IsActive: false, + }, nil + } if err != nil { return nil, fmt.Errorf("failed to check acc state proof: %w", err) } + if t.State == nil { + return nil, fmt.Errorf("state must be presented") + } if !bytes.Equal(shardAcc.Account.Hash(0), t.State.Hash()) { return nil, fmt.Errorf("proof hash not match state account hash") From 3d2d64358563a6762d0d3681fc3e977ee8c213c8 Mon Sep 17 00:00:00 2001 From: Coverage Date: Wed, 18 Sep 2024 06:56:01 +0000 Subject: [PATCH 2/2] Updated coverage badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60e34da..a5e0947 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Based on TON][ton-svg]][ton] [![Telegram Channel][tgc-svg]][tg-channel] -![Coverage](https://img.shields.io/badge/Coverage-73.5%25-brightgreen) +![Coverage](https://img.shields.io/badge/Coverage-73.6%25-brightgreen) Golang library for interacting with TON blockchain.