Skip to content

Commit c14bfbb

Browse files
Moved factory registration from core SDKs to end SDKs
Signed-off-by: Alexandros Filios <[email protected]>
1 parent 8fd15ce commit c14bfbb

File tree

41 files changed

+530
-221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+530
-221
lines changed

Diff for: integration/fabric/atsa/chaincode/atsa_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/atsa/chaincode"
1414
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/atsa/chaincode/views"
1515
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
16-
fabricsdk "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/sdk/dig"
1716
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/state"
1817
. "github.com/onsi/ginkgo/v2"
1918
. "github.com/onsi/gomega"
@@ -41,7 +40,7 @@ type TestSuite struct {
4140

4241
func NewTestSuite(commType fsc.P2PCommunicationType, nodeOpts *integration.ReplicationOptions) *TestSuite {
4342
return &TestSuite{integration.NewTestSuite(func() (*integration.Infrastructure, error) {
44-
return integration.Generate(StartPort(), true, chaincode.Topology(&fabricsdk.SDK{}, commType, nodeOpts)...)
43+
return integration.Generate(StartPort(), true, chaincode.Topology(&chaincode.SDK{}, commType, nodeOpts)...)
4544
})}
4645
}
4746

Diff for: integration/fabric/atsa/chaincode/sdk.go

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package chaincode
8+
9+
import (
10+
"errors"
11+
12+
"github.com/hyperledger-labs/fabric-smart-client/pkg/node"
13+
digutils "github.com/hyperledger-labs/fabric-smart-client/platform/common/utils/dig"
14+
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
15+
fabricsdk "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/sdk/dig"
16+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/core/id"
17+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/driver"
18+
view3 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view"
19+
"go.opentelemetry.io/otel/trace"
20+
)
21+
22+
type SDK struct {
23+
*fabricsdk.SDK
24+
}
25+
26+
func NewSDK(registry node.Registry) *SDK {
27+
return &SDK{SDK: fabricsdk.NewSDK(registry)}
28+
}
29+
30+
func (p *SDK) Install() error {
31+
if err := p.SDK.Install(); err != nil {
32+
return err
33+
}
34+
35+
return errors.Join(
36+
digutils.Register[trace.TracerProvider](p.Container()),
37+
digutils.Register[driver.EndpointService](p.Container()),
38+
digutils.Register[view3.IdentityProvider](p.Container()),
39+
digutils.Register[node.ViewManager](p.Container()), // Need to add it as a field in the node
40+
digutils.Register[id.SigService](p.Container()),
41+
digutils.Register[*fabric.NetworkServiceProvider](p.Container()), // GetFabricNetworkService is used by many components
42+
)
43+
}

Diff for: integration/fabric/atsa/fsc/sdk.go

+11
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ import (
1111

1212
"github.com/hyperledger-labs/fabric-smart-client/pkg/node"
1313
digutils "github.com/hyperledger-labs/fabric-smart-client/platform/common/utils/dig"
14+
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
1415
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/core"
1516
fabricsdk "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/sdk/dig"
1617
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/state"
18+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/core/id"
19+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/driver"
20+
view3 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view"
21+
"go.opentelemetry.io/otel/trace"
1722
)
1823

1924
type SDK struct {
@@ -32,5 +37,11 @@ func (p *SDK) Install() error {
3237
return errors.Join(
3338
digutils.Register[state.VaultService](p.Container()),
3439
digutils.Register[*core.FSNProvider](p.Container()),
40+
digutils.Register[trace.TracerProvider](p.Container()),
41+
digutils.Register[driver.EndpointService](p.Container()),
42+
digutils.Register[view3.IdentityProvider](p.Container()),
43+
digutils.Register[node.ViewManager](p.Container()), // Need to add it as a field in the node
44+
digutils.Register[id.SigService](p.Container()),
45+
digutils.Register[*fabric.NetworkServiceProvider](p.Container()), // GetFabricNetworkService is used by many components
3546
)
3647
}

Diff for: integration/fabric/events/chaincode/events_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/events/chaincode/views"
1515
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric"
1616
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
17-
fabricsdk "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/sdk/dig"
1817
. "github.com/onsi/ginkgo/v2"
1918
. "github.com/onsi/gomega"
2019
)
@@ -47,7 +46,7 @@ type TestSuite struct {
4746

4847
func NewTestSuite(commType fsc.P2PCommunicationType, nodeOpts *integration.ReplicationOptions) *TestSuite {
4948
return &TestSuite{integration.NewTestSuite(func() (*integration.Infrastructure, error) {
50-
return integration.Generate(StartPort(), true, chaincode.Topology(&fabricsdk.SDK{}, commType, nodeOpts)...)
49+
return integration.Generate(StartPort(), true, chaincode.Topology(&chaincode.SDK{}, commType, nodeOpts)...)
5150
})}
5251
}
5352

Diff for: integration/fabric/events/chaincode/sdk.go

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package chaincode
8+
9+
import (
10+
"errors"
11+
12+
"github.com/hyperledger-labs/fabric-smart-client/pkg/node"
13+
digutils "github.com/hyperledger-labs/fabric-smart-client/platform/common/utils/dig"
14+
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
15+
fabricsdk "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/sdk/dig"
16+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/core/id"
17+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/driver"
18+
view3 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view"
19+
"go.opentelemetry.io/otel/trace"
20+
)
21+
22+
type SDK struct {
23+
*fabricsdk.SDK
24+
}
25+
26+
func NewSDK(registry node.Registry) *SDK {
27+
return &SDK{SDK: fabricsdk.NewSDK(registry)}
28+
}
29+
30+
func (p *SDK) Install() error {
31+
if err := p.SDK.Install(); err != nil {
32+
return err
33+
}
34+
35+
return errors.Join(
36+
digutils.Register[trace.TracerProvider](p.Container()),
37+
digutils.Register[driver.EndpointService](p.Container()),
38+
digutils.Register[view3.IdentityProvider](p.Container()),
39+
digutils.Register[node.ViewManager](p.Container()), // Need to add it as a field in the node
40+
digutils.Register[id.SigService](p.Container()),
41+
digutils.Register[*fabric.NetworkServiceProvider](p.Container()), // GetFabricNetworkService is used by many components
42+
)
43+
}

Diff for: integration/fabric/iou/sdk.go

+11
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ import (
1212
"github.com/hyperledger-labs/fabric-smart-client/pkg/node"
1313
dig2 "github.com/hyperledger-labs/fabric-smart-client/platform/common/sdk/dig"
1414
digutils "github.com/hyperledger-labs/fabric-smart-client/platform/common/utils/dig"
15+
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
1516
sdk "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/sdk/dig"
1617
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/state"
18+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/core/id"
19+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/driver"
20+
view3 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view"
21+
"go.opentelemetry.io/otel/trace"
1722
)
1823

1924
type SDK struct {
@@ -31,5 +36,11 @@ func (p *SDK) Install() error {
3136

3237
return errors.Join(
3338
digutils.Register[state.VaultService](p.Container()),
39+
digutils.Register[trace.TracerProvider](p.Container()),
40+
digutils.Register[driver.EndpointService](p.Container()),
41+
digutils.Register[view3.IdentityProvider](p.Container()),
42+
digutils.Register[node.ViewManager](p.Container()), // Need to add it as a field in the node
43+
digutils.Register[id.SigService](p.Container()),
44+
digutils.Register[*fabric.NetworkServiceProvider](p.Container()), // GetFabricNetworkService is used by many components
3445
)
3546
}

Diff for: integration/fabric/stoprestart/sdk.go

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package stoprestart
8+
9+
import (
10+
"errors"
11+
12+
"github.com/hyperledger-labs/fabric-smart-client/pkg/node"
13+
digutils "github.com/hyperledger-labs/fabric-smart-client/platform/common/utils/dig"
14+
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
15+
fabricsdk "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/sdk/dig"
16+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/core/id"
17+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/driver"
18+
view3 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view"
19+
"go.opentelemetry.io/otel/trace"
20+
)
21+
22+
type SDK struct {
23+
*fabricsdk.SDK
24+
}
25+
26+
func NewSDK(registry node.Registry) *SDK {
27+
return &SDK{SDK: fabricsdk.NewSDK(registry)}
28+
}
29+
30+
func (p *SDK) Install() error {
31+
if err := p.SDK.Install(); err != nil {
32+
return err
33+
}
34+
35+
return errors.Join(
36+
digutils.Register[trace.TracerProvider](p.Container()),
37+
digutils.Register[driver.EndpointService](p.Container()),
38+
digutils.Register[view3.IdentityProvider](p.Container()),
39+
digutils.Register[node.ViewManager](p.Container()), // Need to add it as a field in the node
40+
digutils.Register[id.SigService](p.Container()),
41+
digutils.Register[*fabric.NetworkServiceProvider](p.Container()), // GetFabricNetworkService is used by many components
42+
)
43+
}

Diff for: integration/fabric/stoprestart/stoprestart_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"time"
1111

1212
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
13-
fabricsdk "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/sdk/dig"
1413
. "github.com/onsi/ginkgo/v2"
1514
. "github.com/onsi/gomega"
1615

@@ -65,7 +64,7 @@ type TestSuite struct {
6564

6665
func NewTestSuite(commType fsc.P2PCommunicationType, nodeOpts *integration.ReplicationOptions) *TestSuite {
6766
return &TestSuite{integration.NewTestSuite(func() (*integration.Infrastructure, error) {
68-
return integration.Generate(StartPort(), true, stoprestart.Topology(&fabricsdk.SDK{}, commType, nodeOpts)...)
67+
return integration.Generate(StartPort(), true, stoprestart.Topology(&stoprestart.SDK{}, commType, nodeOpts)...)
6968
})}
7069
}
7170

Diff for: integration/fabric/twonets/sdk.go

+11
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ import (
1212
"github.com/hyperledger-labs/fabric-smart-client/pkg/node"
1313
dig2 "github.com/hyperledger-labs/fabric-smart-client/platform/common/sdk/dig"
1414
digutils "github.com/hyperledger-labs/fabric-smart-client/platform/common/utils/dig"
15+
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
1516
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/core"
1617
fabricsdk "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/sdk/dig"
18+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/core/id"
19+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/driver"
20+
view3 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view"
21+
"go.opentelemetry.io/otel/trace"
1722
)
1823

1924
type SDK struct {
@@ -31,5 +36,11 @@ func (p *SDK) Install() error {
3136

3237
return errors.Join(
3338
digutils.Register[*core.FSNProvider](p.Container()),
39+
digutils.Register[trace.TracerProvider](p.Container()),
40+
digutils.Register[driver.EndpointService](p.Container()),
41+
digutils.Register[view3.IdentityProvider](p.Container()),
42+
digutils.Register[node.ViewManager](p.Container()), // Need to add it as a field in the node
43+
digutils.Register[id.SigService](p.Container()),
44+
digutils.Register[*fabric.NetworkServiceProvider](p.Container()), // GetFabricNetworkService is used by many components
3445
)
3546
}

Diff for: integration/fabric/weaver/relay/sdk.go

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import (
1515
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
1616
fabricsdk "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/sdk/dig"
1717
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/weaver"
18+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/core/id"
19+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/driver"
20+
view3 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view"
21+
"go.opentelemetry.io/otel/trace"
1822
"go.uber.org/dig"
1923
)
2024

@@ -42,5 +46,11 @@ func (p *SDK) Install() error {
4246

4347
return errors.Join(
4448
digutils.Register[Provider](p.Container()),
49+
digutils.Register[trace.TracerProvider](p.Container()),
50+
digutils.Register[driver.EndpointService](p.Container()),
51+
digutils.Register[view3.IdentityProvider](p.Container()),
52+
digutils.Register[node.ViewManager](p.Container()), // Need to add it as a field in the node
53+
digutils.Register[id.SigService](p.Container()),
54+
digutils.Register[*fabric.NetworkServiceProvider](p.Container()), // GetFabricNetworkService is used by many components
4555
)
4656
}

Diff for: integration/fsc/pingpong/cmd/initiator/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import (
1010
"github.com/hyperledger-labs/fabric-smart-client/integration/fsc/pingpong"
1111
"github.com/hyperledger-labs/fabric-smart-client/integration/fsc/pingpong/mock"
1212
fscnode "github.com/hyperledger-labs/fabric-smart-client/node"
13+
"github.com/hyperledger-labs/fabric-smart-client/platform/common/utils"
1314
"github.com/hyperledger-labs/fabric-smart-client/platform/view"
1415
)
1516

1617
func main() {
17-
node := fscnode.New()
18+
node := fscnode.NewEmpty("")
19+
utils.Must(node.InstallSDK(pingpong.NewSDK(node)))
1820
node.Execute(func() error {
1921
registry := view.GetRegistry(node)
2022
if err := registry.RegisterFactory("init", &pingpong.InitiatorViewFactory{}); err != nil {

Diff for: integration/fsc/pingpong/cmd/responder/main.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ import (
1010
"github.com/hyperledger-labs/fabric-smart-client/integration/fsc/pingpong"
1111
"github.com/hyperledger-labs/fabric-smart-client/integration/fsc/pingpong/mock"
1212
fscnode "github.com/hyperledger-labs/fabric-smart-client/node"
13+
"github.com/hyperledger-labs/fabric-smart-client/platform/common/utils"
1314
"github.com/hyperledger-labs/fabric-smart-client/platform/view"
15+
registry2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/core/registry"
1416
)
1517

1618
func main() {
17-
node := fscnode.New()
19+
node := fscnode.NewEmpty("")
20+
utils.Must(node.InstallSDK(pingpong.NewSDK(node)))
1821
node.Execute(func() error {
1922
registry := view.GetRegistry(node)
20-
initiatorID := registry.GetIdentifier(&pingpong.Initiator{})
23+
initiatorID := registry2.GetIdentifier(&pingpong.Initiator{})
2124
if err := registry.RegisterResponder(&pingpong.Responder{}, initiatorID); err != nil {
2225
return err
2326
}

Diff for: integration/fsc/pingpong/pingpong_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
2121
"github.com/hyperledger-labs/fabric-smart-client/pkg/api"
2222
"github.com/hyperledger-labs/fabric-smart-client/pkg/node"
23-
viewsdk "github.com/hyperledger-labs/fabric-smart-client/platform/view/sdk/dig"
2423
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/client/web"
2524
. "github.com/onsi/ginkgo/v2"
2625
. "github.com/onsi/gomega"
@@ -194,7 +193,7 @@ var _ = Describe("EndToEnd", func() {
194193
func newNode(conf string) api.FabricSmartClientNode {
195194
n := node.NewEmpty(conf)
196195
Expect(n).NotTo(BeNil())
197-
n.AddSDK(viewsdk.NewSDK(n.Registry()))
196+
n.AddSDK(pingpong.NewSDK(n))
198197
return n
199198
}
200199

Diff for: integration/fsc/pingpong/sdk.go

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package pingpong
8+
9+
import (
10+
"errors"
11+
12+
"github.com/hyperledger-labs/fabric-smart-client/pkg/node"
13+
digutils "github.com/hyperledger-labs/fabric-smart-client/platform/common/utils/dig"
14+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/core/id"
15+
"github.com/hyperledger-labs/fabric-smart-client/platform/view/driver"
16+
sdk "github.com/hyperledger-labs/fabric-smart-client/platform/view/sdk/dig"
17+
view3 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/server/view"
18+
"go.opentelemetry.io/otel/trace"
19+
)
20+
21+
type SDK struct {
22+
*sdk.SDK
23+
}
24+
25+
func NewSDK(registry node.Registry) *SDK {
26+
return &SDK{SDK: sdk.NewSDK(registry)}
27+
}
28+
29+
func (p *SDK) Install() error {
30+
if err := p.SDK.Install(); err != nil {
31+
return err
32+
}
33+
34+
return errors.Join(
35+
digutils.Register[trace.TracerProvider](p.Container()),
36+
digutils.Register[driver.EndpointService](p.Container()),
37+
digutils.Register[view3.IdentityProvider](p.Container()),
38+
digutils.Register[node.ViewManager](p.Container()), // Need to add it as a field in the node
39+
digutils.Register[id.SigService](p.Container()),
40+
)
41+
}

0 commit comments

Comments
 (0)