Skip to content

Commit cd13344

Browse files
authored
TON: include liteserver config url in the node output (#2088)
* feat: embed network config in output * chore: changeset * fix: remove debug sleep
1 parent 69e20bc commit cd13344

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

book/src/framework/components/blockchains/ton.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ The genesis container supports additional environment variables that can be conf
2828
The custom_env parameters will override the default genesis container environment variables, allowing you to customize blockchain configuration as needed.
2929
More info on parameters can be found here <https://github.com/neodix42/mylocalton-docker/wiki/Genesis-setup-parameters>.
3030

31+
## Network Configuration
32+
33+
The framework provides seamless access to the TON network configuration by embedding the config URL directly in the node URLs. The `ExternalHTTPUrl` and `InternalHTTPUrl` include the full path to `localhost.global.config.json`, which can be used directly with `liteclient.GetConfigFromUrl()` without additional URL formatting.
34+
3135
## Default Ports
3236

3337
The TON implementation exposes essential services:
3438

3539
* TON Simple HTTP Server: Port 8000
3640
* TON Lite Server: Port derived from base port + 100
3741

38-
> Note: `tonutils-go` library is used for TON blockchain interactions, which requires a TON Lite Server connection. `tonutils-go` queries config file to determine the Lite Server connection details, which are provided by the MyLocalTon Docker environment.
39-
42+
> Note: `tonutils-go` library is used for TON blockchain interactions, which requires a TON Lite Server connection. The framework embeds the config URL directly in the node URLs for convenient access to the global configuration file needed by `tonutils-go`.
4043
4144
## Usage
4245

@@ -75,8 +78,9 @@ func TestTonSmoke(t *testing.T) {
7578
// Create a connection pool
7679
connectionPool := liteclient.NewConnectionPool()
7780

78-
// Get the network configuration from the global config URL
79-
cfg, cferr := liteclient.GetConfigFromUrl(t.Context(), fmt.Sprintf("http://%s/localhost.global.config.json", bc.Nodes[0].ExternalHTTPUrl))
81+
// Get the network configuration directly from the embedded config URL
82+
// The ExternalHTTPUrl already includes the full path to localhost.global.config.json
83+
cfg, cferr := liteclient.GetConfigFromUrl(t.Context(), bc.Nodes[0].ExternalHTTPUrl)
8084
require.NoError(t, cferr, "Failed to get config from URL")
8185

8286
// Add connections from the config

framework/.changeset/v0.10.21.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Update TON network output to embed LiteServer configuration directly

framework/components/blockchain/ton.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ import (
1616

1717
const (
1818
DefaultTonSimpleServerPort = "8000"
19-
liteServerPortOffset = 100 // internal, arbitrary offset for lite server port
2019
// NOTE: Prefunded high-load wallet from MyLocalTon pre-funded wallet, that can send up to 254 messages per 1 external message
2120
// https://docs.ton.org/v3/documentation/smart-contracts/contracts-specs/highload-wallet#highload-wallet-v2
2221
DefaultTonHlWalletAddress = "-1:5ee77ced0b7ae6ef88ab3f4350d8872c64667ffbe76073455215d3cdfab3294b"
2322
DefaultTonHlWalletMnemonic = "twenty unfair stay entry during please water april fabric morning length lumber style tomorrow melody similar forum width ride render void rather custom coin"
23+
24+
liteServerPortOffset = 100 // internal, arbitrary offset for lite server port
2425
)
2526

2627
type portMapping struct {
@@ -138,9 +139,9 @@ func newTon(in *Input) (*Output, error) {
138139
ContainerName: name,
139140
Container: c,
140141
Nodes: []*Node{{
141-
// Note: define if we need more access other than the global config(tonutils-go only uses liteclients defined in the config)
142-
ExternalHTTPUrl: fmt.Sprintf("%s:%s", "localhost", ports.SimpleServer),
143-
InternalHTTPUrl: fmt.Sprintf("%s:%s", name, DefaultTonSimpleServerPort),
142+
// URLs now include the full config path for direct use with liteclient.GetConfigFromUrl()
143+
ExternalHTTPUrl: fmt.Sprintf("http://localhost:%s/localhost.global.config.json", ports.SimpleServer),
144+
InternalHTTPUrl: fmt.Sprintf("http://%s:%s/localhost.global.config.json", name, DefaultTonSimpleServerPort),
144145
}},
145146
}, nil
146147
}

framework/examples/myproject/smoke_ton.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@
44
port = "8000"
55

66
[blockchain_a.custom_env]
7-
EMBEDDED_FILE_HTTP_SERVER = "true"
8-
EMBEDDED_FILE_HTTP_SERVER_PORT = "8000"

framework/examples/myproject/smoke_ton_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package examples
22

33
import (
4-
"fmt"
54
"strings"
65
"testing"
76

@@ -31,7 +30,8 @@ func TestTonSmoke(t *testing.T) {
3130

3231
t.Run("setup:connect", func(t *testing.T) {
3332
connectionPool := liteclient.NewConnectionPool()
34-
cfg, cferr := liteclient.GetConfigFromUrl(t.Context(), fmt.Sprintf("http://%s/localhost.global.config.json", bc.Nodes[0].ExternalHTTPUrl))
33+
// ExternalHTTPUrl already includes the full config path for direct use
34+
cfg, cferr := liteclient.GetConfigFromUrl(t.Context(), bc.Nodes[0].ExternalHTTPUrl)
3535

3636
require.NoError(t, cferr, "Failed to get config from URL")
3737
caerr := connectionPool.AddConnectionsFromConfig(t.Context(), cfg)

0 commit comments

Comments
 (0)