Coder Social home page Coder Social logo

hyperledger-labs / convector Goto Github PK

View Code? Open in Web Editor NEW
145.0 17.0 45.0 8.71 MB

Smart Contract Systems the easy way. Open source development framework.

License: Other

TypeScript 49.35% Shell 1.70% CSS 30.97% JavaScript 3.23% Handlebars 14.75%
hyperledger-fabric typescript smart-contracts convector

convector's Introduction

CONVECTOR SUITE

The Convector Suite is an Open Source Suite for Enterprise Blockchain Networks created and maintained by WorldSibu. It is composed of a group of Development tools for Hyperledger Fabric and aims to be an agnostic toolset.

WorldSibu is an enterprise development platform for private blockchain systems. Creators of the open source suite Convector, as well as the enterprise offering Forma, the blockchain infrastructure automation platform with multi-cloud capabilities.

The Convector Suite is targeted at beginners and experts alike. For newcomers to the blockchain world is the easiest and fastest way to create great code. For experts it's the means to efficiently create scalable and secure code. The Convector Suite follows modern coding paradigms and was built from the ground up to run in multiple ledger technologies.

The Convector Suite main components are:

  • Convector Smart Contracts - JavaScript-based Development Framework for Enterprise Smart Contract Systems
  • Hurley - the easiest way to quickly setup your Hyperledger development environment. Instead of learning all the config files required and navigating tons of yaml files, just do hurl new and focus on your smart contract.
  • Convector CLI - the fastest and easiest way to build a new Convector Smart Contracts project. It is fully integrated with Hurley as well.
  • Convector REST Server - a RESTful API generator from a Convector smart contract. One command and you can expose your smart contract to the world.

Some key links:

Have doubts, want to collaborate or just meet other Convector devs around the world? Join the Discord (Chat) Community

What is Convector Smart Contracts?

Issues Newsletter npm Discord

TypeScript License lerna

Convector is a JavaScript-based Development Framework for Enterprise Smart Contract Systems. Its goal is to make it easier for developers to create, test and deploy enterprise-grade blockchain-based systems by abstracting complexities that make it hard to get started, plus a collection of tools that speed up your go-to-market.

For now, we only support Hyperledger Fabric, so this documentation is for using Convector Smart Contracts on Hyperledger Fabric.

Model/Controller pattern. Convector is designed to help you write reusable pieces of code that describe the nature of what a developer can do in a blockchain. A blockchain, in the developer’s eyes, is no more than a data layer protected by a logic layer defining the rules of what the outside world can do in with the inner data. Thus, a really comfortable way of writing chaincode logic (smart contracts) is by having Models describing the shape of the data and Controllers describing the actions and rules that apply to the models.

Create your first blockchain project

Make sure you meet the pre-requisites.

npm i -g @worldsibu/convector-cli
conv new car
cd car
npm install

# Start your local blockchain network
npm run env:restart

# Install the smart contract
npm run cc:start -- car

# Send your first transaction to the blockchain - Wait a few seconds!
hurl invoke car car_create '{"id":"car1","name":"jetta", "created":1,"modified":1}'

# See your new record created in the blockchain by visiting: http://localhost:5084/_utils/#database/ch1_car/_all_docs

Then, you can visit the official Docs Site, automatically add a REST API, or build it and deploy it to an enterprise blockchain network.

Assumptions

This documentation assumes that you are familiar with JavaScript, TypeScript, and Hyperledger Fabric (at least the basics!).

Are you looking for an option to Hyperledger Composer?

Yes, we are also aware that Composer's development has experienced some changes and a lot of people are facing uncertainty. If you are one of the devs looking for a way to create smart contract systems with native chaincodes in JavaScript, you are in the right place. You may find this resource valuable on how to Migrate from Composer to Convector.

Support

convector's People

Contributors

dependabot[bot] avatar diestrin avatar friendly-tech avatar jonathande avatar pratikpc avatar ricardomurillo avatar ryjones avatar sgbenav avatar walmon avatar worldsibu-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

convector's Issues

When unit testing: transaction timestamp is 0

The problem

Just a little problem I came accross. Don't no if it's just happening for me but thought it might be relevant:

When debugging my chaincode as explained in the tutorial from @waltermontes I get a txTimestamp = 0 when using this line in my code: const txTimestamp = this.tx.stub.getTxDate().getTime();

