|
5 | 5 |
|
6 | 6 | */
|
7 | 7 |
|
8 |
| -import { Contract, Context } from 'fabric-contract-api'; |
9 |
| -import { ChaincodeStub, ClientIdentity } from 'fabric-shim-api'; |
| 8 | +import {Contract, Context} from 'fabric-contract-api'; |
| 9 | +import {ChaincodeStub, ClientIdentity} from 'fabric-shim-api'; |
10 | 10 |
|
11 |
| -export class ScenarioContext extends Context{ |
12 |
| - customFunction(): void { |
| 11 | +export class ScenarioContext extends Context { |
| 12 | + customFunction(): void { |
13 | 13 |
|
14 |
| - } |
| 14 | + } |
15 | 15 | }
|
16 | 16 |
|
17 | 17 | export default class TestContractOne extends Contract {
|
18 | 18 | constructor() {
|
19 | 19 | super('org.papernet.commercialpaper');
|
20 | 20 | }
|
21 | 21 |
|
22 |
| - beforeTransaction(ctx: ScenarioContext) { |
23 |
| - // test that the context super class properties are available |
24 |
| - const stubApi: ChaincodeStub = ctx.stub; |
25 |
| - const clientIdentity: ClientIdentity = ctx.clientIdentity; |
26 |
| - |
27 |
| - // tests that the functions in the subclasses context be called |
28 |
| - ctx.customFunction(); |
29 |
| - |
30 |
| - // This proves that typescript is enforcing the |
31 |
| - // return type of Promise<void> |
32 |
| - return Promise.resolve(); |
33 |
| - } |
34 |
| - |
35 |
| - afterTransaction(ctx: ScenarioContext,result: any) { |
36 |
| - // This proves that typescript is enforcing the |
37 |
| - // return type of Promise<void> |
38 |
| - return Promise.resolve(); |
39 |
| - } |
40 |
| - |
41 |
| - aroundTransaction(ctx: ScenarioContext, fn: Function, parameters: any) { |
42 |
| - // This proves that typescript is enforcing the |
43 |
| - // return type of Promise<void> |
44 |
| - return super.aroundTransaction(ctx, fn, parameters); |
45 |
| - } |
46 |
| - |
47 |
| - unknownTransaction(ctx: ScenarioContext){ |
48 |
| - // This proves that typescript is enforcing the |
49 |
| - // return type of Promise<void> |
50 |
| - return Promise.resolve(); |
51 |
| - } |
52 |
| - |
53 |
| - createContext(){ |
54 |
| - return new ScenarioContext(); |
55 |
| - } |
56 |
| - |
57 |
| - async Transaction(ctx: ScenarioContext) { |
58 |
| - // test that the context super class properties are available |
59 |
| - const stubApi: ChaincodeStub = ctx.stub; |
60 |
| - const clientIdentity: ClientIdentity = ctx.clientIdentity; |
61 |
| - |
62 |
| - // test that the name returns a string |
63 |
| - const ns: string = this.getName(); |
64 |
| - } |
| 22 | + beforeTransaction(ctx: ScenarioContext) { |
| 23 | + // test that the context super class properties are available |
| 24 | + const stubApi: ChaincodeStub = ctx.stub; |
| 25 | + const clientIdentity: ClientIdentity = ctx.clientIdentity; |
| 26 | + |
| 27 | + // tests that the functions in the subclasses context be called |
| 28 | + ctx.customFunction(); |
| 29 | + |
| 30 | + // This proves that typescript is enforcing the |
| 31 | + // return type of Promise<void> |
| 32 | + return Promise.resolve(); |
| 33 | + } |
| 34 | + |
| 35 | + afterTransaction(ctx: ScenarioContext, result: any) { |
| 36 | + // This proves that typescript is enforcing the |
| 37 | + // return type of Promise<void> |
| 38 | + return Promise.resolve(); |
| 39 | + } |
| 40 | + |
| 41 | + aroundTransaction(ctx: ScenarioContext, fn: Function, parameters: any) { |
| 42 | + // This proves that typescript is enforcing the |
| 43 | + // return type of Promise<void> |
| 44 | + return super.aroundTransaction(ctx, fn, parameters); |
| 45 | + } |
| 46 | + |
| 47 | + unknownTransaction(ctx: ScenarioContext) { |
| 48 | + // This proves that typescript is enforcing the |
| 49 | + // return type of Promise<void> |
| 50 | + return Promise.resolve(); |
| 51 | + } |
| 52 | + |
| 53 | + createContext() { |
| 54 | + return new ScenarioContext(); |
| 55 | + } |
| 56 | + |
| 57 | + async Transaction(ctx: ScenarioContext) { |
| 58 | + // test that the context super class properties are available |
| 59 | + const stubApi: ChaincodeStub = ctx.stub; |
| 60 | + const clientIdentity: ClientIdentity = ctx.clientIdentity; |
| 61 | + |
| 62 | + // test that the name returns a string |
| 63 | + const ns: string = this.getName(); |
| 64 | + } |
65 | 65 | }
|
66 | 66 |
|
67 | 67 | export class TestContractTwo extends Contract {
|
68 |
| - constructor() { |
69 |
| - super(); |
70 |
| - } |
71 |
| - |
72 |
| - async Transaction(ctx: Context) { |
73 |
| - const stubApi: ChaincodeStub = ctx.stub; |
74 |
| - const clientIdentity: ClientIdentity = ctx.clientIdentity; |
75 |
| - } |
| 68 | + constructor() { |
| 69 | + super(); |
| 70 | + } |
| 71 | + |
| 72 | + async Transaction(ctx: Context) { |
| 73 | + const stubApi: ChaincodeStub = ctx.stub; |
| 74 | + const clientIdentity: ClientIdentity = ctx.clientIdentity; |
| 75 | + } |
76 | 76 | }
|
0 commit comments