Fixes for build breakages

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
This commit is contained in:
Mark S. Lewis 2023-09-11 18:46:15 +01:00 committed by Dave Enyeart
parent 30f70f6e73
commit 6e71f634e2
26 changed files with 5792 additions and 3750 deletions

View file

@ -14,8 +14,8 @@
"author": "Hyperledger",
"license": "Apache-2.0",
"dependencies": {
"fabric-ca-client": "^2.2.4",
"fabric-network": "^2.2.4"
"fabric-ca-client": "^2.2.19",
"fabric-network": "^2.2.19"
},
"devDependencies": {
"eslint": "^7.32.0"

View file

@ -20,8 +20,8 @@
"author": "Hyperledger",
"license": "Apache-2.0",
"dependencies": {
"fabric-ca-client": "^2.2.8",
"fabric-network": "^2.2.8"
"fabric-ca-client": "^2.2.19",
"fabric-network": "^2.2.19"
},
"devDependencies": {
"@types/node": "^12.20.55",

View file

@ -5,8 +5,7 @@
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"engines": {
"node": ">=14.14",
"npm": ">=6"
"node": ">=14.14"
},
"scripts": {
"lint": "tslint -c tslint.json 'src/**/*.ts'",
@ -20,10 +19,11 @@
"author": "Hyperledger",
"license": "Apache-2.0",
"dependencies": {
"fabric-ca-client": "^2.2.4",
"fabric-network": "^2.2.4"
"fabric-ca-client": "^2.2.19",
"fabric-network": "^2.2.19"
},
"devDependencies": {
"@tsconfig/node14": "^14.1.0",
"@types/node": "^14.17.32",
"tslint": "^5.11.0",
"typescript": "~4.9.4"

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import * as FabricCAServices from 'fabric-ca-client';
import FabricCAServices from 'fabric-ca-client';
import { Wallet } from 'fabric-network';
const adminUserId = 'admin';

View file

@ -1,14 +1,10 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tsconfig/node14/tsconfig.json",
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "dist",
"target": "es2017",
"moduleResolution": "node",
"module": "commonjs",
"declaration": true,
"sourceMap": true,
"noImplicitAny": true
},
"include": [
"./src/**/*"

File diff suppressed because it is too large Load diff

View file

@ -4,8 +4,7 @@
"description": "Asset Transfer Basic REST API implemented in TypeScript",
"main": "dist/index.js",
"engines": {
"node": ">=12",
"npm": ">=5"
"node": ">=12"
},
"dependencies": {
"bullmq": "^1.47.2",
@ -14,10 +13,11 @@
"env-var": "^7.0.1",
"express": "^4.18.2",
"express-validator": "^6.12.0",
"fabric-network": "^2.2.10",
"fabric-network": "^2.2.19",
"helmet": "^4.6.0",
"http-status-codes": "^2.1.4",
"ioredis": "^4.27.8",
"long": "^5.2.3",
"passport": "^0.6.0",
"passport-headerapikey": "^1.2.2",
"pino": "^6.11.3",
@ -25,6 +25,7 @@
"source-map-support": "^0.5.19"
},
"devDependencies": {
"@tsconfig/node12": "^12.1.0",
"@types/cors": "^2.8.12",
"@types/express": "^4.17.12",
"@types/ioredis": "^4.26.4",
@ -34,21 +35,21 @@
"@types/pino": "^6.3.8",
"@types/pino-http": "^5.4.1",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
"eslint": "^7.29.0",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"eslint": "^8.49.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"ioredis-mock": "^5.6.0",
"jest": "^27.5.1",
"jest-mock-extended": "^2.0.2-beta2",
"jest": "^29.7.0",
"jest-mock-extended": "^3.0.5",
"pino-pretty": "^5.0.2",
"prettier": "^2.3.1",
"rimraf": "^3.0.2",
"supertest": "^6.1.4",
"ts-jest": "^27.1.4",
"ts-jest": "^29.1.1",
"ts-node": "^10.1.0",
"typescript": "^4.3.5"
"typescript": "~5.2.0"
},
"scripts": {
"prebuild": "npm run lint",

View file

@ -7,7 +7,7 @@ import { Application } from 'express';
import { Contract, Transaction } from 'fabric-network';
import * as fabricProtos from 'fabric-protos';
import { mock, MockProxy } from 'jest-mock-extended';
import { mocked } from 'ts-jest/utils';
import { jest } from '@jest/globals';
import request from 'supertest';
import * as config from '../config';
import { createServer } from '../server';
@ -609,7 +609,7 @@ describe('Asset Transfer Besic REST API', () => {
});
it('GET should respond with 404 not found json when there is no job with the specified ID', async () => {
mocked(Job.fromId).mockResolvedValue(undefined);
jest.mocked(Job.fromId).mockResolvedValue(undefined);
const response = await request(app)
.get('/api/jobs/3')

View file

@ -40,7 +40,8 @@ export const authenticateApiKey = (
passport.authenticate(
'headerapikey',
{ session: false },
(err, user, _info) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(err: any, user: Express.User, _info: any) => {
if (err) return next(err);
if (!user)
return res.status(UNAUTHORIZED).json({

View file

@ -8,15 +8,16 @@ import {
DefaultQueryHandlerStrategies,
Gateway,
GatewayOptions,
Wallets,
Network,
Transaction,
Wallet,
Wallets,
} from 'fabric-network';
import * as config from './config';
import { logger } from './logger';
import { handleError } from './errors';
import * as protos from 'fabric-protos';
import Long from 'long';
import * as config from './config';
import { handleError } from './errors';
import { logger } from './logger';
/**
* Creates an in memory wallet to hold credentials for an Org1 and Org2 user
@ -189,7 +190,7 @@ export const getTransactionValidationCode = async (
*/
export const getBlockHeight = async (
qscc: Contract
): Promise<number | Long.Long> => {
): Promise<number | Long> => {
const data = await qscc.evaluateTransaction(
'GetChainInfo',
config.channelName

View file

@ -1,73 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tsconfig/node12/tsconfig.json",
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
"sourceMap": true,
"outDir": "./dist"
},
"include": [
"src/"

View file

@ -13,8 +13,8 @@
"lint": "eslint *.js"
},
"dependencies": {
"fabric-ca-client": "^2.2.2",
"fabric-network": "^2.2.2"
"fabric-ca-client": "^2.2.19",
"fabric-network": "^2.2.19"
},
"devDependencies": {
"eslint": "^7.32.0"

View file

@ -14,8 +14,8 @@
"lint": "eslint *.js"
},
"dependencies": {
"fabric-ca-client": "^2.2.4",
"fabric-network": "^2.2.4"
"fabric-ca-client": "^2.2.19",
"fabric-network": "^2.2.19"
},
"devDependencies": {
"eslint": "^7.32.0"

View file

@ -15,8 +15,8 @@
"author": "Hyperledger",
"license": "Apache-2.0",
"dependencies": {
"fabric-ca-client": "^2.2.4",
"fabric-network": "^2.2.4"
"fabric-ca-client": "^2.2.19",
"fabric-network": "^2.2.19"
},
"devDependencies": {
"chai": "^4.2.0",

View file

@ -13,8 +13,8 @@
"lint": "eslint *.js"
},
"dependencies": {
"fabric-ca-client": "^2.2.4",
"fabric-network": "^2.2.4"
"fabric-ca-client": "^2.2.19",
"fabric-network": "^2.2.19"
},
"devDependencies": {
"eslint": "^7.32.0"

View file

@ -0,0 +1,99 @@
module.exports = {
env: {
node: true,
es2020: true,
},
extends: [
'eslint:recommended',
],
root: true,
ignorePatterns: [
'dist/',
],
rules: {
'arrow-spacing': ['error'],
'comma-style': ['error'],
complexity: ['error', 10],
'eol-last': ['error'],
'generator-star-spacing': ['error', 'after'],
'key-spacing': [
'error',
{
beforeColon: false,
afterColon: true,
mode: 'minimum',
},
],
'keyword-spacing': ['error'],
'no-multiple-empty-lines': ['error'],
'no-trailing-spaces': ['error'],
'no-whitespace-before-property': ['error'],
'object-curly-newline': ['error'],
'padded-blocks': ['error', 'never'],
'rest-spread-spacing': ['error'],
'semi-style': ['error'],
'space-before-blocks': ['error'],
'space-in-parens': ['error'],
'space-unary-ops': ['error'],
'spaced-comment': ['error'],
'template-curly-spacing': ['error'],
'yield-star-spacing': ['error', 'after'],
},
overrides: [
{
files: [
'**/*.ts',
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
impliedStrict: true,
},
project: './tsconfig.json',
tsconfigRootDir: process.env.TSCONFIG_ROOT_DIR || __dirname,
},
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
rules: {
'@typescript-eslint/comma-spacing': ['error'],
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
},
],
'@typescript-eslint/func-call-spacing': ['error'],
'@typescript-eslint/member-delimiter-style': ['error'],
'@typescript-eslint/indent': [
'error',
4,
{
SwitchCase: 0,
},
],
'@typescript-eslint/prefer-nullish-coalescing': ['error'],
'@typescript-eslint/prefer-optional-chain': ['error'],
'@typescript-eslint/prefer-reduce-type-parameter': ['error'],
'@typescript-eslint/prefer-return-this-type': ['error'],
'@typescript-eslint/quotes': ['error', 'single'],
'@typescript-eslint/type-annotation-spacing': ['error'],
'@typescript-eslint/semi': ['error'],
'@typescript-eslint/space-before-function-paren': [
'error',
{
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
},
],
},
},
],
};

View file

@ -5,61 +5,31 @@
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"engines": {
"node": ">=12"
"node": ">=18"
},
"scripts": {
"lint": "tslint -c tslint.json 'src/**/*.ts'",
"lint": "eslint ./src --ext .ts",
"pretest": "npm run lint",
"test": "nyc mocha -r ts-node/register src/**/*.spec.ts",
"test": "echo 'No tests implemented'",
"start": "fabric-chaincode-node start",
"build": "tsc",
"build:watch": "tsc -w",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"postinstall": "npm dedupe"
},
"engineStrict": true,
"author": "Hyperledger",
"license": "Apache-2.0",
"dependencies": {
"@grpc/grpc-js": "1.8.1",
"fabric-contract-api": "~2.5.2",
"fabric-shim": "~2.5.2"
"fabric-contract-api": "~2.5.4",
"fabric-shim": "~2.5.4"
},
"devDependencies": {
"@types/chai": "^4.2.11",
"@types/chai-as-promised": "^7.1.2",
"@types/mocha": "^7.0.2",
"@types/node": "^12.20.55",
"@types/sinon": "^7.5.2",
"@types/sinon-chai": "^3.2.3",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"sinon": "^9.0.1",
"sinon-chai": "^3.5.0",
"ts-node": "^8.8.1",
"tslint": "^6.1.0",
"typescript": "^3.8.3",
"winston": "^3.2.1"
},
"nyc": {
"extension": [
".ts",
".tsx"
],
"exclude": [
"coverage/**",
"dist/**"
],
"reporter": [
"text-summary",
"html"
],
"all": true,
"check-coverage": true,
"statements": 100,
"branches": 100,
"functions": 100,
"lines": 100
"@tsconfig/node18": "^18.2.2",
"@types/node": "^18.17.17",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"eslint": "^8.49.0",
"typescript": "~5.2.0"
}
}

View file

@ -7,14 +7,14 @@ import { Object, Property } from 'fabric-contract-api';
@Object()
export class Asset {
@Property()
public ID: string;
public ID: string = '';
@Property()
public Value: number;
public Value: number = 0;
@Property()
public Owner: string;
public Owner: string = '';
@Property()
public OwnerOrg: string;
public OwnerOrg: string = '';
}

View file

@ -8,7 +8,6 @@ import { KeyEndorsementPolicy } from 'fabric-shim';
@Info({title: 'AssetContract', description: 'Asset Transfer Smart Contract, using State Based Endorsement(SBE), implemented in TypeScript' })
export class AssetContract extends Contract {
// CreateAsset creates a new asset
// CreateAsset sets the endorsement policy of the assetId Key, such that current owner Org Peer is required to endorse future updates
@Transaction()
@ -109,15 +108,14 @@ export class AssetContract extends Contract {
// setStateBasedEndorsementNOutOf sets an endorsement policy to the assetId Key
// setStateBasedEndorsementNOutOf enforces that a given number of Orgs (N) out of the specified Orgs must endorse future update transactions for the specified assetId Key.
private static async setStateBasedEndorsementNOutOf(ctx: Context, assetId: string, nOrgs:number, ownerOrgs: string[]): Promise<void> {
private static async setStateBasedEndorsementNOutOf(ctx: Context, assetId: string, nOrgs: number, ownerOrgs: string[]): Promise<void> {
const ROLE_TYPE_MEMBER = 'MEMBER';
// Use the KeyEndorsementPolicy helper form the chaincode libarries
// If you need more advanced policies, please use that helper as a reference point.
const keyEndorsementPolicy = new KeyEndorsementPolicy();
keyEndorsementPolicy.addOrgs(ROLE_TYPE_MEMBER,...ownerOrgs);
keyEndorsementPolicy.addOrgs(ROLE_TYPE_MEMBER, ...ownerOrgs);
await ctx.stub.setStateValidationParameter(assetId, keyEndorsementPolicy.getPolicy());
}
}

View file

@ -5,4 +5,4 @@
import { AssetContract } from './assetContract';
export { AssetContract } from './assetContract';
export const contracts: any[] = [ AssetContract ];
export const contracts: unknown[] = [ AssetContract ];

View file

@ -1,9 +1,8 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"target": "es2017",
"moduleResolution": "node",
"module": "commonjs",
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,

View file

@ -1,21 +0,0 @@
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"indent": [true, "spaces", 4],
"quotemark": [true, "single"],
"semicolon": [true, "always"],
"no-console": false,
"curly": true,
"triple-equals": true,
"no-string-throw": true,
"no-var-keyword": true,
"no-trailing-whitespace": true,
"object-literal-key-quotes": [true, "as-needed"],
"max-line-length": false
},
"rulesDirectory": []
}

View file

@ -13,8 +13,8 @@
"lint": "eslint *.js"
},
"dependencies": {
"fabric-ca-client": "^2.2.4",
"fabric-network": "^2.2.4"
"fabric-ca-client": "^2.2.19",
"fabric-network": "^2.2.19"
},
"devDependencies": {
"eslint": "^7.32.0"

View file

@ -13,8 +13,8 @@
"lint": "eslint *.js"
},
"dependencies": {
"fabric-ca-client": "^2.2.4",
"fabric-network": "^2.2.4"
"fabric-ca-client": "^2.2.19",
"fabric-network": "^2.2.19"
},
"devDependencies": {
"eslint": "^7.20.0",

View file

@ -13,8 +13,8 @@
"lint": "eslint *.js"
},
"dependencies": {
"fabric-ca-client": "^2.2.4",
"fabric-network": "^2.2.4"
"fabric-ca-client": "^2.2.19",
"fabric-network": "^2.2.19"
},
"devDependencies": {
"eslint": "^7.32.0"

View file

@ -15,8 +15,8 @@
"author": "Hyperledger",
"license": "Apache-2.0",
"dependencies": {
"fabric-ca-client": "^2.2.4",
"fabric-network": "^2.2.4"
"fabric-ca-client": "^2.2.19",
"fabric-network": "^2.2.19"
},
"devDependencies": {
"chai": "^4.2.0",