It's not that big of a deal since I can temporarily change it by hand for testing, but maybe it's just a small thing to change that could make life easier in the future 😃

Environment

  • Convector version 1.3.3
  • OS/version: macOS Mojave Version 10.14.3
  • Node.js version: 8.15.0
  • Npm package manager: 6.4.1
  • Convector CLI version: 1.1.3
  • Hurley CLI version: 1.0.1

Expected Behavior

Ideally, the txTimetamp returned by this.tx.stub.getTxDate().getTime() equals Date.now() of the moment of invokation of the chaincode and not =0

the "getOne function " returns data from the couchdb not from the blockchain

The problem

when I used "getOne function" the chaincode returns data from the CouchDB, not from the blockchain so as anyone can change the CouchDB data than the data loses there integrity

Current Behavior

if anyone changes the data in the world state without using the chaincode the data changes

Expected Behavior

even if the data has been changed in the CouchDB manually, the getOne function should return the unchanged data

Pagination Functionality

The problem

Hyperledger Fabric recently added the pagination feature. So, is it possible to add this feature to convector as pagination is very necessary for production level deployment.

Environment

  • Convector version (or git revision) that exhibits the issue:
  • Last Convector version that did not exhibit the issue (if applicable):
  • OS/version:
  • Node.js version:
  • Npm or Yarn package manager:
  • Convector CLI version (if applicable):
  • Hurley CLI version (if applicable):

Details

Current Behavior

Explain what the current behavior is

Expected Behavior

Explain what you were expecting to happend instead

Code To Reproduce Issue [ Good To Have ]

Please remember that with sample code it's easier to reproduce the bug and it's much faster to fix it.

Use convector-cli if possible as the base to reproduce the issue

Not getting expected output when invoking contract method from Nodejs code. However works fine with `hurl` cli

The problem

I try to invoke a method called create(@Param(Manager) manager: Manager) via Nodejs codebase, its getting successful(and I see log in docker container), Now, If I call get(@Param(yup.string()) id: string) method from nodejs code in order to retrive the object, what I get in return is just {"type":"io.worldsibu.manager"}, not the atual Manager object..... however If I use hurl to call the create method (like this hurl invoke manager manager_create '{"id":"b2abcde","type":"io.worldsibu.manager","name":"Test","created":1554892232910,"modified":1554892232910}') and then if I use get method, I am able to retrive the expected object as "{"id":"b2abcde","type":"io.worldsibu.manager","name":"Test","created":1554892232910,"modified":1554892232910}".

I have also check the docker container log in both the situations, there is not difference in both the creates calls.

Environment

  • Convector version (or git revision) that exhibits the issue:
  • Last Convector version that did not exhibit the issue (if applicable):
  • OS/version: Ubuntu 16.04
  • Node.js version:v10.15.3
  • Npm or Yarn package manager: npm 6.4.1
  • Convector CLI version (if applicable): 1.1.3
  • Hurley CLI version (if applicable): 1.0.4

Current Behavior

Getting {"type":"io.worldsibu.manager"} as output.

Expected Behavior

Should return {"id":"b2abcde","type":"io.worldsibu.manager","name":"Test","created":1554892232910,"modified":1554892232910}" as output

Code To Reproduce Issue [ Good To Have ]

This is how I am calling create method


const create = async (req, res) => {
  try {
    const modelSample = new Manager({
      id: uuid(),
      name: 'Test',
      created: Date.now(),
      modified: Date.now(),
    });
    console.log(modelSample.id);
    await ManagerControllerBackEnd.create(modelSample);
    
    res.status(200).json(JSON.stringify('SUCCESS'));
  } catch (err) {
    console.log(err);
    res.status(500).json(err);
  }
}

Note*:

  • I am able to get the expected result if I use hurl cli.
  • I also noticed the docker container log, in both the cases it is the same

Model and Controller generator

NG style. To bootstrap the basic structure of:

  • A Convector Smart Contract package
  • A Convector Mode
  • A Convector Controller

Add details to model failure exception message

The developer may get this error an exception like this when sending a proposal:

