Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9303a21
state getters and setters, change Move.toml dependency to sui/integra…
optke3 Mar 22, 2023
b69917e
finish state.move
optke3 Mar 22, 2023
0380a1f
add new line to pyth
optke3 Mar 22, 2023
e799fc6
use deployer cap pattern for state module
optke3 Mar 22, 2023
9ac8860
sui pyth
optke3 Mar 22, 2023
05d2121
update price feeds, dynamic object fields, Sui object PriceInfoObject
optke3 Mar 23, 2023
096f31a
register price info object with pyth state after creation
optke3 Mar 23, 2023
690107d
sui governance
optke3 Mar 30, 2023
7966b57
some newlines
optke3 Mar 30, 2023
7301c48
Merge remote-tracking branch 'origin/main' into sui/governance_
optke3 Mar 31, 2023
e0fc803
error codes
optke3 Apr 3, 2023
84ec0d3
update and comment
optke3 Apr 3, 2023
c13c23d
unit tests for pyth.move, add UpgradeCap to Pyth State (will be used …
optke3 Apr 4, 2023
4dd4c41
updates
optke3 Apr 8, 2023
b8877f6
test_get_update_fee test passes
optke3 Apr 9, 2023
5dcb613
fix test_get_update_fee and test_update_price_feeds_corrupt_vaa
optke3 Apr 10, 2023
edf6735
test_update_price_feeds_invalid_data_source
optke3 Apr 10, 2023
48ccac6
test_create_and_update_price_feeds
optke3 Apr 10, 2023
1c2dd4a
test_create_and_update_price_feeds_success and test_create_and_update…
optke3 Apr 10, 2023
b1b6624
test_update_cache
optke3 Apr 10, 2023
a9e37b4
update
optke3 Apr 10, 2023
2965e29
test_update_cache_old_update
optke3 Apr 10, 2023
af364b8
update_price_feeds_if_fresh
optke3 Apr 10, 2023
c3b8858
comment
optke3 Apr 10, 2023
a334e57
Merge branch 'main' into sui/unit_tests_pyth_and_more
optke3 Apr 30, 2023
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
29 changes: 29 additions & 0 deletions target_chains/sui/contracts/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 0

dependencies = [
{ name = "Sui" },
{ name = "Wormhole" },
]

[[move.package]]
name = "MoveStdlib"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "81dbcf2b6cab07d623a1012bf31daf658963c765", subdir = "crates/sui-framework/packages/move-stdlib" }

[[move.package]]
name = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "81dbcf2b6cab07d623a1012bf31daf658963c765", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ name = "MoveStdlib" },
]

[[move.package]]
name = "Wormhole"
source = { git = "https://github.com/wormhole-foundation/wormhole.git", rev = "sui/integration_v2", subdir = "sui/wormhole" }

dependencies = [
{ name = "Sui" },
]
2 changes: 1 addition & 1 deletion target_chains/sui/contracts/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.0.1"
[dependencies.Sui]
git = "https://github.com/MystenLabs/sui.git"
subdir = "crates/sui-framework/packages/sui-framework"
rev = "82c9c80c11488858f1d3930f47ec9f335a566683"
rev = "ddfc3fa0768a38286787319603a5458a9ff91cc1"

