diff --git a/.travis.yml b/.travis.yml index 53a754a..5668357 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ env: global: - NODE_VERSION="v14.7.0" - SOLANA_VERSION="v1.6.6" - - ANCHOR_VERSION="v0.4.4" + - ANCHOR_VERSION="0.4.4" before_deploy: - anchor build --verifiable @@ -17,7 +17,7 @@ before_deploy: - sha256sum target/idl/registry.json > registry_idl.txt - cat *.txt >> release_notes.md - echo "" >> release_notes.md - - echo "Built with Anchor [${ANCHOR_VERSION}](https://github.com/project-serum/anchor/releases/tag/${ANCHOR_VERSION})." >> release_notes.md + - echo "Built with Anchor [v${ANCHOR_VERSION}](https://github.com/project-serum/anchor/releases/tag/v${ANCHOR_VERSION})." >> release_notes.md deploy: provider: releases @@ -38,7 +38,7 @@ _defaults: &defaults before_install: - nvm install $NODE_VERSION - npm install -g mocha - - npm install -g @project-serum/anchor + - npm install -g @project-serum/anchor@${ANCHOR_VERSION} - npm install -g @project-serum/serum - npm install -g @project-serum/common - npm install -g @solana/spl-token @@ -47,7 +47,7 @@ _defaults: &defaults - export PATH="/home/travis/.local/share/solana/install/active_release/bin:$PATH" - export NODE_PATH="/home/travis/.nvm/versions/node/${NODE_VERSION}/lib/node_modules/:${NODE_PATH}" - yes | solana-keygen new - - cargo install --git https://github.com/project-serum/anchor --tag ${ANCHOR_VERSION} anchor-cli --locked + - cargo install --git https://github.com/project-serum/anchor --tag v${ANCHOR_VERSION} anchor-cli --locked jobs: include: diff --git a/Cargo.lock b/Cargo.lock index 8f993b0..876b5a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -707,6 +707,7 @@ dependencies = [ "anchor-lang", "anchor-spl", "lockup", + "solana-program", ] [[package]] diff --git a/programs/registry/Cargo.toml b/programs/registry/Cargo.toml index 2e88920..dc252be 100644 --- a/programs/registry/Cargo.toml +++ b/programs/registry/Cargo.toml @@ -16,3 +16,4 @@ cpi = ["no-entrypoint"] anchor-lang = "0.4.4" anchor-spl = "0.4.4" lockup = { path = "../lockup", features = ["cpi"] } +solana-program = "1.6.6" diff --git a/programs/registry/src/lib.rs b/programs/registry/src/lib.rs index 10e1e4c..c67e4b9 100644 --- a/programs/registry/src/lib.rs +++ b/programs/registry/src/lib.rs @@ -378,6 +378,28 @@ mod registry { if ctx.accounts.clock.unix_timestamp >= expiry_ts { return Err(ErrorCode::InvalidExpiry.into()); } + if ctx.accounts.registrar.to_account_info().key == &fida_registrar::ID { + if ctx.accounts.vendor_vault.mint != fida_mint::ID { + return Err(ErrorCode::InvalidMint.into()); + } + if total < FIDA_MIN_REWARD { + return Err(ErrorCode::InsufficientReward.into()); + } + } else if ctx.accounts.registrar.to_account_info().key == &srm_registrar::ID + || ctx.accounts.registrar.to_account_info().key == &msrm_registrar::ID + { + if ctx.accounts.vendor_vault.mint != srm_mint::ID { + return Err(ErrorCode::InvalidMint.into()); + } + if total < SRM_MIN_REWARD { + return Err(ErrorCode::InsufficientReward.into()); + } + } else { + // TODO: in a future major version upgrade. Add the amount + mint + // to the registrar so that one can remove the hardcoded + // variables. + solana_program::msg!("Reward amount not constrained. Please open a pull request."); + } if let RewardVendorKind::Locked { start_ts, end_ts, @@ -1252,6 +1274,8 @@ pub enum ErrorCode { InvalidVestingSchedule, #[msg("Please specify the correct authority for this program.")] InvalidProgramAuthority, + #[msg("Invalid mint supplied")] + InvalidMint, } impl<'a, 'b, 'c, 'info> From<&mut Deposit<'info>> @@ -1351,3 +1375,23 @@ pub fn no_available_rewards<'info>( Ok(()) } + +// Native units. +pub const SRM_MIN_REWARD: u64 = 500_000_000; +pub const FIDA_MIN_REWARD: u64 = 900_000_000; + +pub mod srm_registrar { + solana_program::declare_id!("5vJRzKtcp4fJxqmR7qzajkaKSiAb6aT9grRsaZKXU222"); +} +pub mod msrm_registrar { + solana_program::declare_id!("7uURiX2DwCpRuMFebKSkFtX9v5GK1Cd8nWLL8tyoyxZY"); +} +pub mod fida_registrar { + solana_program::declare_id!("5C2ayX1E2SJ5kKEmDCA9ue9eeo3EPR34QFrhyzbbs3qh"); +} +pub mod srm_mint { + solana_program::declare_id!("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"); +} +pub mod fida_mint { + solana_program::declare_id!("EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp"); +} diff --git a/tests/lockup.js b/tests/lockup.js index 336e19d..d281866 100644 --- a/tests/lockup.js +++ b/tests/lockup.js @@ -42,12 +42,12 @@ describe("Lockup and Registry", () => { assert.ok(lockupAccount.authority.equals(provider.wallet.publicKey)); assert.ok(lockupAccount.whitelist.length === WHITELIST_SIZE); lockupAccount.whitelist.forEach((e) => { - assert.ok(e.programId.equals(new anchor.web3.PublicKey())); + assert.ok(e.programId.equals(anchor.web3.PublicKey.default)); }); }); it("Deletes the default whitelisted addresses", async () => { - const defaultEntry = { programId: new anchor.web3.PublicKey() }; + const defaultEntry = { programId: anchor.web3.PublicKey.default }; await lockup.state.rpc.whitelistDelete(defaultEntry, { accounts: { authority: provider.wallet.publicKey, @@ -389,7 +389,7 @@ describe("Lockup and Registry", () => { assert.ok(memberAccount.registrar.equals(registrar.publicKey)); assert.ok(memberAccount.beneficiary.equals(provider.wallet.publicKey)); - assert.ok(memberAccount.metadata.equals(new anchor.web3.PublicKey())); + assert.ok(memberAccount.metadata.equals(anchor.web3.PublicKey.default)); assert.equal( JSON.stringify(memberAccount.balances), JSON.stringify(balances)