myapp: error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: {"name":"Error","status":500,"message":"Model io.worldsibu.car is not complete\n{\"type\":\"io.worldsibu.car\",\"make\":\"Volkswagen\",\"model\":\"Jetta\",\"colour\":\"gray\",\"owner\":\"Walter Montes\"}"}

It is not obvious that the hidden property id is missing. The exception message at convector-core-model/dist/src/convector-model.js:131:35 should include a label like "Maybe you forgot to include the 'id' property."

Objects retrieved from Fabric should be mapped to ConvectorModels in terms of their keys

The problem

Functions on retrieved instances derived from a ConvectorModel like history and query promise to return an instance of a defined ConvectorModel. For example history(): Promise<History<T>[]>;
The Template T is as I understand it a model extending ConvectorModel.
Instead of returning an object of type T it returns an object where every key has the prefix '_' to the keys defined in T.

Current Behavior

history(): Promise<History<T>[]> does not return Promise<History<T>[]> but Promise<History<T2>[]> where T2 has '_' as the prefix to every key defined in T.

Expected Behavior

history(): Promise<History<T>[]> should actually return Promise<History<T>[]>

I think this is because those functions call the chaincode and just return the object returned from hyperledger fabric (I therefore suspect that all values are strings too). My expectation would be that the returned object would be cast to the specified ConvectorModel.

@Validate doesn't support yup.lazy

The problem

@Validate throws an error when using yup.lazy() because of the yup version.
Prior version 0.26.10 of yup, lazy doesn't have validateSync

Environment

  • Convector version (or git revision) that exhibits the issue: 1.2.0
  • Last Convector version that did not exhibit the issue (if applicable): n/a
  • OS/version: n/a
  • Node.js version: 8.10
  • Npm or Yarn package manager: npm
  • Convector CLI version (if applicable): n/a
  • Hurley CLI version (if applicable): n/a

Details

Current Behavior

Convector throws an error when using yup.lazy()

Expected Behavior

Convector to support yup.lazy()

'Type MyController is not assignable to type 'ConvectorController<any>'

The problem

I have built a smart contract to store and authenticate users, which has been fully unit tested and thus works just fine when ran as tests. However, when I try to package the chaincode to install it into my fabric network, I get the following error:

https://i.imgur.com/mEi5f4G.png

I am building my project on top of: https://github.com/worldsibu/convector-example-fabcar-rest

Environment

  • Convector version (or git revision) that exhibits the issue:

    • conv-rest-api: 0.1.1
    • convector-adapter-mock: 1.3.6
    • convector-platform-fabric 1.3.6
  • OS/version: Ubuntu 19.04

  • Node.js version: v10.15.2

  • Npm or Yarn package manager: Npm

Code To Reproduce Issue [ Good To Have ]

import * as yup from 'yup';
import {
  Controller,
  ConvectorController,
  Invokable,
  Param
} from '@worldsibu/convector-core';
import * as uuid from 'uuid/v4';
import * as bcrypt from "bcryptjs";
import * as jwt from "jsonwebtoken";
import { User } from './user.model';

const JWT_SECRET = "SOME TOKEN";

@Controller('user')
export class UserController extends ConvectorController<any> {
  @Invokable()
  public async init() {
    ..
  }

  @Invokable()
  public async create(@Param(User) user: User) {
    ..
  }

  @Invokable()
  public async authenticate(@Param(yup.string()) username: string, @Param(yup.string()) password: string): Promise<any> {
    ..
  }

  @Invokable()
  public async queryOne(@Param(yup.string()) id: string): Promise<User> {
    ..
  }

  @Invokable()
  public async getAll(): Promise<User[]> {
    ..
  }
}

Line 21 in the image refers to:

export const UserControllerBackEnd = 
    ClientFactory(UserController, adapter);

export const CompanyControllerBackEnd = 
    ClientFactory(CompanyController, adapter);

Related stackoverflow link: https://stackoverflow.com/questions/58823028/how-to-fix-type-mycontroller-is-not-assignable-to-type-convectorcontrollerany

Empty object should be handled before passing to JSON.parse

The problem

in this line empty object should be handled before passing to JSON.parse... check it out
const result = JSON.parse(txResult.result.response.payload.toString('utf8'));

https://github.com/hyperledger-labs/convector/blob/develop/%40worldsibu/convector-common-fabric-helper/src/client.helper.ts#L198

