From 7a41d00bce8955e878557967eeb134a73af001ec Mon Sep 17 00:00:00 2001 From: Srdjan S Date: Thu, 17 Oct 2024 12:28:43 +0200 Subject: [PATCH] Change lite api workchain type from uint32 to int32 --- liteapi/client.go | 6 +++--- liteapi/pool/connection.go | 2 +- liteclient/extensions.go | 6 +++--- liteclient/generated.go | 16 ++++++++-------- liteclient/lite_api.tl | 12 ++++++------ liteclient/overlay_id.go | 2 +- tl/parser/generator.go | 10 +++++++++- 7 files changed, 31 insertions(+), 23 deletions(-) diff --git a/liteapi/client.go b/liteapi/client.go index 047011ef..49cf3b50 100644 --- a/liteapi/client.go +++ b/liteapi/client.go @@ -441,7 +441,7 @@ func (c *Client) LookupBlock(ctx context.Context, blockID ton.BlockID, mode uint res, err := client.LiteServerLookupBlock(ctx, liteclient.LiteServerLookupBlockRequest{ Mode: mode, Id: liteclient.TonNodeBlockIdC{ - Workchain: uint32(blockID.Workchain), + Workchain: blockID.Workchain, Shard: blockID.Shard, Seqno: blockID.Seqno, }, @@ -602,7 +602,7 @@ func decodeAccountDataFromProof(bocBytes []byte, account ton.AccountID) (uint64, func (c *Client) GetShardInfo( ctx context.Context, blockID ton.BlockIDExt, - workchain uint32, + workchain int32, shard uint64, exact bool, ) (ton.BlockIDExt, error) { @@ -613,7 +613,7 @@ func (c *Client) GetShardInfo( return res.Id.ToBlockIdExt(), nil } -func (c *Client) GetShardInfoRaw(ctx context.Context, blockID ton.BlockIDExt, workchain uint32, shard uint64, exact bool) (liteclient.LiteServerShardInfoC, error) { +func (c *Client) GetShardInfoRaw(ctx context.Context, blockID ton.BlockIDExt, workchain int32, shard uint64, exact bool) (liteclient.LiteServerShardInfoC, error) { client, _, err := c.pool.BestMasterchainClient(ctx) if err != nil { return liteclient.LiteServerShardInfoC{}, err diff --git a/liteapi/pool/connection.go b/liteapi/pool/connection.go index 9f83e55a..1a3604f9 100644 --- a/liteapi/pool/connection.go +++ b/liteapi/pool/connection.go @@ -130,7 +130,7 @@ func (c *connection) FindMinAvailableMasterchainSeqno(ctx context.Context) (uint request := liteclient.LiteServerLookupBlockRequest{ Mode: 1, Id: liteclient.TonNodeBlockIdC{ - Workchain: uint32(workchain), + Workchain: int32(workchain), Shard: 0x8000000000000000, Seqno: next, }, diff --git a/liteclient/extensions.go b/liteclient/extensions.go index b66c382d..0e5a1a20 100644 --- a/liteclient/extensions.go +++ b/liteclient/extensions.go @@ -74,20 +74,20 @@ func (t TonNodeBlockIdExtC) ToBlockIdExt() ton.BlockIDExt { } res.Seqno = t.Seqno res.Shard = t.Shard - res.Workchain = int32(t.Workchain) + res.Workchain = t.Workchain return res } func AccountID(id ton.AccountID) LiteServerAccountIdC { return LiteServerAccountIdC{ - Workchain: uint32(id.Workchain), + Workchain: id.Workchain, Id: id.Address, } } func BlockIDExt(id ton.BlockIDExt) TonNodeBlockIdExtC { return TonNodeBlockIdExtC{ - Workchain: uint32(id.Workchain), + Workchain: id.Workchain, Shard: id.Shard, Seqno: id.Seqno, RootHash: tl.Int256(id.RootHash), diff --git a/liteclient/generated.go b/liteclient/generated.go index 0120c4bd..7626b9e0 100644 --- a/liteclient/generated.go +++ b/liteclient/generated.go @@ -1,6 +1,5 @@ package liteclient - -// Code autogenerated. DO NOT EDIT. +// Code autogenerated. DO NOT EDIT. import ( "bytes" @@ -12,7 +11,7 @@ import ( ) type TonNodeBlockIdC struct { - Workchain uint32 + Workchain int32 Shard uint64 Seqno uint32 } @@ -68,7 +67,7 @@ func (t *TonNodeBlockIdC) UnmarshalTL(r io.Reader) error { } type TonNodeBlockIdExtC struct { - Workchain uint32 + Workchain int32 Shard uint64 Seqno uint32 RootHash tl.Int256 @@ -150,7 +149,7 @@ func (t *TonNodeBlockIdExtC) UnmarshalTL(r io.Reader) error { } type TonNodeZeroStateIdExtC struct { - Workchain uint32 + Workchain int32 RootHash tl.Int256 FileHash tl.Int256 } @@ -206,7 +205,7 @@ func (t *TonNodeZeroStateIdExtC) UnmarshalTL(r io.Reader) error { } type TonNodeShardPublicOverlayIdC struct { - Workchain uint32 + Workchain int32 Shard uint64 ZeroStateFileHash tl.Int256 } @@ -409,7 +408,7 @@ func (t *LiteServerErrorC) UnmarshalTL(r io.Reader) error { } type LiteServerAccountIdC struct { - Workchain uint32 + Workchain int32 Id tl.Int256 } @@ -3603,7 +3602,7 @@ func (c *Client) LiteServerRunSmcMethod(ctx context.Context, request LiteServerR type LiteServerGetShardInfoRequest struct { Id TonNodeBlockIdExtC - Workchain uint32 + Workchain int32 Shard uint64 Exact bool } @@ -5397,3 +5396,4 @@ const ( LiteServerRunSmcMethodRequestName RequestName = "liteServer.runSmcMethod" LiteServerSendMessageRequestName RequestName = "liteServer.sendMessage" ) + diff --git a/liteclient/lite_api.tl b/liteclient/lite_api.tl index a76535fc..a9c661b3 100644 --- a/liteclient/lite_api.tl +++ b/liteclient/lite_api.tl @@ -15,17 +15,17 @@ // int128 4*[ int ] = Int128; // int256 8*[ int ] = Int256; -tonNode.blockId#b7cdb167 workchain:int shard:long seqno:int = tonNode.BlockId; -tonNode.blockIdExt#6752eb78 workchain:int shard:long seqno:int root_hash:int256 file_hash:int256 = tonNode.BlockIdExt; -tonNode.zeroStateIdExt#1d7235ae workchain:int root_hash:int256 file_hash:int256 = tonNode.ZeroStateIdExt; -tonNode.shardPublicOverlayId#4d9ed329 workchain:int shard:long zero_state_file_hash:int256 = tonNode.ShardPublicOverlayId; +tonNode.blockId#b7cdb167 workchain:int32 shard:long seqno:int = tonNode.BlockId; +tonNode.blockIdExt#6752eb78 workchain:int32 shard:long seqno:int root_hash:int256 file_hash:int256 = tonNode.BlockIdExt; +tonNode.zeroStateIdExt#1d7235ae workchain:int32 root_hash:int256 file_hash:int256 = tonNode.ZeroStateIdExt; +tonNode.shardPublicOverlayId#4d9ed329 workchain:int32 shard:long zero_state_file_hash:int256 = tonNode.ShardPublicOverlayId; adnl.message.query#b48bf97a query_id:int256 query:bytes = adnl.Message; adnl.message.answer#0fac8416 query_id:int256 answer:bytes = adnl.Message; liteServer.error#bba9e148 code:int message:string = liteServer.Error; -liteServer.accountId#75a0e2c5 workchain:int id:int256 = liteServer.AccountId; +liteServer.accountId#75a0e2c5 workchain:int32 id:int256 = liteServer.AccountId; liteServer.libraryEntry#8aff2446 hash:int256 data:bytes = liteServer.LibraryEntry; liteServer.masterchainInfo#85832881 last:tonNode.blockIdExt state_root_hash:int256 init:tonNode.zeroStateIdExt = liteServer.MasterchainInfo; @@ -86,7 +86,7 @@ liteServer.sendMessage#690ad482 body:bytes = liteServer.SendMsgStatus; liteServer.getAccountState#6b890e25 id:tonNode.blockIdExt account:liteServer.accountId = liteServer.AccountState; liteServer.getAccountStatePrunned#5a698507 id:tonNode.blockIdExt account:liteServer.accountId = liteServer.AccountState; liteServer.runSmcMethod#5cc65dd2 mode:# id:tonNode.blockIdExt account:liteServer.accountId method_id:long params:bytes = liteServer.RunMethodResult; -liteServer.getShardInfo#46a2f425 id:tonNode.blockIdExt workchain:int shard:long exact:Bool = liteServer.ShardInfo; +liteServer.getShardInfo#46a2f425 id:tonNode.blockIdExt workchain:int32 shard:long exact:Bool = liteServer.ShardInfo; liteServer.getAllShardsInfo#74d3fd6b id:tonNode.blockIdExt = liteServer.AllShardsInfo; liteServer.getOneTransaction#d40f24ea id:tonNode.blockIdExt account:liteServer.accountId lt:long = liteServer.TransactionInfo; liteServer.getTransactions#1c40e7a1 count:# account:liteServer.accountId lt:long hash:int256 = liteServer.TransactionList; diff --git a/liteclient/overlay_id.go b/liteclient/overlay_id.go index 4b6fc239..811ab1b9 100644 --- a/liteclient/overlay_id.go +++ b/liteclient/overlay_id.go @@ -17,7 +17,7 @@ type OverlayID struct { // FullID computes an ID of the overlay that is used to represent overlay in the TON overlay network. func (o OverlayID) FullID() ([]byte, error) { overlayID := TonNodeShardPublicOverlayIdC{ - Workchain: uint32(o.Workchain), + Workchain: o.Workchain, Shard: uint64(o.Shard), ZeroStateFileHash: tl.Int256(o.ZeroStateFileHash), } diff --git a/tl/parser/generator.go b/tl/parser/generator.go index 6dc56658..eadc4ee8 100644 --- a/tl/parser/generator.go +++ b/tl/parser/generator.go @@ -26,7 +26,15 @@ type tlType struct { var ( defaultKnownTypes = map[string]DefaultType{ "#": {"uint32", false}, - "int": {"uint32", false}, + "uint": {"uint32", false}, + "uint8": {"uint8", false}, + "uint16": {"uint16", false}, + "uint32": {"uint32", false}, + "uint64": {"uint64", false}, + "int": {"uint32", false}, // this feels so wrong + "int8": {"int8", false}, + "int32": {"int32", false}, + "int64": {"int64", false}, "int256": {"tl.Int256", false}, "long": {"uint64", false}, "bytes": {"[]byte", true},