@@ -19,14 +19,21 @@ const (
1919 TokenExpiry = time .Hour * 24 * 365 * 10 // 10 years
2020)
2121
22+ type CantonData struct {
23+ // Docker internal endpoints, only reachable if connected to the same Docker network (framework.DefaultNetworkName)
24+ InternalEndpoints CantonEndpoints `toml:"internal_endpoints" comment:"Docker-internal endpoints, only reachable from containers connected to the same networks"`
25+ // External endpoints, reachable from the Docker host
26+ ExternalEndpoints CantonEndpoints `toml:"external_endpoints" comment:"Docker-external endpoints, only reachable from the Docker host"`
27+ }
28+
2229type CantonEndpoints struct {
2330 // ScanAPIURL https://docs.sync.global/app_dev/scan_api/index.html
2431 ScanAPIURL string `toml:"scan_api_url" comment:"https://docs.sync.global/app_dev/scan_api/index.html"`
2532 // RegistryAPIURL https://docs.sync.global/app_dev/token_standard/index.html#api-references
2633 RegistryAPIURL string `toml:"registry_api_url" comment:"https://docs.sync.global/app_dev/token_standard/index.html#api-references"`
2734
2835 // SuperValidator The endpoints for the super validator
29- SuperValidator CantonParticipantEndpoints `toml:"super_validator" comment:"Canton network super validator"`
36+ SuperValidator CantonParticipantEndpoints `toml:"super_validator" comment:"Canton super validator endpoints "`
3037 // Participants The endpoints for the participants, in order from participant1 to participantN - depending on the number of validators requested
3138 Participants []CantonParticipantEndpoints `toml:"participants" comment:"Canton participant endpoints"`
3239}
@@ -119,7 +126,7 @@ func newCanton(ctx context.Context, in *Input) (*Output, error) {
119126 }
120127
121128 // Set up Nginx container
122- nginxReq := canton .NginxContainerRequest (in .NumberOfCantonValidators , in .Port , cantonReq .Name , spliceReq .Name )
129+ nginxReq , nginxContainerName := canton .NginxContainerRequest (in .NumberOfCantonValidators , in .Port , cantonReq .Name , spliceReq .Name )
123130 nginxContainer , err := testcontainers .GenericContainer (ctx , testcontainers.GenericContainerRequest {
124131 ContainerRequest : nginxReq ,
125132 Started : true ,
@@ -133,6 +140,7 @@ func newCanton(ctx context.Context, in *Input) (*Output, error) {
133140 return nil , err
134141 }
135142
143+ // Add SV info to output
136144 svUser := "user-sv"
137145 svToken , err := jwt .NewWithClaims (jwt .SigningMethodHS256 , jwt.RegisteredClaims {
138146 Issuer : "" ,
@@ -146,21 +154,40 @@ func newCanton(ctx context.Context, in *Input) (*Output, error) {
146154 if err != nil {
147155 return nil , fmt .Errorf ("failed to create token for sv: %w" , err )
148156 }
149- endpoints := & CantonEndpoints {
150- ScanAPIURL : fmt .Sprintf ("http://scan.%s:%s/api/scan" , host , in .Port ),
151- RegistryAPIURL : fmt .Sprintf ("http://scan.%s:%s" , host , in .Port ), // Don't add /registry to URL as this is part of the OpenAPI spec and the base URL should point to the root
152- SuperValidator : CantonParticipantEndpoints {
153- JSONLedgerAPIURL : fmt .Sprintf ("http://sv.json-ledger-api.%s:%s" , host , in .Port ),
154- GRPCLedgerAPIURL : fmt .Sprintf ("sv.grpc-ledger-api.%s:%s" , host , in .Port ),
155- AdminAPIURL : fmt .Sprintf ("sv.admin-api.%s:%s" , host , in .Port ),
156- ValidatorAPIURL : fmt .Sprintf ("http://sv.validator-api.%s:%s/api/validator" , host , in .Port ),
157- HTTPHealthCheckURL : fmt .Sprintf ("http://sv.http-health-check.%s:%s" , host , in .Port ),
158- GRPCHealthCheckURL : fmt .Sprintf ("sv.grpc-health-check.%s:%s" , host , in .Port ),
159- UserID : svUser ,
160- JWT : svToken ,
157+ data := & CantonData {
158+ InternalEndpoints : CantonEndpoints {
159+ ScanAPIURL : fmt .Sprintf ("http://scan.%s:%d/api/scan" , nginxContainerName , canton .DefaultNginxInternalPort ),
160+ RegistryAPIURL : fmt .Sprintf ("http://scan.%s:%d" , nginxContainerName , canton .DefaultNginxInternalPort ), // Don't add /registry to URL as this is part of the OpenAPI spec and the base URL should point to the root
161+ SuperValidator : CantonParticipantEndpoints {
162+ JSONLedgerAPIURL : fmt .Sprintf ("http://sv.json-ledger-api.%s:%d" , nginxContainerName , canton .DefaultNginxInternalPort ),
163+ GRPCLedgerAPIURL : fmt .Sprintf ("sv.grpc-ledger-api.%s:%d" , nginxContainerName , canton .DefaultNginxInternalPort ),
164+ AdminAPIURL : fmt .Sprintf ("sv.admin-api.%s:%d" , nginxContainerName , canton .DefaultNginxInternalPort ),
165+ ValidatorAPIURL : fmt .Sprintf ("http://sv.validator-api.%s:%d/api/validator" , nginxContainerName , canton .DefaultNginxInternalPort ),
166+ HTTPHealthCheckURL : fmt .Sprintf ("http://sv.http-health-check.%s:%d" , nginxContainerName , canton .DefaultNginxInternalPort ),
167+ GRPCHealthCheckURL : fmt .Sprintf ("sv.grpc-health-check.%s:%d" , nginxContainerName , canton .DefaultNginxInternalPort ),
168+ UserID : svUser ,
169+ JWT : svToken ,
170+ },
171+ Participants : make ([]CantonParticipantEndpoints , 0 , in .NumberOfCantonValidators ),
172+ },
173+ ExternalEndpoints : CantonEndpoints {
174+ ScanAPIURL : fmt .Sprintf ("http://scan.%s:%s/api/scan" , host , in .Port ),
175+ RegistryAPIURL : fmt .Sprintf ("http://scan.%s:%s" , host , in .Port ), // Don't add /registry to URL as this is part of the OpenAPI spec and the base URL should point to the root
176+ SuperValidator : CantonParticipantEndpoints {
177+ JSONLedgerAPIURL : fmt .Sprintf ("http://sv.json-ledger-api.%s:%s" , host , in .Port ),
178+ GRPCLedgerAPIURL : fmt .Sprintf ("sv.grpc-ledger-api.%s:%s" , host , in .Port ),
179+ AdminAPIURL : fmt .Sprintf ("sv.admin-api.%s:%s" , host , in .Port ),
180+ ValidatorAPIURL : fmt .Sprintf ("http://sv.validator-api.%s:%s/api/validator" , host , in .Port ),
181+ HTTPHealthCheckURL : fmt .Sprintf ("http://sv.http-health-check.%s:%s" , host , in .Port ),
182+ GRPCHealthCheckURL : fmt .Sprintf ("sv.grpc-health-check.%s:%s" , host , in .Port ),
183+ UserID : svUser ,
184+ JWT : svToken ,
185+ },
186+ Participants : make ([]CantonParticipantEndpoints , 0 , in .NumberOfCantonValidators ),
161187 },
162- Participants : nil ,
163188 }
189+
190+ // Add Participant info to output
164191 for i := 1 ; i <= in .NumberOfCantonValidators ; i ++ {
165192 participantUser := fmt .Sprintf ("user-participant%v" , i )
166193 token , err := jwt .NewWithClaims (jwt .SigningMethodHS256 , jwt.RegisteredClaims {
@@ -175,7 +202,17 @@ func newCanton(ctx context.Context, in *Input) (*Output, error) {
175202 if err != nil {
176203 return nil , fmt .Errorf ("failed to create token for participant%v: %w" , i , err )
177204 }
178- participantEndpoints := CantonParticipantEndpoints {
205+ data .InternalEndpoints .Participants = append (data .InternalEndpoints .Participants , CantonParticipantEndpoints {
206+ JSONLedgerAPIURL : fmt .Sprintf ("http://participant%d.json-ledger-api.%s:%d" , i , nginxContainerName , canton .DefaultNginxInternalPort ),
207+ GRPCLedgerAPIURL : fmt .Sprintf ("participant%d.grpc-ledger-api.%s:%d" , i , nginxContainerName , canton .DefaultNginxInternalPort ),
208+ AdminAPIURL : fmt .Sprintf ("participant%d.admin-api.%s:%d" , i , nginxContainerName , canton .DefaultNginxInternalPort ),
209+ ValidatorAPIURL : fmt .Sprintf ("http://participant%d.validator-api.%s:%d/api/validator" , i , nginxContainerName , canton .DefaultNginxInternalPort ),
210+ HTTPHealthCheckURL : fmt .Sprintf ("http://participant%d.http-health-check.%s:%d" , i , nginxContainerName , canton .DefaultNginxInternalPort ),
211+ GRPCHealthCheckURL : fmt .Sprintf ("participant%d.grpc-health-check.%s:%d" , i , nginxContainerName , canton .DefaultNginxInternalPort ),
212+ UserID : participantUser ,
213+ JWT : token ,
214+ })
215+ data .ExternalEndpoints .Participants = append (data .ExternalEndpoints .Participants , CantonParticipantEndpoints {
179216 JSONLedgerAPIURL : fmt .Sprintf ("http://participant%d.json-ledger-api.%s:%s" , i , host , in .Port ),
180217 GRPCLedgerAPIURL : fmt .Sprintf ("participant%d.grpc-ledger-api.%s:%s" , i , host , in .Port ),
181218 AdminAPIURL : fmt .Sprintf ("participant%d.admin-api.%s:%s" , i , host , in .Port ),
@@ -184,8 +221,7 @@ func newCanton(ctx context.Context, in *Input) (*Output, error) {
184221 GRPCHealthCheckURL : fmt .Sprintf ("participant%d.grpc-health-check.%s:%s" , i , host , in .Port ),
185222 UserID : participantUser ,
186223 JWT : token ,
187- }
188- endpoints .Participants = append (endpoints .Participants , participantEndpoints )
224+ })
189225 }
190226
191227 return & Output {
@@ -195,7 +231,7 @@ func newCanton(ctx context.Context, in *Input) (*Output, error) {
195231 ChainID : in .ChainID ,
196232 ContainerName : nginxReq .Name ,
197233 NetworkSpecificData : & NetworkSpecificData {
198- CantonEndpoints : endpoints ,
234+ CantonData : data ,
199235 },
200236 }, nil
201237}
0 commit comments