Skip to content

Commit fb52e84

Browse files
authored
Merge pull request #2795 from pyth-network/pyth-stylus-update-and-initialize
feat(stylus) - initialize and update fees for pyth contract
2 parents 3f5ac86 + de11375 commit fb52e84

File tree

11 files changed

+1485
-93
lines changed

11 files changed

+1485
-93
lines changed

target_chains/stylus/Cargo.lock

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

target_chains/stylus/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
[workspace]
22
members = [
33
"contracts/wormhole",
4-
"contracts/pyth-receiver"
5-
]
4+
"contracts/pyth-receiver"]
65
resolver = "2"
76

87
[workspace.package]
@@ -12,7 +11,7 @@ repository = "https://github.com/pyth-network/pyth-crosschain"
1211
version = "0.1.0"
1312

1413
[workspace.dependencies]
15-
stylus-sdk = { version = "0.6.0", default-features = false }
14+
stylus-sdk = { version = "0.9.0", default-features = false }
1615
alloy-primitives = { version = "0.7.6", default-features = false }
1716
mini-alloc = { version = "0.4.2", default-features = false }
1817
motsu = "0.1.0"
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
[package]
2-
name = "stylus-hello-world"
2+
name = "pyth-receiver-stylus"
33
version = "0.1.11"
44
edition = "2021"
5-
license = "MIT OR Apache-2.0"
6-
homepage = "https://github.com/OffchainLabs/stylus-hello-world"
7-
repository = "https://github.com/OffchainLabs/stylus-hello-world"
8-
keywords = ["arbitrum", "ethereum", "stylus", "alloy"]
9-
description = "Stylus hello world example"
5+
homepage = "https://github.com/pyth-network/pyth-crosschain"
6+
repository = "https://github.com/pyth-network/pyth-crosschain"
7+
keywords = ["arbitrum", "ethereum", "stylus", "alloy", "pyth"]
8+
description = "Pyth receiver contract for the Arbitrum networks, built on Arbitrum Stylus"
109

1110
[dependencies]
1211
alloy-primitives = "=0.8.20"
1312
alloy-sol-types = "=0.8.20"
1413
stylus-sdk = "0.9.0"
14+
byteorder = { version = "1.4.3" }
1515
hex = { version = "0.4", default-features = false }
16+
pythnet-sdk = { path = "../../../../pythnet/pythnet_sdk" }
17+
serde = { version = "1.0", features = ["derive"] }
18+
wormhole-vaas = "0.1.1"
1619

1720
[dev-dependencies]
1821
alloy-primitives = { version = "=0.8.20", features = ["sha3-keccak"] }
@@ -21,6 +24,9 @@ ethers = "2.0"
2124
eyre = "0.6.8"
2225
stylus-sdk = { version = "0.9.0", features = ["stylus-test"] }
2326
dotenv = "0.15.0"
27+
motsu = "0.9.0"
28+
wormhole-contract = { path = "../wormhole" }
29+
mock_instant = "0.6.0"
2430

2531
[features]
2632
default = ["mini-alloc"]
@@ -29,18 +35,16 @@ debug = ["stylus-sdk/debug"]
2935
mini-alloc = ["stylus-sdk/mini-alloc"]
3036

3137
[[bin]]
32-
name = "stylus-hello-world"
38+
name = "pyth-receiver-stylus"
3339
path = "src/main.rs"
3440

3541
[lib]
3642
crate-type = ["lib", "cdylib"]
3743

3844
[profile.release]
3945
codegen-units = 1
40-
strip = true
46+
opt-level = "s"
4147
lto = true
48+
debug = false
4249
panic = "abort"
43-
44-
# If you need to reduce the binary size, it is advisable to try other
45-
# optimization levels, such as "s" and "z"
46-
opt-level = 3
50+
overflow-checks = true

target_chains/stylus/contracts/pyth-receiver/src/error.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
use alloc::vec::Vec;
22

3+
#[derive(PartialEq)]
34
pub enum PythReceiverError {
4-
PriceUnavailable
5+
PriceUnavailable,
6+
InvalidUpdateData,
7+
VaaVerificationFailed,
8+
InvalidVaa,
9+
InvalidWormholeMessage,
10+
InvalidMerkleProof,
11+
InvalidAccumulatorMessage,
12+
InvalidMerkleRoot,
13+
InvalidMerklePath,
14+
InvalidUnknownSource,
15+
NewPriceUnavailable,
16+
InvalidAccumulatorMessageType,
17+
InsufficientFee,
18+
InvalidEmitterAddress,
19+
TooManyUpdates,
520
}
621

722
impl core::fmt::Debug for PythReceiverError {
@@ -14,6 +29,20 @@ impl From<PythReceiverError> for Vec<u8> {
1429
fn from(error: PythReceiverError) -> Vec<u8> {
1530
vec![match error {
1631
PythReceiverError::PriceUnavailable => 1,
32+
PythReceiverError::InvalidUpdateData => 2,
33+
PythReceiverError::VaaVerificationFailed => 3,
34+
PythReceiverError::InvalidVaa => 4,
35+
PythReceiverError::InvalidWormholeMessage => 5,
36+
PythReceiverError::InvalidMerkleProof => 6,
37+
PythReceiverError::InvalidAccumulatorMessage => 7,
38+
PythReceiverError::InvalidMerkleRoot => 8,
39+
PythReceiverError::InvalidMerklePath => 9,
40+
PythReceiverError::InvalidUnknownSource => 10,
41+
PythReceiverError::NewPriceUnavailable => 11,
42+
PythReceiverError::InvalidAccumulatorMessageType => 12,
43+
PythReceiverError::InsufficientFee => 13,
44+
PythReceiverError::InvalidEmitterAddress => 14,
45+
PythReceiverError::TooManyUpdates => 15,
1746
}]
1847
}
19-
}
48+
}

0 commit comments

Comments
 (0)