-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontract_execution_result.js
82 lines (73 loc) · 1.59 KB
/
contract_execution_result.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const {AssetProof} = require('./asset_proof.js');
/**
* @public
*/
class ContractExecutionResult {
/**
* @param {string} contractResult
* @param {string} functionResult
* @param {AssetProof[]} ledgerProofs
* @param {AssetProof[]} auditorProofs
*/
constructor(contractResult, functionResult, ledgerProofs, auditorProofs) {
this.contractResult = contractResult;
this.functionResult = functionResult;
this.ledgerProofs = ledgerProofs;
this.auditorProofs = auditorProofs;
}
/**
* @param {proto.rpc.ContractExecutionResponse} response
* @return {ContractExecutionResult}
*/
static fromGrpcContractExecutionResponse(response) {
return new ContractExecutionResult(
response.getContractResult(),
response.getFunctionResult(),
response
.getProofsList()
.map((proof) => AssetProof.fromGrpcAssetProof(proof)),
[],
);
}
/**
* @deprecated
* @return {Object}
*/
getResult() {
return this.contractResult !== '' ? JSON.parse(this.contractResult) : {};
}
/**
* @return {string}
*/
getContractResult() {
return this.contractResult;
}
/**
* @return {string}
*/
getFunctionResult() {
return this.functionResult;
}
/**
* @deprecated
* @return {AssetProof[]}
*/
getProofs() {
return this.ledgerProofs;
}
/**
* @return {AssetProof[]}
*/
getLedgerProofs() {
return this.ledgerProofs;
}
/**
* @return {AssetProof[]}
*/
getAuditorProofs() {
return this.auditorProofs;
}
}
module.exports = {
ContractExecutionResult,
};