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

Change lite api workchain type from uint32 to int32 #310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions liteapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion liteapi/pool/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
6 changes: 3 additions & 3 deletions liteclient/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
16 changes: 8 additions & 8 deletions liteclient/generated.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package liteclient

// Code autogenerated. DO NOT EDIT.
// Code autogenerated. DO NOT EDIT.

import (
"bytes"
Expand All @@ -12,7 +11,7 @@ import (
)

type TonNodeBlockIdC struct {
Workchain uint32
Workchain int32
Shard uint64
Seqno uint32
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -206,7 +205,7 @@ func (t *TonNodeZeroStateIdExtC) UnmarshalTL(r io.Reader) error {
}

type TonNodeShardPublicOverlayIdC struct {
Workchain uint32
Workchain int32
Shard uint64
ZeroStateFileHash tl.Int256
}
Expand Down Expand Up @@ -409,7 +408,7 @@ func (t *LiteServerErrorC) UnmarshalTL(r io.Reader) error {
}

type LiteServerAccountIdC struct {
Workchain uint32
Workchain int32
Id tl.Int256
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -5397,3 +5396,4 @@ const (
LiteServerRunSmcMethodRequestName RequestName = "liteServer.runSmcMethod"
LiteServerSendMessageRequestName RequestName = "liteServer.sendMessage"
)

12 changes: 6 additions & 6 deletions liteclient/lite_api.tl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion liteclient/overlay_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
10 changes: 9 additions & 1 deletion tl/parser/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down