Skip to content

Commit

Permalink
fixup! start fabtoken driver adjustments
Browse files Browse the repository at this point in the history
Signed-off-by: Hagar Meir <[email protected]>
  • Loading branch information
HagarMeir committed Dec 14, 2022
1 parent 7802f33 commit 8461eb3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ jobs:
interop-fabtoken-t4,
interop-fabtoken-t5,
interop-fabtoken-t6,
interop-fabtoken-t7,
interop-dlog-t1,
interop-dlog-t2,
interop-dlog-t3,
Expand Down
20 changes: 20 additions & 0 deletions token/services/interop/pledge/endorsement.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/pkg/errors"
)

// NewCollectEndorsementsView returns an instance of the ttx collectEndorsementsView struct
func NewCollectEndorsementsView(tx *Transaction) view.View {
return ttx.NewCollectEndorsementsView(tx.Transaction)
}
Expand All @@ -23,6 +24,7 @@ type receiveTransactionView struct {
channel string
}

// NewReceiveTransactionView returns an instance of receiveTransactionView struct
func NewReceiveTransactionView(network string) *receiveTransactionView {
return &receiveTransactionView{network: network}
}
Expand All @@ -45,3 +47,21 @@ func (f *receiveTransactionView) Call(context view.Context) (interface{}, error)
return nil, errors.New("timeout reached")
}
}

// ReceiveTransaction executes the receiveTransactionView and returns the received transaction
func ReceiveTransaction(context view.Context) (*Transaction, error) {
logger.Debugf("receive a new transaction...")

txBoxed, err := context.RunView(NewReceiveTransactionView(""))
if err != nil {
return nil, err
}

cctx, ok := txBoxed.(*Transaction)
if !ok {
return nil, errors.Errorf("received transaction of wrong type [%T]", cctx)
}
logger.Debugf("received transaction with id [%s]", cctx.ID())

return cctx, nil
}
18 changes: 0 additions & 18 deletions token/services/interop/pledge/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package pledge
import (
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/ttx"
"github.com/pkg/errors"
)

type Transaction struct {
Expand Down Expand Up @@ -43,20 +42,3 @@ func NewTransactionFromBytes(ctx view.Context, network, channel string, raw []by
Transaction: tx,
}, nil
}

func ReceiveTransaction(context view.Context) (*Transaction, error) {
logger.Debugf("receive a new transaction...")

txBoxed, err := context.RunView(NewReceiveTransactionView(""))
if err != nil {
return nil, err
}

cctx, ok := txBoxed.(*Transaction)
if !ok {
return nil, errors.Errorf("received transaction of wrong type [%T]", cctx)
}
logger.Debugf("received transaction with id [%s]", cctx.ID())

return cctx, nil
}

0 comments on commit 8461eb3

Please sign in to comment.