diff --git a/staking/Anchor.toml b/staking/Anchor.toml index 4e59442d..27892f2d 100644 --- a/staking/Anchor.toml +++ b/staking/Anchor.toml @@ -2,7 +2,7 @@ seeds = true [programs.localnet] -staking = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" +staking = "sta99txADjRfwHQQMNckb8vUN4jcAAhN2HBMTR2Ah6d" governance = "GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw" chat = "gCHAtYKrUUktTVzE4hEnZdLV4LXrdBf6Hh9qMaJALET" diff --git a/staking/app/PythClient.ts b/staking/app/PythClient.ts index f6cd6271..a5f1468f 100644 --- a/staking/app/PythClient.ts +++ b/staking/app/PythClient.ts @@ -1,6 +1,6 @@ import { AnchorProvider, Wallet } from "@project-serum/anchor"; import { PublicKey } from "@solana/web3.js"; -import { DEVNET_STAKING_ADDRESS, LOCALNET_STAKING_ADDRESS } from "./constants"; +import { STAKING_ADDRESS } from "./constants"; import { StakeConnection } from "./StakeConnection"; export class PythClient { @@ -9,10 +9,7 @@ export class PythClient { constructor(public stakeConnection: StakeConnection, cluster: string) { this.cluster = cluster; this.program = { - programId: - cluster === "localnet" - ? LOCALNET_STAKING_ADDRESS - : DEVNET_STAKING_ADDRESS, + programId: STAKING_ADDRESS, }; } static async connect( @@ -25,9 +22,7 @@ export class PythClient { await StakeConnection.createStakeConnection( provider.connection, provider.wallet as unknown as Wallet, - cluster === "localnet" - ? LOCALNET_STAKING_ADDRESS - : DEVNET_STAKING_ADDRESS + STAKING_ADDRESS ), cluster ); diff --git a/staking/app/constants.ts b/staking/app/constants.ts index be176dc3..a38daabd 100644 --- a/staking/app/constants.ts +++ b/staking/app/constants.ts @@ -13,14 +13,7 @@ export const LOCALNET_GOVERNANCE_ADDRESS = new PublicKey( "GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw" ); -export const MAINNET_STAKING_ADDRESS = new PublicKey( - "sta99txADjRfwHQQMNckb8vUN4jcAAhN2HBMTR2Ah6d" -); -export const LOCALNET_STAKING_ADDRESS = new PublicKey( - "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS" -); - -export const DEVNET_STAKING_ADDRESS = new PublicKey( +export const STAKING_ADDRESS = new PublicKey( "sta99txADjRfwHQQMNckb8vUN4jcAAhN2HBMTR2Ah6d" ); diff --git a/staking/app/deploy/1_create_realm.ts b/staking/app/deploy/1_create_realm.ts index ff586d24..0a4226ce 100644 --- a/staking/app/deploy/1_create_realm.ts +++ b/staking/app/deploy/1_create_realm.ts @@ -10,11 +10,11 @@ import { BN } from "bn.js"; import { AUTHORITY_KEYPAIR, PYTH_TOKEN, - STAKING_PROGRAM, GOVERNANCE_PROGRAM, RPC_NODE, } from "./mainnet_beta"; +import { STAKING_ADDRESS } from "../constants"; import { Constants } from "pyth-staking-wasm"; // Actual transaction hash : // mainnet-beta : 3es1jwFLTwMBSSyVyRJ6kcJK9MmYgoJxBqBLVv6D8iKYJ1Jj2jQ9UA24ZDnJ1jqU3BVvLGMifgaGdhnhsturdtTF @@ -36,8 +36,8 @@ async function main() { Constants.MAX_VOTER_WEIGHT().toString() // Create governance requires realm authority ), { - voterWeightAddin: STAKING_PROGRAM, // Voter weight plugin - maxVoterWeightAddin: STAKING_PROGRAM, // Max voter weight plugin + voterWeightAddin: STAKING_ADDRESS, // Voter weight plugin + maxVoterWeightAddin: STAKING_ADDRESS, // Max voter weight plugin tokenType: GoverningTokenType.Liquid, // Liquid token }, undefined // No council mint diff --git a/staking/app/deploy/3_init_staking.ts b/staking/app/deploy/3_init_staking.ts index c74e68e9..84788f37 100644 --- a/staking/app/deploy/3_init_staking.ts +++ b/staking/app/deploy/3_init_staking.ts @@ -4,12 +4,12 @@ import { getTargetAccount } from "../../tests/utils/utils"; import { AUTHORITY_KEYPAIR, PYTH_TOKEN, - STAKING_PROGRAM, RPC_NODE, REALM, EPOCH_DURATION, } from "./mainnet_beta"; import { BN } from "bn.js"; +import { STAKING_ADDRESS } from "../constants"; // Actual transaction hash : // mainnet-beta : KrWZD8gbH6Afg6suwHrmUi1xDo25rLDqqMAoAdunXmtUmuVk5HZgQvDqxFHC2uidL6TfXSmwKdQnkbnbZc8BZam @@ -21,8 +21,8 @@ async function main() { new Wallet(AUTHORITY_KEYPAIR), {} ); - const idl = (await Program.fetchIdl(STAKING_PROGRAM, provider))!; - const program = new Program(idl, STAKING_PROGRAM, provider); + const idl = (await Program.fetchIdl(STAKING_ADDRESS, provider))!; + const program = new Program(idl, STAKING_ADDRESS, provider); const globalConfig = { governanceAuthority: AUTHORITY_KEYPAIR.publicKey, @@ -35,7 +35,7 @@ async function main() { await program.methods.initConfig(globalConfig).rpc(); const votingTarget = { voting: {} }; - const targetAccount = await getTargetAccount(votingTarget, STAKING_PROGRAM); + const targetAccount = await getTargetAccount(votingTarget, STAKING_ADDRESS); await program.methods .createTarget(votingTarget) .accounts({ diff --git a/staking/app/deploy/devnet.ts b/staking/app/deploy/devnet.ts index 5c72c821..19ee1510 100644 --- a/staking/app/deploy/devnet.ts +++ b/staking/app/deploy/devnet.ts @@ -1,25 +1,17 @@ import { PublicKey, Keypair } from "@solana/web3.js"; import fs from "fs"; +import { homedir } from "os"; -export const AUTHORITY_PATH = - "~/.config/solana/upg8KLALUN7ByDHiBu4wEbMDTC6UnSVFSYfTyGfXuzr.json"; +export const AUTHORITY_PATH = "/.config/solana/deployer.json"; export const AUTHORITY_KEYPAIR = Keypair.fromSecretKey( new Uint8Array( - JSON.parse( - fs - .readFileSync( - "/Users/gbescos/.config/solana/upg8KLALUN7ByDHiBu4wEbMDTC6UnSVFSYfTyGfXuzr.json" - ) - .toString() - ) + JSON.parse(fs.readFileSync(homedir() + AUTHORITY_PATH).toString()) ) ); + export const PYTH_TOKEN = new PublicKey( "7Bd6bEH4wHTMmov8D2WTXgxzLJcxJYczqE5NaDtZdhF6" ); -export const STAKING_PROGRAM = new PublicKey( - "sta99txADjRfwHQQMNckb8vUN4jcAAhN2HBMTR2Ah6d" -); export const GOVERNANCE_PROGRAM = new PublicKey( "GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw" ); diff --git a/staking/app/deploy/mainnet_beta.ts b/staking/app/deploy/mainnet_beta.ts index 3d7011da..fc28cf31 100644 --- a/staking/app/deploy/mainnet_beta.ts +++ b/staking/app/deploy/mainnet_beta.ts @@ -1,5 +1,4 @@ import { PublicKey, Keypair } from "@solana/web3.js"; -import BN from "bn.js"; import fs from "fs"; import { homedir } from "os"; @@ -13,9 +12,6 @@ export const AUTHORITY_KEYPAIR = Keypair.fromSecretKey( export const PYTH_TOKEN = new PublicKey( "3ho8ZM4JVqJzD56FADKdW7NTG5Tv6GiBPFUvyRXMy35Q" ); -export const STAKING_PROGRAM = new PublicKey( - "sta99txADjRfwHQQMNckb8vUN4jcAAhN2HBMTR2Ah6d" -); export const GOVERNANCE_PROGRAM = new PublicKey( "GovFUVGZWWwyoLq8rhnoVWknRFkhDSbQiSoREJ5LiZCV" ); diff --git a/staking/app/scripts/devnet_upgrade.ts b/staking/app/scripts/devnet_upgrade.ts index 43b07786..1fa0edec 100644 --- a/staking/app/scripts/devnet_upgrade.ts +++ b/staking/app/scripts/devnet_upgrade.ts @@ -11,7 +11,7 @@ import { LAMPORTS_PER_SOL, PublicKey, } from "@solana/web3.js"; -import { DEVNET_ENDPOINT, DEVNET_STAKING_ADDRESS } from "../constants"; +import { DEVNET_ENDPOINT, STAKING_ADDRESS } from "../constants"; import { ANCHOR_CONFIG_PATH, CustomAbortController, @@ -160,7 +160,7 @@ async function main() { ); const bpfAccounts = await getBPFUpgradeableUtilAccounts( devnet, - DEVNET_STAKING_ADDRESS + STAKING_ADDRESS ); assert(upgradeAuth.publicKey.equals(bpfAccounts.upgradeAuthority)); @@ -170,7 +170,7 @@ async function main() { if (DRY_RUN) { ({ controller, connection } = await launchClonedValidator( devnet, - DEVNET_STAKING_ADDRESS + STAKING_ADDRESS )); console.log("Localnet is running"); } else { @@ -203,19 +203,19 @@ async function upgradeProgram( throw new Error("Refusing to deploy binary with mock clock enabled"); } shell.exec( - `solana program deploy ${soPath} --program-id ${DEVNET_STAKING_ADDRESS.toBase58()} -u ${ + `solana program deploy ${soPath} --program-id ${STAKING_ADDRESS.toBase58()} -u ${ connection.rpcEndpoint } --upgrade-authority ${UPGRADE_AUTH_KEYPAIR_PATH}` ); console.log("Upgraded program"); - const idlAddressKey = await idlAddress(DEVNET_STAKING_ADDRESS); + const idlAddressKey = await idlAddress(STAKING_ADDRESS); const idlFinished = new Promise((resolve) => { connection.onAccountChange(idlAddressKey, resolve, "finalized"); }); let idlResult = shell.exec( `anchor idl upgrade --provider.cluster ${ connection.rpcEndpoint - } --provider.wallet ${UPGRADE_AUTH_KEYPAIR_PATH} --filepath ${idlPath} ${DEVNET_STAKING_ADDRESS.toBase58()}` + } --provider.wallet ${UPGRADE_AUTH_KEYPAIR_PATH} --filepath ${idlPath} ${STAKING_ADDRESS.toBase58()}` ); console.log("Waiting for IDL: %s", idlResult); await idlFinished; @@ -233,17 +233,17 @@ async function upgradeAccounts(connection: anchor.web3.Connection) { new anchor.Wallet(feePayer), {} ); - let idl = await Program.fetchIdl(DEVNET_STAKING_ADDRESS, provider)!; + let idl = await Program.fetchIdl(STAKING_ADDRESS, provider)!; const program = new Program( idl, - DEVNET_STAKING_ADDRESS, + STAKING_ADDRESS, provider ) as unknown as Program; console.log("Downloading accounts"); // Position Data can't be loaded via Anchor const allPositionAccounts: ToPairAccountInterface[] = ( - await connection.getProgramAccounts(DEVNET_STAKING_ADDRESS, { + await connection.getProgramAccounts(STAKING_ADDRESS, { filters: [{ memcmp: program.coder.accounts.memcmp("positionData") }], }) ).map((e) => { @@ -254,16 +254,12 @@ async function upgradeAccounts(connection: anchor.web3.Connection) { }); const allV1 = await program.account.stakeAccountMetadata.all(); console.log("Accounts downloaded"); - const pairs = await pairAccounts( - allPositionAccounts, - allV1, - DEVNET_STAKING_ADDRESS - ); + const pairs = await pairAccounts(allPositionAccounts, allV1, STAKING_ADDRESS); await connection.confirmTransaction(airDropSignature); const stakeConnection = await StakeConnection.createStakeConnection( connection, new anchor.Wallet(feePayer), - DEVNET_STAKING_ADDRESS + STAKING_ADDRESS ); console.log("%d accounts found in need of upgrade", allV1.length); diff --git a/staking/programs/staking/src/lib.rs b/staking/programs/staking/src/lib.rs index d2426d1a..40c20863 100644 --- a/staking/programs/staking/src/lib.rs +++ b/staking/programs/staking/src/lib.rs @@ -41,9 +41,6 @@ mod utils; #[cfg(feature = "wasm")] pub mod wasm; -#[cfg(not(mainnet))] -declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); -#[cfg(mainnet)] declare_id!("sta99txADjRfwHQQMNckb8vUN4jcAAhN2HBMTR2Ah6d"); #[cfg(not(mainnet))]