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

v1.10.1 #257

Merged
merged 4 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
15 changes: 9 additions & 6 deletions ton/getstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ton
import (
"bytes"
"context"
"errors"
"fmt"
"github.com/xssnick/tonutils-go/address"
"github.com/xssnick/tonutils-go/tl"
Expand Down Expand Up @@ -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")
}
Expand All @@ -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")
Expand Down