Environment

  • Convector version (or git revision) that exhibits the issue:
  • Last Convector version that did not exhibit the issue (if applicable):
  • OS/version:
  • Node.js version:
  • Npm or Yarn package manager:
  • Convector CLI version (if applicable):
  • Hurley CLI version (if applicable):

Details

Current Behavior

Explain what the current behavior is

Expected Behavior

Explain what you were expecting to happend instead

Code To Reproduce Issue [ Good To Have ]

Please remember that with sample code it's easier to reproduce the bug and it's much faster to fix it.

Use convector-cli if possible as the base to reproduce the issue

FlatConvectorModel with optional properties

The problem

When using a FlatConvectorModel and T has optional properties, you are not able to assign T to the property.

See here for example

Details

Current Behavior

A compiler error when assigning T to FlatConvectorModel

Expected Behavior

It should cater for optional properties

Code To Reproduce Issue [ Good To Have ]

class TestModel extends ConvectorModel<TestModel> {
  public type = 'io.worldsibu.test';

  @Validate(yup.string())
  public name: string;

  @Validate(yup.number())
  public optionalProperty?: number;
}

class TestFlatModel extends ConvectorModel<TestFlatModel> {
  public type = 'io.worldsibu.test2';

  @Validate(TestModel)
  public child: FlatConvectorModel<TestModel>;

}

var item = new TestModel();
var parent = new TestFlatModel();
parent.child = item; //Compiler error here..

Better support for arrays for @Param() decorator

When you have a param into a controller method that is an array you need to specify the array schema manually.

public async saveBulk(
@Param(yup.array().transform(values => values.map(v => new MyModel(v)))) 
bulkItems: Array<MyModel>): Promise<any> { ... }

but it would be nice if the @Param() decorator could detect the array input type and handle it accordingly, this may well apply to the Validate() decorator as well.

Catch config-time errors

When a developer makes mistakes on config, details are not shown

It shows something like UnhandledPromiseRejectionWarning with no further details.

Required decorator ignored on properties on child objects

The problem

When creating a convector model which has properties which are simple classes, properties decorated with @require() on this child class are ignored.

Details

Having a property on a convector model that points to another class, then on that child class i have a required property - the save does not fail if i do not pass this value in for this property.

See This issue for code setup, just add a Required() attribute to one of the properties on the child class.

Issue with properties in complex objects and tests.

The problem

When passing a model to a controller in a test and that model has a property that is a simple class (not a convector model), any properties on that child class are not populated when hitting the controller method.

Details

I have a convector Model (lets call it Parent), this has a property called Child with a type of ChildClass (this is a simple class, not Convector model) - this child class has a property called Name (string).

I decorate all of my properties correctly and manually create the schema using yup for the plain old typescript object.

I have a simple controller with a method that just returns whats passed in (and calls .ToJSON()), i write a test that creates an instance of Parent, then creates and instance of Parent.Child and sets Name equal to "NAME".

i simply pass this instance of parent into my controller method - when i hit the controller method, my instance of Parent indeed has an instance of ChildClass in the .Child property but the Name property of this instance is not set.

When running this in the actual network, this does not happen - only in the test.

Current Behavior

Child properties of child classes are not populated on the way in to the controller.

Expected Behavior

All properties should be populated correctly.

Code To Reproduce Issue [ Good To Have ]

Models


import * as yup from 'yup';
import {
  ConvectorModel,
  Default,
  ReadOnly,
  Required,
  Validate,
  getPropertiesValidation
} from '@worldsibu/convector-core-model';

export class ChildClass {
    @Required()
    @Validate(yup.string())
    public childClassName: string;

    public static schema()  {
        var inst = new ChildClass();
        return yup.object().shape({
            ...getPropertiesValidation(inst)
        });
    }
}

export class ParentClass extends ConvectorModel<ParentClass> {
  @ReadOnly()
  @Required()
  public readonly type = 'io.worldsibu.ParentClass';

  @Required()
  @Validate(yup.string())
  public name: string;

  @Required()
  @Validate(ChildClass.schema())
  public Child: ChildClass;
  
  
}

Controller

import {
  Controller,
  ConvectorController,
  Invokable,
  Param
} from '@worldsibu/convector-core-controller';

import { ParentClass } from './bugrepro.model';

