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(connector-polkadot): polkadot connector #1997

Closed

Conversation

RafaelAPB
Copy link
Contributor

This PR adds a long-term effort to adding preliminary support to Substrate-based chains. Most work wonderfully done by @CatarinaPedreira

"The Polkadot Connector provides functionality that enables any permissioned blockchain (as long as it is supported by Hyperledger Cactus) to connect to the Polkadot network and perform monetary transactions to the latter. Besides this, the connector provides methods for these blockchains to deploy and interact with smart contracts in the network.

Our connector in Hyperledger Cactus uses three different API’s to communicate with the Polkadot network: ”@polkadot/api” (which has the base API functionality), ”@polkadot/api-contracts” (which contains the API specific for smart contract interaction) and ”@polkadot/types” (which encompasses specific
Polkadot types)."

Features:
-transact on the network
-read smart contracts
-deploy smart contracts
-read from smart contracts
-endpoints for the features

Future work/limitations

  • The integration tests are commented/skipped because we need to add the source code of the smart contracts (metadata, etc) to the repository, such that they can be executed.
  • Some of the features could be more extensible/flexible, but again, this is the first version of the connector
  • Some endpoints are not fully implemented

Thanks to @petermetz for helping develop the test ledger.

Co-authored-by: CatarinaPedreira [email protected]
Signed-off-by: Rafael Belchior [email protected]


public setProvider(wsProviderUrl: string): void {
try {
this.wsProvider = new WsProvider(wsProviderUrl);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this even try to connect to the wsProviderUrl?
If yes, is there a way to avoid autoconnect by passing some other argument(s) to the WsProvider constructor or some other way? (If this is enabled, this will be helpful in the DAST scan, so that we can pass a dummy wsProviderUrl and don't require to spin up an actual all-in-one image for Polkadot)
@petermetz will we be adding this platform as well to the DAST scans?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it automatically connects (behind the scenes): https://polkadot.js.org/docs/api/start/create/
and yes.

@RafaelAPB RafaelAPB force-pushed the polkadot-connector-squashed branch 3 times, most recently from 782ad1e to 133f245 Compare May 2, 2022 12:01
"Authority",
"Stake",
"Work",
"Substrate"
Copy link
Contributor

Choose a reason for hiding this comment

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

@RafaelAPB By the consesus algorithm family "Substrate" are you referring to all the consensus algorithms listed here on their documentation? https://docs.substrate.io/v3/advanced/consensus/#consensus-in-substrate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to Substrate-GRANPA (for clarity)

Copy link
Contributor

@petermetz petermetz left a comment

Choose a reason for hiding this comment

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

@RafaelAPB Please delete the package-lock.json file, it's not being used since we migrated to yarn.

@@ -0,0 +1,8 @@
import test, { Test } from "tape-promise/tape";
Copy link
Contributor

Choose a reason for hiding this comment

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

@RafaelAPB Any chance that you could write the tests with Jest? See my earlier email on the mailing list for rationale (we've migrated over last summer)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see comment bellow

@@ -0,0 +1,89 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

@RafaelAPB Are these commented out because they are not needed at all to achieve sufficient coverage or some other reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests are not currently passing because the smart contracts are not being generated automatically from the source, and thus we cannot run them. Is this an impeditive issue?

@petermetz petermetz requested review from izuru0 and takeutak and removed request for jonathan-m-hamilton May 2, 2022 18:03
@petermetz petermetz added the Polkadot Tasks related or relevant to the Polkadot connector label May 2, 2022
@RafaelAPB RafaelAPB force-pushed the polkadot-connector-squashed branch 2 times, most recently from c6f30d4 to a296a35 Compare May 9, 2022 11:52
Co-authored-by: CatarinaPedreira <[email protected]>
Signed-off-by: Rafael Belchior <[email protected]>

feat(tools): substrate test ledger

Co-authored-by: CatarinaPedreira <[email protected]>
Co-authored-by: Peter Somogyvari <[email protected]>
Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): add transaction endpoint

Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): add documentation

Signed-off-by: Rafael Belchior <[email protected]>

chore(polkadot-connector): update dependencies

Signed-off-by: Rafael Belchior <[email protected]>

refactor(polkadot-connector): refactor endpoints

Signed-off-by: Rafael Belchior <[email protected]>

refactor(polkadot-connector): refactor connector

Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): get tx info endpoint

Signed-off-by: Rafael Belchior <[email protected]>

test(polkadot-connector): skip tests

Signed-off-by: Rafael Belchior <[email protected]>

feat(connector-polkadot): polkadot connector

Co-authored-by: CatarinaPedreira <[email protected]>
Signed-off-by: Rafael Belchior <[email protected]>

feat(tools): substrate test ledger

Co-authored-by: CatarinaPedreira <[email protected]>
Co-authored-by: Peter Somogyvari <[email protected]>
Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): add transaction endpoint

Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): add documentation

