|
|
9 сар өмнө | |
|---|---|---|
| .. | ||
| .cargo | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
| benches | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
| contracts | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
| examples | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
| pyth-mock-solidity | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
| scripts | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
| .gitignore | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
| Cargo.lock | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
| Cargo.toml | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
| GUIDELINES.md | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
| README.md | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
| rust-toolchain.toml | ee21688c45 feat(target_chains/ethereum): add arbirum stylus sdk (#2041) | 9 сар өмнө |
This package provides utilities for consuming prices from the Pyth Network Oracle in Rust with Stylus. It also includes the Pyth Interface ABI, which can be used in your libraries to interact with the Pyth contract.
It is strongly recommended to follow the consumer best practices when consuming data from Pyth.
pyth-solidity-contracts] library for external calls to Pyth smart contracts.no_std support.koba].To add the Stylus Contracts from crates.io, add the following line to your Cargo.toml (pinning to a specific version is recommended):
[dependencies]
pyth-stylus = "0.1.0"
For the latest changes from the main branch, you can also specify a git dependency:
[dependencies]
pyth-stylus = { git = "https://github.com/pyth-network/pyth-crosschain.git" }
To consume prices, use the functions interface. Be sure to read the function documentation to ensure safe use of price data.
For example, to read the latest price, call getPriceNoOlderThan with the Price ID of the price feed you are interested in:
You can interact directly with the Pyth contract, which implements the IPyth functions, instead of using call functions:
#![cfg_attr(not(test), no_std, no_main)]
extern crate alloc;
use stylus_sdk::prelude::{entrypoint, public, sol_storage};
use pyth_stylus::pyth::pyth_contract::PythContract;
sol_storage! {
#[entrypoint]
struct ProxyCallsExample {
#[borrow]
PythContract pyth;
}
}
#[public]
#[inherit(PythContract)]
impl ProxyCallsExample {
}
MockPyth is a mock contract that can be deployed locally to simulate Pyth contract behavior. To set and update price feeds, call updatePriceFeeds and provide an array of encoded price feeds as the argument. Encoded price feeds can be created using the create_price_feed_update_data function in the mock contract, which is also available in the functions module.
pyth-stylusTo run all the unit tests for the pyth-stylus package with all its features enabled, use the following command:
cargo test -p pyth-stylus --all-features
This command will:
pyth-stylus package specifically (-p pyth-stylus).--all-features).To run the end-to-end tests for pyth-stylus, follow these steps:
Start the test node:
./scripts/nitro-testnode.sh
Run the end-to-end tests:
./scripts/e2e-tests.sh
We use Semantic Versioning for our releases. To release a new version of this package and publish it to npm, follow these steps:
npm version <new version number> --no-git-tag-version to update the package version, then push your changes to GitHub.main, create a release with the tag v<new version number>, such as v1.5.2. A GitHub action will automatically publish the new version of the package to npm.