-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into develop
- Loading branch information
Showing
13 changed files
with
1,305 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import * as anchor from "@coral-xyz/anchor"; | ||
import { | ||
lazyDistributorKey | ||
} from "@helium/lazy-distributor-sdk"; | ||
import { init as initHsd } from "@helium/helium-sub-daos-sdk"; | ||
import { organizationKey } from "@helium/organization-sdk"; | ||
import { oracleSignerKey } from "@helium/rewards-oracle-sdk"; | ||
import { | ||
batchParallelInstructionsWithPriorityFee | ||
} from "@helium/spl-utils"; | ||
import { getAssociatedTokenAddressSync } from "@solana/spl-token"; | ||
import { PublicKey, TransactionInstruction } from "@solana/web3.js"; | ||
import Squads from "@sqds/sdk"; | ||
import fs from "fs"; | ||
import os from "os"; | ||
import yargs from "yargs/yargs"; | ||
import { | ||
loadKeypair, | ||
parseEmissionsSchedule, | ||
sendInstructionsOrSquads, | ||
} from "./utils"; | ||
|
||
export async function run(args: any = process.argv) { | ||
const yarg = yargs(args).options({ | ||
wallet: { | ||
alias: "k", | ||
describe: "Anchor wallet keypair", | ||
default: `${os.homedir()}/.config/solana/id.json`, | ||
}, | ||
url: { | ||
alias: "u", | ||
default: "http://127.0.0.1:8899", | ||
describe: "The solana url", | ||
}, | ||
delegatedPositions: { | ||
type: "string", | ||
describe: "Path to the delegated positions file", | ||
default: __dirname + "/delegatedPositions.txt", | ||
}, | ||
}); | ||
const argv = await yarg.argv; | ||
process.env.ANCHOR_WALLET = argv.wallet; | ||
process.env.ANCHOR_PROVIDER_URL = argv.url; | ||
anchor.setProvider(anchor.AnchorProvider.local(argv.url)); | ||
const provider = anchor.getProvider() as anchor.AnchorProvider; | ||
const wallet = new anchor.Wallet(loadKeypair(argv.wallet)); | ||
const hsdProgram = await initHsd(provider); | ||
|
||
const delegatedPositions = fs.readFileSync(argv.delegatedPositions, "utf-8") | ||
.split("\n") | ||
.filter(line => line.trim() !== ""); // Remove empty lines | ||
|
||
const instructions: TransactionInstruction[] = []; | ||
for (const delegatedPosition of delegatedPositions) { | ||
console.log(delegatedPosition, new PublicKey(delegatedPosition).toBase58()); | ||
instructions.push( | ||
await hsdProgram.methods | ||
.tempFixClaimedEpoch() | ||
.accounts({ | ||
authority: wallet.publicKey, | ||
delegatedPosition: new PublicKey(delegatedPosition), | ||
}) | ||
.instruction() | ||
); | ||
} | ||
await batchParallelInstructionsWithPriorityFee(provider, instructions, {maxSignatureBatch: 100}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import * as anchor from "@coral-xyz/anchor"; | ||
import { | ||
init as initProxy, | ||
proxyConfigKey, | ||
} from "@helium/nft-proxy-sdk"; | ||
import { PublicKey, TransactionInstruction } from "@solana/web3.js"; | ||
import Squads from "@sqds/sdk"; | ||
import fs from "fs"; | ||
import os from "os"; | ||
import yargs from "yargs/yargs"; | ||
import { | ||
loadKeypair, | ||
sendInstructionsOrSquads | ||
} from "./utils"; | ||
|
||
export async function run(args: any = process.argv) { | ||
const yarg = yargs(args).options({ | ||
wallet: { | ||
alias: "k", | ||
describe: "Anchor wallet keypair", | ||
default: `${os.homedir()}/.config/solana/id.json`, | ||
}, | ||
url: { | ||
alias: "u", | ||
default: "http://127.0.0.1:8899", | ||
describe: "The solana url", | ||
}, | ||
name: { | ||
required: true, | ||
type: "string", | ||
describe: "Name of the proxy config to be updated", | ||
}, | ||
maxProxyTime: { | ||
required: false, | ||
describe: "New max proxy time", | ||
type: "string", | ||
default: null, | ||
}, | ||
proxySeasonsFile: { | ||
type: "string", | ||
default: `${__dirname}/../../proxy-seasons.json`, | ||
}, | ||
executeTransaction: { | ||
type: "boolean", | ||
}, | ||
multisig: { | ||
type: "string", | ||
describe: | ||
"Address of the squads multisig to be authority. If not provided, your wallet will be the authority", | ||
}, | ||
authorityIndex: { | ||
type: "number", | ||
describe: "Authority index for squads. Defaults to 1", | ||
default: 1, | ||
}, | ||
}); | ||
const argv = await yarg.argv; | ||
process.env.ANCHOR_WALLET = argv.wallet; | ||
process.env.ANCHOR_PROVIDER_URL = argv.url; | ||
anchor.setProvider(anchor.AnchorProvider.local(argv.url)); | ||
const provider = anchor.getProvider() as anchor.AnchorProvider; | ||
const wallet = new anchor.Wallet(loadKeypair(argv.wallet)); | ||
const proxySeasonsFile = fs.readFileSync(argv.proxySeasonsFile, "utf8"); | ||
const seasons = JSON.parse(proxySeasonsFile).map((s) => ({ | ||
start: new anchor.BN(Math.floor(Date.parse(s.start) / 1000)), | ||
end: new anchor.BN(Math.floor(Date.parse(s.end) / 1000)), | ||
})); | ||
|
||
const program = await initProxy(provider); | ||
|
||
const instructions: TransactionInstruction[] = []; | ||
const proxyConfig = proxyConfigKey(argv.name)[0]; | ||
const proxyConfigAcc = await program.account.proxyConfigV0.fetch(proxyConfig); | ||
|
||
instructions.push( | ||
await program.methods | ||
.updateProxyConfigV0({ | ||
maxProxyTime: argv.maxProxyTime ? new anchor.BN(argv.maxProxyTime) : null, | ||
seasons, | ||
}) | ||
.accounts({ | ||
proxyConfig, | ||
authority: proxyConfigAcc.authority, | ||
}) | ||
.instruction() | ||
); | ||
|
||
const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { | ||
commitmentOrConfig: "finalized", | ||
}); | ||
await sendInstructionsOrSquads({ | ||
provider, | ||
instructions, | ||
executeTransaction: argv.executeTransaction, | ||
squads, | ||
multisig: argv.multisig ? new PublicKey(argv.multisig) : undefined, | ||
authorityIndex: argv.authorityIndex, | ||
signers: [], | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
programs/helium-sub-daos/src/instructions/temp_fix_claimed_epoch.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use std::str::FromStr; | ||
|
||
use anchor_lang::prelude::*; | ||
|
||
use crate::DelegatedPositionV0; | ||
|
||
#[derive(Accounts)] | ||
pub struct TempFixClaimedEpoch<'info> { | ||
#[account( | ||
mut, | ||
address = Pubkey::from_str("hprdnjkbziK8NqhThmAn5Gu4XqrBbctX8du4PfJdgvW").unwrap() | ||
)] | ||
pub authority: Signer<'info>, | ||
#[account(mut)] | ||
pub delegated_position: Account<'info, DelegatedPositionV0>, | ||
pub system_program: Program<'info, System>, | ||
} | ||
|
||
pub fn handler(ctx: Context<TempFixClaimedEpoch>) -> Result<()> { | ||
ctx.accounts.delegated_position.set_unclaimed(20117)?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters