Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Anchor and Solana JS packages #283

Merged
merged 5 commits into from
Nov 23, 2023
Merged
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 frontend/hooks/useStakeAccounts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Wallet } from '@project-serum/anchor'
import { Wallet } from '@coral-xyz/anchor'
import { useAnchorWallet } from '@solana/wallet-adapter-react'
import toast from 'react-hot-toast'
import { capitalizeFirstLetter } from 'utils/capitalizeFirstLetter'
2 changes: 1 addition & 1 deletion frontend/hooks/useStakeConnection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Wallet } from '@project-serum/anchor'
import { Wallet } from '@coral-xyz/anchor'
import { STAKING_ADDRESS, StakeConnection } from '@pythnetwork/staking'
import { useAnchorWallet, useConnection } from '@solana/wallet-adapter-react'
import toast from 'react-hot-toast'
6 changes: 3 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -10,14 +10,14 @@
"dependencies": {
"@headlessui/react": "^1.6.0",
"@heroicons/react": "^1.0.6",
"@project-serum/anchor": "^0.22.1",
"@coral-xyz/anchor": "^0.29.0",
"@pythnetwork/staking": "*",
"@solana/spl-token": "^0.1.8",
"@solana/wallet-adapter-base": "^0.9.22",
"@solana/wallet-adapter-react": "^0.15.32",
"@solana/wallet-adapter-react-ui": "^0.9.31",
"@solana/wallet-adapter-wallets": "^0.19.16",
"@solana/web3.js": "^1.36.0",
"@solana/wallet-adapter-wallets": "=0.19.16",
"@solana/web3.js": "^1.87.5",
"@tippyjs/react": "^4.2.6",
"dotenv": "^16.0.0",
"next": "12.2.5",
2 changes: 1 addition & 1 deletion frontend/pages/approve.tsx
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import {
STAKING_ADDRESS,
} from '@pythnetwork/staking'
import { useEffect, useState } from 'react'
import { utils, Wallet } from '@project-serum/anchor'
import { utils, Wallet } from '@coral-xyz/anchor'
import toast from 'react-hot-toast'
import { capitalizeFirstLetter } from '../utils/capitalizeFirstLetter'
import { PublicKey } from '@solana/web3.js'
12,947 changes: 7,462 additions & 5,485 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions staking/app/PositionAccountJs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Idl, IdlTypes } from "@project-serum/anchor";
import { Idl, IdlTypes } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";
import { Staking } from "../target/types/staking";
import * as idljs from "@project-serum/anchor/dist/cjs/coder/borsh/idl";
import { IdlTypeDef } from "@project-serum/anchor/dist/cjs/idl";
import * as idljs from "@coral-xyz/anchor/dist/cjs/coder/borsh/idl";
import { IdlTypeDef } from "@coral-xyz/anchor/dist/cjs/idl";
import { wasm } from "./StakeConnection";

export type Position = IdlTypes<Staking>["Position"];
4 changes: 2 additions & 2 deletions staking/app/StakeConnection.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import {
IdlAccounts,
IdlTypes,
AnchorProvider,
} from "@project-serum/anchor";
} from "@coral-xyz/anchor";
import {
PublicKey,
Connection,
@@ -24,7 +24,7 @@ import {
u64,
} from "@solana/spl-token";
import BN from "bn.js";
import * as idljs from "@project-serum/anchor/dist/cjs/coder/borsh/idl";
import * as idljs from "@coral-xyz/anchor/dist/cjs/coder/borsh/idl";
import { Staking } from "../target/types/staking";
import IDL from "../target/idl/staking.json";
import { batchInstructions } from "./transaction";
2 changes: 1 addition & 1 deletion staking/app/deploy/2_init_staking.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Wallet, AnchorProvider, Program } from "@project-serum/anchor";
import { Wallet, AnchorProvider, Program } from "@coral-xyz/anchor";
import { Connection } from "@solana/web3.js";
import { getTargetAccount } from "../../tests/utils/utils";
import { AUTHORITY_KEYPAIR, PYTH_TOKEN, RPC_NODE } from "./mainnet_beta";
2 changes: 1 addition & 1 deletion staking/app/deploy/4_transfer_authorities_to_multisig.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import {
} from "./mainnet_beta";

import { GOVERNANCE_ADDRESS, REALM_ID, STAKING_ADDRESS } from "../constants";
import { AnchorProvider, Idl, Program, Wallet } from "@project-serum/anchor";
import { AnchorProvider, Idl, Program, Wallet } from "@coral-xyz/anchor";
import IDL from "../../target/idl/staking.json";

