Skip to content

Commit e64eb21

Browse files
committed
resolve warnings
1 parent 88ef465 commit e64eb21

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

lazer/contracts/sui/sources/admin.move

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
module pyth_lazer::admin;
22

3-
use sui::tx_context::TxContext;
4-
use sui::object;
5-
63
public struct AdminCapability has key, store {
74
id: UID,
85
}

lazer/contracts/sui/sources/pyth_lazer.move

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,26 @@ use pyth_lazer::state;
99
use pyth_lazer::admin;
1010
use sui::bcs;
1111
use sui::ecdsa_k1::secp256k1_ecrecover;
12-
use sui::transfer;
13-
use sui::tx_context::{Self, TxContext};
14-
15-
fun init(ctx: &mut TxContext) {
16-
let s = state::new(ctx);
17-
transfer::public_share_object(s);
18-
let cap = admin::mint(ctx);
19-
transfer::public_transfer(cap, tx_context::sender(ctx));
20-
}
2112

2213
const SECP256K1_SIG_LEN: u32 = 65;
2314
const UPDATE_MESSAGE_MAGIC: u32 = 1296547300;
2415
const PAYLOAD_MAGIC: u32 = 2479346549;
2516

2617

2718
// TODO:
28-
// initializer
29-
// administration -> admin cap, upgrade cap, governance?
30-
// storage module -> trusted signers, update fee?, treasury?
3119
// error handling
3220
// standalone verify signature function
3321

22+
/// Initializes the module. Called at publish time.
23+
/// Creates and shares the singular State object.
24+
/// Creates the singular AdminCapability and transfers it to the deployer.
25+
fun init(ctx: &mut TxContext) {
26+
let s = state::new(ctx);
27+
transfer::public_share_object(s);
28+
let cap = admin::mint(ctx);
29+
transfer::public_transfer(cap, tx_context::sender(ctx));
30+
}
31+
3432
/// Parse the Lazer update message and validate the signature.
3533
///
3634
/// The parsing logic is based on the Lazer rust protocol definition defined here:

lazer/contracts/sui/sources/state.move

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public fun get_trusted_signers(s: &State): &vector<TrustedSignerInfo> {
4747
&s.trusted_signers
4848
}
4949

50-
/// Upsert a trusted signer's information or remove them.
50+
/// Upsert a trusted signer's information or remove them. Can only be called by the AdminCapability holder.
5151
/// - If the trusted signer pubkey already exists, the expires_at will be updated.
5252
/// - If the expired_at is set to zero, the trusted signer will be removed.
5353
/// - If the pubkey isn't found, it is added as a new trusted signer with the given expires_at.
54-
public(package) fun update_trusted_signer(_admin: &AdminCapability, s: &mut State, pubkey: vector<u8>, expires_at: u64) {
54+
public(package) fun update_trusted_signer(_: &AdminCapability, s: &mut State, pubkey: vector<u8>, expires_at: u64) {
5555
assert!(vector::length(&pubkey) as u64 == ED25519_PUBKEY_LEN, EInvalidPubkeyLen);
5656

5757
let mut maybe_idx = find_signer_index(&s.trusted_signers, &pubkey);

0 commit comments

Comments
 (0)