Signed-off-by: Rafael Belchior <[email protected]>

chore(polkadot-connector): update dependencies

Signed-off-by: Rafael Belchior <[email protected]>

refactor(polkadot-connector): refactor endpoints

Signed-off-by: Rafael Belchior <[email protected]>

refactor(polkadot-connector): refactor connector

Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): get tx info endpoint

Signed-off-by: Rafael Belchior <[email protected]>

test(polkadot-connector): skip tests

Signed-off-by: Rafael Belchior <[email protected]>

feat(connector-polkadot): add connector draft

Signed-off-by: Rafael Belchior <[email protected]>
Co-authored-by: CatarinaPedreira <[email protected]>
Signed-off-by: Rafael Belchior <[email protected]>

feat(tools): substrate test ledger

Co-authored-by: CatarinaPedreira <[email protected]>
Co-authored-by: Peter Somogyvari <[email protected]>
Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): add transaction endpoint

Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): add documentation

Signed-off-by: Rafael Belchior <[email protected]>

chore(polkadot-connector): update dependencies

Signed-off-by: Rafael Belchior <[email protected]>

refactor(polkadot-connector): refactor endpoints

Signed-off-by: Rafael Belchior <[email protected]>

refactor(polkadot-connector): refactor connector

Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): get tx info endpoint

Signed-off-by: Rafael Belchior <[email protected]>

test(polkadot-connector): skip tests

Signed-off-by: Rafael Belchior <[email protected]>

feat(connector-polkadot): polkadot connector

Co-authored-by: CatarinaPedreira <[email protected]>
Signed-off-by: Rafael Belchior <[email protected]>

feat(tools): substrate test ledger

Co-authored-by: CatarinaPedreira <[email protected]>
Co-authored-by: Peter Somogyvari <[email protected]>
Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): add transaction endpoint

Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): add documentation

Signed-off-by: Rafael Belchior <[email protected]>

chore(polkadot-connector): update dependencies

Signed-off-by: Rafael Belchior <[email protected]>

refactor(polkadot-connector): refactor endpoints

Signed-off-by: Rafael Belchior <[email protected]>

refactor(polkadot-connector): refactor connector

Signed-off-by: Rafael Belchior <[email protected]>

feat(polkadot-connector): get tx info endpoint

Signed-off-by: Rafael Belchior <[email protected]>

test(polkadot-connector): skip tests

Signed-off-by: Rafael Belchior <[email protected]>

feat(connector-polkadot): add connector draft

Signed-off-by: Rafael Belchior <[email protected]>
@petermetz
Copy link
Contributor

@jagpreetsinghsasan @AnmolBansalDEV I'm closing this for now just to keep our backlog of PRs tidy(er) but please re-open as soon as it is ready for review with the new changes incorporated from the LF mentorship program!

cc: @RafaelAPB

@petermetz petermetz closed this Sep 8, 2023
@RafaelAPB RafaelAPB deleted the polkadot-connector-squashed branch January 30, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Polkadot Tasks related or relevant to the Polkadot connector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants