Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

fabric-contract-api

Package Overview
Dependencies
Maintainers
1
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fabric-contract-api - npm Package Compare versions

Comparing version 1.4.0-snapshot.39 to 1.4.0-snapshot.40

2

lib/annotations/index.js

@@ -16,2 +16,2 @@ /*

'use strict';
Object.assign(module.exports, require('./transaction'), require('./object'));
Object.assign(module.exports, require('./transaction'));

@@ -44,3 +44,3 @@ /*

utils.appendOrUpdate(transactions, 'name', propertyKey, {
utils.appendOrUpdate(transactions, 'transactionId', propertyKey, {
tag: tag,

@@ -58,9 +58,4 @@ parameters: parameters

utils.appendOrUpdate(transactions, 'name', propertyKey, {
returns: {
name: 'success',
schema: {
type: returnType.toLowerCase()
}
}
utils.appendOrUpdate(transactions, 'transactionId', propertyKey, {
returns: returnType.toLowerCase()
});

@@ -67,0 +62,0 @@

@@ -15,3 +15,3 @@ /*

* Overriding of the `beforeTransaction` `afterTransaction` `unknownTransaction` and `createContext` are all optional
* Supplying a name within the constructor is also option and will default to ''
* Supplying a namespace within the constructor is also option and will default to ''
*

@@ -23,11 +23,11 @@ * @memberof fabric-contract-api

/**
* Constructor - supplying a name is recommended but is not mandatory.
* Constructor - supplying a namespace is recommended but is not mandatory.
*
* @param {String} name name for the logic within this contract
* @param {String} namespace namespace for the logic within this contract
*/
constructor(name) {
if (name && name.trim() !== '') {
this.name = name.trim();
constructor(namespace) {
if (namespace && namespace.trim() !== '') {
this.namespace = namespace.trim();
} else {
this.name = '';
this.namespace = '';
}

@@ -92,4 +92,4 @@ }

*/
getName() {
return this.name;
getNamespace() {
return this.namespace;
}

@@ -96,0 +96,0 @@

{
"name": "fabric-contract-api",
"version": "1.4.0-snapshot.39",
"version": "1.4.0-snapshot.40",
"tag": "unstable",

@@ -29,3 +29,4 @@ "description": "A node.js implementation of Hyperledger Fabric chaincode shim, to allow endorsing peers and user-provided chaincodes to communicate with each other",

"types": "./types/index.d.ts",
"devDependencies": {}
"devDependencies": {
}
}

@@ -44,3 +44,3 @@ [![NPM](https://nodei.co/npm/fabric-contract-api.svg?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/fabric-contract-api/)

constructor(){
super('UpdateValuesContract');
super('org.mynamespace.updates');
}

@@ -47,0 +47,0 @@

@@ -46,4 +46,4 @@ "use strict";

const clientIdentity = ctx.clientIdentity;
// test that the name returns a string
const ns = this.getName();
// test that the namespace returns a string
const ns = this.getNamespace();
}

@@ -50,0 +50,0 @@ }

@@ -59,4 +59,4 @@ /*

// test that the name returns a string
const ns: string = this.getName();
// test that the namespace returns a string
const ns: string = this.getNamespace();
}

@@ -63,0 +63,0 @@ }

@@ -69,3 +69,3 @@ /*

const getMetadataStub = sinon.stub(Reflect, 'getMetadata').onFirstCall().returns([{
name: 'someTransaction',
transactionId: 'someTransaction',
tag: ['submitTx'],

@@ -93,7 +93,7 @@ parameters: []

sinon.assert.calledWith(defineMetadataStub, 'fabric:transactions', [{
name: 'someTransaction',
transactionId: 'someTransaction',
tag: ['submitTx'],
parameters: []
}, {
name: 'mockKey',
transactionId: 'mockKey',
tag: ['submitTx'],

@@ -135,3 +135,3 @@ parameters: [

sinon.assert.calledWith(defineMetadataStub, 'fabric:transactions', [{
name: 'mockKey',
transactionId: 'mockKey',
tag: ['submitTx'],

@@ -160,3 +160,3 @@ parameters: []

sinon.assert.calledWith(defineMetadataStub, 'fabric:transactions', [{
name: 'mockKey',
transactionId: 'mockKey',
tag: [],

@@ -179,3 +179,3 @@ parameters: []

const getMetadataStub = sinon.stub(Reflect, 'getMetadata').returns([{
name: 'someTransaction',
transactionId: 'someTransaction',
tag: ['submitTx'],

@@ -192,13 +192,8 @@ parameters: []

sinon.assert.calledWith(defineMetadataStub, 'fabric:transactions', [{
name: 'someTransaction',
transactionId: 'someTransaction',
tag: ['submitTx'],
parameters: []
}, {
name: 'mockKey',
returns: {
name: 'success',
schema: {
type: 'sometype'
}
}
transactionId: 'mockKey',
returns: 'sometype'
}], mockTarget);

@@ -219,9 +214,4 @@

sinon.assert.calledWith(defineMetadataStub, 'fabric:transactions', [{
name: 'mockKey',
returns: {
name: 'success',
schema: {
type: 'sometype'
}
}
transactionId: 'mockKey',
returns: 'sometype'
}], mockTarget);

@@ -228,0 +218,0 @@

@@ -80,12 +80,12 @@ /*

it ('should create with default name', () => {
it ('should create with default namespace', () => {
const sc0 = new Contract();
expect(sc0.getName()).to.equal('');
expect(sc0.getNamespace()).to.equal('');
// should also create default when the supplied name is empty space
const sc1 = new Contract('');
expect(sc1.getName()).to.equal('');
expect(sc1.getNamespace()).to.equal('');
const sc2 = new Contract(' ');
expect(sc2.getName()).to.equal('');
expect(sc2.getNamespace()).to.equal('');
});

@@ -108,8 +108,8 @@

const sc1 = new Contract('brain.size.planet.smart');
expect(sc1.name).to.equal('brain.size.planet.smart');
expect(sc1.getName()).to.equal('brain.size.planet.smart');
expect(sc1.namespace).to.equal('brain.size.planet.smart');
expect(sc1.getNamespace()).to.equal('brain.size.planet.smart');
const sc2 = new Contract(' somewhat.padded.out ');
expect(sc2.name).to.equal('somewhat.padded.out');
expect(sc2.getName()).to.equal('somewhat.padded.out');
expect(sc2.namespace).to.equal('somewhat.padded.out');
expect(sc2.getNamespace()).to.equal('somewhat.padded.out');
});

@@ -141,5 +141,5 @@

it ('should set the correct name', () => {
it ('should set the correct namespace', () => {
const sc = new SCAlpha();
sc.getName().should.equal('alpha.beta.delta');
sc.getNamespace().should.equal('alpha.beta.delta');
});

@@ -146,0 +146,0 @@

@@ -16,3 +16,3 @@ /*

export class Contract {
constructor(name?: string);
constructor(namespace?: string);

@@ -25,3 +25,3 @@ beforeTransaction(ctx : Context): Promise<void>;

createContext(): Context;
getName(): string;
getNamespace(): string;

@@ -32,4 +32,2 @@ }

export function Returns(returnType?: string): (target: any, propertyKey: string | symbol) => void;
export function Object(type?: string): (target: any) => void;
export function Property(name?: string, type?: string): (target: any, propertyKey: string | symbol) => void;
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc