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

Abehjati/fix-mem-layout #25

Merged
merged 4 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions AbstractPyth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ abstract contract AbstractPyth is IPyth {
return price;
}

function diff(uint x, uint y) private pure returns (uint) {
function diff(uint x, uint y) internal pure returns (uint) {
if (x > y) {
return x - y;
} else {
Expand All @@ -63,9 +63,9 @@ abstract contract AbstractPyth is IPyth {
}

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

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

bool updateNeeded = false;
Expand Down
4 changes: 2 additions & 2 deletions IPyth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ interface IPyth {
/// The call will succeed even if the update is not the most recent.
/// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid.
/// @param updateData Array of price update data.
function updatePriceFeeds(bytes[] memory updateData) external payable;
function updatePriceFeeds(bytes[] calldata updateData) external payable;

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

/// @notice Returns the required fee to update an array of price updates.
/// @param updateDataSize Number of price updates.
Expand Down
8 changes: 6 additions & 2 deletions MockPyth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ contract MockPyth is AbstractPyth {
// Takes an array of encoded price feeds and stores them.
// You can create this data either by calling createPriceFeedData or
// by using web3.js or ethers abi utilities.
function updatePriceFeeds(bytes[] memory updateData) public override payable {
function updatePriceFeeds(bytes[] calldata updateData) public override payable {
uint requiredFee = getUpdateFee(updateData.length);
require(msg.value >= requiredFee, "Insufficient paid fee amount");
payable(msg.sender).transfer(msg.value - requiredFee);

if (msg.value > requiredFee) {
(bool success, ) = payable(msg.sender).call{value: msg.value - requiredFee}("");
require(success, "failed to transfer update fee");
}

uint freshPrices = 0;

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/pyth-sdk-solidity",
"version": "0.5.1",
"version": "0.5.2",
"description": "Read prices from the Pyth oracle",
"repository": {
"type": "git",
Expand Down