Skip to content

Commit

Permalink
change program id + bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Giannis Chatziveroglou committed Dec 7, 2022
1 parent 80425db commit 1ca9f6d
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
run: cargo build-bpf

- name: Run local validator
run: solana-test-validator --url https://api.mainnet-beta.solana.com --clone metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s --clone PwDiXFxQsGra4sFFTT8r1QWRMd4vfumiWC1jfWNfdYT --clone 3dxFgrZt9DLn1J5ZB1bDwjeDvbESzNxA11KggRcywKbm --clone AmJdpbtEzFBVWhznaEQM3V4fNZBa8FWj36Lu2BtnaDYt --clone CUeHFsFqfbLfBGSbuNbaAi4wK6V835PoRg1CqCLo8tpM --bpf-program rwcn6Ry17ChPXpJCN2hoK5kwpgFarQqzycXwVJ3om7U ./target/deploy/cardinal_rewards_center.so --reset --quiet & echo $$! > validator.PID
run: solana-test-validator --url https://api.devnet.solana.com --clone metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s --clone PwDiXFxQsGra4sFFTT8r1QWRMd4vfumiWC1jfWNfdYT --clone HqiCY5NqfHfyhyjheQ4ENo5J2XSQBpeqhNoeESkDWBpU --clone 382KXQfzC26jbFmLZBmKoZ6eRz53iwGfxXwoGyyyH8po --clone SdFEeJxn7XxcnYEMNpnoMMSsTfmA1bHfiRdu6qra7zL --bpf-program crcBwD7wUjzwsy8tJsVCzZvBTHeq5GoboGg84YraRyd ./target/deploy/cardinal_rewards_center.so --reset --quiet & echo $$! > validator.PID
- run: sleep 6
- run: solana airdrop 1000 $(solana-keygen pubkey ./tests/test-keypairs/test-key.json) --url http://localhost:8899
- run: yarn test
Expand Down
8 changes: 4 additions & 4 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ cluster = "localnet"
wallet = "./tests/test-key.json"

[programs.mainnet]
cardinal_rewards_center = "rwcn6Ry17ChPXpJCN2hoK5kwpgFarQqzycXwVJ3om7U"
cardinal_rewards_center = "crcBwD7wUjzwsy8tJsVCzZvBTHeq5GoboGg84YraRyd"

[programs.devnet]
cardinal_rewards_center = "rwcn6Ry17ChPXpJCN2hoK5kwpgFarQqzycXwVJ3om7U"
cardinal_rewards_center = "crcBwD7wUjzwsy8tJsVCzZvBTHeq5GoboGg84YraRyd"

[programs.testnet]
cardinal_rewards_center = "rwcn6Ry17ChPXpJCN2hoK5kwpgFarQqzycXwVJ3om7U"
cardinal_rewards_center = "crcBwD7wUjzwsy8tJsVCzZvBTHeq5GoboGg84YraRyd"

[programs.localnet]
cardinal_rewards_center = "rwcn6Ry17ChPXpJCN2hoK5kwpgFarQqzycXwVJ3om7U"
cardinal_rewards_center = "crcBwD7wUjzwsy8tJsVCzZvBTHeq5GoboGg84YraRyd"
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ build:
yarn idl:generate && yarn lint && yarn build

start:
solana-test-validator --url https://api.mainnet-beta.solana.com \
solana-test-validator --url https://api.devnet.solana.com \
--clone metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s --clone PwDiXFxQsGra4sFFTT8r1QWRMd4vfumiWC1jfWNfdYT \
--clone 3dxFgrZt9DLn1J5ZB1bDwjeDvbESzNxA11KggRcywKbm \
--clone AmJdpbtEzFBVWhznaEQM3V4fNZBa8FWj36Lu2BtnaDYt \
--clone CUeHFsFqfbLfBGSbuNbaAi4wK6V835PoRg1CqCLo8tpM \
--bpf-program rwcn6Ry17ChPXpJCN2hoK5kwpgFarQqzycXwVJ3om7U ./target/deploy/cardinal_rewards_center.so \
--clone HqiCY5NqfHfyhyjheQ4ENo5J2XSQBpeqhNoeESkDWBpU \
--clone 382KXQfzC26jbFmLZBmKoZ6eRz53iwGfxXwoGyyyH8po \
--clone SdFEeJxn7XxcnYEMNpnoMMSsTfmA1bHfiRdu6qra7zL \
--bpf-program crcBwD7wUjzwsy8tJsVCzZvBTHeq5GoboGg84YraRyd ./target/deploy/cardinal_rewards_center.so \
--reset --quiet & echo $$!
sleep 10
solana-keygen pubkey ./tests/test-keypairs/test-key.json
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Cardinal rewards center is a modular smart contract for staking tokens and distr

