-
Notifications
You must be signed in to change notification settings - Fork 0
/
contract.ts
59 lines (51 loc) · 1.47 KB
/
contract.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Activity, Event } from "@activeledger/activecontracts";
/**
* New Activeledger Smart Contract
*
* @export
* @class MyContract
* @extends {Standard}
*/
export default class MyContract extends Event {
/**
* Quick Transaction Check - Verify Input Properties (Known & Relevant Transaction?)
* Signatureless - Verify if this contract is happy to run with selfsigned transactions
*
* @param {boolean} selfsigned
* @returns {Promise<boolean>}
* @memberof MyContract
*/
public verify(selfsigned: boolean): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
// Allow Self signed transaction (anonymous)
resolve(true)
});
}
/**
* Voting Round, Is the transaction request valid?
*
* @returns {Promise<boolean>}
* @memberof MyContract
*/
public vote(): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
this.ActiveLogger.debug("Voting Round - Automatic True");
resolve(true);
});
}
/**
* Prepares the new streams state to be comitted to the ledger
*
* @returns {Promise<any>}
* @memberof MyContract
*/
public commit(): Promise<any> {
return new Promise<any>((resolve, reject) => {
// Create a new activity stream
const newStream = this.newActivityStream("demo");
newStream.setState({metadata : this.transactions.$i.demo.metadata});
this.event.emit("newstream", { streamId: newStream.getId() })
this.
});
}
}