// Actual transaction hash :
2 changes: 1 addition & 1 deletion staking/app/deploy/create_vesting_account.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Wallet } from "@project-serum/anchor";
import { Wallet } from "@coral-xyz/anchor";
import { Connection, PublicKey } from "@solana/web3.js";
import { AUTHORITY_KEYPAIR, RPC_NODE } from "./devnet";
import { STAKING_ADDRESS } from "../constants";
2 changes: 1 addition & 1 deletion staking/app/deploy/ledger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Wallet } from "@project-serum/anchor/dist/cjs/provider";
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
import Transport, {
StatusCodes,
TransportStatusError,
6 changes: 3 additions & 3 deletions staking/app/scripts/devnet_upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as anchor from "@project-serum/anchor";
import { AnchorProvider, Program, utils } from "@project-serum/anchor";
import * as anchor from "@coral-xyz/anchor";
import { AnchorProvider, Program, utils } from "@coral-xyz/anchor";
import {
Connection,
Keypair,
@@ -16,7 +16,7 @@ import {
import { Staking } from "../../target/types/staking";
import { assert } from "node:console";
import * as wasm from "../../wasm";
import { idlAddress } from "@project-serum/anchor/dist/cjs/idl";
import { idlAddress } from "@coral-xyz/anchor/dist/cjs/idl";
import shell from "shelljs";
import { StakeConnection } from "../StakeConnection";
import { loadKeypair } from "../../tests/utils/keys";
2 changes: 1 addition & 1 deletion staking/app/scripts/localnet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as anchor from "@project-serum/anchor";
import * as anchor from "@coral-xyz/anchor";
import BN from "bn.js";
import { Keypair, PublicKey } from "@solana/web3.js";
import {
2 changes: 1 addition & 1 deletion staking/app/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Provider } from "@project-serum/anchor";
import { Provider } from "@coral-xyz/anchor";
import { TransactionInstruction, Transaction } from "@solana/web3.js";

const MAX_INSTRUCTIONS_PER_TRANSACTION = 10;
4 changes: 2 additions & 2 deletions staking/package.json
Original file line number Diff line number Diff line change
@@ -12,11 +12,11 @@
],
"repository": "https://github.com/pyth-network/governance/tree/main/staking",
"dependencies": {
"@project-serum/anchor": "0.24.2",
"@coral-xyz/anchor": "^0.29.0",
"@pythnetwork/staking-wasm": "*",
"@solana/spl-governance": "0.3.26",
"@solana/spl-token": "^0.1.8",
"@solana/web3.js": "^1.36.0",
"@solana/web3.js": "^1.87.5",
"encoding": "^0.1.13",
"ts-node": "^10.7.0",
"typescript": "^4.3.5"
4 changes: 2 additions & 2 deletions staking/programs/staking/src/context.rs
Original file line number Diff line number Diff line change
@@ -27,8 +27,8 @@ pub const SPLIT_REQUEST: &str = "split_request";
impl positions::Target {
pub fn get_seed(&self) -> Vec<u8> {
match *self {
positions::Target::VOTING => VOTING_TARGET_SEED.as_bytes().to_vec(),
positions::Target::STAKING { ref product } => DATA_TARGET_SEED
positions::Target::Voting => VOTING_TARGET_SEED.as_bytes().to_vec(),
positions::Target::Staking { ref product } => DATA_TARGET_SEED
.as_bytes()
.iter()
.chain(product.as_ref().iter())
2 changes: 1 addition & 1 deletion staking/programs/staking/src/lib.rs
Original file line number Diff line number Diff line change
@@ -519,7 +519,7 @@ pub mod staking {
let target_account = &mut ctx.accounts.target_account;
let config = &ctx.accounts.config;

if !(matches!(target, Target::VOTING)) {
if !(matches!(target, Target::Voting)) {
return Err(error!(ErrorCode::NotImplemented));
}

26 changes: 13 additions & 13 deletions staking/programs/staking/src/state/positions.rs
Original file line number Diff line number Diff line change
@@ -135,15 +135,15 @@ pub struct Position {
Eq,
)]
pub enum Target {
VOTING,
STAKING { product: Pubkey },
Voting,
Staking { product: Pubkey },
}

#[derive(AnchorSerialize, AnchorDeserialize, Debug, Clone, Copy, BorshSchema, PartialEq, Eq)]
#[cfg_attr(test, derive(Hash))]
pub enum TargetWithParameters {
VOTING,
STAKING {
Voting,
Staking {
product: Pubkey,
publisher: Publisher,
},
@@ -159,11 +159,11 @@ pub enum Publisher {
impl TargetWithParameters {
pub fn get_target(&self) -> Target {
match *self {
TargetWithParameters::VOTING => Target::VOTING,
TargetWithParameters::STAKING {
TargetWithParameters::Voting => Target::Voting,
TargetWithParameters::Staking {
product,
publisher: _,
} => Target::STAKING { product },
} => Target::Staking { product },
}
}
}
@@ -203,7 +203,7 @@ impl Position {
}

pub fn is_voting(&self) -> bool {
matches!(self.target_with_parameters, TargetWithParameters::VOTING)
matches!(self.target_with_parameters, TargetWithParameters::Voting)
}
}

@@ -255,7 +255,7 @@ pub mod tests {
let p = Position {
activation_epoch: 8,
unlocking_start: Some(12),
target_with_parameters: TargetWithParameters::VOTING,
target_with_parameters: TargetWithParameters::Voting,
amount: 10,
};
assert_eq!(
@@ -289,7 +289,7 @@ pub mod tests {
let p = Position {
activation_epoch: 8,
unlocking_start: None,
target_with_parameters: TargetWithParameters::VOTING,
target_with_parameters: TargetWithParameters::Voting,
amount: 10,
};
assert_eq!(
@@ -345,22 +345,22 @@ pub mod tests {
return Position {
activation_epoch: u64::arbitrary(g),
unlocking_start: Option::<u64>::arbitrary(g),
target_with_parameters: TargetWithParameters::VOTING,
target_with_parameters: TargetWithParameters::Voting,
amount: u64::arbitrary(g),
};
}
}
impl Arbitrary for TargetWithParameters {
fn arbitrary(g: &mut Gen) -> Self {
if bool::arbitrary(g) {
TargetWithParameters::STAKING {
TargetWithParameters::Staking {
product: Pubkey::new_unique(),
publisher: Publisher::SOME {
address: Pubkey::new_unique(),
},
}
} else {
TargetWithParameters::VOTING
TargetWithParameters::Voting
}
}
}
26 changes: 13 additions & 13 deletions staking/programs/staking/src/utils/risk.rs
Original file line number Diff line number Diff line change
@@ -79,12 +79,12 @@ pub fn validate(
let mut total_exposure: u64 = 0;
for (target, exposure) in &current_exposures {
match target {
Target::VOTING => {
Target::Voting => {
// This is the special voting position that ignores vesting
// If there are multiple voting positions, they've been aggregated at this point
governance_exposure = *exposure;
}
Target::STAKING { .. } => {
Target::Staking { .. } => {
// A normal position
max_target_exposure = cmp::max(max_target_exposure, *exposure);
total_exposure = total_exposure
@@ -149,7 +149,7 @@ pub mod tests {
&Position {
activation_epoch: 1,
amount: 7,
target_with_parameters: TargetWithParameters::STAKING {
target_with_parameters: TargetWithParameters::Staking {
product: Pubkey::new_unique(),
publisher: Publisher::SOME {
address: Pubkey::new_unique(),
@@ -164,7 +164,7 @@ pub mod tests {
&Position {
activation_epoch: 1,
amount: 3,
target_with_parameters: TargetWithParameters::STAKING {
target_with_parameters: TargetWithParameters::Staking {
product: Pubkey::new_unique(),
publisher: Publisher::SOME {
address: Pubkey::new_unique(),
@@ -205,7 +205,7 @@ pub mod tests {
&Position {
activation_epoch: 1,
amount: 7,
target_with_parameters: TargetWithParameters::VOTING,
target_with_parameters: TargetWithParameters::Voting,
unlocking_start: None,
},
)
@@ -215,7 +215,7 @@ pub mod tests {
&Position {
activation_epoch: 1,
amount: 3,
target_with_parameters: TargetWithParameters::STAKING {
target_with_parameters: TargetWithParameters::Staking {
product: Pubkey::new_unique(),
publisher: Publisher::SOME {
address: Pubkey::new_unique(),
@@ -243,7 +243,7 @@ pub mod tests {
&Position {
activation_epoch: 1,
amount: 7,
target_with_parameters: TargetWithParameters::STAKING {
target_with_parameters: TargetWithParameters::Staking {
product,
publisher: Publisher::DEFAULT,
},
@@ -256,7 +256,7 @@ pub mod tests {
&Position {
activation_epoch: 1,
amount: 3,
target_with_parameters: TargetWithParameters::STAKING {
target_with_parameters: TargetWithParameters::Staking {
product,
publisher: Publisher::DEFAULT,
},
@@ -280,7 +280,7 @@ pub mod tests {
&Position {
activation_epoch: 1,
amount: 10,
target_with_parameters: TargetWithParameters::STAKING {
target_with_parameters: TargetWithParameters::Staking {
product: Pubkey::new_unique(),
publisher: Publisher::SOME {
address: Pubkey::new_unique(),
@@ -299,7 +299,7 @@ pub mod tests {
&Position {
activation_epoch: 1,
amount: 10,
target_with_parameters: TargetWithParameters::STAKING {
target_with_parameters: TargetWithParameters::Staking {
product: Pubkey::new_unique(),
publisher: Publisher::SOME {
address: Pubkey::new_unique(),
@@ -323,7 +323,7 @@ pub mod tests {
&Position {
activation_epoch: 1,
amount: 10,
target_with_parameters: TargetWithParameters::VOTING,
target_with_parameters: TargetWithParameters::Voting,
unlocking_start: None,
},
)
@@ -346,7 +346,7 @@ pub mod tests {
&Position {
activation_epoch: 1,
amount: u64::MAX / 3,
target_with_parameters: TargetWithParameters::VOTING,
target_with_parameters: TargetWithParameters::Voting,
unlocking_start: None,
},
)
@@ -367,7 +367,7 @@ pub mod tests {
&Position {
activation_epoch: 1,
amount: u64::MAX / 3,
target_with_parameters: TargetWithParameters::STAKING {
target_with_parameters: TargetWithParameters::Staking {
product,
publisher: Publisher::SOME {
address: Pubkey::new_unique(),
Loading