@Controller('bugrepro')
export class BugreproController extends ConvectorController {
  @Invokable()
  public async test(@Param(ParentClass) pc: ParentClass): Promise<any> {
    // The issue isnt that this toJSON doesnt allow the property out, its that its not here on the way in
    if (!pc.Child.childClassName)   {
      // Was set in our test so shouldnt be missing, but it is...?
        // Toggle debug with --inspect-brk
        //pc.Child._childClassName is  set.. ?
      debugger;
    }
    return pc.toJSON();
  }
}

Test


// tslint:disable:no-unused-expression
import { join } from 'path';
import { expect } from 'chai';
import * as uuid from 'uuid/v4';
import { MockControllerAdapter } from '@worldsibu/convector-adapter-mock';
import 'mocha';

import {ChildClass, ParentClass} from '../src/bugrepro.model';
import { BugreproControllerClient } from '../client';

describe('Bugrepro', () => {
    let modelSample: ParentClass;
    let adapter: MockControllerAdapter;
    let bugreproCtrl: BugreproControllerClient;

    before(async () => {
        const now = new Date().getTime();
        modelSample = new ParentClass();
       
        modelSample.name = 'Parent';
        modelSample.Child = new ChildClass();
        modelSample.Child.childClassName = 'Child';
        adapter = new MockControllerAdapter();
        bugreproCtrl = new BugreproControllerClient(adapter);
        await adapter.init([
            {
            version: '*',
            controller: 'BugreproController',
            name: join(__dirname, '..')
            }
        ]);

    });

    it('should return whats passed in', async () => {
        var item = await bugreproCtrl.test(modelSample);
        expect(item.Child.childClassName).to.equal('Child');
    });
});

Error in generate-controller-interface when adding static method as first method in controller

The problem

Adding a single static method as the first method in a controller, causes the following error

Error: Argument Error (order): Range is 0 to 24, but 25 was provided.

Details

I had some static methods in my class, when i ran linting in moved these to the top - i then got the error(s).
Interestingly if you add it as last method, or add another static method it goes away..

Code To Reproduce Issue

Added to the supplychain controller

@Controller('supplychainchaincode')
export class SupplychainchaincodeController extends ConvectorController {
  //Just add this
  private static test(){}

  @Create('Supplier')
  @Invokable()
  public async createSupplier() ....

Then run npm run test - there are no tests but shows the error.

Add relationships to models

Right now, relationships are based by keys. We should add proper relationships decorators following ORM patterns like One-to-One, One-to-Many and Many-to-Many.

On Server SDK show error details

The problem

When sending a transaction that should fail, the nodejs SDK won't show all the levels of the error.

Environment

  • Convector version (or git revision) that exhibits the issue: 1.3.0
  • Last Convector version that did not exhibit the issue (if applicable):
  • OS/version: Mac
  • Node.js version: 8.11
  • Npm or Yarn package manager: NPM
  • Convector CLI version (if applicable):
  • Hurley CLI version (if applicable):

Details

Show more details of the error by printing the whole response object.

Current Behavior

It won't show the exact error of the responses.

Expected Behavior

Should show the details of the errors from every peer.

Code To Reproduce Issue [ Good To Have ]

Send a transaction from nodejs to a function inside of the chaincode that breaks by design such as:

throw new Error('expected')

Fix

Add this to the place where the error is printed (import util first)

console.log(util.inspect(ex, {showHidden: false, depth: null}))

Document common issues for Linux users

From the Discord chat we have seen Linux users facing similar difficulties, we should update DOCs accordingly.

  1. Docker Compose

Docker doesn't include Compose by default: https://docs.docker.com/compose/install/

