Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(target_chains/ethereum): add arbirum stylus sdk #2041

Open
wants to merge 237 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
237 commits
Select commit Hold shift + click to select a range
e002660
chore: init stylus project
Ifechukwudaniel Sep 18, 2024
8d19bc1
chore: added scripts
Ifechukwudaniel Sep 18, 2024
08c010c
chore: created workspace
Ifechukwudaniel Sep 18, 2024
483eced
chore: docs setup
Ifechukwudaniel Sep 18, 2024
9d4a368
chore: pyth contracts init
Ifechukwudaniel Sep 19, 2024
900f2d4
chore: docs command setup
Ifechukwudaniel Sep 19, 2024
583ca72
mock: example project
Ifechukwudaniel Sep 19, 2024
c813c7a
chore : created test workspace
Ifechukwudaniel Sep 19, 2024
c088e12
chore: changed toml version
Ifechukwudaniel Sep 19, 2024
62030d7
chore: created mock pyth workspace
Ifechukwudaniel Sep 20, 2024
d731068
chore: renamed project sdk
Ifechukwudaniel Sep 23, 2024
83ccc12
chore: refactored files
Ifechukwudaniel Sep 24, 2024
e94d4c5
chore : helpers functions
Ifechukwudaniel Sep 24, 2024
c891962
refacor : refactord code
Ifechukwudaniel Sep 24, 2024
93a7291
chore: removed struct type , implemented abstract_pyth
Ifechukwudaniel Sep 27, 2024
65ea9a5
chore: created storage price and storage price feed
Ifechukwudaniel Sep 27, 2024
28019ed
chore: integrating storage price and storage price feed
Ifechukwudaniel Sep 27, 2024
81f45ae
chore: fixed error created by storage type
Ifechukwudaniel Oct 3, 2024
96dda48
chore: config changes
Ifechukwudaniel Oct 3, 2024
dc847cd
chore: forge init
Ifechukwudaniel Oct 3, 2024
6588fe6
forge install: forge-std
Ifechukwudaniel Oct 3, 2024
da11d45
mock pyth : created mock solidity pyth contract
Ifechukwudaniel Oct 3, 2024
5cc9626
chore: Renamed MockPyth Scripts
Ifechukwudaniel Oct 4, 2024
da154c0
chore: started testing
Ifechukwudaniel Oct 5, 2024
e3302d8
chore: removed projects
Ifechukwudaniel Oct 14, 2024
824d767
feture :completed unit test and stylus contracts
Ifechukwudaniel Oct 14, 2024
60baf08
added initializtion for mock
Ifechukwudaniel Oct 14, 2024
86ad529
examples setup
Ifechukwudaniel Oct 14, 2024
a131593
chore:fixed imports
Ifechukwudaniel Oct 23, 2024
299b0ce
chore:fixed types
Ifechukwudaniel Oct 23, 2024
7ac267f
completed contract
Ifechukwudaniel Oct 23, 2024
41e3009
External call and fution call sample
Ifechukwudaniel Oct 23, 2024
05b9593
chore: Changed motsu
Ifechukwudaniel Oct 23, 2024
70e2e6c
chore: Created Proxy call example
Ifechukwudaniel Oct 24, 2024
5ad08c4
feture: Example for both type of call
Ifechukwudaniel Oct 24, 2024
568ba56
chore: Added beches
Ifechukwudaniel Oct 24, 2024
72a9b5b
Lib Changes
Ifechukwudaniel Oct 24, 2024
ec4d75b
chore:Scripts modifications
Ifechukwudaniel Oct 24, 2024
047a73d
chore : fuction call and proxy call
Ifechukwudaniel Oct 24, 2024
ded7cb4
chore: added workflow
Ifechukwudaniel Oct 24, 2024
d31557a
chore: doc pages docs
Ifechukwudaniel Oct 24, 2024
86dfbb1
chore: doc changes
Ifechukwudaniel Oct 24, 2024
bcd86d6
smaller chages
Ifechukwudaniel Oct 24, 2024
94517ee
chore: benches and toml changes
Ifechukwudaniel Oct 27, 2024
703e43a
chore: added foundry to e2e workflow
Ifechukwudaniel Oct 28, 2024
28fa93e
chore:set up benchmark
Ifechukwudaniel Oct 28, 2024
22bae51
Added Benches
Ifechukwudaniel Oct 28, 2024
85cd41c
chore:added setup mock pyth script to bench and e2e and logs
Ifechukwudaniel Oct 28, 2024
d1c010b
changes
Ifechukwudaniel Oct 29, 2024
8826fa5
feture: Added Proxy call to bench
Ifechukwudaniel Oct 30, 2024
343de13
chore: Removed sol file
Ifechukwudaniel Oct 30, 2024
1407ed4
Added deploy scripts
Ifechukwudaniel Oct 30, 2024
15a47a9
chore: proxy calls
Ifechukwudaniel Oct 30, 2024
5904a1a
chore: removed file
Ifechukwudaniel Oct 30, 2024
28d9316
changes
Ifechukwudaniel Oct 30, 2024
74a4dd4
chore:added constructor file and worked on bench
Ifechukwudaniel Oct 31, 2024
b1dc655
chore: moved Ipyth to pyth-contract file
Ifechukwudaniel Oct 31, 2024
5fafd30
chore: added variable to bash scripts
Ifechukwudaniel Oct 31, 2024
5171513
chore:decode and encode helper
Ifechukwudaniel Oct 31, 2024
08fd4cb
chore: fixed mock pyth deploy script
Ifechukwudaniel Nov 1, 2024
e5ba09d
chore: removed dotenv crates
Ifechukwudaniel Nov 1, 2024
d1d5cec
chore: completed benches functions
Ifechukwudaniel Nov 1, 2024
64e3be5
chore: examples and proxy call fixes
Ifechukwudaniel Nov 1, 2024
69b61df
changes
Ifechukwudaniel Nov 1, 2024
a21b5fa
chore: added create functions
Ifechukwudaniel Nov 2, 2024
b354747
chore: completed get data benchmarks
Ifechukwudaniel Nov 3, 2024
d1a4eae
chore:contract changes
Ifechukwudaniel Nov 3, 2024
8464896
chore:function calls
Ifechukwudaniel Nov 3, 2024
196018c
chore: Ignore all broadcast
Ifechukwudaniel Nov 3, 2024
072ec4e
chore: completed get benches
Ifechukwudaniel Nov 3, 2024
70432b7
chore:changes
Ifechukwudaniel Nov 3, 2024
cd728b6
chore: Added Type Test
Ifechukwudaniel Nov 4, 2024
30c5056
chore: tests
Ifechukwudaniel Nov 5, 2024
908b866
env and examples
Ifechukwudaniel Nov 5, 2024
3538303
Update README.md
Ifechukwudaniel Nov 5, 2024
bd054a3
Update README.md
Ifechukwudaniel Nov 5, 2024
e0f68e4
Update README.md
Ifechukwudaniel Nov 5, 2024
58f5a2d
chore: worked on bench and e2e test
Ifechukwudaniel Nov 6, 2024
0af7c1a
removed log
Ifechukwudaniel Nov 6, 2024
f389baa
chore: completed e2e test for function call example
Ifechukwudaniel Nov 7, 2024
9471852
chore : changed pyth script
Ifechukwudaniel Nov 7, 2024
dee2846
chore:completed e2e test
Ifechukwudaniel Nov 7, 2024
9a8d23d
chore:benches
Ifechukwudaniel Nov 7, 2024
ebb4858
Update README.md
Ifechukwudaniel Nov 7, 2024
0f6da86
Update README.md
Ifechukwudaniel Nov 7, 2024
4b84ac0
Update README.md
Ifechukwudaniel Nov 7, 2024
d5b33e0
Update README.md
Ifechukwudaniel Nov 7, 2024
87ea83b
Update README.md
Ifechukwudaniel Nov 7, 2024
46810a6
Merge branch 'pyth-network:main' into stylus-sdk
Ifechukwudaniel Nov 7, 2024
de44253
chore: removed docs
Ifechukwudaniel Nov 7, 2024
670456a
Update README.md
Ifechukwudaniel Nov 7, 2024
4b8f43c
Update README.md
Ifechukwudaniel Nov 7, 2024
0625759
Update CODEOWNERS
Ifechukwudaniel Nov 9, 2024
1924721
Delete target_chains/ethereum/sdk/stylus/SECURITY.md
Ifechukwudaniel Nov 9, 2024
b7e1a30
Delete target_chains/ethereum/sdk/stylus/lib/crypto directory
Ifechukwudaniel Nov 9, 2024
2ca8638
Delete target_chains/ethereum/sdk/stylus/.linkspector.yml
Ifechukwudaniel Nov 9, 2024
4ee4ccf
Delete target_chains/ethereum/sdk/stylus/netlify.toml
Ifechukwudaniel Nov 9, 2024
bf3199d
Update Cargo.toml removed openzepline crypto
Ifechukwudaniel Nov 9, 2024
a74751d
Update README.md
Ifechukwudaniel Nov 9, 2024
3ed5a92
Delete target_chains/ethereum/sdk/stylus/pyth-solidity/.env.example
Ifechukwudaniel Nov 9, 2024
7d2f445
Update gas-bench.yml
Ifechukwudaniel Nov 9, 2024
5c2b2c0
chore:removed a bunch of openzeplin files
Ifechukwudaniel Nov 9, 2024
038015b
chore: removed workflow
Ifechukwudaniel Nov 9, 2024
013ea47
chore:Added Guidlines
Ifechukwudaniel Nov 9, 2024
655e55e
chore: motsu changes
Ifechukwudaniel Nov 11, 2024
9628334
Create Test.md
Ifechukwudaniel Nov 11, 2024
3628d14
Update Test.md
Ifechukwudaniel Nov 11, 2024
859e6e8
Rename Test.md to TEST.md
Ifechukwudaniel Nov 11, 2024
28c3def
Update README.md
Ifechukwudaniel Nov 11, 2024
42241a6
Update README.md
Ifechukwudaniel Nov 11, 2024
45ff362
Update README.md
Ifechukwudaniel Nov 11, 2024
a118553
Delete target_chains/ethereum/sdk/stylus/TEST.md
Ifechukwudaniel Nov 11, 2024
5f5bc5e
chore: removed mostu
Ifechukwudaniel Nov 11, 2024
1397b2b
chore: changed Fixedbytes<32> to B256
Ifechukwudaniel Nov 11, 2024
6b37ea5
chore: removed local e2e testing library
Ifechukwudaniel Nov 11, 2024
b2ab6db
chore: changes
Ifechukwudaniel Nov 12, 2024
a610d23
forge install: forge-std
Ifechukwudaniel Nov 12, 2024
86a5d4a
forge install: openzeppelin-foundry-upgrades
Ifechukwudaniel Nov 12, 2024
819f8a1
forge install: openzeppelin-contracts
Ifechukwudaniel Nov 12, 2024
bc78af5
chore: formated code
Ifechukwudaniel Nov 14, 2024
36b862d
Merge branch 'main' into stylus-sdk
Ifechukwudaniel Nov 16, 2024
8617b13
chore: fixed scripts
Ifechukwudaniel Nov 17, 2024
746dfdf
Update target_chains/ethereum/sdk/stylus/README.md
Ifechukwudaniel Nov 25, 2024
fa25f06
Update target_chains/ethereum/sdk/stylus/README.md
Ifechukwudaniel Nov 25, 2024
fb942d2
chore: rustfmt changes
Ifechukwudaniel Nov 25, 2024
c2e0629
chore: changed solidity licenses to Apache 2
Ifechukwudaniel Nov 25, 2024
cf0f807
chore: deleted codeowner file and link
Ifechukwudaniel Nov 25, 2024
1b1e351
chore: removed comments
Ifechukwudaniel Nov 25, 2024
7c529fe
solidity changes
Ifechukwudaniel Nov 25, 2024
c1e656d
chore: removed folder
Ifechukwudaniel Nov 25, 2024
c9be56a
chore: removed = for version
Ifechukwudaniel Nov 25, 2024
8831682
forge install: forge-std
Ifechukwudaniel Nov 25, 2024
88ace13
forge install: openzeppelin-foundry-upgrades
Ifechukwudaniel Nov 25, 2024
1cd711e
forge install: openzeppelin-contracts-upgradeable
Ifechukwudaniel Nov 25, 2024
841af31
chore: Remove MIT license
Ifechukwudaniel Nov 25, 2024
f6a5fe6
chore: script changes
Ifechukwudaniel Nov 25, 2024
ce78d45
chore: removed dependices
Ifechukwudaniel Nov 25, 2024
f693364
forge install: forge-std
Ifechukwudaniel Nov 25, 2024
7a63cfd
forge install: openzeppelin-foundry-upgrades
Ifechukwudaniel Nov 25, 2024
42903d5
chore:added description to script
Ifechukwudaniel Nov 25, 2024
45d2d8d
Update target_chains/ethereum/sdk/stylus/README.md
Ifechukwudaniel Nov 25, 2024
3912338
Update target_chains/ethereum/sdk/stylus/README.md
Ifechukwudaniel Nov 25, 2024
50c7cb9
Update target_chains/ethereum/sdk/stylus/contracts/src/pyth/mod.rs
Ifechukwudaniel Nov 25, 2024
a399be4
Update target_chains/ethereum/sdk/stylus/contracts/src/pyth/errors.rs
Ifechukwudaniel Nov 25, 2024
4e00e9f
chore: changed // to /// and remove licenses because of root licenese
Ifechukwudaniel Nov 25, 2024
86e1b5b
chore: Apache-2.0 license
Ifechukwudaniel Nov 25, 2024
a91e478
chore: renamed file name pyth-solidity to pyth-mock-solidity
Ifechukwudaniel Nov 25, 2024
ebe40a8
Merge branch 'main' into stylus-sdk
Ifechukwudaniel Nov 25, 2024
f01d0e8
chore: removed commented code
Ifechukwudaniel Nov 25, 2024
a87645b
chore: foundry test workflow
Ifechukwudaniel Nov 25, 2024
ad0468f
chore: workflows
Ifechukwudaniel Nov 25, 2024
d3167e0
chore: changed readme to rust
Ifechukwudaniel Nov 25, 2024
7f53584
chore: fixed description mock solidity
Ifechukwudaniel Nov 25, 2024
605fc58
chore: fixed zero case
Ifechukwudaniel Nov 26, 2024
233f68b
chore: change all use case of gt and lt to > and <
Ifechukwudaniel Nov 26, 2024
d0973f2
chore: workflow
Ifechukwudaniel Nov 26, 2024
cea2843
chore: replaced the file with the link
Ifechukwudaniel Nov 26, 2024
0fdbb3e
chore: refactor and removed unused code
Ifechukwudaniel Nov 26, 2024
36f05f4
chore: renamed function for test
Ifechukwudaniel Nov 26, 2024
658ad51
chore: added some sort of path filters
Ifechukwudaniel Nov 26, 2024
5a15e17
Merge pull request #1 from pyth-network/main
Ifechukwudaniel Nov 27, 2024
dd82af7
chore: add cargo fmt and cargo clippy for stylus sdk
Ifechukwudaniel Nov 28, 2024
8e7c7cc
chore: package-json.lock moved depencies to pnpm-workspace.yaml
Ifechukwudaniel Nov 28, 2024
9e34259
chore:test attribute
Ifechukwudaniel Nov 28, 2024
4a9c2c1
Merge branch 'pyth-network:main' into stylus-sdk
Ifechukwudaniel Dec 17, 2024
960ea37
chore: git workflows
Ifechukwudaniel Dec 20, 2024
1bd5dee
Merge branch 'pyth-network:main' into stylus-sdk
Ifechukwudaniel Dec 20, 2024
a1816b1
chore: removed functions example
Ifechukwudaniel Dec 20, 2024
3094296
chore: switch for item in update_data
Ifechukwudaniel Dec 20, 2024
b1646d5
chore: fixed example
Ifechukwudaniel Dec 21, 2024
a0e25ee
chore: refactor examples
Ifechukwudaniel Dec 21, 2024
153ebc5
cargo changes
Ifechukwudaniel Dec 21, 2024
a676824
chore: pyth example , and function call example
Ifechukwudaniel Dec 21, 2024
c93aca8
chore: added other example
Ifechukwudaniel Dec 21, 2024
14b400a
chore: install
Ifechukwudaniel Dec 21, 2024
15ca2f3
chore:installations
Ifechukwudaniel Dec 21, 2024
19673ea
chore: mock pyth
Ifechukwudaniel Dec 22, 2024
f1626ef
chore: benches and test
Ifechukwudaniel Dec 23, 2024
a447f3f
smaller changes
Ifechukwudaniel Dec 23, 2024
6571d3b
chore: mock
Ifechukwudaniel Dec 23, 2024
37ede70
chore: bench format
Ifechukwudaniel Dec 31, 2024
a1258ed
chore: code format
Ifechukwudaniel Dec 31, 2024
5a828da
chore: code format
Ifechukwudaniel Dec 31, 2024
84ecf17
chore: removed workflow
Ifechukwudaniel Jan 17, 2025
379dd58
chore: pnpm install
Ifechukwudaniel Jan 17, 2025
45d4721
chore: removed package-lock.json
Ifechukwudaniel Jan 17, 2025
7557a76
chore: fixed commented out job
Ifechukwudaniel Jan 17, 2025
4380ef4
chore: ran pre-commit run --all
Ifechukwudaniel Jan 17, 2025
996f398
chore: pre-commit run --all
Ifechukwudaniel Jan 18, 2025
186d3a8
chore:removed space
Ifechukwudaniel Jan 20, 2025
796680d
Update .github/workflows/cli-foundry-test.yml
Ifechukwudaniel Jan 20, 2025
326561a
chore:removed space
Ifechukwudaniel Jan 20, 2025
1fced8d
chore: data changes
Ifechukwudaniel Jan 21, 2025
f73cd0f
Update .github/workflows/cli-stylus-nostd.yml
Ifechukwudaniel Jan 22, 2025
71f0040
Update .github/workflows/cli-stylus-gas-bench.yml
Ifechukwudaniel Jan 22, 2025
3e8d049
Update .github/workflows/cli-stylus-e2e-tests.yml
Ifechukwudaniel Jan 22, 2025
27b5f0c
Update .github/workflows/cli-stylus-check.yml
Ifechukwudaniel Jan 22, 2025
d41cac7
Update .github/workflows/cli-stylus-check-wasm.yml
Ifechukwudaniel Jan 22, 2025
a6c1570
Update .github/workflows/cli-foundry-test.yml
Ifechukwudaniel Jan 22, 2025
0200d55
Update .github/workflows/cli-stylus-e2e-tests.yml
Ifechukwudaniel Jan 22, 2025
5dcbcf0
Update .github/workflows/cli-stylus-check-wasm.yml
Ifechukwudaniel Jan 22, 2025
4a380ce
Update .github/workflows/cli-stylus-check.yml
Ifechukwudaniel Jan 22, 2025
7065e7e
Update .github/workflows/cli-stylus-nostd.yml
Ifechukwudaniel Jan 22, 2025
e92f61e
Update .github/workflows/cli-stylus-gas-bench.yml
Ifechukwudaniel Jan 22, 2025
315ab4d
chore: added back existing submodule
Ifechukwudaniel Jan 22, 2025
fdeaa4b
chore: data changes
Ifechukwudaniel Jan 22, 2025
823eab0
cl fixes
Ifechukwudaniel Jan 28, 2025
4c1d9dc
Merge branch 'pyth-network:main' into stylus-sdk
Ifechukwudaniel Jan 29, 2025
468c3c3
cli fixes
Ifechukwudaniel Jan 29, 2025
c57fee0
chore: toolchain: nightly-2024-01-01
Ifechukwudaniel Jan 29, 2025
ea1fdcf
chore: version changes
Ifechukwudaniel Jan 29, 2025
5cd82fd
toolchain
Ifechukwudaniel Jan 29, 2025
4e10a11
removed typo workflow
Ifechukwudaniel Jan 29, 2025
953bb25
fixed rust issue
Ifechukwudaniel Jan 29, 2025
2ae7cf6
changed rust version
Ifechukwudaniel Jan 29, 2025
126e076
added foundry
Ifechukwudaniel Jan 29, 2025
654a777
Merge branch 'pyth-network:main' into stylus-sdk
Ifechukwudaniel Feb 2, 2025
fd1768f
Merge branch 'pyth-network:main' into stylus-sdk
Ifechukwudaniel Feb 2, 2025
f5384fc
chore: changes
Ifechukwudaniel Feb 3, 2025
4171d15
chore:bench fixes
Ifechukwudaniel Feb 3, 2025
187ada8
chore: changed cli workflow
Ifechukwudaniel Feb 3, 2025
35886d8
chore: format
Ifechukwudaniel Feb 3, 2025
8aa761f
ci changes
Ifechukwudaniel Feb 3, 2025
68e9a6d
chore: added space
Ifechukwudaniel Feb 3, 2025
568c9d2
precommit fixes
Ifechukwudaniel Feb 4, 2025
0c1d72b
added new line
Ifechukwudaniel Feb 4, 2025
05c1324
removed
Ifechukwudaniel Feb 4, 2025
d0b18c4
removed line
Ifechukwudaniel Feb 5, 2025
0d38c25
chore: ci changes
Ifechukwudaniel Feb 5, 2025
996ef9a
chore : changes
Ifechukwudaniel Feb 5, 2025
7f8384c
changed ci script
Ifechukwudaniel Feb 5, 2025
916ade7
removed if statements for test
Ifechukwudaniel Feb 5, 2025
a2154af
chore: changes
Ifechukwudaniel Feb 5, 2025
5b3b68e
chore:fixes
Ifechukwudaniel Feb 5, 2025
fd9c769
chore: fixes
Ifechukwudaniel Feb 5, 2025
c27255a
chore: fixes
Ifechukwudaniel Feb 5, 2025
590d433
added evm file
Ifechukwudaniel Feb 5, 2025
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
Prev Previous commit
Next Next commit
chore: changed Fixedbytes<32> to B256
  • Loading branch information