[dependencies.Wormhole]
git = "https://github.com/wormhole-foundation/wormhole.git"
Expand Down
12 changes: 6 additions & 6 deletions target_chains/sui/contracts/sources/governance/governance.move
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module pyth::governance {
use sui::tx_context::{TxContext};
use sui::clock::{Clock};

use pyth::data_source::{Self};
use pyth::governance_instruction;
Expand All @@ -19,14 +19,14 @@ module pyth::governance {
const E_INVALID_GOVERNANCE_ACTION: u64 = 1;
const E_INVALID_GOVERNANCE_DATA_SOURCE: u64 = 2;
const E_INVALID_GOVERNANCE_SEQUENCE_NUMBER: u64 = 3;

public entry fun execute_governance_instruction(
pyth_state : &mut State,
worm_state: &WormState,
vaa_bytes: vector<u8>,
ctx: &mut TxContext
clock: &Clock
) {
let parsed_vaa = parse_and_verify_governance_vaa(pyth_state, worm_state, vaa_bytes, ctx);
let parsed_vaa = parse_and_verify_governance_vaa(pyth_state, worm_state, vaa_bytes, clock);
let instruction = governance_instruction::from_byte_vec(vaa::take_payload(parsed_vaa));

// Dispatch the instruction to the appropiate handler
Expand All @@ -53,9 +53,9 @@ module pyth::governance {
pyth_state: &mut State,
worm_state: &WormState,
bytes: vector<u8>,
ctx: &mut TxContext
clock: &Clock,
): VAA {
let parsed_vaa = vaa::parse_and_verify(worm_state, bytes, ctx);
let parsed_vaa = vaa::parse_and_verify(worm_state, bytes, clock);

// Check that the governance data source is valid
assert!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module pyth::governance_action {
const SET_DATA_SOURCES: u8 = 2;
const SET_UPDATE_FEE: u8 = 3;
const SET_STALE_PRICE_THRESHOLD: u8 = 4;

const E_INVALID_GOVERNANCE_ACTION: u64 = 5;

struct GovernanceAction has copy, drop {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module pyth::governance_instruction {
const E_INVALID_GOVERNANCE_MODULE: u64 = 0;
const E_INVALID_GOVERNANCE_MAGIC_VALUE: u64 = 1;
const E_TARGET_CHAIN_MISMATCH: u64 = 2;

struct GovernanceInstruction {
module_: u8,
action: GovernanceAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module pyth::set_data_sources {

use wormhole::cursor;
use wormhole::external_address::{Self};
use wormhole::bytes32::{Self};

use pyth::deserialize;
use pyth::data_source::{Self, DataSource};
Expand All @@ -28,7 +29,7 @@ module pyth::set_data_sources {
let i = 0;
while (i < data_sources_count) {
let emitter_chain_id = deserialize::deserialize_u16(&mut cursor);
let emitter_address = external_address::from_bytes(deserialize::deserialize_vector(&mut cursor, 32));
let emitter_address = external_address::new(bytes32::from_bytes(deserialize::deserialize_vector(&mut cursor, 32)));
vector::push_back(&mut sources, data_source::new((emitter_chain_id as u64), emitter_address));

i = i + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module pyth::set_governance_data_source {

use wormhole::cursor;
use wormhole::external_address::{Self, ExternalAddress};
use wormhole::bytes32::{Self};
//use wormhole::state::{Self}

friend pyth::governance;
Expand All @@ -24,7 +25,7 @@ module pyth::set_governance_data_source {
fun from_byte_vec(bytes: vector<u8>): SetGovernanceDataSource {
let cursor = cursor::new(bytes);
let emitter_chain_id = deserialize::deserialize_u16(&mut cursor);
let emitter_address = external_address::from_bytes(deserialize::deserialize_vector(&mut cursor, 32));
let emitter_address = external_address::new(bytes32::from_bytes(deserialize::deserialize_vector(&mut cursor, 32)));
let initial_sequence = deserialize::deserialize_u64(&mut cursor);
cursor::destroy_empty(cursor);
SetGovernanceDataSource {
Expand Down
4 changes: 2 additions & 2 deletions target_chains/sui/contracts/sources/price_info.move
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module pyth::price_info {

friend pyth::pyth;

/// Sui Object version of PriceInfo.
/// Has a key and lives in global store.
/// Sui object version of PriceInfo.
/// Has a key ability, is unique for each price identifier, and lives in global store.
struct PriceInfoObject has key, store {
id: UID,
price_info: PriceInfo
Expand Down
Loading