Skip to content

Commit

Permalink
feat(ledger-connector): quorum added with contract deployment now gen…
Browse files Browse the repository at this point in the history
…eric

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed May 19, 2020
1 parent 3df6b73 commit 123d6ee
Show file tree
Hide file tree
Showing 32 changed files with 3,201 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules/
docs/main
logs/
jspm_packages/
generated-sources/

# Optional npm cache directory
.npm
Expand Down
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ For example web3 can be added as a dependency to the besu ledger connector plugi

```sh
npx lerna add web3@latest --scope '*/*plugin-ledger-connector-besu' --exact # [--dev] [--peer]
npx lerna add is-port-reachable --scope '*/*test-tooling' --exact # [--dev] [--peer]
```

If you are adding a development dependency you can use the `--dev` option and `--peer` for a peer dependency.
Expand All @@ -45,3 +44,9 @@ For example the `bif-test-tooling` can be added as a dev dependency to the besu
```sh
npx lerna add @hyperledger-labs/bif-test-tooling --scope '*/*plugin-ledger-connector-besu' --exact --dev
```

Or add the common library to allow you the usage of the logger for example:

```sh
npx lerna add @hyperledger-labs/bif-common --scope '*/*plugin-ledger-connector-quorum' --exact --dev
```
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"scripts": {
"configure": "lerna clean --yes && lerna bootstrap && npm run build && node ./tools/generate-api-server-config.js",
"start:api-server": "node ./packages/bif-cmd-api-server/dist/lib/main/typescript/cmd/bif-api.js --config-file=.config.json",
"pregenerate-sdk": "ts-node -e 'import(\"./packages/bif-cmd-api-server/src/main/typescript/openapi-spec\").then((x) => x.exportToFileSystemAsJson());'",
"export-open-api-spec": "ts-node -e 'import(\"./packages/bif-cmd-api-server/src/main/typescript/openapi-spec\").then((x) => x.exportToFileSystemAsJson());'",
"pregenerate-sdk": "npm-run-all export-open-api-spec",
"generate-sdk": "openapi-generator generate --input-spec bif-openapi-spec.json -g typescript-axios -o packages/bif-sdk/src/main/typescript/generated/openapi/typescript-axios/",
"tsc": "lerna exec --stream --ignore '*/*cockpit' -- tsc --project ./tsconfig.json",
"tsc": "lerna run tsc",
"clean": "lerna exec --stream --ignore '*/*cockpit' -- del-cli dist/** && del-cli packages/bif-sdk/src/main/typescript/generated/openapi/typescript-axios/*",
"build": "npm-run-all build:backend build:frontend",
"build:frontend": "lerna exec --stream --scope '*/*cockpit' -- ng build --prod",
Expand Down
4 changes: 3 additions & 1 deletion packages/bif-cmd-api-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"mainMinified": "dist/bif-core-api.node.umd.min.js",
"module": "dist/lib/main/typescript/index.js",
"types": "dist/types/main/typescript/index.d.ts",
"scripts": {},
"scripts": {
"tsc": "tsc --project ./tsconfig.json"
},
"engines": {
"node": ">=10",
"npm": ">=6"
Expand Down
3 changes: 3 additions & 0 deletions packages/bif-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"files": [
"dist/*"
],
"scripts": {
"tsc": "tsc --project ./tsconfig.json"
},
"publishConfig": {
"access": "public"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/bif-core-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"files": [
"dist/*"
],
"scripts": {
"tsc": "tsc --project ./tsconfig.json"
},
"engines": {
"node": ">=10",
"npm": ">=6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
/**
* Common interface to be implemented by plugins which are implementing the connection to ledgers.
*/
export interface IPluginLedgerConnector {
export interface IPluginLedgerConnector<T,K> {

/**
* Deploys the BIF build-in smart contract written for this ledger to manage the validator's public keys.
*/
deployContract(): Promise<void>;
deployContract(options?: T): Promise<K>;

/**
* Adds the public key to the ledger state.
Expand Down
3 changes: 3 additions & 0 deletions packages/bif-plugin-keychain-memory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"files": [
"dist/*"
],
"scripts": {
"tsc": "tsc --project ./tsconfig.json"
},
"publishConfig": {
"access": "public"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/bif-plugin-kv-storage-memory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"files": [
"dist/*"
],
"scripts": {
"tsc": "tsc --project ./tsconfig.json"
},
"engines": {
"node": ">=10",
"npm": ">=6"
Expand Down
4 changes: 4 additions & 0 deletions packages/bif-plugin-ledger-connector-besu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"files": [
"dist/*"
],
"scripts": {
"tsc": "tsc --project ./tsconfig.json"
},
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -46,6 +49,7 @@
},
"homepage": "https://github.com/hyperledger-labs/blockchain-integration-framework#readme",
"dependencies": {
"@hyperledger-labs/bif-common": "0.2.0",
"@hyperledger-labs/bif-core-api": "^0.2.0",
"joi": "14.3.1",
"web3": "1.2.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ITransactionOptions {
privateKey?: string;
}

export class PluginLedgerConnectorBesu implements IPluginLedgerConnector {
export class PluginLedgerConnectorBesu implements IPluginLedgerConnector<any, any> {

private readonly web3: Web3;
private readonly web3Eea: IWeb3InstanceExtended;
Expand All @@ -33,11 +33,8 @@ export class PluginLedgerConnectorBesu implements IPluginLedgerConnector {
return contract;
}

public async deployContractInternal(options: any): Promise<void> {

// const contract = this.instantiateContract(contractJsonArtifact);

const privateKey = options.privateKey.toLowerCase().startsWith('0x') ? options.privateKey.substring(2): options.privateKey; // besu node's private key
public async deployContract(options: any): Promise<void> {
const privateKey = options.privateKey.toLowerCase().startsWith('0x') ? options.privateKey.substring(2) : options.privateKey; // besu node's private key
const publicKey = options.publicKey; // orion public key of the sender
const allOrionPublicKeys: string[] = [options.publicKey]; // all orion public keys of receipients

Expand All @@ -55,10 +52,6 @@ export class PluginLedgerConnectorBesu implements IPluginLedgerConnector {
return txHash;
}

public deployContract(): Promise<void> {
return this.sendTransaction({});
}

public async addPublicKey(publicKeyHex: string): Promise<void> {
throw new Error("Method not implemented.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tap.test('deploys contract via .json file', async (assert: any) => {
contractJsonArtifact: HelloWorldContractJson,
};

const out = await connector.deployContractInternal(options);
const out = await connector.deployContract(options);
assert.ok(out);

assert.end();
Expand Down
9 changes: 9 additions & 0 deletions packages/bif-plugin-ledger-connector-quorum/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# `@hyperledger-labs/bif-plugin-ledger-connector-quorum`

> TODO: description
## Usage

```
// TODO: DEMONSTRATE API
```

0 comments on commit 123d6ee

Please sign in to comment.