Evgenii Akentev
·
2024-09-02
declarations.go
1package main
2
3import (
4 "log"
5 "context"
6
7 "github.com/xssnick/tonutils-go/ton"
8
9 "main/contracts"
10)
11
12type DeclareDocument struct {
13}
14
15type DocumentDeclaration struct {
16 authorAddress Address
17 declarationAddress Address
18 txLt int
19 txHash string
20 declaration DeclareDocument
21}
22
23func readDeclarations(client ton.APIClientWrapped, ctx context.Context, b *ton.BlockIDExt, prevLt *uint64) []DocumentDeclaration {
24 res, err := client.WaitForBlock(b.SeqNo).GetAccount(ctx, b, contracts.GetContractAddress())
25 if err != nil {
26 log.Fatalln("get account err:", err.Error())
27 return nil
28 }
29
30 var declarations []DocumentDeclaration
31
32 var lastLt = res.LastTxLT
33 var lastHash = res.LastTxHash
34
35 for {
36 if lastLt == 0 { break }
37
38 list, err := client.ListTransactions(ctx, contracts.GetContractAddress(), 15, lastLt, lastHash)
39 if err != nil {
40 log.Printf("send err: %s", err.Error())
41 return nil
42 }
43
44 for _, tx := range list {
45
46 if prevLt != nil && tx.LT <= *prevLt {
47 return declarations
48 }
49
50// var declaration DocumentDeclaration
51
52 outMessage := tx.IO.Out.List
53 log.Println("%V", outMessage)
54
55// append(declarations, declaration)
56 }
57
58 lastLt = list[0].PrevTxLT
59 lastHash = list[0].PrevTxHash
60 }
61
62 return declarations
63}