@@ -47,14 +47,17 @@ export class Lucid {
47
47
value : void 0
48
48
} ) ;
49
49
}
50
- static async new ( provider , network ) {
50
+ static async new ( { provider, network, protocolParameters , } ) {
51
51
const lucid = new this ( ) ;
52
52
if ( network )
53
53
lucid . network = network ;
54
- if ( provider ) {
55
- lucid . provider = provider ;
56
- const protocolParameters = await provider . getProtocolParameters ( ) ;
54
+ if ( protocolParameters ) {
57
55
lucid . protocolParameters = protocolParameters ;
56
+ }
57
+ if ( provider && ! protocolParameters ) {
58
+ lucid . provider = provider ;
59
+ const protocolParams = await provider . getProtocolParameters ( ) ;
60
+ lucid . protocolParameters = protocolParams ;
58
61
if ( lucid . provider instanceof Emulator ) {
59
62
lucid . network = "Custom" ;
60
63
SLOT_CONFIG_NETWORK [ lucid . network ] = {
@@ -63,18 +66,20 @@ export class Lucid {
63
66
slotLength : 1000 ,
64
67
} ;
65
68
}
69
+ }
70
+ if ( lucid . protocolParameters ) {
66
71
const slotConfig = SLOT_CONFIG_NETWORK [ lucid . network ] ;
67
72
lucid . txBuilderConfig = C . TransactionBuilderConfigBuilder . new ( )
68
- . coins_per_utxo_byte ( C . BigNum . from_str ( protocolParameters . coinsPerUtxoByte . toString ( ) ) )
69
- . fee_algo ( C . LinearFee . new ( C . BigNum . from_str ( protocolParameters . minFeeA . toString ( ) ) , C . BigNum . from_str ( protocolParameters . minFeeB . toString ( ) ) ) )
70
- . key_deposit ( C . BigNum . from_str ( protocolParameters . keyDeposit . toString ( ) ) )
71
- . pool_deposit ( C . BigNum . from_str ( protocolParameters . poolDeposit . toString ( ) ) )
72
- . max_tx_size ( protocolParameters . maxTxSize )
73
- . max_value_size ( protocolParameters . maxValSize )
74
- . collateral_percentage ( protocolParameters . collateralPercentage )
75
- . max_collateral_inputs ( protocolParameters . maxCollateralInputs )
76
- . max_tx_ex_units ( C . ExUnits . new ( C . BigNum . from_str ( protocolParameters . maxTxExMem . toString ( ) ) , C . BigNum . from_str ( protocolParameters . maxTxExSteps . toString ( ) ) ) )
77
- . ex_unit_prices ( C . ExUnitPrices . from_float ( protocolParameters . priceMem , protocolParameters . priceStep ) )
73
+ . coins_per_utxo_byte ( C . BigNum . from_str ( lucid . protocolParameters . coinsPerUtxoByte . toString ( ) ) )
74
+ . fee_algo ( C . LinearFee . new ( C . BigNum . from_str ( lucid . protocolParameters . minFeeA . toString ( ) ) , C . BigNum . from_str ( lucid . protocolParameters . minFeeB . toString ( ) ) ) )
75
+ . key_deposit ( C . BigNum . from_str ( lucid . protocolParameters . keyDeposit . toString ( ) ) )
76
+ . pool_deposit ( C . BigNum . from_str ( lucid . protocolParameters . poolDeposit . toString ( ) ) )
77
+ . max_tx_size ( lucid . protocolParameters . maxTxSize )
78
+ . max_value_size ( lucid . protocolParameters . maxValSize )
79
+ . collateral_percentage ( lucid . protocolParameters . collateralPercentage )
80
+ . max_collateral_inputs ( lucid . protocolParameters . maxCollateralInputs )
81
+ . max_tx_ex_units ( C . ExUnits . new ( C . BigNum . from_str ( lucid . protocolParameters . maxTxExMem . toString ( ) ) , C . BigNum . from_str ( lucid . protocolParameters . maxTxExSteps . toString ( ) ) ) )
82
+ . ex_unit_prices ( C . ExUnitPrices . from_float ( lucid . protocolParameters . priceMem , lucid . protocolParameters . priceStep ) )
78
83
. slot_config ( C . BigNum . from_str ( slotConfig . zeroTime . toString ( ) ) , C . BigNum . from_str ( slotConfig . zeroSlot . toString ( ) ) , slotConfig . slotLength )
79
84
. blockfrost (
80
85
// We have Aiken now as native plutus core engine (primary), but we still support blockfrost (secondary) in case of bugs.
@@ -83,7 +88,7 @@ export class Lucid {
83
88
( provider ?. url || "" ) + "/utils/txs/evaluate" ,
84
89
// deno-lint-ignore no-explicit-any
85
90
provider ?. projectId || "" ) )
86
- . costmdls ( createCostModels ( protocolParameters . costModels ) )
91
+ . costmdls ( createCostModels ( lucid . protocolParameters . costModels ) )
87
92
. build ( ) ;
88
93
}
89
94
lucid . utils = new Utils ( lucid ) ;
0 commit comments