1
- import { InvalidArgumentError , InvalidStateError } from '@cardano-sdk/util' ;
1
+ import { InvalidArgumentError } from '@cardano-sdk/util' ;
2
2
import { PlutusLanguageVersion } from '../../../Cardano/types/Script' ;
3
3
4
- const PLUTUS_V1_COST_MODEL_OP_COUNT = 166 ;
5
- const PLUTUS_V2_COST_MODEL_OP_COUNT = 175 ;
6
- const PLUTUS_V3_COST_MODEL_OP_COUNT = 179 ;
7
-
8
4
/**
9
5
* The execution of plutus scripts consumes resources. To make sure that these
10
6
* scripts don't run indefinitely or consume excessive resources (which would be
@@ -28,32 +24,6 @@ export class CostModel {
28
24
constructor ( language : PlutusLanguageVersion , costs : Array < number > ) {
29
25
this . #language = language ;
30
26
this . #costs = costs ;
31
-
32
- switch ( this . #language) {
33
- case PlutusLanguageVersion . V1 :
34
- if ( costs . length !== PLUTUS_V1_COST_MODEL_OP_COUNT )
35
- throw new InvalidArgumentError (
36
- 'costs' ,
37
- `Cost model for PlutusV2 language should have ${ PLUTUS_V2_COST_MODEL_OP_COUNT } operations, but got ${ costs . length } .`
38
- ) ;
39
- break ;
40
- case PlutusLanguageVersion . V2 :
41
- if ( costs . length !== PLUTUS_V2_COST_MODEL_OP_COUNT )
42
- throw new InvalidArgumentError (
43
- 'costs' ,
44
- `Cost model for PlutusV2 language should have ${ PLUTUS_V2_COST_MODEL_OP_COUNT } operations, but got ${ costs . length } .`
45
- ) ;
46
- break ;
47
- case PlutusLanguageVersion . V3 :
48
- if ( costs . length !== PLUTUS_V3_COST_MODEL_OP_COUNT )
49
- throw new InvalidArgumentError (
50
- 'costs' ,
51
- `Cost model for PlutusV3 language should have ${ PLUTUS_V3_COST_MODEL_OP_COUNT } operations, but got ${ costs . length } .`
52
- ) ;
53
- break ;
54
- default :
55
- throw new InvalidStateError ( 'Invalid plutus language version.' ) ;
56
- }
57
27
}
58
28
59
29
/**
@@ -141,21 +111,6 @@ export class CostModel {
141
111
* @returns true if is a valid operation; otherwise; false.
142
112
*/
143
113
#isOperationValid( operation : number ) : boolean {
144
- let isValid = false ;
145
- switch ( this . #language) {
146
- case PlutusLanguageVersion . V1 :
147
- isValid = operation >= 0 && operation < PLUTUS_V1_COST_MODEL_OP_COUNT ;
148
- break ;
149
- case PlutusLanguageVersion . V2 :
150
- isValid = operation >= 0 && operation < PLUTUS_V2_COST_MODEL_OP_COUNT ;
151
- break ;
152
- case PlutusLanguageVersion . V3 :
153
- isValid = operation >= 0 && operation < PLUTUS_V3_COST_MODEL_OP_COUNT ;
154
- break ;
155
- default :
156
- throw new InvalidStateError ( 'Invalid plutus language version.' ) ;
157
- }
158
-
159
- return isValid ;
114
+ return operation >= 0 ;
160
115
}
161
116
}
0 commit comments