11package canton
22
33import (
4+ "golang.org/x/oauth2"
5+ "google.golang.org/grpc"
6+
7+ apiv2 "github.com/digital-asset/dazl-client/v8/go/api/com/daml/ledger/api/v2"
8+ adminv2 "github.com/digital-asset/dazl-client/v8/go/api/com/daml/ledger/api/v2/admin"
9+ participantv30 "github.com/digital-asset/dazl-client/v8/go/api/com/digitalasset/canton/admin/participant/v30"
10+
411 chaincommon "github.com/smartcontractkit/chainlink-deployments-framework/chain/internal/common"
512)
613
714type ChainMetadata = chaincommon.ChainMetadata
815
9- // Chain represents a Canton network instance used CLDF.
16+ // Chain represents a Canton network instance initialized by CLDF.
1017// It contains chain metadata and augments it with Canton-specific information.
1118// In particular, it tracks all known Canton participants and their connection
1219// details so that callers can discover and interact with the network's APIs.
@@ -22,15 +29,26 @@ type Chain struct {
2229// A participant hosts parties and their local ledger state, and mediates all
2330// interactions with the Canton ledger for those parties via its exposed APIs
2431// (ledger, admin, validator, etc.). It is identified by a human-readable
25- // name, provides a set of API endpoints, and uses a JWT provider to issue
32+ // name, provides a set of API endpoints, and uses a TokenSource to issue
2633// authentication tokens for secure access to those endpoints.
2734type Participant struct {
2835 // A human-readable name for the participant
2936 Name string
3037 // The endpoints to interact with the participant's APIs
3138 Endpoints ParticipantEndpoints
32- // A JWT provider instance to generate JWTs for authentication with the participant's APIs
33- JWTProvider JWTProvider
39+ // The set of service clients to interact with the participant's Ledger API.
40+ // All clients are ready-to-use and are already configured with the correct authentication.
41+ LedgerServices LedgerServiceClients
42+ // (Optional) The set of service clients to interact with the participant's Admin API.
43+ // Will only be populated if the participant has been configured with an Admin API URL
44+ AdminServices * AdminServiceClients
45+ // An OAuth2 token source to obtain access tokens for authentication with the participant's APIs
46+ TokenSource oauth2.TokenSource
47+ // The UserID that will be used to interact with this participant.
48+ // The TokenSource will return access tokens containing this UserID as a subject claim.
49+ UserID string
50+ // The PartyID that will be used to interact with this participant.
51+ PartyID string
3452}
3553
3654// ParticipantEndpoints holds all available API endpoints for a Canton participant
@@ -46,5 +64,87 @@ type ParticipantEndpoints struct {
4664 AdminAPIURL string
4765 // (HTTP) The URL to access the participant's Validator API
4866 // https://docs.sync.global/app_dev/validator_api/index.html
67+ // This also serves the Scan Proxy API, which provides access to the Global Scan and Token Standard APIs:
68+ // https://docs.sync.global/app_dev/validator_api/index.html#validator-api-scan-proxy
4969 ValidatorAPIURL string
5070}
71+
72+ // LedgerAdminServiceClients provides all available Ledger API admin gRPC service clients.
73+ type LedgerAdminServiceClients struct {
74+ CommandInspection adminv2.CommandInspectionServiceClient
75+ IdentityProviderConfig adminv2.IdentityProviderConfigServiceClient
76+ PackageManagement adminv2.PackageManagementServiceClient
77+ ParticipantPruning adminv2.ParticipantPruningServiceClient
78+ PartyManagement adminv2.PartyManagementServiceClient
79+ UserManagement adminv2.UserManagementServiceClient
80+ }
81+
82+ // LedgerServiceClients provides all available Ledger API gRPC service clients.
83+ type LedgerServiceClients struct {
84+ CommandCompletion apiv2.CommandCompletionServiceClient
85+ Command apiv2.CommandServiceClient
86+ CommandSubmission apiv2.CommandSubmissionServiceClient
87+ EventQuery apiv2.EventQueryServiceClient
88+ PackageService apiv2.PackageServiceClient
89+ State apiv2.StateServiceClient
90+ Update apiv2.UpdateServiceClient
91+ Version apiv2.VersionServiceClient
92+ // Ledger API admin clients
93+ // These endpoints can only be accessed if the user the participant has been configured with
94+ // has admin rights. Access with caution and only if you're certain that admin rights are available.
95+ Admin LedgerAdminServiceClients
96+ }
97+
98+ // CreateLedgerServiceClients creates all LedgerServiceClients given a gRPC client connection.
99+ func CreateLedgerServiceClients (conn grpc.ClientConnInterface ) LedgerServiceClients {
100+ return LedgerServiceClients {
101+ Admin : LedgerAdminServiceClients {
102+ CommandInspection : adminv2 .NewCommandInspectionServiceClient (conn ),
103+ IdentityProviderConfig : adminv2 .NewIdentityProviderConfigServiceClient (conn ),
104+ PackageManagement : adminv2 .NewPackageManagementServiceClient (conn ),
105+ ParticipantPruning : adminv2 .NewParticipantPruningServiceClient (conn ),
106+ PartyManagement : adminv2 .NewPartyManagementServiceClient (conn ),
107+ UserManagement : adminv2 .NewUserManagementServiceClient (conn ),
108+ },
109+ CommandCompletion : apiv2 .NewCommandCompletionServiceClient (conn ),
110+ Command : apiv2 .NewCommandServiceClient (conn ),
111+ CommandSubmission : apiv2 .NewCommandSubmissionServiceClient (conn ),
112+ EventQuery : apiv2 .NewEventQueryServiceClient (conn ),
113+ PackageService : apiv2 .NewPackageServiceClient (conn ),
114+ State : apiv2 .NewStateServiceClient (conn ),
115+ Update : apiv2 .NewUpdateServiceClient (conn ),
116+ Version : apiv2 .NewVersionServiceClient (conn ),
117+ }
118+ }
119+
120+ // AdminServiceClients provides all available Admin API service clients.
121+ // These services can only be accessed if the user the participant has been configured with has
122+ // admin rights.
123+ type AdminServiceClients struct {
124+ Package participantv30.PackageServiceClient
125+ ParticipantInspection participantv30.ParticipantInspectionServiceClient
126+ ParticipantRepair participantv30.ParticipantRepairServiceClient
127+ ParticipantStatus participantv30.ParticipantStatusServiceClient
128+ PartyManagement participantv30.PartyManagementServiceClient
129+ Ping participantv30.PingServiceClient
130+ Pruning participantv30.PruningServiceClient
131+ ResourceManagement participantv30.ResourceManagementServiceClient
132+ SynchronizerConnectivity participantv30.SynchronizerConnectivityServiceClient
133+ TrafficControl participantv30.TrafficControlServiceClient
134+ }
135+
136+ // CreateAdminServiceClients creates all AdminServiceClients given a gRPC client connection.
137+ func CreateAdminServiceClients (conn grpc.ClientConnInterface ) AdminServiceClients {
138+ return AdminServiceClients {
139+ Package : participantv30 .NewPackageServiceClient (conn ),
140+ ParticipantInspection : participantv30 .NewParticipantInspectionServiceClient (conn ),
141+ ParticipantRepair : participantv30 .NewParticipantRepairServiceClient (conn ),
142+ ParticipantStatus : participantv30 .NewParticipantStatusServiceClient (conn ),
143+ PartyManagement : participantv30 .NewPartyManagementServiceClient (conn ),
144+ Ping : participantv30 .NewPingServiceClient (conn ),
145+ Pruning : participantv30 .NewPruningServiceClient (conn ),
146+ ResourceManagement : participantv30 .NewResourceManagementServiceClient (conn ),
147+ SynchronizerConnectivity : participantv30 .NewSynchronizerConnectivityServiceClient (conn ),
148+ TrafficControl : participantv30 .NewTrafficControlServiceClient (conn ),
149+ }
150+ }
0 commit comments