Skip to content

Commit df071e8

Browse files
authored
clean up dependencies of sdk.go (#635)
Signed-off-by: Angelo De Caro <[email protected]>
1 parent 095c68d commit df071e8

File tree

58 files changed

+969
-599
lines changed

Some content is hidden

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

58 files changed

+969
-599
lines changed

docs/deployment/deployment.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Deployment
2+
3+
The Fabric Token SDK and the Fabric Smart Client form an Application Layer stack to build token-based distributed applications.
4+
5+
The stack can run as:
6+
- A standalone network node
7+
- Embedded in an already existing Application
8+
9+
![img.png](../imgs/deployment.png)
10+
11+
Either way, the token-sdk and smart client stacks must be initialized.
12+
Here are the steps you need to keep in mind:
13+
1. Create a smart client node;
14+
2. Install the application SDKs you need;
15+
3. Start the node;
16+
17+
```go
18+
/*
19+
Copyright IBM Corp. All Rights Reserved.
20+
21+
SPDX-License-Identifier: Apache-2.0
22+
*/
23+
24+
package main
25+
26+
import (
27+
fscnode "github.com/hyperledger-labs/fabric-smart-client/node"
28+
fsdk "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/sdk"
29+
tsdk "github.com/hyperledger-labs/fabric-token-sdk/token/sdk"
30+
31+
// The Token SDK must be further customized with `blank imports`.
32+
// Here are the required imports:
33+
// - Token Drivers: Import all the token drivers your application must support
34+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/driver"
35+
// - DB Drivers: Import all the db drivers your application must support
36+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/db/sql/driver/unity"
37+
// - Network Drivers: Import all the network drivers your application must support
38+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/network/fabric"
39+
// The DB driver `unity` uses an SQL database, therefore we need to import the one we want to use.
40+
// In this case, it is sqlite
41+
_ "modernc.org/sqlite"
42+
)
43+
44+
func main() {
45+
// 1. Create a smart client node;
46+
n := fscnode.New()
47+
// 2. Install the application SDKs you need;
48+
// In this case, we install the Fabric SDK (from the smart client), and the Token SDK (from the token sdk)
49+
n.InstallSDK(fsdk.NewSDK(n))
50+
n.InstallSDK(tsdk.NewSDK(n))
51+
// 3. Start the node;
52+
// If the boostrap is successful then this callback function is invoked.
53+
n.Execute(func() error {
54+
// At this point, it is possible to access any service, provided by the installed SDKs,
55+
// for further initializations.
56+
return nil
57+
})
58+
}
59+
```

docs/design.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
**Additional Information:**
2323

2424
* The SDK leverages the Fabric Smart Client stack for complex workflows, secure storage, and event listening.
25-
* Configuration examples can be found in the [`Example Core File Section`](./core-token.md) documentation.
25+
* Configuration examples can be found in the [`Example Core File Section`](./core-token.md) documentation.
26+
* Deployment guideline can be found in the [`Deployment`](./deployment/deployment.md) documentation.

docs/imgs/deployment.png

634 KB
Loading

docs/services/storage.md

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,73 @@
33
The Fabric Token SDK utilizes a robust data management system to ensure the secure and reliable tracking of all token-related activities.
44
This system leverages several databases, each with a specific purpose:
55

6-
* **Transaction Database (ttxdb)**:
6+
* **Transaction Database (`ttxdb`)**:
77
This critical database serves as the central repository for all transaction records.
88
It captures every token issuance, transfer, or redemption, providing a complete historical record of token activity within the network.
9-
The ttxdb service is locate under [`token/services/ttxdb`](./../../token/services/ttxdb).
9+
The `ttxdb` service is locate under [`token/services/ttxdb`](./../../token/services/ttxdb).
1010

11-
* **Token Database (tokendb)**:
12-
The tokendb acts as the registry for all tokens within the system.
11+
* **Token Database (`tokendb`)**:
12+
The `tokendb` acts as the registry for all tokens within the system.
1313
It stores detailed information about each token, including its unique identifier, denomination type (think currency or unique identifier), current ownership, and total quantity in circulation.
14-
By referencing the tokendb, developers and network participants can obtain a clear picture of the token landscape.
15-
The tokendb is used by the `Token Selector`, to select the tokens to use in each transaction, and by the `Token Vault Service` to provide its services.
16-
The tokendb service is locate under [`token/services/tokendb`](./../../token/services/tokendb).
14+
By referencing the `tokendb`, developers and network participants can obtain a clear picture of the token landscape.
15+
The `tokendb` is used by the `Token Selector`, to select the tokens to use in each transaction, and by the `Token Vault Service` to provide its services.
16+
The `tokendb` service is locate under [`token/services/tokendb`](./../../token/services/tokendb).
1717

18-
* **Audit Database (auditdb)** (if applicable):
19-
For applications requiring enhanced auditability, the auditdb provides an additional layer of transparency.
18+
* **Audit Database (`auditdb`)** (if applicable):
19+
For applications requiring enhanced auditability, the `auditdb` provides an additional layer of transparency.
2020
It meticulously stores audit records for transactions that have undergone the auditing process.
2121
This functionality is particularly valuable for scenarios where regulatory compliance or tamper-proof records are essential.
22-
The auditdb service is locate under [`token/services/auditdb`](./../../token/services/auditdb).
22+
The `auditdb` service is locate under [`token/services/auditdb`](./../../token/services/auditdb).
2323

24-
* **Identity Database (identitydb)**:
25-
The identitydb plays a crucial role in managing user identities and wallets within the network.
26-
It securely stores walet configurations, identity-related audit information, and so on, enabling secure interactions with the token system.
27-
The identitydb service is locate under [`token/services/identitydb`](./../../token/services/identitydb).
24+
* **Identity Database (`identitydb`)**:
25+
The `identitydb` plays a crucial role in managing user identities and wallets within the network.
26+
It securely stores wallet configurations, identity-related audit information, and so on, enabling secure interactions with the token system.
27+
The `identitydb` service is locate under [`token/services/identitydb`](./../../token/services/identitydb).
2828

29-
The Fabric Token SDK offers flexibility in deploying these databases. Developers can choose to:
29+
## Configuration
30+
31+
The Token SDK offers flexibility in deploying these databases. Developers can choose to:
3032

3133
* **Instantiate in Isolation:** Each database can operate independently, utilizing a distinct backend system for optimal performance and manageability.
34+
Here is an example of configuration
35+
```yaml
36+
token:
37+
tms:
38+
mytms: # unique name of this token management system
39+
network: default # the name of the network this TMS refers to (Fabric, Orion, etc)
40+
channel: testchannel # the name of the network's channel this TMS refers to, if applicable
41+
namespace: tns # the name of the channel's namespace this TMS refers to, if applicable
42+
# db specific driver
43+
tokendb:
44+
persistence:
45+
type: sql
46+
opts:
47+
createSchema: true
48+
driver: sqlite
49+
maxOpenConns: 10
50+
dataSource: /some/path/tokendb
51+
```
3252
3353
* **Shared Backend:** Alternatively, a single backend system can be shared by all databases, offering a more streamlined approach for deployments with simpler requirements.
54+
```yaml
55+
token:
56+
tms:
57+
mytms: # unique name of this token management system
58+
network: default # the name of the network this TMS refers to (Fabric, Orion, etc)
59+
channel: testchannel # the name of the network's channel this TMS refers to, if applicable
60+
namespace: tns # the name of the channel's namespace this TMS refers to, if applicable
61+
62+
# shared db configuration. The `unity` driver is used as provider.
63+
db:
64+
persistence:
65+
# configuration for the unity db driver. It uses sql as backend
66+
type: unity
67+
opts:
68+
createSchema: true
69+
driver: sqlite
70+
maxOpenConns: 10
71+
dataSource: /some/path/unitydb
72+
```
3473
3574
The specific driver used by the application will ultimately determine the available deployment options.
75+
Don't forget to import the driver that you are ultimately using with a blank import in your executable.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package fall
8+
9+
import (
10+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/driver"
11+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/driver"
12+
sdk "github.com/hyperledger-labs/fabric-token-sdk/token/sdk"
13+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/auditdb/db/sql"
14+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/db/sql/driver/unity"
15+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/identitydb/db/sql"
16+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/network/fabric"
17+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokendb/db/sql"
18+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokenlockdb/db/sql"
19+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/ttxdb/db/sql"
20+
_ "modernc.org/sqlite"
21+
)
22+
23+
type SDK struct {
24+
*sdk.SDK
25+
}
26+
27+
func NewSDK(registry sdk.Registry) *SDK {
28+
return &SDK{SDK: sdk.NewSDK(registry)}
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package fdlog
8+
9+
import (
10+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/driver"
11+
sdk "github.com/hyperledger-labs/fabric-token-sdk/token/sdk"
12+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/auditdb/db/sql"
13+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/db/sql/driver/unity"
14+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/identitydb/db/sql"
15+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/network/fabric"
16+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokendb/db/sql"
17+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokenlockdb/db/sql"
18+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/ttxdb/db/sql"
19+
_ "modernc.org/sqlite"
20+
)
21+
22+
type SDK struct {
23+
*sdk.SDK
24+
}
25+
26+
func NewSDK(registry sdk.Registry) *SDK {
27+
return &SDK{SDK: sdk.NewSDK(registry)}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package ffabtoken
8+
9+
import (
10+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/driver"
11+
sdk "github.com/hyperledger-labs/fabric-token-sdk/token/sdk"
12+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/auditdb/db/sql"
13+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/db/sql/driver/unity"
14+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/identitydb/db/sql"
15+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/network/fabric"
16+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokendb/db/sql"
17+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokenlockdb/db/sql"
18+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/ttxdb/db/sql"
19+
_ "modernc.org/sqlite"
20+
)
21+
22+
type SDK struct {
23+
*sdk.SDK
24+
}
25+
26+
func NewSDK(registry sdk.Registry) *SDK {
27+
return &SDK{SDK: sdk.NewSDK(registry)}
28+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package fodlog
8+
9+
import (
10+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/driver"
11+
sdk "github.com/hyperledger-labs/fabric-token-sdk/token/sdk"
12+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/auditdb/db/sql"
13+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/db/sql/driver/unity"
14+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/identitydb/db/sql"
15+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/network/fabric"
16+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/network/orion"
17+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokendb/db/sql"
18+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokenlockdb/db/sql"
19+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/ttxdb/db/sql"
20+
_ "modernc.org/sqlite"
21+
)
22+
23+
type SDK struct {
24+
*sdk.SDK
25+
}
26+
27+
func NewSDK(registry sdk.Registry) *SDK {
28+
return &SDK{SDK: sdk.NewSDK(registry)}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package fofabtoken
8+
9+
import (
10+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/driver"
11+
sdk "github.com/hyperledger-labs/fabric-token-sdk/token/sdk"
12+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/auditdb/db/sql"
13+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/db/sql/driver/unity"
14+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/identitydb/db/sql"
15+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/network/fabric"
16+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/network/orion"
17+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokendb/db/sql"
18+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokenlockdb/db/sql"
19+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/ttxdb/db/sql"
20+
_ "modernc.org/sqlite"
21+
)
22+
23+
type SDK struct {
24+
*sdk.SDK
25+
}
26+
27+
func NewSDK(registry sdk.Registry) *SDK {
28+
return &SDK{SDK: sdk.NewSDK(registry)}
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package odlog
8+
9+
import (
10+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/driver"
11+
sdk "github.com/hyperledger-labs/fabric-token-sdk/token/sdk"
12+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/auditdb/db/sql"
13+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/db/sql/driver/unity"
14+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/identitydb/db/sql"
15+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/network/orion"
16+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokendb/db/sql"
17+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokenlockdb/db/sql"
18+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/ttxdb/db/sql"
19+
_ "modernc.org/sqlite"
20+
)
21+
22+
type SDK struct {
23+
*sdk.SDK
24+
}
25+
26+
func NewSDK(registry sdk.Registry) *SDK {
27+
return &SDK{SDK: sdk.NewSDK(registry)}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package ofabtoken
8+
9+
import (
10+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/driver"
11+
sdk "github.com/hyperledger-labs/fabric-token-sdk/token/sdk"
12+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/auditdb/db/sql"
13+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/db/sql/driver/unity"
14+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/identitydb/db/sql"
15+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/network/orion"
16+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokendb/db/sql"
17+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokenlockdb/db/sql"
18+
_ "github.com/hyperledger-labs/fabric-token-sdk/token/services/ttxdb/db/sql"
19+
_ "modernc.org/sqlite"
20+
)
21+
22+
type SDK struct {
23+
*sdk.SDK
24+
}
25+
26+
func NewSDK(registry sdk.Registry) *SDK {
27+
return &SDK{SDK: sdk.NewSDK(registry)}
28+
}

integration/token/common/topology.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,24 @@ SPDX-License-Identifier: Apache-2.0
77
package common
88

99
import (
10+
"github.com/hyperledger-labs/fabric-smart-client/pkg/api"
1011
"github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token/generators/dlog"
1112
"github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token/topology"
1213
. "github.com/onsi/gomega"
1314
)
1415

16+
type Opts struct {
17+
Backend string
18+
TokenSDKDriver string
19+
AuditorAsIssuer bool
20+
Aries bool
21+
FSCLogSpec string
22+
NoAuditor bool
23+
HSM bool
24+
SDKs []api.SDK
25+
WebEnabled bool
26+
}
27+
1528
func SetDefaultParams(tokenSDKDriver string, tms *topology.TMS, aries bool) {
1629
switch tokenSDKDriver {
1730
case "dlog":

0 commit comments

Comments
 (0)