Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@pythnetwork/pyth-sdk-solidity/IPyth.sol";
import "./IPulse.sol";
import "./PulseState.sol";
import "./PulseErrors.sol";
import "./IEcho.sol";
import "./EchoState.sol";
import "./EchoErrors.sol";

abstract contract Pulse is IPulse, PulseState {
abstract contract Echo is IEcho, EchoState {
function _initialize(
address admin,
uint96 pythFeeInWei,
Expand Down Expand Up @@ -174,7 +174,7 @@ abstract contract Pulse is IPulse, PulseState {
}

try
IPulseConsumer(req.requester)._pulseCallback{
IEchoConsumer(req.requester)._echoCallback{
gas: req.callbackGasLimit
}(sequenceNumber, priceFeeds)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "./PulseState.sol";
import "./EchoState.sol";

interface PulseEvents {
event PriceUpdateRequested(PulseState.Request request, bytes32[] priceIds);
interface EchoEvents {
event PriceUpdateRequested(EchoState.Request request, bytes32[] priceIds);

event PriceUpdateExecuted(
uint64 indexed sequenceNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.0;

contract PulseState {
contract EchoState {
uint8 public constant NUM_REQUESTS = 32;
bytes1 public constant NUM_REQUESTS_MASK = 0x1f;
// Maximum number of price feeds per request. This limit keeps gas costs predictable and reasonable. 10 is a reasonable number for most use cases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import "./Pulse.sol";
import "./Echo.sol";

contract PulseUpgradeable is
contract EchoUpgradeable is
Initializable,
Ownable2StepUpgradeable,
UUPSUpgradeable,
Pulse
Echo
{
event ContractUpgraded(
address oldImplementation,
Expand All @@ -33,7 +33,7 @@ contract PulseUpgradeable is
__Ownable_init();
__UUPSUpgradeable_init();

Pulse._initialize(
Echo._initialize(
admin,
pythFeeInWei,
pythAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@
pragma solidity ^0.8.0;

import "@pythnetwork/pyth-sdk-solidity/IPyth.sol";
import "./PulseEvents.sol";
import "./PulseState.sol";
import "./EchoEvents.sol";
import "./EchoState.sol";

abstract contract IPulseConsumer {
// This method is called by Pulse to provide the price updates to the consumer.
// It asserts that the msg.sender is the Pulse contract. It is not meant to be
abstract contract IEchoConsumer {
// This method is called by Echo to provide the price updates to the consumer.
// It asserts that the msg.sender is the Echo contract. It is not meant to be
// overridden by the consumer.
function _pulseCallback(
function _echoCallback(
uint64 sequenceNumber,
PythStructs.PriceFeed[] memory priceFeeds
) external {
address pulse = getPulse();
require(pulse != address(0), "Pulse address not set");
require(msg.sender == pulse, "Only Pulse can call this function");
address echo = getEcho();
require(echo != address(0), "Echo address not set");
require(msg.sender == echo, "Only Echo can call this function");

pulseCallback(sequenceNumber, priceFeeds);
echoCallback(sequenceNumber, priceFeeds);
}

// getPulse returns the Pulse contract address. The method is being used to check that the
// callback is indeed from the Pulse contract. The consumer is expected to implement this method.
function getPulse() internal view virtual returns (address);
// getEcho returns the Echo contract address. The method is being used to check that the
// callback is indeed from the Echo contract. The consumer is expected to implement this method.
function getEcho() internal view virtual returns (address);

// This method is expected to be implemented by the consumer to handle the price updates.
// It will be called by _pulseCallback after _pulseCallback ensures that the call is
// indeed from Pulse contract.
function pulseCallback(
// It will be called by _echoCallback after _echoCallback ensures that the call is
// indeed from Echo contract.
function echoCallback(
uint64 sequenceNumber,
PythStructs.PriceFeed[] memory priceFeeds
) internal virtual;
}

interface IPulse is PulseEvents {
interface IEcho is EchoEvents {
// Core functions
/**
* @notice Requests price updates with a callback
Expand Down Expand Up @@ -103,7 +103,7 @@ interface IPulse is PulseEvents {

function getRequest(
uint64 sequenceNumber
) external view returns (PulseState.Request memory req);
) external view returns (EchoState.Request memory req);

function setFeeManager(address manager) external;

Expand All @@ -130,7 +130,7 @@ interface IPulse is PulseEvents {

function getProviderInfo(
address provider
) external view returns (PulseState.ProviderInfo memory);
) external view returns (EchoState.ProviderInfo memory);

function getDefaultProvider() external view returns (address);

Expand All @@ -157,5 +157,5 @@ interface IPulse is PulseEvents {
)
external
view
returns (PulseState.Request[] memory requests, uint256 actualCount);
returns (EchoState.Request[] memory requests, uint256 actualCount);
}
Loading
Loading