Skip to content

Commit f012d66

Browse files
committed
introduce common views
Signed-off-by: Angelo De Caro <[email protected]>
1 parent d46eaf0 commit f012d66

File tree

8 files changed

+23
-58
lines changed

8 files changed

+23
-58
lines changed

integration/fabric/atsa/fsc/client/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package client
99
import (
1010
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/atsa/fsc/states"
1111
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/atsa/fsc/views"
12+
views2 "github.com/hyperledger-labs/fabric-smart-client/integration/fabric/common/views"
1213
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/common"
1314
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
1415
)
@@ -79,7 +80,7 @@ func (c *Client) Transfer(assetID string, agreementID string, recipient view.Ide
7980
}
8081

8182
func (c *Client) IsTxFinal(id string) error {
82-
_, err := c.c.CallView("finality", common.JSONMarshall(views.Finality{TxID: id}))
83+
_, err := c.c.CallView("finality", common.JSONMarshall(views2.Finality{TxID: id}))
8384
if err != nil {
8485
return err
8586
}

integration/fabric/atsa/fsc/topology.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package fsc
99
import (
1010
"github.com/hyperledger-labs/fabric-smart-client/integration"
1111
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/atsa/fsc/views"
12+
cviews "github.com/hyperledger-labs/fabric-smart-client/integration/fabric/common/views"
1213
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/api"
1314
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric"
1415
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
@@ -38,14 +39,14 @@ func Topology(sdk api2.SDK, commType fsc.P2PCommunicationType, replicationOpts *
3839
RegisterResponder(&views.ApproverView{}, &views.AgreeToSellView{}).
3940
RegisterResponder(&views.ApproverView{}, &views.AgreeToBuyView{}).
4041
RegisterResponder(&views.ApproverView{}, &views.TransferView{}).
41-
RegisterViewFactory("finality", &views.FinalityViewFactory{})
42+
RegisterViewFactory("finality", &cviews.FinalityViewFactory{})
4243

4344
// Issuer
4445
fscTopology.AddNodeByName("issuer").
4546
AddOptions(fabric.WithOrganization("Org3")).
4647
AddOptions(replicationOpts.For("issuer")...).
4748
RegisterViewFactory("issue", &views.IssueViewFactory{}).
48-
RegisterViewFactory("finality", &views.FinalityViewFactory{})
49+
RegisterViewFactory("finality", &cviews.FinalityViewFactory{})
4950

5051
// Alice
5152
fscTopology.AddNodeByName("alice").
@@ -56,7 +57,7 @@ func Topology(sdk api2.SDK, commType fsc.P2PCommunicationType, replicationOpts *
5657
RegisterViewFactory("agreeToBuy", &views.AgreeToBuyViewFactory{}).
5758
RegisterResponder(&views.AcceptAssetView{}, &views.IssueView{}).
5859
RegisterResponder(&views.TransferResponderView{}, &views.TransferView{}).
59-
RegisterViewFactory("finality", &views.FinalityViewFactory{})
60+
RegisterViewFactory("finality", &cviews.FinalityViewFactory{})
6061

6162
// Bob
6263
fscTopology.AddNodeByName("bob").
@@ -67,7 +68,7 @@ func Topology(sdk api2.SDK, commType fsc.P2PCommunicationType, replicationOpts *
6768
RegisterViewFactory("agreeToBuy", &views.AgreeToBuyViewFactory{}).
6869
RegisterResponder(&views.AcceptAssetView{}, &views.IssueView{}).
6970
RegisterResponder(&views.TransferResponderView{}, &views.TransferView{}).
70-
RegisterViewFactory("finality", &views.FinalityViewFactory{})
71+
RegisterViewFactory("finality", &cviews.FinalityViewFactory{})
7172

7273
// Add Fabric SDK to FSC Nodes
7374
fscTopology.AddSDK(sdk)

integration/fabric/iou/commands.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"context"
1111
"time"
1212

13+
cviews "github.com/hyperledger-labs/fabric-smart-client/integration/fabric/common/views"
14+
1315
"github.com/hyperledger-labs/fabric-smart-client/integration"
1416
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/iou/views"
1517
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/common"
@@ -58,7 +60,7 @@ func UpdateIOUWithBorrower(ii *integration.Infrastructure, borrower, iouStateID
5860
)
5961
Expect(err).NotTo(HaveOccurred())
6062
txID := common.JSONUnmarshalString(txIDBoxed)
61-
_, err = ii.Client("lender").CallView("finality", common.JSONMarshall(views.Finality{TxID: txID}))
63+
_, err = ii.Client("lender").CallView("finality", common.JSONMarshall(cviews.Finality{TxID: txID}))
6264
Expect(err).NotTo(HaveOccurred())
6365
}
6466

integration/fabric/iou/topology.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package iou
88

99
import (
1010
"github.com/hyperledger-labs/fabric-smart-client/integration"
11+
cviews "github.com/hyperledger-labs/fabric-smart-client/integration/fabric/common/views"
1112
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/iou/views"
1213
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/api"
1314
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric"
@@ -44,7 +45,7 @@ func Topology(sdk api2.SDK, commType fsc.P2PCommunicationType, replicationOpts *
4445
RegisterResponder(&views.ApproverView{}, &views.CreateIOUView{}).
4546
RegisterResponder(&views.ApproverView{}, &views.UpdateIOUView{}).
4647
RegisterViewFactory("init", &views.ApproverInitViewFactory{}).
47-
RegisterViewFactory("finality", &views.FinalityViewFactory{})
48+
RegisterViewFactory("finality", &cviews.FinalityViewFactory{})
4849

4950
// Add another approver as well
5051
fscTopology.AddNodeByName("approver2").
@@ -55,7 +56,7 @@ func Topology(sdk api2.SDK, commType fsc.P2PCommunicationType, replicationOpts *
5556
RegisterResponder(&views.ApproverView{}, &views.CreateIOUView{}).
5657
RegisterResponder(&views.ApproverView{}, &views.UpdateIOUView{}).
5758
RegisterViewFactory("init", &views.ApproverInitViewFactory{}).
58-
RegisterViewFactory("finality", &views.FinalityViewFactory{})
59+
RegisterViewFactory("finality", &cviews.FinalityViewFactory{})
5960

6061
// Add the borrower's FSC node
6162
fscTopology.AddNodeByName("borrower").
@@ -64,7 +65,7 @@ func Topology(sdk api2.SDK, commType fsc.P2PCommunicationType, replicationOpts *
6465
RegisterViewFactory("create", &views.CreateIOUViewFactory{}).
6566
RegisterViewFactory("update", &views.UpdateIOUViewFactory{}).
6667
RegisterViewFactory("query", &views.QueryViewFactory{}).
67-
RegisterViewFactory("finality", &views.FinalityViewFactory{})
68+
RegisterViewFactory("finality", &cviews.FinalityViewFactory{})
6869

6970
// Add the lender's FSC node
7071
fscTopology.AddNodeByName("lender").
@@ -73,7 +74,7 @@ func Topology(sdk api2.SDK, commType fsc.P2PCommunicationType, replicationOpts *
7374
RegisterResponder(&views.CreateIOUResponderView{}, &views.CreateIOUView{}).
7475
RegisterResponder(&views.UpdateIOUResponderView{}, &views.UpdateIOUView{}).
7576
RegisterViewFactory("query", &views.QueryViewFactory{}).
76-
RegisterViewFactory("finality", &views.FinalityViewFactory{})
77+
RegisterViewFactory("finality", &cviews.FinalityViewFactory{})
7778

7879
// Monitoring
7980
monitoringTopology := monitoring.NewTopology()

integration/fabric/iou/views/finality.go

Lines changed: 0 additions & 41 deletions
This file was deleted.

integration/fabric/iouhsm/topology.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package iouhsm
88

99
import (
1010
"github.com/hyperledger-labs/fabric-smart-client/integration"
11+
cviews "github.com/hyperledger-labs/fabric-smart-client/integration/fabric/common/views"
1112
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/iou/views"
1213
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/api"
1314
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric"
@@ -37,7 +38,7 @@ func Topology(sdk api2.SDK, commType fsc.P2PCommunicationType, replicationOpts *
3738
AddOptions(replicationOpts.For("approver")...).
3839
RegisterResponder(&views.ApproverView{}, &views.CreateIOUView{}).
3940
RegisterResponder(&views.ApproverView{}, &views.UpdateIOUView{}).
40-
RegisterViewFactory("finality", &views.FinalityViewFactory{})
41+
RegisterViewFactory("finality", &cviews.FinalityViewFactory{})
4142

4243
// Add the borrower's FSC node
4344
fscTopology.AddNodeByName("borrower").
@@ -46,7 +47,7 @@ func Topology(sdk api2.SDK, commType fsc.P2PCommunicationType, replicationOpts *
4647
RegisterViewFactory("create", &views.CreateIOUViewFactory{}).
4748
RegisterViewFactory("update", &views.UpdateIOUViewFactory{}).
4849
RegisterViewFactory("query", &views.QueryViewFactory{}).
49-
RegisterViewFactory("finality", &views.FinalityViewFactory{})
50+
RegisterViewFactory("finality", &cviews.FinalityViewFactory{})
5051

5152
// Add the lender's FSC node
5253
fscTopology.AddNodeByName("lender").
@@ -55,7 +56,7 @@ func Topology(sdk api2.SDK, commType fsc.P2PCommunicationType, replicationOpts *
5556
RegisterResponder(&views.CreateIOUResponderView{}, &views.CreateIOUView{}).
5657
RegisterResponder(&views.UpdateIOUResponderView{}, &views.UpdateIOUView{}).
5758
RegisterViewFactory("query", &views.QueryViewFactory{}).
58-
RegisterViewFactory("finality", &views.FinalityViewFactory{})
59+
RegisterViewFactory("finality", &cviews.FinalityViewFactory{})
5960

6061
// Add Fabric SDK to FSC Nodes
6162
fscTopology.AddSDK(sdk)

samples/fabric/iou/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ If you reached this point, you can now invoke the business views on the FSC node
524524
To create an IOU, you can run the following command in a new terminal window:
525525

526526
```shell
527-
./iou view -c ./testdata/fsc/nodes/borrower.0/client-config.yaml -f create -i '{"Amount":10}'
527+
./iou views -c ./testdata/fsc/nodes/borrower.0/client-config.yaml -f create -i '{"Amount":10}'
528528
```
529529

530530
The above command invoke the `create` view on the borrower's FSC node. The `-c` option specifies the client configuration file.
@@ -540,7 +540,7 @@ The above is the IOU ID that we will use to update the IOU or query it.
540540
Indeed, once the IOU is created, you can query the IOUs by running the following command (substituting the IOU LinearID output from the previous command):
541541

542542
```shell
543-
./iou view -c ./testdata/fsc/nodes/borrower.0/client-config.yaml -f query -i '{"LinearID":"bd90b6c8-0a54-4719-8caa-00759bad7d69"}'
543+
./iou views -c ./testdata/fsc/nodes/borrower.0/client-config.yaml -f query -i '{"LinearID":"bd90b6c8-0a54-4719-8caa-00759bad7d69"}'
544544
```
545545

546546
The above command will query the IOU with the linear ID `bd90b6c8-0a54-4719-8caa-00759bad7d69` on the borrower's FSC node.
@@ -549,13 +549,13 @@ If everything is successful, you will the current amount contained in the IOU st
549549
If you want to query the IOU start on the lender node, you can run the following command:
550550

551551
```shell
552-
./iou view -c ./testdata/fsc/nodes/lender.0/client-config.yaml -f query -i '{"LinearID":"bd90b6c8-0a54-4719-8caa-00759bad7d69"}'
552+
./iou views -c ./testdata/fsc/nodes/lender.0/client-config.yaml -f query -i '{"LinearID":"bd90b6c8-0a54-4719-8caa-00759bad7d69"}'
553553
```
554554

555555
To update the IOU, you can run the following command:
556556

557557
```shell
558-
./iou view -c ./testdata/fsc/nodes/borrower.0/client-config.yaml -f update -i '{"LinearID":"bd90b6c8-0a54-4719-8caa-00759bad7d69","Amount":8}'
558+
./iou views -c ./testdata/fsc/nodes/borrower.0/client-config.yaml -f update -i '{"LinearID":"bd90b6c8-0a54-4719-8caa-00759bad7d69","Amount":8}'
559559
```
560560

561561
The above command will update the IOU with the linear ID `bd90b6c8-0a54-4719-8caa-00759bad7d69`. The new amount will be 8.

0 commit comments

Comments
 (0)