markgenuine / ever-client-go Goto Github PK
View Code? Open in Web Editor NEWGolang-Binding for TVM blockchains (Everscale, Gosh, TON, Venom Blockchain, etc).
License: Apache License 2.0
Golang-Binding for TVM blockchains (Everscale, Gosh, TON, Venom Blockchain, etc).
License: Apache License 2.0
Hi, i'm trying to build the lib in a container. The error is:
[builder 10/10] RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./cmd/main.go:
#18 16.39 # github.com/move-ton/ton-client-go/gateway/client
#18 16.39 /go/pkg/mod/github.com/move-ton/[email protected]/gateway/client/methods.go:8:10: undefined: clientGateway
#18 16.39 /go/pkg/mod/github.com/move-ton/[email protected]/gateway/client/methods.go:15:10: undefined: clientGateway
#18 16.39 /go/pkg/mod/github.com/move-ton/[email protected]/gateway/client/methods.go:22:10: undefined: clientGateway
#18 16.39 /go/pkg/mod/github.com/move-ton/[email protected]/gateway/client/methods.go:29:10: undefined: clientGateway
My dockerfile is:
FROM golang:latest as builder
WORKDIR /app
COPY ./go.mod ./go.sum ./
RUN go mod download
COPY ./ ./
RUN mkdir -p /app/lib
ENV TON_SDK_INSTALLATION_PATH=/app/lib
RUN wget https://binaries.tonlabs.io/tonclient_0_linux.gz -O $TON_SDK_INSTALLATION_PATH/libton_client.so.gz
RUN gzip -d $TON_SDK_INSTALLATION_PATH/libton_client.so.gz
RUN chmod +x $TON_SDK_INSTALLATION_PATH/libton_client.so
ENV CGO_LDFLAGS="-L$TON_SDK_INSTALLATION_PATH -lton_client"
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./cmd/main.go
But when i set CGO_ENABLED=1, then the build is passed, but the resulted binary is not worked (exec user process caused: no such file or directory
).
Any advices please?
This is a piece of code that can reproduce the issue below:
package main
import (
"encoding/json"
"fmt"
"log"
"testing"
"time"
"github.com/move-ton/ever-client-go/domain"
"github.com/move-ton/ever-client-go/gateway/client"
everNet "github.com/move-ton/ever-client-go/usecase/net"
"github.com/stretchr/testify/assert"
)
func TestNet(t *testing.T) {
config := domain.NewDefaultConfig("", domain.GetDevNetBaseUrls())
clientConn, err := client.NewClientGateway(config)
assert.Equal(t, nil, err)
defer clientConn.Destroy()
netUC := everNet.NewNet(config, clientConn)
t.Run("TestSubscribeCollection", func(t *testing.T) {
// # Prepare query
nowTime := int(time.Now().Unix())
queryParams := &domain.ParamsOfSubscribeCollection{
Collection: "messages",
Filter: json.RawMessage(fmt.Sprintf(`{"created_at":{"gt":%d}}`, nowTime)),
Result: "id, src, dst, boc, body, msg_type, value(format:DEC), created_at",
}
// # Create generator
generator, handle, err := netUC.SubscribeCollection(queryParams)
assert.NotNil(t, generator)
assert.Equal(t, nil, err)
assert.NotNil(t, handle)
log.Println("messages")
go func() {
for g := range generator {
defer netUC.Unsubscribe(&domain.ResultOfSubscribeCollection{Handle: handle.Handle})
log.Println(string(g))
}
}()
time.Sleep(2 * time.Minute)
})
}
Result of work:
`
2022/08/18 13:44:11 result{"id":"edd2fabca392474bd902a774c37e5f79750b3c15effc2bd86052094b9937ddc4","src":"","dst":"0:c0d158e97b7c7f2d72d0dd4dacd6cd690d08c131a718b9b445d432c9a19e5466","boc":"te6ccgEBAQEAeQAA7YgBgaKx0vb4/lrlobqbWa2a0hoRgmNOMXNoi6hlk0M8qMwES/w5EKLtn87bMJXe+1OVoV1EIapS2EWiYr6Cbsu1PNJfI+JeFe8JkZpxwjlRmNMTuClHFIzu5K5D9tWpoXQUPAAABgrCNiuZi/hguH6TaLWL+F7e","body":"te6ccgEBAQEAVwAAqYl/hyIUXbP522YSu99qcrQrqIQ1SlsItExX0E3ZdqeaS+R8S8K94TIzTjhHKjMaYncFKOKRndyVyH7atTQugoeAAADBWEbFczF/DBcP0m0WsX8L28A=","msg_type":1,"value":null,"created_at":1660819444}
2022/08/18 13:44:11 result{"id":"5f425a19cfc52e85d472a4bf2aea1f591dda4b6e67dbd41c26c3e631faad0c73","src":"","dst":"0:802f5476cc99425184757c0672fe7737e94b3cbc2cee59e156dfe61c0c0c630c","boc":"te6ccgEBAQEAeQAA7YgBAF6o7ZkyhKMI6vgM5fzub9KWeXhZ3LPCrb/MOBgYxhgEm5IdELY0uc1RECiRPifZRVawjUTq+V3jLvI2Xy9RcY2QV92tvUGQqvjfXeGgmwEVNcmAYQoWMNvy534Bajh4PAAABgrCNiqxi/hguH6TaLWL+F7a","body":"te6ccgEBAQEAVwAAqZNyQ6IWxpc5qiIFEifE+yiq1hGonV8rvGXeRsvl6i4xsgr7tbeoMhVfG+u8NBNgIqa5MAwhQsYbflzvwC1HDweAAADBWEbFVjF/DBcP0m0WsX8L20A=","msg_type":1,"value":null,"created_at":1660819443}
2022/08/18 13:44:11 {"id":"edd2fabca392474bd902a774c37e5f79750b3c15effc2bd86052094b9937ddc4","src":"","dst":"0:c0d158e97b7c7f2d72d0dd4dacd6cd690d08c131a718b9b445d432c9a19e5466","boc":"te6ccgEBAQEAeQAA7YgBgaKx0vb4/lrlobqbWa2a0hoRgmNOMXNoi6hlk0M8qMwES/w5EKLtn87bMJXe+1OVoV1EIapS2EWiYr6Cbsu1PNJfI+JeFe8JkZpxwjlRmNMTuClHFIzu5K5D9tWpoXQUPAAABgrCNiuZi/hguH6TaLWL+F7e","body":"te6ccgEBAQEAVwAAqYl/hyIUXbP522YSu99qcrQrqIQ1SlsItExX0E3ZdqeaS+R8S8K94TIzTjhHKjMaYncFKO
2022/08/18 13:44:11 {"id":"5f425a19cfc52e85d472a4bf2aea1f591dda4b6e67dbd41c26c3e631faad0c73","src":"","dst":"0:802f5476cc99425184757c0672fe7737e94b3cbc2cee59e156dfe61c0c0c630c","boc":"te6ccgEBAQEAeQAA7YgBAF6o7ZkyhKMI6vgM5fzub9KWeXhZ3LPCrb/MOBgYxhgEm5IdELY0uc1RECiRPifZRVawjUTq+V3jLvI2Xy9RcY2QV92tvUGQqvjfXeGgmwEVNcmAYQoWMNvy534Bajh4PAAABgrCNiqxi/hguH6TaLWL+F7a","body":"te6ccgEBAQEAVwAAqZNyQ6IWxpc5qiIFEifE+yiq1hGonV8rvGXeRsvl6i4xsgr7tbeoMhVfG+u8NBNgIqa5MAwhQsYbflzvwC1HDweAAADBWEbFVjF/DBcP0m0WsX8L20A=","msg_type":1,"value":null,"created_at":1660819443}
2022/08/18 13:44:11 {"id":"644213c1537a0c7cfe1ec41a2d9eca75ca8fb22f501fe0740ad790b39e120010","src":"","dst":"0:e0babd9c1c1532fcbaf16d8cec1a0e7af8aef4fb137d3599f124292ab90d8eae","boc":"te6ccgEBAQEAeQAA7YgBwXV7ODgqZfl14tsZ2DQc9fFd6fYm+msz4khSVXIbHVwGPDZrDAKmGD8mW2jzwXZPWkEUXuFD05zVJRYeBWHDLl1HjA7AHu7R7lSYvyAR7tkKAn8+aa3D/6RtCohOri40LAAABgrCNiuFi/hguH6TaLWL+F7i","body":"te6ccgEBAQEAVwAAqceGzWGAVMMH5MttHnguyetIIovcKHpzmqSiw8CsOGXLqPGB2APd2j3KkxfkAj3bIUBP5801uH/0jaFRCdXFxoWAAADBWEbFcLF/DBcP0m0WsX8L3EA=","msg_type":1,"value":null,"created_at":1660819444}
2022/08/18 13:44:11 result{"id":"644213c1537a0c7cfe1ec41a2d9eca75ca8fb22f501fe0740ad790b39e120010","src":"","dst":"0:e0babd9c1c1532fcbaf16d8cec1a0e7af8aef4fb137d3599f124292ab90d8eae","boc":"te6ccgEBAQEAeQAA7YgBwXV7ODgqZfl14tsZ2DQc9fFd6fYm+msz4khSVXIbHVwGPDZrDAKmGD8mW2jzwXZPWkEUXuFD05zVJRYeBWHDLl1HjA7AHu7R7lSYvyAR7tkKAn8+aa3D/6RtCohOri40LAAABgrCNiuFi/hguH6TaLWL+F7i","body":"te6ccgEBAQEAVwAAqceGzWGAVMMH5MttHnguyetIIovcKHpzmqSiw8CsOGXLqPGB2APd2j3KkxfkAj3bIUBP5801uH/0jaFRCdXFxoWAAADBWEbFcLF/DBcP0m0WsX8L3EA=","msg_type":1,"value":null,"created_at":1660819444}
`
The third messages were received as a piece of the buffer.
To print and compare results before sending to the channel and after, there was added the log message with "result" here https://github.com/markgenuine/ever-client-go/blob/master/usecase/net/net.go#L96
result := body.Result
log.Println("result" + string(result))
chanResult <- result
By the fact observes some inconsistent of data while data goes by the channel.
go version go1.18.3 windows/amd64
I was unable to install the package with the instruction in the Readme until I changed it to github.com/move-ton/ever-client-go
could you provide a demo
Hello!
In the description there is a mention about support of TVM blockchains, including TON. I didn't find a way to connect to TON with this lib, is it supported? Can you either point to the right direction for connecting to TON or remove it from the description please.
Thanks!
os: macos Monterey(Apple M2)
goversion: 1.19.4
sdkVersion: ever-client-go v1.38.1
query string:
query($p1: BlockchainMasterSeqNoFilter, $p2: Int, $p3: String) {
blockchain {
transactions(master_seq_no_range: $p1, workchain: $p2, after: $p3) {
edges {
node {
hash
now
tr_type
tr_type_name
account_addr
balance_delta(format: DEC)
total_fees(format: DEC)
aborted
status
block_id
in_msg
message_in: in_message {
hash
msg_type
msg_type_name
value(format: DEC)
src
dst
bounce
}
out_msgs
message_out: out_messages {
hash
dst
value(format: DEC)
}
}
}
pageInfo {
startCursor
hasNextPage
}
}
}
}
{"p1":{"start":23933862,"end":23933863},"p2": 0, "p3":""}
code:
queryParams := &domain.ParamsOfQuery{
Query: NewQueryWorkChain,
Variables: json.RawMessage(fmt.Sprintf({"p1":{"start":%d,"end":%d},"p2": 0, "p3":"%s"}
, startNo, endNo, cursor)),
}
result, err := c.sdkRpc.Net.Query(queryParams)
if err != nil {
return nil, fmt.Errorf("List: Query (%w)", err)
}
When I start the program, the program blocks without any errors. When I debug, I can't step into this block of code。If need some other info,please tell me.
Hi! Thanks for the library, faced with such an error:
json: cannot unmarshal number into Go struct field TransactionFees.fees.in_msg_fwd_fee of type string
TransactionFees struct {
InMsgFwdFee string `json:"in_msg_fwd_fee"`
StorageFee string `json:"storage_fee"`
GasFee string `json:"gas_fee"`
OutMsgsFwdFee string `json:"out_msgs_fwd_fee"`
TotalAccountFees string `json:"total_account_fees"`
TotalOutput string `json:"total_output"`
Maybe big.Int type?
Hello, im trying to evaluate local call of the contract method, but receive an error.
My code:
// Load ABI
abiFilePath := fmt.Sprintf("./data/abi/DePool-%s.abi.json", depool.CodeHash)
tvcFilePath := fmt.Sprintf("./data/tvc/DePool-%s.tvc", depool.CodeHash)
abiFile, err := os.Open(abiFilePath)
if err != nil {
log.Error().Msg("Cannot open ABI file: " + err.Error())
return err
}
abiBytes, err := ioutil.ReadAll(abiFile)
if err != nil {
log.Error().Msg("Cannot load ABI file: " + err.Error())
return err
}
abiValue := domain.NewAbiContract()
abiValue.Value = abiBytes
// Load TVC
tvcFile, err := os.Open(tvcFilePath)
if err != nil {
log.Error().Msg("Cannot open TVC file: " + err.Error())
return err
}
tvcBytes, err := ioutil.ReadAll(tvcFile)
if err != nil {
log.Error().Msg("Cannot load TVC file: " + err.Error())
return err
}
deploySet := domain.DeploySet{Tvc: base64.StdEncoding.EncodeToString(tvcBytes)}
keypair, err := ton.Crypto.GenerateRandomSignKeys()
if err != nil {
log.Error().Msg("Cannot generate random sign keys: " + err.Error())
return err
}
signer := domain.NewSignerKeys()
signer.Keys = *keypair
callSet := domain.CallSet{FunctionName: "getDePoolInfo"}
res, err := ton.Processing.ProcessMessage(&domain.ParamsOfProcessMessage{
MessageEncodeParams: &domain.ParamsOfEncodeMessage{
Type: "EncodingParams",
Abi: abiValue,
Signer: signer,
DeploySet: &deploySet,
CallSet: &callSet}, SendEvents: false}, nil)
if err != nil {
return err
}
The error is:
{"code":23,"message":"Invalid parameters: invalid type: string \"ewo....==\", expected struct AbiContract at line 1 column 11281\nparams: {\"message_encode_params\":{\"type\":\"EncodingParams\",\"abi\":{\"type\":\"Contract\",\"value\":\"ewo...g==\"},\"deploy_set\":{\"tvc\":\"t...w==\",\"workchain_id\":0,\"initial_data\":null},\"call_set\":{\"function_name\":\"getDePoolInfo\"},\"signer\":{\"type\":\"Keys\",\"keys\":{\"public\":\"65080f686abf47fc23ac6dd649ef473ec33a4eed53a978975d7b0ca812f54a6f\",\"secret\":\"01a9674e7227efcc864d33acfd59563b75fefa21478566f1994031f4a2b73f71\"}},\"processing_try_index\":0},\"send_events\":false}","data":{"core_version":"1.13.0"}
Any advices please?
The SDK version is 1.13.0, could it be the problem?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.