diff --git a/liteclient/client_test.go b/liteclient/client_test.go index 2c5b707..e8c1a8b 100644 --- a/liteclient/client_test.go +++ b/liteclient/client_test.go @@ -5,6 +5,7 @@ import ( "encoding/base64" "encoding/hex" "fmt" + "github.com/tonkeeper/tongo/ton" "os" "testing" @@ -188,3 +189,42 @@ func TestClient_WaitMasterchainSeqno(t *testing.T) { t.Fatalf("want seqno: %v, got: %v", seqno, resp.Last.Seqno) } } + +func TestGeneratedMethod6(t *testing.T) { + c, err := createTestLiteServerConnection() + if err != nil { + t.Fatalf("NewConnection() failed: %v", err) + } + + client := NewClient(c) + + rh, _ := hex.DecodeString("46AC090C863EE487711E4647F8D4A92C62229AC428D56E1DF8C3DB55558A19AC") + fh, _ := hex.DecodeString("858B89D5E8C74753371188EDD93B2B0F89DAA5F1CEB95C3D3647284041A8B3B0") + + var rh1, fh1 [32]byte + copy(rh1[:], rh) + copy(fh1[:], fh) + + // mainnet + block := TonNodeBlockIdExtC{ + Workchain: 0, + Shard: 0xf000000000000000, + Seqno: 45481694, + RootHash: rh1, + FileHash: fh1, + } + req := LiteServerGetDispatchQueueInfoRequest{ + Mode: 0, + Id: block, + AfterAddr: nil, + MaxAccounts: 10, + } + r, err := client.LiteServerGetDispatchQueueInfo(context.Background(), req) + if err != nil { + panic(err) + } + for _, a := range r.AccountDispatchQueues { + addr := ton.AccountID{Workchain: 0, Address: a.Addr} + fmt.Printf("Address: %s Queue size: %d\n", addr.String(), a.Size) + } +} diff --git a/liteclient/generated.go b/liteclient/generated.go index fd2e86b..c01ec3b 100644 --- a/liteclient/generated.go +++ b/liteclient/generated.go @@ -2696,6 +2696,163 @@ func (t *LiteServerOutMsgQueueSizesC) UnmarshalTL(r io.Reader) error { return nil } +type LiteServerAccountDispatchQueueInfoC struct { + Addr tl.Int256 + Size uint64 + MinLt uint64 + MaxLt uint64 +} + +func (t LiteServerAccountDispatchQueueInfoC) MarshalTL() ([]byte, error) { + var ( + err error + b []byte + ) + buf := new(bytes.Buffer) + b, err = tl.Marshal(t.Addr) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + b, err = tl.Marshal(t.Size) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + b, err = tl.Marshal(t.MinLt) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + b, err = tl.Marshal(t.MaxLt) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +func (t *LiteServerAccountDispatchQueueInfoC) UnmarshalTL(r io.Reader) error { + var err error + err = tl.Unmarshal(r, &t.Addr) + if err != nil { + return err + } + err = tl.Unmarshal(r, &t.Size) + if err != nil { + return err + } + err = tl.Unmarshal(r, &t.MinLt) + if err != nil { + return err + } + err = tl.Unmarshal(r, &t.MaxLt) + if err != nil { + return err + } + return nil +} + +type LiteServerDispatchQueueInfoC struct { + Mode uint32 + Id TonNodeBlockIdExtC + AccountDispatchQueues []LiteServerAccountDispatchQueueInfoC + Complete bool + Proof []byte +} + +func (t LiteServerDispatchQueueInfoC) MarshalTL() ([]byte, error) { + var ( + err error + b []byte + ) + buf := new(bytes.Buffer) + b, err = tl.Marshal(t.Mode) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + b, err = tl.Marshal(t.Id) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + b, err = tl.Marshal(t.AccountDispatchQueues) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + b, err = tl.Marshal(t.Complete) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + if (t.Mode>>0)&1 == 1 { + b, err = tl.Marshal(t.Proof) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + } + return buf.Bytes(), nil +} + +func (t *LiteServerDispatchQueueInfoC) UnmarshalTL(r io.Reader) error { + var err error + err = tl.Unmarshal(r, &t.Mode) + if err != nil { + return err + } + err = tl.Unmarshal(r, &t.Id) + if err != nil { + return err + } + err = tl.Unmarshal(r, &t.AccountDispatchQueues) + if err != nil { + return err + } + err = tl.Unmarshal(r, &t.Complete) + if err != nil { + return err + } + if (t.Mode>>0)&1 == 1 { + var tempProof []byte + err = tl.Unmarshal(r, &tempProof) + if err != nil { + return err + } + t.Proof = tempProof + } + return nil +} + type LiteServerDebugVerbosityC struct { Value uint32 } @@ -4442,3 +4599,84 @@ func (c *Client) LiteServerGetOutMsgQueueSizes(ctx context.Context, request Lite } return res, fmt.Errorf("invalid tag") } + +type LiteServerGetDispatchQueueInfoRequest struct { + Mode uint32 + Id TonNodeBlockIdExtC + AfterAddr *tl.Int256 + MaxAccounts uint32 +} + +func (t LiteServerGetDispatchQueueInfoRequest) MarshalTL() ([]byte, error) { + var ( + err error + b []byte + ) + buf := new(bytes.Buffer) + b, err = tl.Marshal(t.Mode) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + b, err = tl.Marshal(t.Id) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + if (t.Mode>>1)&1 == 1 { + b, err = tl.Marshal(t.AfterAddr) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + } + b, err = tl.Marshal(t.MaxAccounts) + if err != nil { + return nil, err + } + _, err = buf.Write(b) + if err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +func (c *Client) LiteServerGetDispatchQueueInfo(ctx context.Context, request LiteServerGetDispatchQueueInfoRequest) (res LiteServerDispatchQueueInfoC, err error) { + payload, err := tl.Marshal(struct { + tl.SumType + Req LiteServerGetDispatchQueueInfoRequest `tlSumType:"01e66bf3"` + }{SumType: "Req", Req: request}) + if err != nil { + return res, err + } + resp, err := c.liteServerRequest(ctx, payload) + if err != nil { + return res, err + } + if len(resp) < 4 { + return res, fmt.Errorf("not enough bytes for tag") + } + tag := binary.LittleEndian.Uint32(resp[:4]) + if tag == 0xbba9e148 { + var errRes LiteServerErrorC + err = tl.Unmarshal(bytes.NewReader(resp[4:]), &errRes) + if err != nil { + return res, err + } + return res, errRes + } + if tag == 0x5d1132d0 { + err = tl.Unmarshal(bytes.NewReader(resp[4:]), &res) + return res, err + } + return res, fmt.Errorf("invalid tag") +} diff --git a/liteclient/lite_api.tl b/liteclient/lite_api.tl index 671c7f8..697087c 100644 --- a/liteclient/lite_api.tl +++ b/liteclient/lite_api.tl @@ -60,6 +60,8 @@ liteServer.shardBlockProof#1d62a07a masterchain_id:tonNode.blockIdExt links:(vec liteServer.lookupBlockResult#57c7ccc5 id:tonNode.blockIdExt mode:# mc_block_id:tonNode.blockIdExt client_mc_state_proof:bytes mc_block_proof:bytes shard_links:(vector liteServer.shardBlockLink) header:bytes prev_header:bytes = liteServer.LookupBlockResult; liteServer.outMsgQueueSize#a7c64c85 id:tonNode.blockIdExt size:int = liteServer.OutMsgQueueSize; liteServer.outMsgQueueSizes#f8504a03 shards:(vector liteServer.outMsgQueueSize) ext_msg_queue_size_limit:int = liteServer.OutMsgQueueSizes; +liteServer.accountDispatchQueueInfo#9b52aabb addr:int256 size:long min_lt:long max_lt:long = liteServer.AccountDispatchQueueInfo; +liteServer.dispatchQueueInfo#5d1132d0 mode:# id:tonNode.blockIdExt account_dispatch_queues:(vector liteServer.accountDispatchQueueInfo) complete:Bool proof:mode.0?bytes = liteServer.DispatchQueueInfo; liteServer.debug.verbosity#5d404733 value:int = liteServer.debug.Verbosity; @@ -99,6 +101,7 @@ liteServer.getLibraries#d122b662 library_list:(vector int256) = liteServer.Libra liteServer.getLibrariesWithProof#8c026c31 id:tonNode.blockIdExt mode:# library_list:(vector int256) = liteServer.LibraryResultWithProof; liteServer.getShardBlockProof#4ca60350 id:tonNode.blockIdExt = liteServer.ShardBlockProof; liteServer.getOutMsgQueueSizes#7bc19c36 mode:# wc:mode.0?int shard:mode.0?long = liteServer.OutMsgQueueSizes; +liteServer.getDispatchQueueInfo#01e66bf3 mode:# id:tonNode.blockIdExt after_addr:mode.1?int256 max_accounts:int want_proof:mode.0?true = liteServer.DispatchQueueInfo; // liteServer.nonfinal.getValidatorGroups mode:# wc:mode.0?int shard:mode.1?long = liteServer.nonfinal.ValidatorGroups; // liteServer.nonfinal.getCandidate id:liteServer.nonfinal.candidateId = liteServer.nonfinal.Candidate;