Skip to content

Commit

Permalink
feat(polkadot): creation of polkadot connector openapi specs, test ca…
Browse files Browse the repository at this point in the history
…se and connector class

Primary Changes
---------------
1. Created openapi specs for get-prometheus-exporter-metrics, get-transaction-info,
   get-raw-transaction, sign-raw-transaction, run-transaction, deploy-contract-ink,
   and invoke-contract endpoints
2. Created relevant types for the request as well as response for the above endpoints
3. Added generated code for these endpoints
4. Created connector class with functions to interact with the polkadot ledger
5. Created webservices to interact with the endpoint and the relevant class method
6. Created unit and integration testcases in jest to test base functionality of the connector

Secondary Changes
-----------------
1. Added an ink! contract for running the testcases
2. Added the polkadot connector to ci workflow
3. Created substrate.md to docs-cactus
4. Added the polkadot connector to tsconfig.json

Signed-off-by: Anmol Bansal <[email protected]>
  • Loading branch information
AnmolBansalDEV committed Jan 13, 2024
1 parent cf223c8 commit d533ddc
Show file tree
Hide file tree
Showing 46 changed files with 6,479 additions and 38 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,31 @@ jobs:
node-version: ${{ env.NODEJS_VERSION }}
- uses: actions/[email protected]

- id: yarn-cache
name: Restore Yarn Cache
uses: actions/[email protected]
with:
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
path: ./.yarn/
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
- run: ./tools/ci.sh
cactus-plugin-ledger-connector-polkadot:
continue-on-error: false
env:
FULL_BUILD_DISABLED: true
JEST_TEST_PATTERN: packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_RUNNER_DISABLED: false
TAPE_TEST_RUNNER_DISABLED: true
needs: build-dev
runs-on: ubuntu-20.04
steps:
- name: Use Node.js ${{ env.NODEJS_VERSION }}
uses: actions/[email protected]
with:
node-version: ${{ env.NODEJS_VERSION }}
- uses: actions/[email protected]

- id: yarn-cache
name: Restore Yarn Cache
uses: actions/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions docs-cactus/source/support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ This section contains the ledger supported versions for connectors in Hyperledge
Fabric <support/fabric.md>
Iroha <support/iroha.md>
Quorum <support/quorum.md>
xDai <support/xdai.md>

xDai <support/xdai.md>
Substrate <support/substrate.md>

16 changes: 16 additions & 0 deletions docs-cactus/source/support/substrate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Substrate Support
-----------------


```{note}
Substrate chains include Polkadot, Kusama, Rococco, etc. The deployContract feature is for development and test case authoring only, not recommended to be used in production environments for managing smart contracts.
```

<details>
<summary>Hyperledger Cactus v1.0.0-rc3</summary>

| Substrate API version | deployContract* | invokeContract | runTransaction |
| --- | :---: | :---: | :---: |
| @polkadot/api 10.9.1 |[test]() |[test]() |[test]() |

</details>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "6.6.0"
}
}
123 changes: 123 additions & 0 deletions packages/cactus-plugin-ledger-connector-polkadot/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"name": "@hyperledger/cactus-plugin-ledger-connector-polkadot",
"version": "2.0.0-alpha.2",
"description": "Allows Cactus nodes to connect to a Substrate 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": "[email protected]",
"url": "https://www.hyperledger.org/use/cactus"
},
"contributors": [
{
"name": "Please add yourself to the list of contributors",
"email": "[email protected]",
"url": "https://example.com"
},
{
"name": "Catarina Pedreira"
},
{
"name": "Rafael Belchior"
},
{
"name": "Anmol Bansal",
"email": "[email protected]"
}
],
"type": "module",
"main": "dist/lib/main/typescript/index.js",
"module": "dist/lib/main/typescript/index.js",
"browser": "dist/cactus-plugin-ledger-connector-polkadot.web.umd.js",
"types": "dist/types/main/typescript/index.d.ts",
"files": [
"dist/*"
],
"scripts": {
"codegen": "run-p 'codegen:*'",
"codegen:openapi": "npm run generate-sdk",
"generate-sdk": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected",
"lint": "tslint tests/*.ts -t verbose",
"lint-fix": "tslint --fix tests/*.ts -t verbose",
"watch": "npm-watch",
"webpack": "npm-run-all webpack:dev webpack:prod",
"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",
"webpack:prod": "npm-run-all webpack:prod:node webpack:prod:web",
"webpack:prod:node": "webpack --env=prod --target=node --config ../../webpack.config.js",
"webpack:prod:web": "webpack --env=prod --target=web --config ../../webpack.config.js"
},
"dependencies": {
"@hyperledger/cactus-common": "2.0.0-alpha.2",
"@hyperledger/cactus-core": "2.0.0-alpha.2",
"@hyperledger/cactus-core-api": "2.0.0-alpha.2",
"@polkadot/api": "10.9.1",
"@polkadot/api-contract": "10.9.1",
"@polkadot/rpc-provider": "10.9.1",
"@polkadot/types": "10.9.1",
"@polkadot/util": "12.6.2",
"bl": "5.0.0",
"eslint": "7.21.0",
"express": "4.17.1",
"express-openapi-validator": "4.13.1",
"form-data": "4.0.0",
"fs-extra": "11.2.0",
"http-errors": "2.0.0",
"http-status-codes": "2.1.4",
"joi": "14.3.1",
"multer": "1.4.2",
"ngo": "2.6.2",
"openapi-types": "9.1.0",
"prom-client": "13.2.0",
"temp": "0.9.1",
"tslint": "6.1.3",
"typescript-optional": "2.0.1",
"uuid": "8.3.2"
},
"devDependencies": {
"@hyperledger/cactus-plugin-keychain-memory": "2.0.0-alpha.2",
"@hyperledger/cactus-test-tooling": "2.0.0-alpha.2",
"@types/express": "4.17.19",
"@types/http-errors": "2.0.4",
"@types/joi": "14.3.4",
"@types/multer": "1.4.7",
"@types/ssh2": "0.5.44",
"@types/supertest": "2.0.11",
"@types/temp": "0.9.1",
"@types/uuid": "8.3.1",
"axios": "0.22.0",
"supertest": "6.1.6"
},
"engines": {
"node": ">=10",
"npm": ">=6"
},
"publishConfig": {
"access": "public"
},
"browserMinified": "dist/cactus-plugin-ledger-connector-polkadot.web.umd.min.js",
"mainMinified": "dist/cactus-plugin-ledger-connector-polkadot.node.umd.min.js",
"watch": {
"codegen:openapi": {
"patterns": [
"./src/main/json/openapi.json"
]
}
}
}
Loading

0 comments on commit d533ddc

Please sign in to comment.