Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(daml): creation of connector class #3615

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"Crpc",
"CSDE",
"csdetemplate",
"daio",
"daml",
"data",
"davecgh",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "6.6.0"
}
}

101 changes: 101 additions & 0 deletions packages/cactus-plugin-ledger-connector-daml/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"name": "@hyperledger/cactus-plugin-ledger-connector-daml",
"version": "2.0.0",
"description": "Allows Cactus nodes to connect to a DAML ledger.",
"keywords": [
"Hyperledger",
"Cactus",
"Integration",
"Blockchain",
"Distributed Ledger Technology"
],
"homepage": "https://github.com/hyperledger/cacti#readme",
"bugs": {
"url": "https://github.com/hyperledger/cacti/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/hyperledger/cacti.git"
},
"license": "Apache-2.0",
"author": {
"name": "Hyperledger Cactus Contributors",
"email": "cactus@lists.hyperledger.org",
"url": "https://www.hyperledger.org/use/cacti"
},
"contributors": [
{
"name": "Please add yourself to the list of contributors",
"email": "your.name@example.com",
"url": "https://example.com"
},
{
"name": "Peter Somogyvari",
"email": "peter.somogyvari@accenture.com",
"url": "https://accenture.com"
}
],
"main": "dist/lib/main/typescript/index.js",
"module": "dist/lib/main/typescript/index.js",
"browser": "dist/cactus-plugin-ledger-connector-corda.web.umd.js",
"types": "dist/lib/main/typescript/index.d.ts",
"files": [
"dist/*"
],
"scripts": {
"codegen": "yarn run --top-level run-s 'codegen:*'",
"codegen:openapi": "npm run generate-sdk",
"generate-sdk": "run-p 'generate-sdk:*'",
"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",
"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",
"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",
"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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need this. Please remove this (might got have remained when you copied this from corda connector)

"watch": "npm-watch",
"webpack": "npm-run-all webpack:dev",
"webpack:dev": "npm-run-all webpack:dev:node webpack:dev:web",
"webpack:dev:node": "webpack --env=dev --target=node --config ../../webpack.config.js",
"webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js"
},
"dependencies": {
"@hyperledger/cactus-common": "2.0.0",
"@hyperledger/cactus-core": "2.0.0",
"@hyperledger/cactus-core-api": "2.0.0",
"axios": "1.7.7",
"express-openapi-validator": "5.2.0",
"http-errors-enhanced-cjs": "2.0.1",
"internal-ip": "6.2.0",
"joi": "17.13.3",
"node-ssh": "13.1.0",
"prom-client": "15.1.3",
"rxjs": "7.8.1",
"temp": "0.9.4",
"typescript-optional": "2.0.1"
},
"devDependencies": {
"@hyperledger/cactus-test-tooling": "2.0.0",
"@types/body-parser": "1.19.4",
"@types/express": "5.0.0",
"@types/multer": "1.4.7",
"@types/temp": "0.9.1",
"@types/uuid": "10.0.0",
"body-parser": "1.20.2",
"express": "4.21.0",
"uuid": "10.0.0"
},
"engines": {
"node": ">=18",
"npm": ">=8"
},
"publishConfig": {
"access": "public"
},
"browserMinified": "dist/cactus-plugin-ledger-connector-corda.web.umd.min.js",
"mainMinified": "dist/cactus-plugin-ledger-connector-corda.node.umd.min.js",
"watch": {
"codegen:openapi": {
"patterns": [
"./src/main/json/openapi.json"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.travis.yml
README.md
api/openapi.yaml
api_default.go
client.go
configuration.go
go.mod
go.sum
model_create_iou_endpoint_request.go
model_create_iou_endpoint_request_payload.go
model_create_iou_endpoint_response.go
model_exercise_iou_endpoint_request.go
model_exercise_iou_endpoint_request_argument.go
model_exercise_iou_endpoint_response.go
model_get_parties_involved_endpoint_request.go
model_query_iou_endpoint_request.go
model_query_iou_endpoint_request_query.go
model_query_iou_endpoint_response.go
model_query_iou_endpoint_response_events_inner.go
model_query_iou_endpoint_response_events_inner_archived.go
model_query_raw_iou_endpoint_request.go
response.go
utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.6.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: go

install:
- go get -d -v .

script:
- go build -v ./

Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Go API client for cactus-plugin-ledger-connector-daml

Can perform basic tasks on a DAML ledger

## Overview
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.

- API version: 2.0.0-rc.3
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen

## Installation

Install the following dependencies:

```shell
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
```

Put the package under your project folder and add the following in import:

```golang
import cactus-plugin-ledger-connector-daml "github.com/hyperledger/cactus-plugin-ledger-connector-daml/src/main/go/generated/openapi/go-client"
```

To use a proxy, set the environment variable `HTTP_PROXY`:

```golang
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
```

## Configuration of Server URL

Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.

### Select Server Configuration

For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.

```golang
ctx := context.WithValue(context.Background(), cactus-plugin-ledger-connector-daml.ContextServerIndex, 1)
```

### Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.

```golang
ctx := context.WithValue(context.Background(), cactus-plugin-ledger-connector-daml.ContextServerVariables, map[string]string{
"basePath": "v2",
})
```

Note, enum values are always validated and all unused variables are silently ignored.

### URLs Configuration per Operation

Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.

```golang
ctx := context.WithValue(context.Background(), cactus-plugin-ledger-connector-daml.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), cactus-plugin-ledger-connector-daml.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
```

## Documentation for API Endpoints

All URIs are relative to *http://localhost*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*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
*DefaultApi* | [**ExerciseChoice**](docs/DefaultApi.md#exercisechoice) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-daml/exercise-iou-endpoint | This method exercise choices(DAML term for function on contracts) for iou countract
*DefaultApi* | [**GetPartiesInvolved**](docs/DefaultApi.md#getpartiesinvolved) | **Get** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-daml/get-parties-involved-endpoint | This method queries all the parties that is included on IOU contract
*DefaultApi* | [**QueryContract**](docs/DefaultApi.md#querycontract) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-daml/query-iou-endpoint | This method queries DAML contracts
*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 that does not include request body


## Documentation For Models

- [CreateIOUEndpointRequest](docs/CreateIOUEndpointRequest.md)
- [CreateIOUEndpointRequestPayload](docs/CreateIOUEndpointRequestPayload.md)
- [CreateIOUEndpointResponse](docs/CreateIOUEndpointResponse.md)
- [ExerciseIOUEndpointRequest](docs/ExerciseIOUEndpointRequest.md)
- [ExerciseIOUEndpointRequestArgument](docs/ExerciseIOUEndpointRequestArgument.md)
- [ExerciseIOUEndpointResponse](docs/ExerciseIOUEndpointResponse.md)
- [GetPartiesInvolvedEndpointRequest](docs/GetPartiesInvolvedEndpointRequest.md)
- [QueryIOUEndpointRequest](docs/QueryIOUEndpointRequest.md)
- [QueryIOUEndpointRequestQuery](docs/QueryIOUEndpointRequestQuery.md)
- [QueryIOUEndpointResponse](docs/QueryIOUEndpointResponse.md)
- [QueryIOUEndpointResponseEventsInner](docs/QueryIOUEndpointResponseEventsInner.md)
- [QueryIOUEndpointResponseEventsInnerArchived](docs/QueryIOUEndpointResponseEventsInnerArchived.md)
- [QueryRawIOUEndpointRequest](docs/QueryRawIOUEndpointRequest.md)


## Documentation For Authorization

Endpoints do not require authorization.


## Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains
a number of utility functions to easily obtain pointers to values of basic types.
Each of these functions takes a value of the given basic type and returns a pointer to it:

* `PtrBool`
* `PtrInt`
* `PtrInt32`
* `PtrInt64`
* `PtrFloat`
* `PtrFloat32`
* `PtrFloat64`
* `PtrString`
* `PtrTime`

## Author



Loading
Loading