Skip to content
Merged
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
12 changes: 8 additions & 4 deletions book/src/framework/components/blockchains/ton.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ The genesis container supports additional environment variables that can be conf
The custom_env parameters will override the default genesis container environment variables, allowing you to customize blockchain configuration as needed.
More info on parameters can be found here <https://github.com/neodix42/mylocalton-docker/wiki/Genesis-setup-parameters>.

## Network Configuration

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.

## Default Ports

The TON implementation exposes essential services:

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

> 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.

> 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`.

## Usage

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

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

// Add connections from the config
Expand Down
1 change: 1 addition & 0 deletions framework/.changeset/v0.10.21.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Update TON network output to embed LiteServer configuration directly
9 changes: 5 additions & 4 deletions framework/components/blockchain/ton.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import (

const (
DefaultTonSimpleServerPort = "8000"
liteServerPortOffset = 100 // internal, arbitrary offset for lite server port
// NOTE: Prefunded high-load wallet from MyLocalTon pre-funded wallet, that can send up to 254 messages per 1 external message
// https://docs.ton.org/v3/documentation/smart-contracts/contracts-specs/highload-wallet#highload-wallet-v2
DefaultTonHlWalletAddress = "-1:5ee77ced0b7ae6ef88ab3f4350d8872c64667ffbe76073455215d3cdfab3294b"
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"

liteServerPortOffset = 100 // internal, arbitrary offset for lite server port
)

type portMapping struct {
Expand Down Expand Up @@ -138,9 +139,9 @@ func newTon(in *Input) (*Output, error) {
ContainerName: name,
Container: c,
Nodes: []*Node{{
// Note: define if we need more access other than the global config(tonutils-go only uses liteclients defined in the config)
ExternalHTTPUrl: fmt.Sprintf("%s:%s", "localhost", ports.SimpleServer),
InternalHTTPUrl: fmt.Sprintf("%s:%s", name, DefaultTonSimpleServerPort),
// URLs now include the full config path for direct use with liteclient.GetConfigFromUrl()
ExternalHTTPUrl: fmt.Sprintf("http://localhost:%s/localhost.global.config.json", ports.SimpleServer),
InternalHTTPUrl: fmt.Sprintf("http://%s:%s/localhost.global.config.json", name, DefaultTonSimpleServerPort),
}},
}, nil
}
2 changes: 0 additions & 2 deletions framework/examples/myproject/smoke_ton.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@
port = "8000"

[blockchain_a.custom_env]
EMBEDDED_FILE_HTTP_SERVER = "true"
EMBEDDED_FILE_HTTP_SERVER_PORT = "8000"
4 changes: 2 additions & 2 deletions framework/examples/myproject/smoke_ton_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package examples

import (
"fmt"
"strings"
"testing"

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

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

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