diff --git a/book/src/framework/components/blockchains/ton.md b/book/src/framework/components/blockchains/ton.md index a861b1146..d6fadd971 100644 --- a/book/src/framework/components/blockchains/ton.md +++ b/book/src/framework/components/blockchains/ton.md @@ -28,6 +28,10 @@ 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 . +## 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: @@ -35,8 +39,7 @@ 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 @@ -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 diff --git a/framework/.changeset/v0.10.21.md b/framework/.changeset/v0.10.21.md new file mode 100644 index 000000000..c56c636b1 --- /dev/null +++ b/framework/.changeset/v0.10.21.md @@ -0,0 +1 @@ +- Update TON network output to embed LiteServer configuration directly diff --git a/framework/components/blockchain/ton.go b/framework/components/blockchain/ton.go index 21be42a24..58ff7b73b 100644 --- a/framework/components/blockchain/ton.go +++ b/framework/components/blockchain/ton.go @@ -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 { @@ -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 } diff --git a/framework/examples/myproject/smoke_ton.toml b/framework/examples/myproject/smoke_ton.toml index 0ebdd5e39..0efb0de3a 100644 --- a/framework/examples/myproject/smoke_ton.toml +++ b/framework/examples/myproject/smoke_ton.toml @@ -4,5 +4,3 @@ port = "8000" [blockchain_a.custom_env] - EMBEDDED_FILE_HTTP_SERVER = "true" - EMBEDDED_FILE_HTTP_SERVER_PORT = "8000" diff --git a/framework/examples/myproject/smoke_ton_test.go b/framework/examples/myproject/smoke_ton_test.go index 8d1db70f5..bc670845d 100644 --- a/framework/examples/myproject/smoke_ton_test.go +++ b/framework/examples/myproject/smoke_ton_test.go @@ -1,7 +1,6 @@ package examples import ( - "fmt" "strings" "testing" @@ -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)