Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion solana/pyth2wormhole/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub fn gen_migrate_tx(

let accs = MigrateAccounts {
new_config: Derived(p2w_addr),
old_config: DerivedRO(p2w_addr),
old_config: Derived(p2w_addr),
current_owner: Signer(owner),
payer: Signer(payer),
};
Expand Down
7 changes: 6 additions & 1 deletion solana/pyth2wormhole/program/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ pub struct Pyth2WormholeConfigV2 {
pub is_active: bool,
}

/// Note: If you get stuck with a pre-existing config account
/// (e.g. someone transfers into a PDA that we're not using yet), it's
/// usually easier to change the seed slightly
/// (e.g. pyth2wormhole-config-v2 -> pyth2wormhole-config-v2.1). This
/// saves a lot of time coding around this edge case.
pub type P2WConfigAccountV2<'b, const IsInitialized: AccountState> =
Derive<Data<'b, Pyth2WormholeConfigV2, { IsInitialized }>, "pyth2wormhole-config-v2">;
Derive<Data<'b, Pyth2WormholeConfigV2, { IsInitialized }>, "pyth2wormhole-config-v2.1">;

impl From<Pyth2WormholeConfigV1> for Pyth2WormholeConfigV2 {
fn from(old: Pyth2WormholeConfigV1) -> Self {
Expand Down
6 changes: 4 additions & 2 deletions solana/pyth2wormhole/program/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct Migrate<'b> {
/// New config account to be populated. Must be unused.
pub new_config: Mut<P2WConfigAccount<'b, { AccountState::Uninitialized }>>,
/// Old config using the previous format.
pub old_config: OldP2WConfigAccount<'b>,
pub old_config: Mut<OldP2WConfigAccount<'b>>,
/// Current owner authority of the program
pub current_owner: Mut<Signer<Info<'b>>>,
/// Payer account for updating the account data
Expand Down Expand Up @@ -78,7 +78,7 @@ pub fn migrate(ctx: &ExecutionContext, accs: &mut Migrate, data: ()) -> SoliResu
**accs.old_config.info().lamports.borrow_mut() = 0;

// Credit payer with saved balance
accs.payer
let new_payer_balance = accs.payer
.info()
.lamports
.borrow_mut()
Expand All @@ -88,5 +88,7 @@ pub fn migrate(ctx: &ExecutionContext, accs: &mut Migrate, data: ()) -> SoliResu
SolitaireError::ProgramError(ProgramError::Custom(0xDEADBEEF))
})?;

**accs.payer.info().lamports.borrow_mut() = new_payer_balance;

Ok(())
}