  1. Node Gyp rebuild

https://github.com/nodejs/node-gyp#on-unix

- > node-gyp rebuild

gyp ERR! build error 
gyp ERR! stack Error: not found: make
  1. Node Gyp permissions

worldsibu/hurley#6

gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/@worldsibu/hurley/node_modules/pkcs11js/.node-gyp'
  1. Script incompatibility: (thanks to @xcottos)
Hi all, it's not a convector issue but more an Ubuntu 18.04 one but I want to share it with you: there were some ppl receiving an error in Ubuntu 18.04 while invoking the cc:invoke script defined like that: "cc:invoke": "f() { chaincode-manager --config ./$2.$1.config.json --user $3 invoke $1 ${@:4}; }; f". The error was something like sh: 1: bad substitution. It's because by default linux uses sh (symlinked to dash in Ubuntu) for executing the npm scripts. For this reason if anyone asks for help on that the procedure is the following:
1) updating npm to a version >= 5
2) npm config set script-shell /bin/bash
this is general for all ppl having the issue, while for Ubuntu users if the command npm -v still shows the old version of npm (like 3.5.7) they have to:
3) sudo apt purge npm
4) ln -s /usr/local/bin/npm /usr/bin/npm
5) npm config set script-shell /bin/bash
it's because of bash caching the binaries links as documented here  https://askubuntu.com/questions/1036278/npm-is-incorrect-version-on-latest-ubuntu-18-04-installation

Allow models inheritance

Current Behavior:
Right now models cannot extend another model, since it will loose all the decorator's information

Expected Behavior:
We should be able to extend models and still keep the decorators validations

Ignored Errors from chaincode

The problem

When an Error occurs inside of the chaincode (i.e.: making a throw new Error(...)) the returning message is not parsed as an Error object, therefore errors are going missing. It's returning null right now.

Environment

  • Convector version (or git revision) that exhibits the issue: 1.2.0
  • Last Convector version that did not exhibit the issue (if applicable):
  • OS/version: MAC Mojave 10.14
  • Node.js version: v8.12.0
  • Npm or Yarn package manager: 6.4.1
  • Convector CLI version (if applicable): 1.0.6
  • Hurley CLI version (if applicable):

Details

Unexpected way of handling errors, looks like Fabric changed something from 1.1 to 1.3-1.4.

Current Behavior

It returns null instead of an Error object.

Expected Behavior

Throw the original Error.

Code To Reproduce Issue [ Good To Have ]

Inside a controller

throw new Error(`Ups, the requesting identity is not authorized to update the model`);

In a unit test just call it with a try catch and the error won't be found, but the response will be null.

 try {
            let rs = await mybuggychaincodeCtrl.update(modelSample);
            // returns null
            console.log(rs);
            await expect.fail('Should have failed');
        } catch (ex) {
            // should fall in here
            console.log(ex);
        }

Support ConvectorComplexType<MyComplexType> similar to ConvectorModel<MyType>

Currently, if a class inherits from ConvectorModel:

export class Account extends ConvectorModel
and
@Validate(Account)

However, if you have classes that don't inherit from ConvectorModel, it is quite cumbersome.

export interface ContentItem {
value: any;
name: string;
}

export const ContentItem = yup.object({
value: yup.mixed().required(),
name: yup.string().required()
});

I propose that you support:

class MyComplexType extends ConvectorComplexType

Show how to integrate backend and front end

Getting Started only shows how to setup a project. There's a reference to a fullstack project, but it is necessary to show the actual details and step by step which are not documented outside the fullstack example.

TLS authentication

We need to think about the TLS connection on how to handle it. Since the cert must be set on each peer directly, we must figure out this for the user.

It needs to handle TLS as well mutual TLS auth.

Private Data support validation

The problem

Validate Private Data support. There are some errors when accessing the stub directly: https://github.com/worldsibu/convector-test-private-data/blob/master/packages/product-cc/src/product.controller.ts#L40

Environment

  • Convector version (or git revision) that exhibits the issue: 1.2.1-0-alpha.d00d4639
  • Last Convector version that did not exhibit the issue (if applicable):
  • OS/version:
  • Node.js version: 8.11
  • Npm or Yarn package manager: 6.4.1
  • Convector CLI version (if applicable):
  • Hurley CLI version (if applicable):

Details

Current Behavior

Expected Behavior

Save data as save() does.

Code To Reproduce Issue [ Good To Have ]

When invoking with the wrong function name, Convector fails with `[Object object]`

No info is provided about the error, this is the chaincode error

info: [Chaincode] Args: CarCar_create,{'name':'test','id':'iddd',created:0,modified:0}
error: [Chaincode] no function of name: CarCar_create found
2019-02-20T05:53:20.939Z ERROR [lib/handler.js] [ch1-a0f5c273]Calling chaincode Invoke() returned error response [[object Object]]. Sending ERROR message back to peer

Silent error - cosmetic fix

