我正在使用 VSCodeExtention IBM Blockchain Platform 在打字稿中运行示例智能合约。
我只是按照这个步骤进行扩展:
- 创建新项目(在打字稿中)
- 打包这个项目
- 安装智能合约
- 实例化智能合约
当我更新我的模型 MyCloth 并运行时,npm run build
一切都很顺利。但是当我尝试升级我的 SmartContrat 时,我收到了这个错误:
[17.09.2019 à 07:28:39] [INFO] fabricvscodelocalfabric-peer0.org1.example.com-ClotheContract-0.0.4| --module-path [string] [default: "/usr/local/src"]
[17.09.2019 à 07:28:39] [INFO] fabricvscodelocalfabric-peer0.org1.example.com-ClotheContract-0.0.4|
[17.09.2019 à 07:28:39] [INFO] fabricvscodelocalfabric-peer0.org1.example.com-ClotheContract-0.0.4|{ [Error: can't resolve reference Object from id MyClothe#]
[17.09.2019 à 07:28:39] [INFO] fabricvscodelocalfabric-peer0.org1.example.com-ClotheContract-0.0.4| message: 'can\'t resolve reference Object from id MyClothe#',
[17.09.2019 à 07:28:39] [INFO] fabricvscodelocalfabric-peer0.org1.example.com-ClotheContract-0.0.4| missingRef: 'Object',
[17.09.2019 à 07:28:39] [INFO] fabricvscodelocalfabric-peer0.org1.example.com-ClotheContract-0.0.4| missingSchema: 'Object' }
[17.09.2019 à 07:28:39] [INFO] fabricvscodelocalfabric-peer0.org1.example.com-ClotheContract-0.0.4|npm ERR! code ELIFECYCLE
[17.09.2019 à 07:28:39] [INFO] fabricvscodelocalfabric-peer0.org1.example.com-ClotheContract-0.0.4|npm ERR! errno 1
[17.09.2019 à 07:28:39] [INFO] fabricvscodelocalfabric-peer0.org1.example.com-ClotheContract-0.0.4|npm ERR! ClotheContract@0.0.4 start: `fabric-chaincode-node start "--peer.address" "peer0.org1.example.com:17052"`
我的模型:
import { Object, Property } from 'fabric-contract-api';
import { Stakeholder, State } from '../enum';
@Object()
export class MyClothe {
@Property()
public id: string;
@Property()
public issuer: Stakeholder = Stakeholder.XXX; // the name or id of the company who issue the asset
@Property()
public owner: Stakeholder = Stakeholder.XXX; // the current owner of the asset
@Property()
public maturityDate: number = Date.now() + 1000 * 60 * 60 * 24 * 365; // the end date return of the asset in milisecond
@Property()
public additionalFee: number = 0; // Fee to charge the customer
@Property()
public currentState: State = State.Issued; // current state of the asset
@Property()
public params: any = { //new attribute added
param1: 'param1',
param2: 'param2',
}; // Additional params in the future need
}
包.json
{
"name": "ClotheContract",
"version": "0.0.4",
"description": "My Smart Contract",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"engines": {
"node": ">=8",
"npm": ">=5"
},
"scripts": {
"lint": "tslint -c tslint.json 'src/**/*.ts'",
"pretest": "npm run lint",
"test": "nyc mocha -r ts-node/register src/**/*.spec.ts",
"start": "fabric-chaincode-node start",
"build": "tsc",
"build:watch": "tsc -w",
"prepublishOnly": "npm run build"
},
"engineStrict": true,
"author": "John Doe",
"license": "Apache-2.0",
"dependencies": {
"fabric-contract-api": "1.4.2",
"fabric-shim": "1.4.2"
},
"devDependencies": {
"@types/chai": "^4.1.7",
"@types/chai-as-promised": "^7.1.0",
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.10",
"@types/sinon": "^5.0.7",
"@types/sinon-chai": "^3.2.1",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"mocha": "^5.2.0",
"nyc": "^14.0.0",
"sinon": "^7.1.1",
"sinon-chai": "^3.3.0",
"winston": "^3.2.1",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typescript": "^3.1.6"
},
"nyc": {
"extension": [
".ts",
".tsx"
],
"exclude": [
"coverage/**",
"dist/**"
],
"reporter": [
"text-summary",
"html"
],
"all": true,
"check-coverage": true,
"statements": 100,
"branches": 100,
"functions": 100,
"lines": 100
}
}