Program addresses are the same on devnet, testnet, and mainnet-beta.

- RewardsCenter: [`rwcn6Ry17ChPXpJCN2hoK5kwpgFarQqzycXwVJ3om7U`](https://explorer.solana.com/address/rwcn6Ry17ChPXpJCN2hoK5kwpgFarQqzycXwVJ3om7U)
- RewardsCenter: [`crcBwD7wUjzwsy8tJsVCzZvBTHeq5GoboGg84YraRyd`](https://explorer.solana.com/address/crcBwD7wUjzwsy8tJsVCzZvBTHeq5GoboGg84YraRyd)

## State map

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cardinal/rewards-center",
"version": "2.0.0",
"version": "2.1.0",
"description": "Cardinal rewards center",
"keywords": [
"solana",
Expand Down
6 changes: 3 additions & 3 deletions programs/cardinal-rewards-center/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cardinal-rewards-center"
version = "2.0.0"
version = "2.1.0"
description = "Cardinal rewards center"
edition = "2021"
homepage = "https://cardinal.so"
Expand All @@ -23,8 +23,8 @@ default = []
anchor-lang = { version = "0.25.0", features = ["init-if-needed"] }
anchor-spl = "0.25.0"
solana-program = "1.10.41"
spl-token = { version = "3.1.1", features = ["no-entrypoint"] }
mpl-token-metadata = { version = "1.3.3", features = ["no-entrypoint"] }
spl-token = { version = "3.2.0", features = ["no-entrypoint"] }
mpl-token-metadata = { version = "=1.3.3", features = ["no-entrypoint"] }

[dev-dependencies]
proptest = { version = "1.0" }
4 changes: 2 additions & 2 deletions programs/cardinal-rewards-center/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ pub enum ErrorCode {
InvalidBoostPayerTokenAccount,
#[msg("Invalid boost payment recipient token account")]
InvalidBoostPaymentRecipientTokenAccount,
#[msg("Invalid payment manager")]
InvalidPaymentManager,
#[msg("Invalid payment info")]
InvalidPaymentInfo,
#[msg("Cannot boost a fungible token stake entry")]
CannotBoostFungibleToken,

Expand Down
6 changes: 4 additions & 2 deletions programs/cardinal-rewards-center/src/payment/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ pub enum Action {
pub fn assert_payment_info(stake_pool: Pubkey, action: Action, payment_info: Pubkey) -> Result<()> {
let default_allowed_payment_infos = match action {
_ => [
"7cKQgnFTzLtdNWgMuQVQG4LjWShsGsgXx284VBr5eRsM".to_string(), // cardinal-default 0.005
"382KXQfzC26jbFmLZBmKoZ6eRz53iwGfxXwoGyyyH8po".to_string(), // cardinal-test-wsol
"HqiCY5NqfHfyhyjheQ4ENo5J2XSQBpeqhNoeESkDWBpU".to_string(), // cardinal-test (native)
"SdFEeJxn7XxcnYEMNpnoMMSsTfmA1bHfiRdu6qra7zL".to_string(), // cardinal-default 0.005
]
.to_vec(),
};
let allowed_payment_infos = match (stake_pool.key().to_string().as_str(), action) {
_ => default_allowed_payment_infos,
};
if !allowed_payment_infos.contains(&payment_info.to_string()) {
return Err(error!(ErrorCode::InvalidPaymentManager));
return Err(error!(ErrorCode::InvalidPaymentInfo));
}
Ok(())
}
Expand Down
18 changes: 7 additions & 11 deletions sdk/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ import { IDL } from "./idl/cardinal_rewards_center";
export const REWARDS_CENTER_IDL = IDL;

export const REWARDS_CENTER_ADDRESS = new PublicKey(
"rwcn6Ry17ChPXpJCN2hoK5kwpgFarQqzycXwVJ3om7U"
"crcBwD7wUjzwsy8tJsVCzZvBTHeq5GoboGg84YraRyd"
);

export const SOL_PAYMENT_INFO = new PublicKey(
"3dxFgrZt9DLn1J5ZB1bDwjeDvbESzNxA11KggRcywKbm"
export const WRAPPED_SOL_PAYMENT_INFO = new PublicKey(
"382KXQfzC26jbFmLZBmKoZ6eRz53iwGfxXwoGyyyH8po"
);

export const WRAPPED_SOL_PAYMENT_INFO = new PublicKey(
"AmJdpbtEzFBVWhznaEQM3V4fNZBa8FWj36Lu2BtnaDYt"
export const SOL_PAYMENT_INFO = new PublicKey(
"HqiCY5NqfHfyhyjheQ4ENo5J2XSQBpeqhNoeESkDWBpU"
);

export const DUST_PAYMENT_INFO = new PublicKey(
"AmJdpbtEzFBVWhznaEQM3V4fNZBa8FWj36Lu2BtnaDYt"
export const DEFAULT_PAYMENT_INFO = new PublicKey(
"SdFEeJxn7XxcnYEMNpnoMMSsTfmA1bHfiRdu6qra7zL"
);

export type IDLAccountInfo<IDL extends Idl = CardinalRewardsCenter> = {
Expand All @@ -43,10 +43,6 @@ export type IDLAccount<IDL extends Idl = CardinalRewardsCenter> = {
} & IDLAccountInfo<IDL>[T];
};

export const CLAIM_REWARDS_PAYMENT_INFO = new PublicKey(
"CUeHFsFqfbLfBGSbuNbaAi4wK6V835PoRg1CqCLo8tpM"
);

export type RewardDistributor = IDLAccount["rewardDistributor"];
export type RewardEntry = IDLAccount["rewardEntry"];
export type StakePool = IDLAccount["stakePool"];
Expand Down
12 changes: 6 additions & 6 deletions sdk/idl/cardinal_rewards_center.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type CardinalRewardsCenter = {
version: "2.0.0";
version: "2.1.0";
name: "cardinal_rewards_center";
instructions: [
{
Expand Down Expand Up @@ -2042,8 +2042,8 @@ export type CardinalRewardsCenter = {
},
{
code: 6064;
name: "InvalidPaymentManager";
msg: "Invalid payment manager";
name: "InvalidPaymentInfo";
msg: "Invalid payment info";
},
{
code: 6065;
Expand Down Expand Up @@ -2174,7 +2174,7 @@ export type CardinalRewardsCenter = {
};

export const IDL: CardinalRewardsCenter = {
version: "2.0.0",
version: "2.1.0",
name: "cardinal_rewards_center",
instructions: [
{
Expand Down Expand Up @@ -4217,8 +4217,8 @@ export const IDL: CardinalRewardsCenter = {
},
{
code: 6064,
name: "InvalidPaymentManager",
msg: "Invalid payment manager",
name: "InvalidPaymentInfo",
msg: "Invalid payment info",
},
{
code: 6065,
Expand Down
6 changes: 3 additions & 3 deletions sdk/idl/cardinal_rewards_center_idl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.0",
"version": "2.1.0",
"name": "cardinal_rewards_center",
"instructions": [
{
Expand Down Expand Up @@ -2042,8 +2042,8 @@
},
{
"code": 6064,
"name": "InvalidPaymentManager",
"msg": "Invalid payment manager"
"name": "InvalidPaymentInfo",
"msg": "Invalid payment info"
},
{
"code": 6065,
Expand Down
17 changes: 13 additions & 4 deletions tests/reward-distribution/claim-rewards-sol.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
import { BN } from "bn.js";

import {
CLAIM_REWARDS_PAYMENT_INFO,
claimRewards,
DEFAULT_PAYMENT_INFO,
fetchIdlAccount,
findRewardDistributorId,
findRewardEntryId,
Expand All @@ -43,7 +43,7 @@ const REWARD_AMOUNT = 2;
let mintId: PublicKey;
let rewardMintId: PublicKey;

const PAYMENT_AMOUNT = 0.002 * LAMPORTS_PER_SOL;
const PAYMENT_AMOUNT = 0.005 * LAMPORTS_PER_SOL;

beforeAll(async () => {
provider = await getProvider();
Expand Down Expand Up @@ -125,7 +125,7 @@ test("Init reward distributor", async () => {
defaultMultiplier: new BN(1),
multiplierDecimals: 0,
maxRewardSecondsReceived: null,
claimRewardsPaymentInfo: CLAIM_REWARDS_PAYMENT_INFO,
claimRewardsPaymentInfo: DEFAULT_PAYMENT_INFO,
})
.accounts({
rewardDistributor: rewardDistributorId,
Expand Down Expand Up @@ -173,7 +173,7 @@ test("Init reward distributor", async () => {
expect(rewardDistributor.parsed.multiplierDecimals).toBe(0);
expect(Number(rewardDistributor.parsed.defaultMultiplier)).toBe(1);
expect(rewardDistributor.parsed.claimRewardsPaymentInfo.toString()).toBe(
CLAIM_REWARDS_PAYMENT_INFO.toString()
DEFAULT_PAYMENT_INFO.toString()
);

// reward account check
Expand Down Expand Up @@ -250,6 +250,15 @@ test("Claim rewards", async () => {
const balanceBefore = await provider.connection.getBalance(
provider.wallet.publicKey
);

await claimRewards(
provider.connection,
provider.wallet,
stakePoolIdentifier,
[{ mintId }],
[rewardDistributorId]
);

await executeTransactions(
provider.connection,
await claimRewards(
Expand Down

0 comments on commit 1ca9f6d

Please sign in to comment.