Skip to content

Commit 5e4f74c

Browse files
fixup! Register optional dig dependency
Signed-off-by: Alexandros Filios <[email protected]>
1 parent 8f83ce0 commit 5e4f74c

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

Diff for: integration/fabric/atsa/fsc/views/issue.go

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

1212
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/atsa/fsc/states"
13-
"github.com/hyperledger-labs/fabric-smart-client/platform/common/utils"
1413
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
1514
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/state"
1615
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/assert"
@@ -37,7 +36,7 @@ func (f *IssueView) Call(context view.Context) (interface{}, error) {
3736
assert.NoError(err, "failed getting recipient identity")
3837

3938
// The issuer creates a new transaction
40-
tx, err := state.NewTransaction(utils.MustGet(fabric.GetNetworkServiceProvider(context)), context)
39+
tx, err := state.NewTransaction(context)
4140
assert.NoError(err, "failed creating transaction")
4241

4342
// Sets the namespace where the state should be stored

Diff for: integration/fabric/iou/views/borrower.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (i *CreateIOUView) Call(context view.Context) (interface{}, error) {
4646
assert.NoError(err, "failed exchanging recipient identity")
4747

4848
// The borrower creates a new transaction
49-
tx, err := state.NewTransaction(i.fnsProvider, context)
49+
tx, err := i.stateView.NewTransaction(context)
5050
assert.NoError(err, "failed creating a new transaction")
5151

5252
// Sets the namespace where the state should be stored
@@ -132,7 +132,7 @@ type UpdateIOUView struct {
132132

133133
func (u UpdateIOUView) Call(context view.Context) (interface{}, error) {
134134
// The borrower starts by creating a new transaction to update the IOU state
135-
tx, err := state.NewTransaction(u.fnsProvider, context)
135+
tx, err := u.stateView.NewTransaction(context)
136136
assert.NoError(err)
137137

138138
// Sets the namespace where the state is stored

Diff for: platform/fabric/services/state/factory.go

+8
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ package state
99
import (
1010
"time"
1111

12+
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
1213
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/endorser"
1314
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
1415
)
1516

1617
func NewViewFactory(
18+
fnsProvider *fabric.NetworkServiceProvider,
1719
endorseView *endorser.EndorseViewFactory,
1820
finalityView *endorser.FinalityViewFactory,
1921
collectEndorsementsView *endorser.CollectEndorsementsViewFactory,
@@ -23,6 +25,7 @@ func NewViewFactory(
2325
receiveTransactionView *ReceiveTransactionViewFactory,
2426
) *ViewFactory {
2527
return &ViewFactory{
28+
fnsProvider: fnsProvider,
2629
endorseView: endorseView,
2730
finalityView: finalityView,
2831
collectEndorsementsView: collectEndorsementsView,
@@ -34,6 +37,7 @@ func NewViewFactory(
3437
}
3538

3639
type ViewFactory struct {
40+
fnsProvider *fabric.NetworkServiceProvider
3741
endorseView *endorser.EndorseViewFactory
3842
finalityView *endorser.FinalityViewFactory
3943
collectEndorsementsView *endorser.CollectEndorsementsViewFactory
@@ -43,6 +47,10 @@ type ViewFactory struct {
4347
receiveTransactionView *ReceiveTransactionViewFactory
4448
}
4549

50+
func (f *ViewFactory) NewTransaction(context view.Context) (*Transaction, error) {
51+
return newTransaction(f.fnsProvider, context)
52+
}
53+
4654
func (f *ViewFactory) NewEndorseView(tx *Transaction, ids ...view.Identity) view.View {
4755
return f.endorseView.New(tx.tx, ids...)
4856
}

Diff for: platform/fabric/services/state/transaction.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ func Wrap(tx *endorser.Transaction) (*Transaction, error) {
3535
}
3636

3737
// NewTransaction returns a new instance of a state-based transaction that embeds a single namespace.
38-
func NewTransaction(fnsProvider *fabric.NetworkServiceProvider, context view.Context) (*Transaction, error) {
38+
func NewTransaction(context view.Context) (*Transaction, error) {
39+
return newTransaction(utils.MustGet(fabric.GetNetworkServiceProvider(context)), context)
40+
}
41+
42+
func newTransaction(fnsProvider *fabric.NetworkServiceProvider, context view.Context) (*Transaction, error) {
3943
_, tx, err := endorser.NewTransaction(fnsProvider, context)
4044
if err != nil {
4145
return nil, err

Diff for: samples/fabric/iou/views/borrower.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ package views
99
import (
1010
"encoding/json"
1111

12-
"github.com/hyperledger-labs/fabric-smart-client/platform/common/utils"
13-
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
1412
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/state"
1513
view2 "github.com/hyperledger-labs/fabric-smart-client/platform/view"
1614
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/assert"
@@ -50,7 +48,7 @@ func (i *CreateIOUView) Call(context view.Context) (interface{}, error) {
5048
assert.NoError(err, "failed exchanging recipient identity")
5149
span.AddEvent("completed_identity_exchange")
5250
// The borrower creates a new transaction
53-
tx, err := state.NewTransaction(utils.MustGet(fabric.GetNetworkServiceProvider(context)), context)
51+
tx, err := state.NewTransaction(context)
5452
assert.NoError(err, "failed creating a new transaction")
5553

5654
// Sets the namespace where the state should be stored
@@ -115,7 +113,7 @@ func (u UpdateIOUView) Call(context view.Context) (interface{}, error) {
115113
}
116114

117115
// The borrower starts by creating a new transaction to update the IOU state
118-
tx, err := state.NewTransaction(utils.MustGet(fabric.GetNetworkServiceProvider(context)), context)
116+
tx, err := state.NewTransaction(context)
119117
assert.NoError(err)
120118

121119
// Sets the namespace where the state is stored

0 commit comments

Comments
 (0)