When installing a chaincode there's a silent error. No stopper, everything works. This is a cosmetic fix.

> [email protected] cc:install /Users/walter/Development/testerx/project
> f() { chaincode-manager --config ./$3.$1.config.json install ./chaincode $1 $2; }; f "token" "1" "org2"

Installing now...
info: [packager/Node.js]: packaging Node Chaincode from /Users/walter/Development/testerx/project/chaincode
Installed successfully

> [email protected] cc:instantiate /Users/walter/Development/testerx/project
> f() { chaincode-manager --config ./$3.$1.config.json instantiate $1 $2; }; f "token" "1" "org1"

Instantiating now...
error: [Transform] Error parsing buffer to JSON
token1escc"vscc*(



Org1MSP

Org2MSP2D
 3P�f�����7F0Uz�Hk/r��7빼!m�@ �>k
                                 �l��O���q�f�M �Q�AM�ѸM1�x�: �J��FH�
                                                                    tP)��>��rf���[(֗[���aB,



Org1MSP

Org2MSP
Instantiated successfully
Initializing controllers now...

is this project is active ?

I like the work,effort here , and i am planing to use this framework in my next project .

But i am afraid that this project will be under development anymore .

So the question is : what is the road map for this project ?

Thank you .

ConvectorModel.getOne: Check the matching between the JSON fetched from the database and the target Convector model

The problem

The method ConvectorModel.getOne is supposed to throw an exception when the value of the field type is different between the Convector model and the JSON fetched from the database.

  • First, the reason why the exception is not thrown in this method can be a bug.
  • And second, I think that Convector should be in general be able to throw an exception when one or some details do not match between the data fetched from the ledger and the Convector model in TypeScript. This can be seen as one advantage of strong typing and therefore allow to detect potential incoherence early during the execution.

Environment

  • Convector version (or git revision) that exhibits the issue: 1.3.3

Details

In a situation where I have for example two types of participants in my network: InvestorParticipant and CareerAdvisorParticipant. The two models have the same structure, their unique difference is the value of the field type.

export class InvestorParticipant extends AbstractTrainingParticipantModel<InvestorParticipant> {
    @ReadOnly()
    @Required()
    readonly type = 'io.worldsibu.investor';
}
export class CareerAdvisorParticipant extends AbstractTrainingParticipantModel<CareerAdvisorParticipant> {
     @ReadOnly()
    @Required()
    readonly type =  'io.worldsibu.careerAdvisor';
}

And we have the set of AssetA owned by CareerAdvisorParticipant :

// AssetA owned by CareerAdvisorParticipant 
export  class AssetA<T extends AssetA<any>> extends ConvectorModel<T> {
    @ReadOnly()
    @Required()
    public readonly type = 'io.worldsibu.AssetA';
    
    @Required()
    @Validate(yup.string())
     ownerId: string;
}

Current Behavior

Before saving AssetA for example, I must verify that the owner exists and is a CareerAdvisorParticipant:
const participant = await CareerAdvisorParticipant.getOne(assetA.ownerId);
Surprisingly, this call wil work fine if assetA.ownerId is the id of an InvestorParticipant. But in the code, the method ConvectorModel.getOne is supposed to throw an exception because we were expecting from the database a "data of type CareerAdvisorParticipant", but we got a "data of type InvestorParticipant" instead. This is the code:

    const content = await BaseStorage.current.get(id, storageOptions);

    const model = new type(content);

    if ((content && model) && content.type !== model.type) {
      throw new Error(`Possible ID collision, element ${id} of type ${content.type} is not ${model.type}`);
    }

    return model;

The exception is not thown because the value of the field "type" of model that is supposed to be a constant is overwritten by the value of the field "type" in the JSON(content) during the conversion.

Expected Behavior

As shown above, the expected behavior of the method ConvectorModel.getOne seems to be to throw an exception in this kind of scenario.

And in general, I think that Convector should help us to detect incoherence when we are trying to use the data fetched from the ledger with Convector models.

Hurley install fails at x509

The problem

Hi I am trying to install hruley on ubuntu 18.04, but it fails at the install of x509. I even tried building x509 from source with node-gyp it still fails with same error as below. Any help would be appreciated

The Issue :

node-gyp/12.3.1/include/node/v8.h:5947:46: note: candidate expects 1 argument, 0 provided
../src/addon.cc:29:57: error: no matching function for call to ‘v8::FunctionTemplate::GetFunction()’
Nan::New(parse_cert)->GetFunction());
^
In file included from ./.cache/node-gyp/12.3.1/include/node/node.h:63:0,
from ../include/addon.h:4,
from ../src/addon.cc:4:
./.cache/node-gyp/12.3.1/include/node/v8.h:5947:46: note: candidate: v8::MaybeLocalv8::Function v8::FunctionTemplate::GetFunction(v8::Localv8::Context)
V8_WARN_UNUSED_RESULT MaybeLocal GetFunction(
^~~
./.cache/node-gyp/12.3.1/include/node/v8.h:5947:46: note: candidate expects 1 argument, 0 provided
x509.target.mk:112: recipe for target 'Release/obj.target/x509/src/addon.o' fail

Environment

  • Convector version (or git revision) that exhibits the issue: npm i @worldsibu/hurley
  • Last Convector version that did not exhibit the issue (if applicable):
  • OS/version: Ubuntu 18.04
  • Node.js version: v12.3.1
  • Npm or Yarn package manager:6.9.0
  • Convector CLI version (if applicable):
  • Hurley CLI version (if applicable):

npm install error

npm v - 6.4.1
node v - 8.11.0
os - ubantu 18.04.1 LTS
After creating a new convector project by following steps at
--> https://worldsibu.github.io/convector/modules/getting_started.html
on installing npm in my test project I get this error.


/home/engineer/testing/node_modules/ts-simple-ast/dist/manipulation/manipulations/doManipulation.js:14
throw new errors.InvalidOperationError(err.message + "\n" +
^

Error: Error replacing tree: Should not have new children left over.
-- Details --
Path: /home/engineer/testing/packages/testing-chain-cc/client/testing-chain.controller.ts
Text: "...nds ConvectorController {\n @invokable()\n public async create(\n @param(TestingChain)\n testing\n\n public name = 'testing-chain';\n-chain: TestingChain\n ) {\n await testing-chain.save();\n }\n}"
at InvalidOperationError.BaseError [as constructor] (/home/engineer/testing/node_modules/ts-simple-ast/dist/errors/BaseError.js:7:28)
at new InvalidOperationError (/home/engineer/testing/node_modules/ts-simple-ast/dist/errors/InvalidOperationError.js:8:28)
at Object.doManipulation (/home/engineer/testing/node_modules/ts-simple-ast/dist/manipulation/manipulations/doManipulation.js:14:15)
at insertIntoBracesOrSourceFile (/home/engineer/testing/node_modules/ts-simple-ast/dist/manipulation/manipulations/insertion.js:101:22)
at Object.insertIntoBracesOrSourceFileWithGetChildren (/home/engineer/testing/node_modules/ts-simple-ast/dist/manipulation/manipulations/insertion.js:140:5)
at ClassDeclaration.insertProperties (/home/engineer/testing/node_modules/ts-simple-ast/dist/compiler/class/ClassDeclaration.js:288:31)
at ClassDeclaration.addProperties (/home/engineer/testing/node_modules/ts-simple-ast/dist/compiler/class/ClassDeclaration.js:271:21)
at ClassDeclaration.addProperty (/home/engineer/testing/node_modules/ts-simple-ast/dist/compiler/class/ClassDeclaration.js:264:21)
at Object. (/home/engineer/testing/node_modules/@worldsibu/convector-core-adapter/dist/src/generate-interface.js:32:12)
at Module._compile (module.js:652:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] client:generate: generate-controller-interface -c TestingChainController
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] client:generate script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/engineer/.npm/_logs/2018-12-03T07_35_16_803Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: npm run clean && npm run client:generate && tsc
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/engineer/.npm/_logs/2018-12-03T07_35_16_819Z-debug.log
lerna info lifecycle [email protected]~prepare: Failed to exec prepare script
lerna ERR! lifecycle "prepare" errored in "testing-chain-cc", exiting 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lerna:install: lerna bootstrap
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] lerna:install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/engineer/.npm/_logs/2018-12-03T07_35_16_837Z-debug.log
ERROR: "lerna:install" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: npm-run-all -s lerna:install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/engineer/.npm/_logs/2018-12-03T07_35_16_858Z-debug.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.