Skip to content

Commit 20cc75d

Browse files
feat(daml): creation of connector class
Primary Changes --------------- 1. Create a DAML connector class 2. Created OpenAPI endpoints of DAML 3. Created DAML web services for create, exercise and query contracts 4. Create simple IOU Transaction using DAML Fixes #3489 Signed-off-by: raynato.c.pedrajeta <[email protected]>
1 parent 35f31fa commit 20cc75d

File tree

91 files changed

+18393
-11286
lines changed

Some content is hidden

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

91 files changed

+18393
-11286
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
3+
"spaces": 2,
4+
"generator-cli": {
5+
"version": "6.6.0"
6+
}
7+
}
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"name": "@hyperledger/cactus-plugin-ledger-connector-daml",
3+
"version": "2.0.0",
4+
"description": "Allows Cactus nodes to connect to a DAML ledger.",
5+
"keywords": [
6+
"Hyperledger",
7+
"Cactus",
8+
"Integration",
9+
"Blockchain",
10+
"Distributed Ledger Technology"
11+
],
12+
"homepage": "https://github.com/hyperledger/cacti#readme",
13+
"bugs": {
14+
"url": "https://github.com/hyperledger/cacti/issues"
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "git+https://github.com/hyperledger/cacti.git"
19+
},
20+
"license": "Apache-2.0",
21+
"author": {
22+
"name": "Hyperledger Cactus Contributors",
23+
"email": "[email protected]",
24+
"url": "https://www.hyperledger.org/use/cacti"
25+
},
26+
"contributors": [
27+
{
28+
"name": "Please add yourself to the list of contributors",
29+
"email": "[email protected]",
30+
"url": "https://example.com"
31+
},
32+
{
33+
"name": "Peter Somogyvari",
34+
"email": "[email protected]",
35+
"url": "https://accenture.com"
36+
}
37+
],
38+
"main": "dist/lib/main/typescript/index.js",
39+
"module": "dist/lib/main/typescript/index.js",
40+
"browser": "dist/cactus-plugin-ledger-connector-corda.web.umd.js",
41+
"types": "dist/lib/main/typescript/index.d.ts",
42+
"files": [
43+
"dist/*"
44+
],
45+
"scripts": {
46+
"codegen": "yarn run --top-level run-s 'codegen:*'",
47+
"codegen:openapi": "npm run generate-sdk",
48+
"generate-sdk": "run-p 'generate-sdk:*'",
49+
"generate-sdk:go": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g go -o ./src/main/go/generated/openapi/go-client/ --git-user-id hyperledger --git-repo-id $(echo $npm_package_name | replace @hyperledger/ \"\" -z)/src/main/go/generated/openapi/go-client --package-name $(echo $npm_package_name | replace @hyperledger/ \"\" -z) --reserved-words-mappings protected=protected --ignore-file-override ../../openapi-generator-ignore",
50+
"generate-sdk:kotlin": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g kotlin -o ./src/main/kotlin/generated/openapi/kotlin-client/ --reserved-words-mappings protected=protected --ignore-file-override ../../openapi-generator-ignore",
51+
"generate-sdk:typescript-axios": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --ignore-file-override ../../openapi-generator-ignore",
52+
"generate-server": "yarn run --top-level openapi-generator-cli generate -i ./src/main/json/openapi.json -g kotlin-spring -o ./src/main-server/kotlin/gen/kotlin-spring/ -c ./src/main-server/openapi-generator-config.yaml --ignore-file-override ../../openapi-generator-ignore",
53+
"watch": "npm-watch",
54+
"webpack": "npm-run-all webpack:dev",
55+
"webpack:dev": "npm-run-all webpack:dev:node webpack:dev:web",
56+
"webpack:dev:node": "webpack --env=dev --target=node --config ../../webpack.config.js",
57+
"webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js"
58+
},
59+
"dependencies": {
60+
"@hyperledger/cactus-common": "2.0.0",
61+
"@hyperledger/cactus-core": "2.0.0",
62+
"@hyperledger/cactus-core-api": "2.0.0",
63+
"axios": "1.6.0",
64+
"express-openapi-validator": "5.2.0",
65+
"http-errors-enhanced-cjs": "2.0.1",
66+
"internal-ip": "6.2.0",
67+
"joi": "17.13.3",
68+
"node-ssh": "13.1.0",
69+
"prom-client": "15.1.3",
70+
"rxjs": "7.8.1",
71+
"temp": "0.9.4",
72+
"typescript-optional": "2.0.1"
73+
},
74+
"devDependencies": {
75+
"@hyperledger/cactus-test-tooling": "2.0.0",
76+
"@types/body-parser": "1.19.4",
77+
"@types/express": "4.17.21",
78+
"@types/multer": "1.4.7",
79+
"@types/temp": "0.9.1",
80+
"@types/uuid": "10.0.0",
81+
"body-parser": "1.20.2",
82+
"express": "4.19.2",
83+
"uuid": "10.0.0"
84+
},
85+
"engines": {
86+
"node": ">=18",
87+
"npm": ">=8"
88+
},
89+
"publishConfig": {
90+
"access": "public"
91+
},
92+
"browserMinified": "dist/cactus-plugin-ledger-connector-corda.web.umd.min.js",
93+
"mainMinified": "dist/cactus-plugin-ledger-connector-corda.node.umd.min.js",
94+
"watch": {
95+
"codegen:openapi": {
96+
"patterns": [
97+
"./src/main/json/openapi.json"
98+
]
99+
}
100+
}
101+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.travis.yml
2+
README.md
3+
api/openapi.yaml
4+
api_default.go
5+
client.go
6+
configuration.go
7+
go.mod
8+
go.sum
9+
model_create_iou_endpoint_request.go
10+
model_create_iou_endpoint_request_payload.go
11+
model_create_iou_endpoint_response.go
12+
model_exercise_iou_endpoint_request.go
13+
model_exercise_iou_endpoint_request_argument.go
14+
model_exercise_iou_endpoint_response.go
15+
model_get_parties_involved_endpoint_request.go
16+
model_query_iou_endpoint_request.go
17+
model_query_iou_endpoint_request_query.go
18+
model_query_iou_endpoint_response.go
19+
model_query_iou_endpoint_response_events_inner.go
20+
model_query_iou_endpoint_response_events_inner_archived.go
21+
model_query_raw_iou_endpoint_request.go
22+
response.go
23+
utils.go
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.6.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
language: go
2+
3+
install:
4+
- go get -d -v .
5+
6+
script:
7+
- go build -v ./
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Go API client for cactus-plugin-ledger-connector-daml
2+
3+
Can perform basic tasks on a DAML ledger
4+
5+
## Overview
6+
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.
7+
8+
- API version: 2.0.0-rc.3
9+
- Package version: 1.0.0
10+
- Build package: org.openapitools.codegen.languages.GoClientCodegen
11+
12+
## Installation
13+
14+
Install the following dependencies:
15+
16+
```shell
17+
go get github.com/stretchr/testify/assert
18+
go get golang.org/x/net/context
19+
```
20+
21+
Put the package under your project folder and add the following in import:
22+
23+
```golang
24+
import cactus-plugin-ledger-connector-daml "github.com/hyperledger/cactus-plugin-ledger-connector-daml/src/main/go/generated/openapi/go-client"
25+
```
26+
27+
To use a proxy, set the environment variable `HTTP_PROXY`:
28+
29+
```golang
30+
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
31+
```
32+
33+
## Configuration of Server URL
34+
35+
Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
36+
37+
### Select Server Configuration
38+
39+
For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.
40+
41+
```golang
42+
ctx := context.WithValue(context.Background(), cactus-plugin-ledger-connector-daml.ContextServerIndex, 1)
43+
```
44+
45+
### Templated Server URL
46+
47+
Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.
48+
49+
```golang
50+
ctx := context.WithValue(context.Background(), cactus-plugin-ledger-connector-daml.ContextServerVariables, map[string]string{
51+
"basePath": "v2",
52+
})
53+
```
54+
55+
Note, enum values are always validated and all unused variables are silently ignored.
56+
57+
### URLs Configuration per Operation
58+
59+
Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
60+
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
61+
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.
62+
63+
```golang
64+
ctx := context.WithValue(context.Background(), cactus-plugin-ledger-connector-daml.ContextOperationServerIndices, map[string]int{
65+
"{classname}Service.{nickname}": 2,
66+
})
67+
ctx = context.WithValue(context.Background(), cactus-plugin-ledger-connector-daml.ContextOperationServerVariables, map[string]map[string]string{
68+
"{classname}Service.{nickname}": {
69+
"port": "8443",
70+
},
71+
})
72+
```
73+
74+
## Documentation for API Endpoints
75+
76+
All URIs are relative to *http://localhost*
77+
78+
Class | Method | HTTP request | Description
79+
------------ | ------------- | ------------- | -------------
80+
*DefaultApi* | [**CreateIou**](docs/DefaultApi.md#createiou) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-daml/create-iou-endpoint | This method creates a simple iou countract
81+
*DefaultApi* | [**ExerciseChoice**](docs/DefaultApi.md#exercisechoice) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-daml/exercise-iou-endpoint | This method creates a simple iou countract
82+
*DefaultApi* | [**GetPartiesInvolved**](docs/DefaultApi.md#getpartiesinvolved) | **Get** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-daml/get-parties-involved-endpoint | This method queries DAML contracts
83+
*DefaultApi* | [**QueryContract**](docs/DefaultApi.md#querycontract) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-daml/query-iou-endpoint | This method queries DAML contracts
84+
*DefaultApi* | [**QueryRawContract**](docs/DefaultApi.md#queryrawcontract) | **Get** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-daml/query-raw-iou-endpoint | This method queries DAML contracts
85+
86+
87+
## Documentation For Models
88+
89+
- [CreateIOUEndpointRequest](docs/CreateIOUEndpointRequest.md)
90+
- [CreateIOUEndpointRequestPayload](docs/CreateIOUEndpointRequestPayload.md)
91+
- [CreateIOUEndpointResponse](docs/CreateIOUEndpointResponse.md)
92+
- [ExerciseIOUEndpointRequest](docs/ExerciseIOUEndpointRequest.md)
93+
- [ExerciseIOUEndpointRequestArgument](docs/ExerciseIOUEndpointRequestArgument.md)
94+
- [ExerciseIOUEndpointResponse](docs/ExerciseIOUEndpointResponse.md)
95+
- [GetPartiesInvolvedEndpointRequest](docs/GetPartiesInvolvedEndpointRequest.md)
96+
- [QueryIOUEndpointRequest](docs/QueryIOUEndpointRequest.md)
97+
- [QueryIOUEndpointRequestQuery](docs/QueryIOUEndpointRequestQuery.md)
98+
- [QueryIOUEndpointResponse](docs/QueryIOUEndpointResponse.md)
99+
- [QueryIOUEndpointResponseEventsInner](docs/QueryIOUEndpointResponseEventsInner.md)
100+
- [QueryIOUEndpointResponseEventsInnerArchived](docs/QueryIOUEndpointResponseEventsInnerArchived.md)
101+
- [QueryRawIOUEndpointRequest](docs/QueryRawIOUEndpointRequest.md)
102+
103+
104+
## Documentation For Authorization
105+
106+
Endpoints do not require authorization.
107+
108+
109+
## Documentation for Utility Methods
110+
111+
Due to the fact that model structure members are all pointers, this package contains
112+
a number of utility functions to easily obtain pointers to values of basic types.
113+
Each of these functions takes a value of the given basic type and returns a pointer to it:
114+
115+
* `PtrBool`
116+
* `PtrInt`
117+
* `PtrInt32`
118+
* `PtrInt64`
119+
* `PtrFloat`
120+
* `PtrFloat32`
121+
* `PtrFloat64`
122+
* `PtrString`
123+
* `PtrTime`
124+
125+
## Author
126+
127+
128+

0 commit comments

Comments
 (0)