@@ -14,12 +14,37 @@ import "./PythInternalStructs.sol";
14
14
abstract contract Pyth is PythGetters , PythSetters , AbstractPyth {
15
15
function _initialize (
16
16
address wormhole ,
17
- uint16 pyth2WormholeChainId ,
18
- bytes32 pyth2WormholeEmitter
17
+ uint16 [] calldata dataSourceEmitterChainIds ,
18
+ bytes32 [] calldata dataSourceEmitterAddresses ,
19
+ uint validTimePeriodSeconds ,
20
+ uint singleUpdateFeeInWei
19
21
) internal {
20
22
setWormhole (wormhole);
21
- setPyth2WormholeChainId (pyth2WormholeChainId);
22
- setPyth2WormholeEmitter (pyth2WormholeEmitter);
23
+
24
+ require (
25
+ dataSourceEmitterChainIds.length ==
26
+ dataSourceEmitterAddresses.length ,
27
+ "data source arguments should have the same length "
28
+ );
29
+
30
+ for (uint i = 0 ; i < dataSourceEmitterChainIds.length ; i++ ) {
31
+ PythInternalStructs.DataSource memory ds = PythInternalStructs
32
+ .DataSource (
33
+ dataSourceEmitterChainIds[i],
34
+ dataSourceEmitterAddresses[i]
35
+ );
36
+
37
+ require (
38
+ ! PythGetters.isValidDataSource (ds.chainId, ds.emitterAddress),
39
+ "Data source already added "
40
+ );
41
+
42
+ _state.isValidDataSource[hashDataSource (ds)] = true ;
43
+ _state.validDataSources.push (ds);
44
+ }
45
+
46
+ PythSetters.setValidTimePeriodSeconds (validTimePeriodSeconds);
47
+ PythSetters.setSingleUpdateFeeInWei (singleUpdateFeeInWei);
23
48
}
24
49
25
50
function updatePriceBatchFromVm (bytes calldata encodedVm ) private {
0 commit comments