How to use the fabric-contract-api.Property function in fabric-contract-api

To help you get started, we’ve selected a few fabric-contract-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM-Blockchain / vehicle-manufacture / contract / src / lib / assets / order.ts View on Github external
}

        this._orderStatus = orderStatus;
    }

    @Property()
    get vehicleDetails(): IVehicleDetails {
        return this._vehicleDetails;
    }

    @Property()
    get ordererId(): string {
        return this._ordererId;
    }

    @Property()
    get vin(): string {
        return this._vin;
    }

    set vin(vin: string) {
        this._vin = vin;
    }

    public madeByOrg(orgId: string) {
        return this.vehicleDetails.makeId === orgId;
    }
}

// tslint:disable:max-classes-per-file
@Object()
export class HistoricOrder extends HistoricState {
github ampretia / fabric-application-examples / contracts / helloworld-ts / src / greeting.ts View on Github external
const text = greeting.text;

        if (text.length !== greeting.textLength) {
            throw new Error('Length incorrectly set');
        }

        if (text.split(' ').length !== greeting.wordCount) {
            throw new Error('Word count incorrectly set');
        }

    }

    @Property('text')
    private text: string;

    @Property('length')
    private textLength: number;

    @Property('wordcount')
    private wordCount: number;

    constructor(text: string) {
        this.text = text;
        this.textLength = text.length;
        this.wordCount = text.split(' ').length;
    }

    public setText(text: string): void {
        this.text = text;
    }

    public getText(): string {
github ampretia / fabric-application-examples / contracts / helloworld-ts / src / greeting.ts View on Github external
throw new Error('Length incorrectly set');
        }

        if (text.split(' ').length !== greeting.wordCount) {
            throw new Error('Word count incorrectly set');
        }

    }

    @Property('text')
    private text: string;

    @Property('length')
    private textLength: number;

    @Property('wordcount')
    private wordCount: number;

    constructor(text: string) {
        this.text = text;
        this.textLength = text.length;
        this.wordCount = text.split(' ').length;
    }

    public setText(text: string): void {
        this.text = text;
    }

    public getText(): string {
        return this.text;
    }
github ampretia / fabric-application-examples / contracts / helloworld-ts / src / greeting.ts View on Github external
export default class Greeting {

    public static validate(greeting: Greeting) {
        const text = greeting.text;

        if (text.length !== greeting.textLength) {
            throw new Error('Length incorrectly set');
        }

        if (text.split(' ').length !== greeting.wordCount) {
            throw new Error('Word count incorrectly set');
        }

    }

    @Property('text')
    private text: string;

    @Property('length')
    private textLength: number;

    @Property('wordcount')
    private wordCount: number;

    constructor(text: string) {
        this.text = text;
        this.textLength = text.length;
        this.wordCount = text.split(' ').length;
    }

    public setText(text: string): void {
        this.text = text;
github IBM-Blockchain / vehicle-manufacture / contract / src / lib / assets / options.ts View on Github external
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { Object, Property } from 'fabric-contract-api';

@Object()
export class IOptions {
    @Property()
    public trim: string;

    @Property()
    public interior: string;

    @Property('extras', 'string[]')
    public extras: string[];
}
github IBM-Blockchain / vehicle-manufacture / contract / src / lib / assets / vehicle.ts View on Github external
vehicleStatus: VehicleStatus,
        manufactured: number,
        @NotRequired ownerId?: string,
    ) {
        super(id, Vehicle.name);

        this.vehicleDetails = vehicleDetails;
        this._vehicleStatus = vehicleStatus;
        this.manufactured = manufactured;

        if (ownerId) {
            this._ownerId = ownerId;
        }
    }

    @Property()
    get ownerId(): string {
        return this._ownerId;
    }

    set ownerId(ownerId: string) {
        this._ownerId = ownerId;
    }

    @Property()
    get vehicleStatus(): VehicleStatus {
        return this._vehicleStatus;
    }

    set vehicleStatus(status: VehicleStatus) {
        this._vehicleStatus = status;
    }
github IBM-Blockchain / vehicle-manufacture / contract / src / lib / assets / vehicle.ts View on Github external
if (ownerId) {
            this._ownerId = ownerId;
        }
    }

    @Property()
    get ownerId(): string {
        return this._ownerId;
    }

    set ownerId(ownerId: string) {
        this._ownerId = ownerId;
    }

    @Property()
    get vehicleStatus(): VehicleStatus {
        return this._vehicleStatus;
    }

    set vehicleStatus(status: VehicleStatus) {
        this._vehicleStatus = status;
    }

    public madeByOrg(orgId: string) {
        return this.vehicleDetails.makeId === orgId;
    }
}
github IBM-Blockchain / vehicle-manufacture / contract / src / lib / participants / participant.ts View on Github external
import { NetworkName } from '../../constants';
import { State } from '../ledger-api/state';

@ContractObject()
export class Participant extends State {
    public static generateClass(participantType: string): string {
        return NetworkName + '.participants.'  + participantType;
    }

    @Property()
    public readonly id: string;

    @Property()
    public readonly orgId: string;

    @Property('roles', 'string[]')
    protected roles: string[];

    constructor(
        id: string, roles: string[], orgId: string, participantType: string,
    ) {
        super(Participant.generateClass(participantType), [id]);
        this.id = id;
        this.roles = roles;
        this.orgId = orgId;
    }

    public serialize(): Buffer {
        const toSerialize = JSON.parse(State.serialize(this).toString());

        Object.keys(this).forEach((key) => {
            if (key.startsWith('_')) {
github IBM-Blockchain / vehicle-manufacture / contract / src / lib / assets / order.ts View on Github external
return this._orderStatus;
    }

    set orderStatus(orderStatus: OrderStatus) {
        if (orderStatus <= this._orderStatus) {
            throw new Error('Status of order cannot go backwards or remain the same');
        }

        if (orderStatus - this._orderStatus !== 1) {
            throw new Error('Cannot skip order status step');
        }

        this._orderStatus = orderStatus;
    }

    @Property()
    get vehicleDetails(): IVehicleDetails {
        return this._vehicleDetails;
    }

    @Property()
    get ordererId(): string {
        return this._ordererId;
    }

    @Property()
    get vin(): string {
        return this._vin;
    }

    set vin(vin: string) {
        this._vin = vin;
github IBM-Blockchain / vehicle-manufacture / contract / src / lib / assets / order.ts View on Github external
throw new Error('Status of order cannot go backwards or remain the same');
        }

        if (orderStatus - this._orderStatus !== 1) {
            throw new Error('Cannot skip order status step');
        }

        this._orderStatus = orderStatus;
    }

    @Property()
    get vehicleDetails(): IVehicleDetails {
        return this._vehicleDetails;
    }

    @Property()
    get ordererId(): string {
        return this._ordererId;
    }

    @Property()
    get vin(): string {
        return this._vin;
    }

    set vin(vin: string) {
        this._vin = vin;
    }

    public madeByOrg(orgId: string) {
        return this.vehicleDetails.makeId === orgId;
    }