@@ -44,38 +44,35 @@ abstract contract PythGovernance is PythGetters, PythSetters, PythGovernanceInst
44
44
45
45
if (gi.action == GovernanceAction.UpgradeContract) {
46
46
require (gi.targetChainId != 0 , "upgrade with chain id 0 is not possible " );
47
- upgradeContract (gi.payload);
47
+ upgradeContract (parseUpgradeContractPayload ( gi.payload) );
48
48
} else if (gi.action == GovernanceAction.AuthorizeGovernanceDataSourceTransfer) {
49
- AuthorizeGovernanceDataSourceTransfer (gi.payload);
49
+ AuthorizeGovernanceDataSourceTransfer (parseAuthorizeGovernanceDataSourceTransferPayload ( gi.payload) );
50
50
} else if (gi.action == GovernanceAction.SetDataSources) {
51
- setDataSources (gi.payload);
51
+ setDataSources (parseSetDataSourcesPayload ( gi.payload) );
52
52
} else if (gi.action == GovernanceAction.SetFee) {
53
- setFee (gi.payload);
53
+ setFee (parseSetFeePayload ( gi.payload) );
54
54
} else if (gi.action == GovernanceAction.SetValidPeriod) {
55
- setValidPeriod (gi.payload);
55
+ setValidPeriod (parseSetValidPeriodPayload ( gi.payload) );
56
56
} else if (gi.action == GovernanceAction.RequestGovernanceDataSourceTransfer) {
57
57
revert ("RequestGovernanceDataSourceTransfer can be only part of AuthorizeGovernanceDataSourceTransfer message " );
58
58
} else {
59
59
revert ("invalid governance action " );
60
60
}
61
61
}
62
62
63
- function upgradeContract (bytes memory encodedPayload ) internal {
64
- UpgradeContractPayload memory payload = parseUpgradeContractPayload (encodedPayload);
65
- // This contract does not have enough access to execute this, it should be executed on the
66
- // upgradable
63
+ function upgradeContract (UpgradeContractPayload memory payload ) internal {
64
+ // This method on this contract does not have enough access to execute this, it should be executed on the
65
+ // upgradable contract.
67
66
upgradeUpgradableContract (payload);
68
67
}
69
68
70
69
function upgradeUpgradableContract (UpgradeContractPayload memory payload ) virtual internal ;
71
70
72
71
// Transfer the governance data source to a new value with sanity checks
73
72
// to ensure the new governance data source can manage the contract.
74
- function AuthorizeGovernanceDataSourceTransfer (bytes memory encodedPayload ) internal {
73
+ function AuthorizeGovernanceDataSourceTransfer (AuthorizeGovernanceDataSourceTransferPayload memory payload ) internal {
75
74
PythInternalStructs.DataSource memory oldGovernanceDatSource = governanceDataSource ();
76
75
77
- AuthorizeGovernanceDataSourceTransferPayload memory payload = parseAuthorizeGovernanceDataSourceTransferPayload (encodedPayload);
78
-
79
76
// Make sure the claimVaa is a valid VAA with RequestGovernanceDataSourceTransfer governance message
80
77
// If it's valid then its emitter can take over the governance from the current emitter.
81
78
// The VAA is checked here to ensure that the new governance data source is valid and can send message
@@ -106,9 +103,7 @@ abstract contract PythGovernance is PythGetters, PythSetters, PythGovernanceInst
106
103
emit GovernanceDataSourceSet (oldGovernanceDatSource, governanceDataSource (), lastExecutedGovernanceSequence ());
107
104
}
108
105
109
- function setDataSources (bytes memory encodedPayload ) internal {
110
- SetDataSourcesPayload memory payload = parseSetDataSourcesPayload (encodedPayload);
111
-
106
+ function setDataSources (SetDataSourcesPayload memory payload ) internal {
112
107
PythInternalStructs.DataSource[] memory oldDataSources = validDataSources ();
113
108
114
109
for (uint i = 0 ; i < oldDataSources.length ; i += 1 ) {
@@ -124,18 +119,14 @@ abstract contract PythGovernance is PythGetters, PythSetters, PythGovernanceInst
124
119
emit DataSourcesSet (oldDataSources, validDataSources ());
125
120
}
126
121
127
- function setFee (bytes memory encodedPayload ) internal {
128
- SetFeePayload memory payload = parseSetFeePayload (encodedPayload);
129
-
122
+ function setFee (SetFeePayload memory payload ) internal {
130
123
uint oldFee = singleUpdateFeeInWei ();
131
124
setSingleUpdateFeeInWei (payload.newFee);
132
125
133
126
emit FeeSet (oldFee, singleUpdateFeeInWei ());
134
127
}
135
128
136
- function setValidPeriod (bytes memory encodedPayload ) internal {
137
- SetValidPeriodPayload memory payload = parseSetValidPeriodPayload (encodedPayload);
138
-
129
+ function setValidPeriod (SetValidPeriodPayload memory payload ) internal {
139
130
uint oldValidPeriod = validTimePeriodSeconds ();
140
131
setValidTimePeriodSeconds (payload.newValidPeriod);
141
132
0 commit comments