From 12915a3a73779c17519ecd0063af0146300f9db0 Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Tue, 16 Apr 2024 16:25:48 -0500 Subject: [PATCH 1/9] feat(#632): HIP 109 implementation --- Cargo.lock | 2 +- packages/hexboosting-sdk/src/pdas.ts | 3 ++- programs/hexboosting/Cargo.toml | 2 +- programs/hexboosting/src/instructions/boost_v0.rs | 6 ++++-- programs/hexboosting/src/state.rs | 9 +++++++++ tests/hexboosting.ts | 9 +++++++-- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a871bc3a..0394d8e90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1999,7 +1999,7 @@ dependencies = [ [[package]] name = "hexboosting" -version = "0.0.5" +version = "0.1.0" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/packages/hexboosting-sdk/src/pdas.ts b/packages/hexboosting-sdk/src/pdas.ts index 639157a38..ae6d53319 100644 --- a/packages/hexboosting-sdk/src/pdas.ts +++ b/packages/hexboosting-sdk/src/pdas.ts @@ -4,13 +4,14 @@ import BN from "bn.js"; export function boostedHexKey( boostConfig: PublicKey, + carrier: PublicKey, location: BN, programId: PublicKey = PROGRAM_ID ) { const locBuffer = Buffer.alloc(8); locBuffer.writeBigUint64LE(BigInt(location.toString())); return PublicKey.findProgramAddressSync( - [Buffer.from("boosted_hex", "utf-8"), boostConfig.toBuffer(), locBuffer], + [Buffer.from("boosted_hex", "utf-8"), boostConfig.toBuffer(), carrier.toBuffer(), locBuffer], programId ); } diff --git a/programs/hexboosting/Cargo.toml b/programs/hexboosting/Cargo.toml index 4ba727415..c230d4123 100644 --- a/programs/hexboosting/Cargo.toml +++ b/programs/hexboosting/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hexboosting" -version = "0.0.5" +version = "0.1.0" description = "Created with Anchor" edition = "2021" diff --git a/programs/hexboosting/src/instructions/boost_v0.rs b/programs/hexboosting/src/instructions/boost_v0.rs index 4fea62691..0c9748739 100644 --- a/programs/hexboosting/src/instructions/boost_v0.rs +++ b/programs/hexboosting/src/instructions/boost_v0.rs @@ -1,4 +1,4 @@ -use crate::error::ErrorCode; +use crate::{error::ErrorCode, DeviceTypeV0}; use anchor_lang::prelude::*; use anchor_spl::{ associated_token::AssociatedToken, @@ -20,6 +20,7 @@ pub struct BoostArgsV0 { // invalid pub version: u32, pub amounts: Vec, + pub device_types: Vec, } #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] @@ -69,7 +70,7 @@ pub struct BoostV0<'info> { init_if_needed, payer = payer, space = get_space(boosted_hex), - seeds = [b"boosted_hex", boost_config.key().as_ref(), &args.location.to_le_bytes()], + seeds = [b"boosted_hex", boost_config.key().as_ref(), carrier.key().as_ref(), &args.location.to_le_bytes()], bump, constraint = boosted_hex.version == args.version @ ErrorCode::InvalidVersion, )] @@ -87,6 +88,7 @@ pub fn handler(ctx: Context, args: BoostArgsV0) -> Result<()> { ctx.accounts.boosted_hex.location = args.location; ctx.accounts.boosted_hex.bump_seed = ctx.bumps["boosted_hex"]; ctx.accounts.boosted_hex.version += 1; + ctx.accounts.boosted_hex.device_types = args.device_types; // Insert the new periods let max_period = args diff --git a/programs/hexboosting/src/state.rs b/programs/hexboosting/src/state.rs index f34425e65..0e8180bb9 100644 --- a/programs/hexboosting/src/state.rs +++ b/programs/hexboosting/src/state.rs @@ -20,6 +20,14 @@ pub struct BoostConfigV0 { pub start_authority: Pubkey, } +#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Default, PartialEq)] +pub enum DeviceTypeV0 { + #[default] + Cbrs, + WifiIndoor, + WifiOutdoor, +} + #[account] pub struct BoostedHexV0 { pub boost_config: Pubkey, @@ -34,6 +42,7 @@ pub struct BoostedHexV0 { pub boosts_by_period: Vec, // Track changes to the boosted hex so client can pass what version it made a change to pub version: u32, + pub device_types: Vec, } impl BoostedHexV0 { diff --git a/tests/hexboosting.ts b/tests/hexboosting.ts index 596cc5cc5..8bf603e80 100644 --- a/tests/hexboosting.ts +++ b/tests/hexboosting.ts @@ -253,6 +253,7 @@ describe("hexboosting", () => { .boostV0({ location: new BN(1), version: 0, + deviceTypes: [{ wifiIndoor: {} }], amounts: [ { period: 0, @@ -293,7 +294,6 @@ describe("hexboosting", () => { ) ).amount; - console.log(pythPrice); const expected = Number( BigInt(toBN((6 * 0.005) / pythPrice, 6).toNumber()) ); @@ -304,6 +304,7 @@ describe("hexboosting", () => { const hex = await program.account.boostedHexV0.fetch(boostedHex!); + expect(Object.keys(hex.deviceTypes[0])[0]).to.eq("wifiIndoor"); expect(hex.location.toNumber()).to.eq(1); expect(hex.startTs.toNumber()).to.eq(0); expect(hex.boostsByPeriod.toJSON().data).to.deep.eq([1, 1, 1, 1, 1, 1]); @@ -315,6 +316,7 @@ describe("hexboosting", () => { .boostV0({ location: new BN(1), version: 0, + deviceTypes: [{ wifiIndoor: {} }], amounts: [ { period: 0, @@ -362,6 +364,7 @@ describe("hexboosting", () => { .boostV0({ location: new BN(1), version: 1, + deviceTypes: [{ wifiIndoor: {} }], amounts: [ { period: 2, @@ -407,7 +410,7 @@ describe("hexboosting", () => { }); it("allows starting a boost", async () => { - const boostedHex = boostedHexKey(boostConfigKey(mint)[0], new BN(1))[0]; + const boostedHex = boostedHexKey(boostConfigKey(mint)[0], carrier, new BN(1))[0]; await program.methods .startBoostV0({ startTs: new BN(1), @@ -429,6 +432,7 @@ describe("hexboosting", () => { beforeEach(async () => { const boostedHex = boostedHexKey( boostConfigKey(mint)[0], + carrier, new BN(1) )[0]; await program.methods @@ -444,6 +448,7 @@ describe("hexboosting", () => { it("allows closing the boost when it's done", async () => { const boostedHex = boostedHexKey( boostConfigKey(mint)[0], + carrier, new BN(1) )[0]; // Wait 7 seconds so it is fully expired From a5449adec627a9eadabfbad21760a2a7adc0d69d Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Wed, 17 Apr 2024 11:03:09 -0500 Subject: [PATCH 2/9] feat(#632): Hexboosting by device type --- .../src/create-boost-config.ts | 2 +- .../src/update-boost-config.ts | 4 +-- packages/hexboosting-sdk/src/pdas.ts | 18 ++++++++-- packages/hexboosting-sdk/src/resolvers.ts | 10 +++++- .../hexboosting/src/instructions/boost_v0.rs | 11 +++--- programs/hexboosting/src/state.rs | 9 ++--- tests/hexboosting.ts | 34 ++++++++----------- 7 files changed, 54 insertions(+), 34 deletions(-) diff --git a/packages/helium-admin-cli/src/create-boost-config.ts b/packages/helium-admin-cli/src/create-boost-config.ts index ce4a1cbba..65d2335ec 100644 --- a/packages/helium-admin-cli/src/create-boost-config.ts +++ b/packages/helium-admin-cli/src/create-boost-config.ts @@ -104,7 +104,7 @@ export async function run(args: any = process.argv) { rentReclaimAuthority: new PublicKey(argv.rentReclaimAuthority), authority: subDaoAuth, subDao, - startAuthority: new PublicKey(argv.startAuthority) + startAuthority: new PublicKey(argv.startAuthority), }) .instruction(), ]; diff --git a/packages/helium-admin-cli/src/update-boost-config.ts b/packages/helium-admin-cli/src/update-boost-config.ts index 3009efe74..3ce2b623a 100644 --- a/packages/helium-admin-cli/src/update-boost-config.ts +++ b/packages/helium-admin-cli/src/update-boost-config.ts @@ -50,11 +50,11 @@ export async function run(args: any = process.argv) { }, minimumPeriods: { type: "number", - describe: "The new minimum number of periods" + describe: "The new minimum number of periods", }, boostPrice: { type: "string", - describe: "The boost price in bones" + describe: "The boost price in bones", }, dntMint: { type: "string", diff --git a/packages/hexboosting-sdk/src/pdas.ts b/packages/hexboosting-sdk/src/pdas.ts index ae6d53319..8b7a94a89 100644 --- a/packages/hexboosting-sdk/src/pdas.ts +++ b/packages/hexboosting-sdk/src/pdas.ts @@ -2,16 +2,30 @@ import { PublicKey } from "@solana/web3.js"; import { PROGRAM_ID } from "./constants"; import BN from "bn.js"; +const deviceTypeValues = { + cbrsIndoor: 0, + cbrsOutdoor: 1, + wifiIndoor: 2, + wifiOutdoor: 3, +}; + export function boostedHexKey( boostConfig: PublicKey, - carrier: PublicKey, + deviceType: any, location: BN, programId: PublicKey = PROGRAM_ID ) { const locBuffer = Buffer.alloc(8); locBuffer.writeBigUint64LE(BigInt(location.toString())); + const deviceTypeName = Object.keys(deviceType)[0]; + let deviceTypeValue = deviceTypeValues[deviceTypeName]; return PublicKey.findProgramAddressSync( - [Buffer.from("boosted_hex", "utf-8"), boostConfig.toBuffer(), carrier.toBuffer(), locBuffer], + [ + Buffer.from("boosted_hex", "utf-8"), + boostConfig.toBuffer(), + Buffer.from([deviceTypeValue]), + locBuffer, + ], programId ); } diff --git a/packages/hexboosting-sdk/src/resolvers.ts b/packages/hexboosting-sdk/src/resolvers.ts index d0eb7e978..67bd4cc61 100644 --- a/packages/hexboosting-sdk/src/resolvers.ts +++ b/packages/hexboosting-sdk/src/resolvers.ts @@ -6,13 +6,21 @@ import { } from "@helium/anchor-resolvers"; import { subDaoKey } from "@helium/helium-sub-daos-sdk"; import { PublicKey } from "@solana/web3.js"; +import { boostedHexKey } from "./pdas"; export const hexboostingResolvers = combineResolvers( heliumCommonResolver, - resolveIndividual(async ({ path, accounts }) => { + resolveIndividual(async ({ path, accounts, args }) => { if (path[path.length - 1] === "subDao" && accounts.dntMint) { return subDaoKey(accounts.dntMint as PublicKey)[0]; } + if (path[path.length - 1] === "boostedHex" && accounts.boostConfig && args[0].deviceType && args[0].location) { + return boostedHexKey( + accounts.boostConfig as PublicKey, + args[0].deviceType, + args[0].location + )[0] + } }), ataResolver({ instruction: "boostV0", diff --git a/programs/hexboosting/src/instructions/boost_v0.rs b/programs/hexboosting/src/instructions/boost_v0.rs index 0c9748739..db44d50df 100644 --- a/programs/hexboosting/src/instructions/boost_v0.rs +++ b/programs/hexboosting/src/instructions/boost_v0.rs @@ -20,7 +20,7 @@ pub struct BoostArgsV0 { // invalid pub version: u32, pub amounts: Vec, - pub device_types: Vec, + pub device_type: DeviceTypeV0, } #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] @@ -70,7 +70,7 @@ pub struct BoostV0<'info> { init_if_needed, payer = payer, space = get_space(boosted_hex), - seeds = [b"boosted_hex", boost_config.key().as_ref(), carrier.key().as_ref(), &args.location.to_le_bytes()], + seeds = [b"boosted_hex", boost_config.key().as_ref(), &[(args.device_type as u8)], &args.location.to_le_bytes()], bump, constraint = boosted_hex.version == args.version @ ErrorCode::InvalidVersion, )] @@ -88,7 +88,7 @@ pub fn handler(ctx: Context, args: BoostArgsV0) -> Result<()> { ctx.accounts.boosted_hex.location = args.location; ctx.accounts.boosted_hex.bump_seed = ctx.bumps["boosted_hex"]; ctx.accounts.boosted_hex.version += 1; - ctx.accounts.boosted_hex.device_types = args.device_types; + ctx.accounts.boosted_hex.device_type = args.device_type; // Insert the new periods let max_period = args @@ -104,6 +104,7 @@ pub fn handler(ctx: Context, args: BoostArgsV0) -> Result<()> { .boosts_by_period .resize(max_period + 1, 0); } + let now = Clock::get()?.unix_timestamp; for amount in args.amounts.clone() { @@ -165,8 +166,8 @@ pub fn handler(ctx: Context, args: BoostArgsV0) -> Result<()> { let total_fee: u64 = args .amounts .iter() - .map(|amount| amount.amount as u64 * ctx.accounts.boost_config.boost_price) - .sum(); + .map(|amount| (amount.amount as u64 * ctx.accounts.boost_config.boost_price)) + .sum::(); let mobile_price_oracle = load_price_feed_from_account_info(&ctx.accounts.price_oracle).map_err(|e| { msg!("Pyth error {}", e); diff --git a/programs/hexboosting/src/state.rs b/programs/hexboosting/src/state.rs index 0e8180bb9..0d0957e80 100644 --- a/programs/hexboosting/src/state.rs +++ b/programs/hexboosting/src/state.rs @@ -23,9 +23,10 @@ pub struct BoostConfigV0 { #[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Default, PartialEq)] pub enum DeviceTypeV0 { #[default] - Cbrs, - WifiIndoor, - WifiOutdoor, + CbrsIndoor = 0, + CbrsOutdoor = 1, + WifiIndoor = 2, + WifiOutdoor = 3, } #[account] @@ -42,7 +43,7 @@ pub struct BoostedHexV0 { pub boosts_by_period: Vec, // Track changes to the boosted hex so client can pass what version it made a change to pub version: u32, - pub device_types: Vec, + pub device_type: DeviceTypeV0, } impl BoostedHexV0 { diff --git a/tests/hexboosting.ts b/tests/hexboosting.ts index 8bf603e80..c7d7b74e3 100644 --- a/tests/hexboosting.ts +++ b/tests/hexboosting.ts @@ -21,13 +21,11 @@ import { } from "@solana/web3.js"; import { BN } from "bn.js"; import { expect } from "chai"; -import { - init as initHeliumEntityManager -} from "../packages/helium-entity-manager-sdk/src"; +import { init as initHeliumEntityManager } from "../packages/helium-entity-manager-sdk/src"; import { boostConfigKey, boostedHexKey, - init + init, } from "../packages/hexboosting-sdk"; import { init as initMobileEntityManager } from "../packages/mobile-entity-manager-sdk/src"; import { DataCredits } from "../target/types/data_credits"; @@ -39,7 +37,7 @@ import { ensureHEMIdl, ensureHSDIdl, ensureMemIdl, - initTestDataCredits + initTestDataCredits, } from "./utils/fixtures"; import { random } from "./utils/string"; @@ -253,7 +251,7 @@ describe("hexboosting", () => { .boostV0({ location: new BN(1), version: 0, - deviceTypes: [{ wifiIndoor: {} }], + deviceType: { wifiIndoor: {} }, amounts: [ { period: 0, @@ -304,7 +302,7 @@ describe("hexboosting", () => { const hex = await program.account.boostedHexV0.fetch(boostedHex!); - expect(Object.keys(hex.deviceTypes[0])[0]).to.eq("wifiIndoor"); + expect(Object.keys(hex.deviceType)[0]).to.eq("wifiIndoor"); expect(hex.location.toNumber()).to.eq(1); expect(hex.startTs.toNumber()).to.eq(0); expect(hex.boostsByPeriod.toJSON().data).to.deep.eq([1, 1, 1, 1, 1, 1]); @@ -316,7 +314,7 @@ describe("hexboosting", () => { .boostV0({ location: new BN(1), version: 0, - deviceTypes: [{ wifiIndoor: {} }], + deviceType: { wifiIndoor: {} }, amounts: [ { period: 0, @@ -364,7 +362,7 @@ describe("hexboosting", () => { .boostV0({ location: new BN(1), version: 1, - deviceTypes: [{ wifiIndoor: {} }], + deviceType: { wifiIndoor: {} }, amounts: [ { period: 2, @@ -399,18 +397,16 @@ describe("hexboosting", () => { const hex = await program.account.boostedHexV0.fetch(boostedHex!); expect(hex.boostsByPeriod.toJSON().data).to.deep.eq([ - 1, - 1, - 2, - 1, - 1, - 1, - 2, + 1, 1, 2, 1, 1, 1, 2, ]); }); it("allows starting a boost", async () => { - const boostedHex = boostedHexKey(boostConfigKey(mint)[0], carrier, new BN(1))[0]; + const boostedHex = boostedHexKey( + boostConfigKey(mint)[0], + { wifiIndoor: {} }, + new BN(1) + )[0]; await program.methods .startBoostV0({ startTs: new BN(1), @@ -432,7 +428,7 @@ describe("hexboosting", () => { beforeEach(async () => { const boostedHex = boostedHexKey( boostConfigKey(mint)[0], - carrier, + { wifiIndoor: {} }, new BN(1) )[0]; await program.methods @@ -448,7 +444,7 @@ describe("hexboosting", () => { it("allows closing the boost when it's done", async () => { const boostedHex = boostedHexKey( boostConfigKey(mint)[0], - carrier, + { wifiIndoor: {} }, new BN(1) )[0]; // Wait 7 seconds so it is fully expired From 47cca68166e5cf3af3bb38e2b833a182da826743 Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Fri, 26 Apr 2024 10:20:32 -0700 Subject: [PATCH 3/9] Use ts enum --- packages/hexboosting-sdk/src/pdas.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/hexboosting-sdk/src/pdas.ts b/packages/hexboosting-sdk/src/pdas.ts index 8b7a94a89..19b336b81 100644 --- a/packages/hexboosting-sdk/src/pdas.ts +++ b/packages/hexboosting-sdk/src/pdas.ts @@ -2,12 +2,12 @@ import { PublicKey } from "@solana/web3.js"; import { PROGRAM_ID } from "./constants"; import BN from "bn.js"; -const deviceTypeValues = { - cbrsIndoor: 0, - cbrsOutdoor: 1, - wifiIndoor: 2, - wifiOutdoor: 3, -}; +enum DeviceType { + cbrsIndoor, + cbrsOutdoor, + wifiIndoor, + wifiOutdoor, +} export function boostedHexKey( boostConfig: PublicKey, @@ -18,7 +18,7 @@ export function boostedHexKey( const locBuffer = Buffer.alloc(8); locBuffer.writeBigUint64LE(BigInt(location.toString())); const deviceTypeName = Object.keys(deviceType)[0]; - let deviceTypeValue = deviceTypeValues[deviceTypeName]; + let deviceTypeValue = DeviceType[deviceTypeName]; return PublicKey.findProgramAddressSync( [ Buffer.from("boosted_hex", "utf-8"), From b6aebbea6860cc1246c6ea14e08dd1d36f402acd Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Mon, 29 Apr 2024 17:06:59 -0500 Subject: [PATCH 4/9] Remove padding by adding V1 struct --- .../hexboosting/src/instructions/boost_v0.rs | 6 +++--- .../src/instructions/close_boost_v0.rs | 4 ++-- .../src/instructions/start_boost_v0.rs | 4 ++-- programs/hexboosting/src/state.rs | 16 +++++++++++++++- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/programs/hexboosting/src/instructions/boost_v0.rs b/programs/hexboosting/src/instructions/boost_v0.rs index db44d50df..2ca72e9d8 100644 --- a/programs/hexboosting/src/instructions/boost_v0.rs +++ b/programs/hexboosting/src/instructions/boost_v0.rs @@ -8,7 +8,7 @@ use mobile_entity_manager::CarrierV0; use pyth_sdk_solana::load_price_feed_from_account_info; use shared_utils::resize_to_fit; -use crate::{BoostConfigV0, BoostedHexV0}; +use crate::{BoostConfigV0, BoostedHexV1}; pub const TESTING: bool = std::option_env!("TESTING").is_some(); @@ -31,7 +31,7 @@ pub struct BoostAmountV0 { fn get_space(boosted_hex: &AccountInfo) -> usize { if boosted_hex.data_len() == 0 { - 8 + 60 + std::mem::size_of::() + 8 + 60 + std::mem::size_of::() } else { boosted_hex.data_len() } @@ -74,7 +74,7 @@ pub struct BoostV0<'info> { bump, constraint = boosted_hex.version == args.version @ ErrorCode::InvalidVersion, )] - pub boosted_hex: Box>, + pub boosted_hex: Box>, pub system_program: Program<'info, System>, pub token_program: Program<'info, Token>, pub associated_token_program: Program<'info, AssociatedToken>, diff --git a/programs/hexboosting/src/instructions/close_boost_v0.rs b/programs/hexboosting/src/instructions/close_boost_v0.rs index 09998e26d..26da47cff 100644 --- a/programs/hexboosting/src/instructions/close_boost_v0.rs +++ b/programs/hexboosting/src/instructions/close_boost_v0.rs @@ -1,6 +1,6 @@ use anchor_lang::prelude::*; -use crate::{BoostConfigV0, BoostedHexV0}; +use crate::{BoostConfigV0, BoostedHexV1}; #[derive(Accounts)] pub struct CloseBoostV0<'info> { @@ -15,7 +15,7 @@ pub struct CloseBoostV0<'info> { constraint = boosted_hex.is_expired(&boost_config), has_one = boost_config )] - pub boosted_hex: Box>, + pub boosted_hex: Box>, } pub fn handler(_ctx: Context) -> Result<()> { diff --git a/programs/hexboosting/src/instructions/start_boost_v0.rs b/programs/hexboosting/src/instructions/start_boost_v0.rs index 81e6e6689..98288359a 100644 --- a/programs/hexboosting/src/instructions/start_boost_v0.rs +++ b/programs/hexboosting/src/instructions/start_boost_v0.rs @@ -1,6 +1,6 @@ use anchor_lang::prelude::*; -use crate::{BoostConfigV0, BoostedHexV0}; +use crate::{BoostConfigV0, BoostedHexV1}; #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct StartBoostArgsV0 { @@ -18,7 +18,7 @@ pub struct StartBoostV0<'info> { mut, has_one = boost_config, )] - pub boosted_hex: Box>, + pub boosted_hex: Box>, } pub fn handler(ctx: Context, args: StartBoostArgsV0) -> Result<()> { diff --git a/programs/hexboosting/src/state.rs b/programs/hexboosting/src/state.rs index 0d0957e80..27d03629c 100644 --- a/programs/hexboosting/src/state.rs +++ b/programs/hexboosting/src/state.rs @@ -43,10 +43,24 @@ pub struct BoostedHexV0 { pub boosts_by_period: Vec, // Track changes to the boosted hex so client can pass what version it made a change to pub version: u32, +} + +#[account] +pub struct BoostedHexV1 { pub device_type: DeviceTypeV0, + pub boost_config: Pubkey, + // Track changes to the boosted hex so client can pass what version it made a change to + pub version: u32, + pub location: u64, + // 0 if the boosting has not yet started. Avoding using an option here to keep serialization length + // consistent + pub start_ts: i64, + pub bump_seed: u8, + /// Each entry represents the boost multiplier for a given period + pub boosts_by_period: Vec, } -impl BoostedHexV0 { +impl BoostedHexV1 { pub fn is_expired(&self, boost_config: &BoostConfigV0) -> bool { if self.start_ts == 0 { false From ac515d45979797a74d0e4f7f7525b47c8f816d1f Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Thu, 30 May 2024 12:15:02 -0700 Subject: [PATCH 5/9] Trigger retest --- tests/hexboosting.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/hexboosting.ts b/tests/hexboosting.ts index c7d7b74e3..2579627ea 100644 --- a/tests/hexboosting.ts +++ b/tests/hexboosting.ts @@ -41,6 +41,7 @@ import { } from "./utils/fixtures"; import { random } from "./utils/string"; + describe("hexboosting", () => { anchor.setProvider(anchor.AnchorProvider.local("http://127.0.0.1:8899")); From b8ab11a806a0d60b18469d9d4d9b5a8b5c750270 Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Mon, 3 Jun 2024 09:03:34 -0700 Subject: [PATCH 6/9] Fix tests --- tests/hexboosting.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/hexboosting.ts b/tests/hexboosting.ts index 2579627ea..ffe20a0d7 100644 --- a/tests/hexboosting.ts +++ b/tests/hexboosting.ts @@ -301,7 +301,7 @@ describe("hexboosting", () => { expected ); - const hex = await program.account.boostedHexV0.fetch(boostedHex!); + const hex = await program.account.boostedHexV1.fetch(boostedHex!); expect(Object.keys(hex.deviceType)[0]).to.eq("wifiIndoor"); expect(hex.location.toNumber()).to.eq(1); @@ -395,7 +395,7 @@ describe("hexboosting", () => { Number(expected) ); - const hex = await program.account.boostedHexV0.fetch(boostedHex!); + const hex = await program.account.boostedHexV1.fetch(boostedHex!); expect(hex.boostsByPeriod.toJSON().data).to.deep.eq([ 1, 1, 2, 1, 1, 1, 2, @@ -416,7 +416,7 @@ describe("hexboosting", () => { boostedHex, }) .rpc({ skipPreflight: true }); - const acc = await program.account.boostedHexV0.fetch(boostedHex!); + const acc = await program.account.boostedHexV1.fetch(boostedHex!); expect(acc.startTs.toNumber()).to.not.eq(0); }); From dc7318df733732e243e475ffb48541d669353a2e Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Mon, 3 Jun 2024 09:35:06 -0700 Subject: [PATCH 7/9] Fix tests --- tests/utils/compression.ts | 6 +++--- utils/bulk-claim-rewards/src/claim_rewards.rs | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/utils/compression.ts b/tests/utils/compression.ts index b5b010700..3b1b5743b 100644 --- a/tests/utils/compression.ts +++ b/tests/utils/compression.ts @@ -94,7 +94,7 @@ export async function createCompressionNft({ creators: [], editionNonce: 0, tokenProgramVersion: TokenProgramVersion.Original, - tokenStandard: TokenStandard.Fungible, + tokenStandard: TokenStandard.NonFungible, uses: null, collection: null, primarySaleHappened: false, @@ -126,7 +126,7 @@ export async function createCompressionNft({ await bubblegum.methods .mintToCollectionV1({ ...metadata, - tokenStandard: { fungible: {} }, + tokenStandard: { nonFungible: {} }, tokenProgramVersion: { original: {} }, }) .accounts({ @@ -144,7 +144,7 @@ export async function createCompressionNft({ await bubblegum.methods .mintV1({ ...metadata, - tokenStandard: { fungible: {} }, + tokenStandard: { nonFungible: {} }, tokenProgramVersion: { original: {} }, }) .accounts({ diff --git a/utils/bulk-claim-rewards/src/claim_rewards.rs b/utils/bulk-claim-rewards/src/claim_rewards.rs index 6f35e3de7..3acdd6234 100644 --- a/utils/bulk-claim-rewards/src/claim_rewards.rs +++ b/utils/bulk-claim-rewards/src/claim_rewards.rs @@ -954,7 +954,6 @@ fn construct_distribute_rewards_accounts + Clone> associated_token_program: spl_associated_token_account::id(), circuit_breaker_program: CB_PID, system_program: system_program::id(), - token_program: anchor_spl::token::ID, }, merkle_tree, compression_program, From 13f5c91ba36a471c8c0f63c74a26f8fb293692d3 Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Mon, 3 Jun 2024 09:50:21 -0700 Subject: [PATCH 8/9] Fix tests --- utils/bulk-claim-rewards/src/claim_rewards.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/utils/bulk-claim-rewards/src/claim_rewards.rs b/utils/bulk-claim-rewards/src/claim_rewards.rs index 3acdd6234..96d85d77c 100644 --- a/utils/bulk-claim-rewards/src/claim_rewards.rs +++ b/utils/bulk-claim-rewards/src/claim_rewards.rs @@ -957,7 +957,6 @@ fn construct_distribute_rewards_accounts + Clone> }, merkle_tree, compression_program, - token_program: anchor_spl::token::ID, }) } @@ -999,7 +998,6 @@ fn construct_distribute_custom_destination_accounts Date: Mon, 3 Jun 2024 10:34:06 -0700 Subject: [PATCH 9/9] Fix tests --- utils/bulk-claim-rewards/Cargo.lock | 2 +- utils/bulk-claim-rewards/src/claim_rewards.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/bulk-claim-rewards/Cargo.lock b/utils/bulk-claim-rewards/Cargo.lock index cd6505543..e244a0d08 100644 --- a/utils/bulk-claim-rewards/Cargo.lock +++ b/utils/bulk-claim-rewards/Cargo.lock @@ -2285,7 +2285,7 @@ dependencies = [ [[package]] name = "helium-sub-daos" -version = "0.1.5" +version = "0.1.6" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/utils/bulk-claim-rewards/src/claim_rewards.rs b/utils/bulk-claim-rewards/src/claim_rewards.rs index 96d85d77c..00cee4517 100644 --- a/utils/bulk-claim-rewards/src/claim_rewards.rs +++ b/utils/bulk-claim-rewards/src/claim_rewards.rs @@ -954,6 +954,7 @@ fn construct_distribute_rewards_accounts + Clone> associated_token_program: spl_associated_token_account::id(), circuit_breaker_program: CB_PID, system_program: system_program::id(), + token_program: anchor_spl::token::ID, }, merkle_tree, compression_program, @@ -998,6 +999,7 @@ fn construct_distribute_custom_destination_accounts