Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit a657d3e

Browse files
ali-behjatitompntn
andauthored
Abehjati/fix-mem-layout (#25)
* Update mem modifiers + refactor Mostly based on solsecurity * Bump version to 0.5.2 * Fix formatting * Update MockPyth.sol Co-authored-by: Tom Pointon <tom@teepeestudios.net> Co-authored-by: Tom Pointon <tom@teepeestudios.net>
1 parent dc52595 commit a657d3e

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

AbstractPyth.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ abstract contract AbstractPyth is IPyth {
5454
return price;
5555
}
5656

57-
function diff(uint x, uint y) private pure returns (uint) {
57+
function diff(uint x, uint y) internal pure returns (uint) {
5858
if (x > y) {
5959
return x - y;
6060
} else {
@@ -63,9 +63,9 @@ abstract contract AbstractPyth is IPyth {
6363
}
6464

6565
// Access modifier is overridden to public to be able to call it locally.
66-
function updatePriceFeeds(bytes[] memory updateData) public virtual payable override;
66+
function updatePriceFeeds(bytes[] calldata updateData) public virtual payable override;
6767

68-
function updatePriceFeedsIfNecessary(bytes[] memory updateData, bytes32[] memory priceIds, uint64[] memory publishTimes) external payable override {
68+
function updatePriceFeedsIfNecessary(bytes[] calldata updateData, bytes32[] calldata priceIds, uint64[] calldata publishTimes) external payable override {
6969
require(priceIds.length == publishTimes.length, "priceIds and publishTimes arrays should have same length");
7070

7171
bool updateNeeded = false;

IPyth.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ interface IPyth {
7272
/// The call will succeed even if the update is not the most recent.
7373
/// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid.
7474
/// @param updateData Array of price update data.
75-
function updatePriceFeeds(bytes[] memory updateData) external payable;
75+
function updatePriceFeeds(bytes[] calldata updateData) external payable;
7676

7777
/// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is
7878
/// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the
@@ -90,7 +90,7 @@ interface IPyth {
9090
/// @param updateData Array of price update data.
9191
/// @param priceIds Array of price ids.
9292
/// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]`
93-
function updatePriceFeedsIfNecessary(bytes[] memory updateData, bytes32[] memory priceIds, uint64[] memory publishTimes) external payable;
93+
function updatePriceFeedsIfNecessary(bytes[] calldata updateData, bytes32[] calldata priceIds, uint64[] calldata publishTimes) external payable;
9494

9595
/// @notice Returns the required fee to update an array of price updates.
9696
/// @param updateDataSize Number of price updates.

MockPyth.sol

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ contract MockPyth is AbstractPyth {
2222
// Takes an array of encoded price feeds and stores them.
2323
// You can create this data either by calling createPriceFeedData or
2424
// by using web3.js or ethers abi utilities.
25-
function updatePriceFeeds(bytes[] memory updateData) public override payable {
25+
function updatePriceFeeds(bytes[] calldata updateData) public override payable {
2626
uint requiredFee = getUpdateFee(updateData.length);
2727
require(msg.value >= requiredFee, "Insufficient paid fee amount");
28-
payable(msg.sender).transfer(msg.value - requiredFee);
28+
29+
if (msg.value > requiredFee) {
30+
(bool success, ) = payable(msg.sender).call{value: msg.value - requiredFee}("");
31+
require(success, "failed to transfer update fee");
32+
}
2933

3034
uint freshPrices = 0;
3135

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-sdk-solidity",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"description": "Read prices from the Pyth oracle",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)