@@ -11,8 +11,7 @@ import (
1111
1212 "github.com/hyperledger-labs/fabric-smart-client/pkg/utils/errors"
1313 "github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
14- "github.com/hyperledger-labs/fabric-token-sdk/token/services/network"
15- "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokens"
14+ "github.com/hyperledger-labs/fabric-token-sdk/token/services/ttx/dep"
1615)
1716
1817type orderingView struct {
@@ -23,11 +22,7 @@ type orderingView struct {
2322// The view does the following:
2423// 1. It broadcasts the token transaction to the proper backend.
2524func NewOrderingView (tx * Transaction , opts ... TxOption ) * orderingView {
26- return NewOrderingViewWithOpts (append ([]TxOption {WithTransactions (tx )}, opts ... )... )
27- }
28-
29- func NewOrderingViewWithOpts (opts ... TxOption ) * orderingView {
30- return & orderingView {opts : opts }
25+ return & orderingView {opts : append ([]TxOption {WithTransactions (tx )}, opts ... )}
3126}
3227
3328// Call execute the view.
@@ -44,12 +39,12 @@ func (o *orderingView) Call(context view.Context) (interface{}, error) {
4439 }
4540
4641 // cache the token request into the tokens db
47- t , err := tokens . GetService (context , options . Transaction . TMSID () )
42+ storageProvider , err := GetStorageProvider (context )
4843 if err != nil {
49- return nil , errors .Wrapf (err , "failed to get tokens db for [%s]" , options . Transaction . TMSID () )
44+ return nil , errors .Wrapf (err , "failed to get storage provider" )
5045 }
5146 if ! options .NoCachingRequest {
52- if err := t .CacheRequest (context .Context (), options .Transaction .TMSID (), options .Transaction .TokenRequest ); err != nil {
47+ if err := storageProvider .CacheRequest (context .Context (), options .Transaction .TMSID (), options .Transaction .TokenRequest ); err != nil {
5348 logger .WarnfContext (context .Context (), "failed to cache token request [%s], this might cause delay, investigate when possible: [%s]" , options .Transaction .TokenRequest .Anchor , err )
5449 }
5550 }
@@ -60,11 +55,15 @@ func (o *orderingView) broadcast(context view.Context, transaction *Transaction)
6055 if transaction == nil {
6156 return errors .Errorf ("transaction is nil" )
6257 }
63- nw := network .GetInstance (context , transaction .Network (), transaction .Channel ())
64- if nw == nil {
65- return errors .Errorf ("network [%s] not found" , transaction .Network ())
58+ np , err := dep .GetNetworkProvider (context )
59+ if err != nil {
60+ return errors .Join (err , ErrDepNotAvailableInContext )
61+ }
62+ network , err := np .GetNetwork (transaction .Network (), transaction .Channel ())
63+ if err != nil {
64+ return errors .WithMessagef (err , "failed to get network [%s]" , transaction .Network ())
6665 }
67- if err := nw .Broadcast (context .Context (), transaction .Envelope ); err != nil {
66+ if err := network .Broadcast (context .Context (), transaction .Envelope ); err != nil {
6867 return errors .WithMessagef (err , "failed to broadcast token transaction [%s]" , transaction .ID ())
6968 }
7069 return nil
0 commit comments