Deprecate upgrade (#101)

* deprecate upgrade function

* bump versions

* move flag
This commit is contained in:
Hardhat Chad
2024-11-01 16:08:02 -05:00
committed by GitHub
parent cb24b65133
commit 0e1460e2a4
7 changed files with 11 additions and 69 deletions

4
Cargo.lock generated
View File

@@ -1287,7 +1287,7 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
[[package]]
name = "ore-api"
version = "2.5.0"
version = "2.6.0"
dependencies = [
"array-const-fn-init",
"bytemuck",
@@ -1323,7 +1323,7 @@ dependencies = [
[[package]]
name = "ore-program"
version = "2.5.0"
version = "2.6.0"
dependencies = [
"drillx",
"mpl-token-metadata",

View File

@@ -3,7 +3,7 @@ resolver = "2"
members = ["api", "program"]
[workspace.package]
version = "2.5.0"
version = "2.6.0"
edition = "2021"
license = "Apache-2.0"
homepage = "https://ore.supply"

View File

@@ -16,7 +16,6 @@
- [`Mine`](program/src/mine.rs) Verifies a hash and increments a miner's claimable balance.
- [`Reset`](program/src/reset.rs) Resets the program for a new epoch.
- [`Update`](program/src/update.rs) Updates a proof account's miner authority.
- [`Upgrade`](program/src/upgrade.rs) Migrates ORE v1 tokens to ORE v2, one-for-one.
- [`Initialize`](program/src/initialize.rs)  Initializes the program and creates the global accounts.
## State

View File

@@ -12,6 +12,7 @@ pub enum OreInstruction {
#[deprecated(since = "2.4.0", note = "Please stake with the boost program")]
Stake = 5,
Update = 6,
#[deprecated(since = "2.6.0", note = "v1 tokens are no longer eligable to upgrade")]
Upgrade = 7,
// Admin
@@ -57,6 +58,7 @@ pub struct Stake {
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Update {}
#[deprecated(since = "2.6.0", note = "v1 tokens are no longer eligable to upgrade")]
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Upgrade {

View File

@@ -125,10 +125,10 @@ pub fn reset(signer: Pubkey) -> Instruction {
}
/// Build a stake instruction.
#[allow(deprecated)]
#[deprecated(since = "2.4.0", note = "Please stake with the boost program")]
pub fn stake(signer: Pubkey, sender: Pubkey, amount: u64) -> Instruction {
let proof = proof_pda(signer).0;
#[allow(deprecated)]
Instruction {
program_id: crate::ID,
accounts: vec![
@@ -160,6 +160,8 @@ pub fn update(signer: Pubkey, miner: Pubkey) -> Instruction {
}
// Build an upgrade instruction.
#[allow(deprecated)]
#[deprecated(since = "2.6.0", note = "v1 tokens are no longer eligable to upgrade")]
pub fn upgrade(signer: Pubkey, beneficiary: Pubkey, sender: Pubkey, amount: u64) -> Instruction {
Instruction {
program_id: crate::ID,

View File

@@ -21,6 +21,7 @@ use upgrade::*;
use ore_api::instruction::*;
use steel::*;
#[allow(deprecated)]
pub fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
@@ -34,7 +35,6 @@ pub fn process_instruction(
OreInstruction::Mine => process_mine(accounts, data)?,
OreInstruction::Open => process_open(accounts, data)?,
OreInstruction::Reset => process_reset(accounts, data)?,
#[allow(deprecated)]
OreInstruction::Stake => process_stake(accounts, data)?,
OreInstruction::Update => process_update(accounts, data)?,
OreInstruction::Upgrade => process_upgrade(accounts, data)?,

View File

@@ -1,67 +1,6 @@
use ore_api::prelude::*;
use steel::*;
/// Upgrade allows a user to migrate a v1 token to a v2 token at a 1:1 exchange rate.
pub fn process_upgrade(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
// Parse args
let args = Upgrade::try_from_bytes(data)?;
let amount = u64::from_le_bytes(args.amount);
// Load accounts
let [signer_info, beneficiary_info, mint_info, mint_v1_info, sender_info, treasury_info, token_program] =
accounts
else {
return Err(ProgramError::NotEnoughAccountKeys);
};
signer_info.is_signer()?;
beneficiary_info
.is_writable()?
.as_token_account()?
.assert(|t| t.owner == *signer_info.key)?
.assert(|t| t.mint == MINT_ADDRESS)?;
let mint = mint_info
.is_writable()?
.has_address(&MINT_ADDRESS)?
.as_mint()?;
mint_v1_info
.is_writable()?
.has_address(&MINT_V1_ADDRESS)?
.as_mint()?;
sender_info
.is_writable()?
.as_token_account()?
.assert(|t| t.owner == *signer_info.key)?
.assert(|t| t.mint == MINT_V1_ADDRESS)?;
treasury_info.is_treasury()?;
token_program.is_program(&spl_token::ID)?;
// Burn v1 tokens
burn(
sender_info,
mint_v1_info,
signer_info,
token_program,
amount,
)?;
// Account for decimals change.
// v1 token has 9 decimals. v2 token has 11.
let amount_to_mint = amount.saturating_mul(100);
// Cap at max supply.
if mint.supply.saturating_add(amount_to_mint).gt(&MAX_SUPPLY) {
return Err(OreError::MaxSupply.into());
}
// Mint to the beneficiary account
mint_to_signed(
mint_info,
beneficiary_info,
treasury_info,
token_program,
amount_to_mint,
&[TREASURY],
)?;
Ok(())
pub fn process_upgrade(_accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
panic!("This instruction has been deprecated. v1 tokens are no longer eligable to upgrade.");
}