Ifechukwudaniel committed Nov 11, 2024
commit 1397b2b5bb677c8affec5685564bf29d79753e12
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::pyth::types::{
use crate::utils::helpers::{call_helper, delegate_call_helper};
use alloc::vec::Vec;
use stylus_sdk::storage::TopLevelStorage;
use alloy_primitives::{ Address, FixedBytes, U256, Bytes};
use alloy_primitives::{ Address, B256, U256, Bytes};
use crate::pyth::mock::DecodeDataType;
use alloy_sol_types::SolType;

Expand All @@ -32,7 +32,7 @@ use alloy_sol_types::SolType;
pub fn get_price_no_older_than(
Ifechukwudaniel marked this conversation as resolved.
Show resolved Hide resolved
storage: &mut impl TopLevelStorage,
pyth_address: Address,
id: FixedBytes<32>,
id: B256,
age: U256,
) -> Result<Price, Vec<u8>> {
let price_call = call_helper::<getPriceNoOlderThanCall>(storage, pyth_address, (id, age,))?;
Expand Down Expand Up @@ -69,7 +69,7 @@ pub fn get_update_fee(
pub fn get_ema_price_unsafe(
storage: &mut impl TopLevelStorage,
pyth_address: Address,
id: FixedBytes<32>,
id: B256,
) -> Result<Price, Vec<u8>> {
let ema_price = call_helper::<getEmaPriceUnsafeCall>(storage, pyth_address, (id,))?;
Ok(ema_price.price)
Expand All @@ -88,7 +88,7 @@ pub fn get_ema_price_unsafe(
pub fn get_ema_price_no_older_than(
storage: &mut impl TopLevelStorage,
pyth_address: Address,
id: FixedBytes<32>,
id: B256,
age: U256,
) -> Result<Price, Vec<u8>> {
let ema_price = call_helper::<getEmaPriceNoOlderThanCall>(storage, pyth_address, (id, age,))?;
Expand All @@ -107,7 +107,7 @@ pub fn get_ema_price_no_older_than(
pub fn get_price_unsafe(
storage: &mut impl TopLevelStorage,
pyth_address: Address,
id: FixedBytes<32>,
id: B256,
) -> Result<Price, Vec<u8>> {
let price = call_helper::<getPriceUnsafeCall>(storage, pyth_address, (id,))?;
let price = Price {
Expand Down Expand Up @@ -168,7 +168,7 @@ pub fn update_price_feeds_if_necessary(
storage: &mut impl TopLevelStorage,
pyth_address: Address,
update_data: Vec<Bytes>,
price_ids: Vec<FixedBytes<32>>,
price_ids: Vec<B256>,
publish_times: Vec<u64>,
) -> Result<(), Vec<u8>> {
delegate_call_helper::<updatePriceFeedsIfNecessaryCall>(
Expand All @@ -195,7 +195,7 @@ pub fn parse_price_feed_updates(
storage: &mut impl TopLevelStorage,
pyth_address: Address,
update_data: Vec<Bytes>,
price_ids: Vec<FixedBytes<32>>,
price_ids: Vec<B256>,
min_publish_time: u64,
max_publish_time: u64,
) -> Result<Vec<PriceFeed>, Vec<u8>> {
Expand All @@ -218,7 +218,7 @@ pub fn parse_price_feed_updates_unique(
storage: &mut impl TopLevelStorage,
pyth_address: Address,
update_data: Vec<Bytes>,
price_ids: Vec<FixedBytes<32>>,
price_ids: Vec<B256>,
min_publish_time: u64,
max_publish_time: u64
) -> Result<Vec<PriceFeed>, Vec<u8>> {
Expand All @@ -243,7 +243,7 @@ pub fn parse_price_feed_updates_unique(
/// # Returns
/// - `Vec<u8>`: A byte vector containing the encoded update data for the price feed.
pub fn create_price_feed_update_data(
id: FixedBytes<32>,
id: B256,
price: i64,
conf: u64,
expo: i32,
Expand Down
39 changes: 16 additions & 23 deletions target_chains/ethereum/sdk/stylus/contracts/src/pyth/mock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloc::vec::Vec;
use alloy_primitives::{Uint, FixedBytes, U256, Bytes};
use alloy_primitives::{Uint, U256, Bytes, B256};
use alloy_sol_types::{ sol_data::Uint as SolUInt, SolType, SolValue};
use stylus_sdk::{abi::Bytes as AbiBytes,evm, msg, prelude::*};
use crate::{pyth::errors::{FalledDecodeData, InsufficientFee, InvalidArgument}, utils::helpers::CALL_RETDATA_DECODING_ERROR_MESSAGE};
Expand Down Expand Up @@ -32,15 +32,15 @@ impl MockPythContract {
}


fn query_price_feed(&self, id: FixedBytes<32>) -> Result<Vec<u8>, Vec<u8>> {
fn query_price_feed(&self, id: B256) -> Result<Vec<u8>, Vec<u8>> {
let price_feed = self.price_feeds.get(id).to_price_feed();
if price_feed.id.eq(&FixedBytes::<32>::ZERO) {
if price_feed.id.eq(&B256::ZERO) {
Ifechukwudaniel marked this conversation as resolved.
Show resolved Hide resolved
return Err(Error::PriceFeedNotFound(PriceFeedNotFound {}).into());
}
Ok(price_feed.abi_encode())
}

fn price_feed_exists(&self, id:FixedBytes<32>) -> bool {
fn price_feed_exists(&self, id:B256) -> bool {
self.price_feeds.getter(id).id.is_empty()
}

Expand Down Expand Up @@ -97,7 +97,7 @@ impl MockPythContract {
fn parse_price_feed_updates(
&mut self,
update_data:Vec<AbiBytes>,
price_ids:Vec<FixedBytes<32>>,
price_ids:Vec<B256>,
min_publish_time:u64,
max_publish_time:u64
) -> Result<Vec<u8>, Vec<u8>>{
Expand All @@ -108,15 +108,15 @@ impl MockPythContract {
fn parse_price_feed_updates_unique(
&mut self,
update_data:Vec<AbiBytes>,
price_ids:Vec<FixedBytes<32>>,
price_ids:Vec<B256>,
min_publish_time:u64,
max_publish_time:u64
) -> Result<Vec<u8>, Vec<u8>>{
self.parse_price_feed_updates_internal(update_data, price_ids, min_publish_time, max_publish_time, true)
}

fn create_price_feed_update_data(&self,
id:FixedBytes<32>,
id:B256,
price:i64,
conf:u64,
expo:i32,
Expand All @@ -141,7 +141,7 @@ impl MockPythContract {

fn parse_price_feed_updates_internal(&mut self,
update_data: Vec<AbiBytes>,
price_ids: Vec<FixedBytes<32>>,
price_ids: Vec<B256>,
min_publish_time:u64,
max_publish_time:u64,
unique:bool
Expand Down Expand Up @@ -183,7 +183,7 @@ impl MockPythContract {
{
break;
} else {
feeds[i].id = FixedBytes::<32>::ZERO;
feeds[i].id = B256::ZERO;
}
}

Expand All @@ -197,10 +197,10 @@ impl MockPythContract {
}
}

pub fn create_price_feed_update_data_list() -> (Vec<Bytes>, Vec<FixedBytes<32>>) {
pub fn create_price_feed_update_data_list() -> (Vec<Bytes>, Vec<B256>) {
let id = ["ETH","SOL","BTC"].map(|x| {
let x = keccak_const::Keccak256::new().update(x.as_bytes()).finalize().to_vec();
return FixedBytes::<32>::from_slice(&x) ;
return B256::from_slice(&x);
});
let mut price_feed_data_list = Vec::new();
for i in 0..3 {
Expand All @@ -214,7 +214,7 @@ pub fn create_price_feed_update_data_list() -> (Vec<Bytes>, Vec<FixedBytes<32>>)
#[cfg(all(test, feature = "std"))]
mod tests {
use alloc::vec;
use alloy_primitives::{ U256, FixedBytes};
use alloy_primitives::{ U256, B256};
use stylus_sdk::abi::Bytes;
use
crate::pyth::mock::{MockPythContract, DecodeDataType};
Expand All @@ -228,8 +228,8 @@ mod tests {
const EMA_CONF: u64 = 1000;
const PREV_PUBLISH_TIME: u64 = 1000;

fn generate_bytes() -> FixedBytes<32> {
FixedBytes::<32>::repeat_byte(30)
fn generate_bytes() -> B256 {
B256::repeat_byte(30)
}

#[motsu::test]
Expand All @@ -241,7 +241,8 @@ mod tests {

#[motsu::test]
fn error_initialize_mock_contract(contract: MockPythContract) {
let err = contract.initialize(U256::from(0), U256::from(0)).expect_err("should not initialize with invalid parameters");
let err = contract.initialize(U256::from(0), U256::from(0)) ;
assert!(err.is_err())
}

#[motsu::test]
Expand Down Expand Up @@ -298,12 +299,4 @@ mod tests {
assert_eq!(valid_time_period, U256::from(1000));
}

#[motsu::test]
fn can_update_price_feeds(contract: MockPythContract) {
let _ = contract.initialize(U256::from(1000), U256::from(1000));
let id = generate_bytes();
//let price_feed_created = contract.create_price_feed_update_data(id, PRICE, CONF, EXPO, EMA_PRICE, EMA_CONF, U256::from(1000), PREV_PUBLISH_TIME);
//let mut update_data: Vec<Bytes> = vec![];
//update_data.push(Bytes::from(price_feed_created));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloy_sol_types::SolValue;
use stylus_sdk::{abi::Bytes as AbiBytes, prelude::*, storage::TopLevelStorage};
use alloc::vec::Vec;
use alloy_primitives::{ FixedBytes, U256 , Bytes };
use alloy_primitives::{ U256 , Bytes, B256 };
use crate::pyth::functions::{
get_price_unsafe,
get_price_no_older_than,
Expand All @@ -27,7 +27,7 @@ pub trait IPyth {
///
/// # Returns
/// - `Result<Vec<u8>, Self::Error>`: The price data in bytes, or an error.
fn get_price_unsafe(&mut self, id: FixedBytes<32>) -> Result<Vec<u8>, Self::Error>;
fn get_price_unsafe(&mut self, id: B256) -> Result<Vec<u8>, Self::Error>;

/// Retrieves a price that is no older than a specified `age`.
///
Expand All @@ -37,7 +37,7 @@ pub trait IPyth {
///
/// # Returns
/// - `Result<Vec<u8>, Self::Error>`: The price data in bytes, or an error.
fn get_price_no_older_than(&mut self, id: FixedBytes<32>, age: U256) -> Result<Vec<u8>, Self::Error>;
fn get_price_no_older_than(&mut self, id: B256, age: U256) -> Result<Vec<u8>, Self::Error>;

/// Retrieves the exponentially-weighted moving average (EMA) price without recency checks.
///
Expand All @@ -46,7 +46,7 @@ pub trait IPyth {
///
/// # Returns
/// - `Result<Vec<u8>, Self::Error>`: The EMA price data in bytes, or an error.
fn get_ema_price_unsafe(&mut self, id: FixedBytes<32>) -> Result<Vec<u8>, Self::Error>;
fn get_ema_price_unsafe(&mut self, id: B256) -> Result<Vec<u8>, Self::Error>;

/// Retrieves an EMA price that is no older than the specified `age`.
///
Expand All @@ -56,7 +56,7 @@ pub trait IPyth {
///
/// # Returns
/// - `Result<Vec<u8>, Self::Error>`: The EMA price data in bytes, or an error.
fn get_ema_price_no_older_than(&mut self, id: FixedBytes<32>, age: U256) -> Result<Vec<u8>, Self::Error>;
fn get_ema_price_no_older_than(&mut self, id: B256, age: U256) -> Result<Vec<u8>, Self::Error>;

/// Updates price feeds with the given data.
///
Expand All @@ -79,7 +79,7 @@ pub trait IPyth {
fn update_price_feeds_if_necessary(
&mut self,
update_data: Vec<AbiBytes>,
price_ids: Vec<FixedBytes<32>>,
price_ids: Vec<B256>,
publish_times: Vec<u64>,
) -> Result<(), Self::Error>;

Expand Down Expand Up @@ -114,7 +114,7 @@ pub trait IPyth {
fn parse_price_feed_updates(
&mut self,
update_data: Vec<AbiBytes>,
price_ids: Vec<FixedBytes<32>>,
price_ids: Vec<B256>,
min_publish_time: u64,
max_publish_time: u64,
) -> Result<Vec<u8>, Self::Error>;
Expand All @@ -132,7 +132,7 @@ pub trait IPyth {
fn parse_price_feed_updates_unique(
&mut self,
update_data: Vec<AbiBytes>,
price_ids: Vec<FixedBytes<32>>,
price_ids: Vec<B256>,
min_publish_time: u64,
max_publish_time: u64,
) -> Result<Vec<u8>, Self::Error>;
Expand All @@ -154,25 +154,25 @@ impl IPyth for PythContract {

type Error = Vec<u8>;

fn get_price_unsafe(&mut self, id: FixedBytes<32>) -> Result<Vec<u8>, Self::Error> {
fn get_price_unsafe(&mut self, id: B256) -> Result<Vec<u8>, Self::Error> {
let price = get_price_unsafe(self, self._ipyth.get(), id)?;
let data = price.abi_encode();
Ok(data)
}

fn get_price_no_older_than(&mut self,id: FixedBytes<32>, age: U256) -> Result<Vec<u8>, Self::Error> {
fn get_price_no_older_than(&mut self,id: B256, age: U256) -> Result<Vec<u8>, Self::Error> {
let price = get_price_no_older_than(self, self._ipyth.get(), id,age)?;
let data = price.abi_encode();
Ok(data)
}

fn get_ema_price_unsafe(&mut self, id: FixedBytes<32>) -> Result<Vec<u8>, Self::Error> {
fn get_ema_price_unsafe(&mut self, id: B256) -> Result<Vec<u8>, Self::Error> {
let price = get_ema_price_unsafe(self, self._ipyth.get(), id)?;
let data = price.abi_encode();
Ok(data)
}

fn get_ema_price_no_older_than(&mut self, id: FixedBytes<32>, age: U256) -> Result<Vec<u8>, Self::Error> {
fn get_ema_price_no_older_than(&mut self, id: B256, age: U256) -> Result<Vec<u8>, Self::Error> {
let price = get_ema_price_no_older_than(self, self._ipyth.get(), id,age)?;
let data = price.abi_encode();
Ok(data)
Expand Down Expand Up @@ -200,7 +200,7 @@ impl IPyth for PythContract {
fn update_price_feeds_if_necessary(
&mut self,
update_data: Vec<AbiBytes>,
price_ids: Vec<FixedBytes<32>>,
price_ids: Vec<B256>,
publish_times: Vec<u64>,
) -> Result<(), Self::Error> {
let data = update_data.into_iter().map(|x| Bytes::from(x.0)).collect();
Expand All @@ -212,7 +212,7 @@ impl IPyth for PythContract {
fn parse_price_feed_updates(
&mut self,
update_data: Vec<AbiBytes>,
price_ids: Vec<FixedBytes<32>>,
price_ids: Vec<B256>,
min_publish_time: u64,
max_publish_time: u64,
) -> Result<Vec<u8>, Self::Error> {
Expand All @@ -225,7 +225,7 @@ impl IPyth for PythContract {
fn parse_price_feed_updates_unique(
&mut self,
update_data: Vec<AbiBytes>,
price_ids: Vec<FixedBytes<32>>,
price_ids: Vec<B256>,
min_publish_time: u64,
max_publish_time: u64,
) -> Result<Vec<u8>, Self::Error> {
Expand Down
16 changes: 10 additions & 6 deletions target_chains/ethereum/sdk/stylus/contracts/src/pyth/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,22 @@ impl StoragePriceFeed {

#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{ FixedBytes, U256};
use alloy_primitives::{ B256, U256};
use crate::pyth::types::{PriceFeed, Price, StoragePriceFeed, StoragePrice};

// Updated constants to use uppercase naming convention
const PRICE: i64 = 1000;
const CONF: u64 = 1000;
const EXPO: i32 = 1000;
const EMA_PRICE: i64 = 1000;
const EMA_CONF: u64 = 1000;
const EXPO: i32 = 1000;

fn generate_bytes() -> FixedBytes<32> {
FixedBytes::<32>::repeat_byte(30)


/// Generates a 256-bit hash filled with the byte value 30.
///
/// # Returns
/// - `B256`: A 256-bit hash where each byte is set to 30.
fn generate_bytes() -> B256 {
B256::repeat_byte(30)
}

#[motsu::test]
Expand Down