Skip to content

Agave 2.0 #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 17 additions & 22 deletions packages/helium-admin-cli/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import * as anchor from "@coral-xyz/anchor";
import { idlAddress } from "@coral-xyz/anchor/dist/cjs/idl";
import {
confirmTransaction,
createAtaAndMintInstructions,
createMintInstructions,
sendInstructions,
toBN,
withPriorityFees,
} from "@helium/spl-utils";
import {
createCreateMetadataAccountV3Instruction,
PROGRAM_ID as METADATA_PROGRAM_ID,
createCreateMetadataAccountV3Instruction,
} from "@metaplex-foundation/mpl-token-metadata";
import {
AccountMetaData,
BPF_UPGRADE_LOADER_ID,
getGovernanceProgramVersion,
getProposalTransactionAddress,
getTokenOwnerRecordAddress,
Governance,
GovernanceAccountParser,
InstructionData,
ProposalTransaction,
Realm,
Vote,
VoteType,
YesNoVote,
getGovernanceProgramVersion,
getProposalTransactionAddress,
getTokenOwnerRecordAddress,
withAddSignatory,
withCastVote,
withCreateProposal,
@@ -34,7 +36,6 @@ import {
withRelinquishVote,
withSignOffProposal,
withWithdrawGoverningTokens,
YesNoVote,
} from "@solana/spl-governance";
import {
AuthorityType,
@@ -49,9 +50,9 @@ import {
Connection,
Keypair,
PublicKey,
Signer,
SYSVAR_CLOCK_PUBKEY,
SYSVAR_RENT_PUBKEY,
Signer,
TransactionInstruction,
TransactionMessage,
VersionedTransaction,
@@ -489,7 +490,7 @@ export async function sendInstructionsOrCreateProposal({
console.log("Created lookup table since ix too big", lut.toBase58());
await tx.sign([walletSigner!]);
const sent = await provider.connection.sendTransaction(tx);
await provider.connection.confirmTransaction(sent, "confirmed");
await confirmTransaction(provider, sent, "confirmed");
console.log(`Added tx ${idx}`, sent);

await AddressLookupTableProgram.closeLookupTable({
@@ -785,39 +786,33 @@ export async function sendInstructionsOrSquads({
await withPriorityFees({
connection: provider.connection,
instructions: [
await squads.buildAddInstruction(
multisig,
txKey,
ix,
index
),
await squads.buildAddInstruction(multisig, txKey, ix, index),
],
computeUnits: 200000,
})
);
index++;
}

const ixs: TransactionInstruction[] = []
ixs.push(await squads.buildActivateTransaction(multisig, txKey))
ixs.push(await squads.buildApproveTransaction(multisig, txKey))
const ixs: TransactionInstruction[] = [];
ixs.push(await squads.buildActivateTransaction(multisig, txKey));
ixs.push(await squads.buildApproveTransaction(multisig, txKey));

if (executeTransaction) {
ixs.push(await squads.buildExecuteTransaction(
txKey,
provider.wallet.publicKey
));
ixs.push(
await squads.buildExecuteTransaction(txKey, provider.wallet.publicKey)
);
}

await sendInstructions(
provider,
await withPriorityFees({
connection: provider.connection,
computeUnits: 1000000,
instructions: ixs
instructions: ixs,
}),
signers
)
);
}

export async function parseEmissionsSchedule(filepath: string) {
1 change: 1 addition & 0 deletions packages/migration-service/package.json
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@
"@helium/helium-sub-daos-sdk": "^0.9.6",
"@helium/lazy-distributor-sdk": "^0.9.6",
"@helium/lazy-transactions-sdk": "^0.9.6",
"@helium/spl-utils": "^0.9.6",
"@helium/treasury-management-sdk": "^0.9.6",
"@helium/voter-stake-registry-sdk": "^0.9.6",
"@metaplex-foundation/mpl-token-metadata": "^2.10.0",
50 changes: 31 additions & 19 deletions packages/migration-service/src/test-submit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as anchor from "@coral-xyz/anchor";
import { confirmTransaction } from "@helium/spl-utils";
import axios from "axios";
import os from "os";
import yargs from "yargs/yargs";
@@ -22,8 +23,8 @@ const yarg = yargs(hideBin(process.argv)).options({
},
targetWallet: {
alias: "t",
type: "string"
}
type: "string",
},
});

async function run() {
@@ -33,25 +34,36 @@ async function run() {
anchor.setProvider(anchor.AnchorProvider.local(argv.url));

const provider = anchor.getProvider() as anchor.AnchorProvider;
const txs = (await axios.get(`${argv.migrateUrl}/migrate/${argv.targetWallet}`)).data.transactions;
const txids = await Promise.all(txs.map(async tx => await provider.connection.sendRawTransaction(
Buffer.from(tx),
{
skipPreflight: true
}
)));
const txs = (
await axios.get(`${argv.migrateUrl}/migrate/${argv.targetWallet}`)
).data.transactions;
const txids = await Promise.all(
txs.map(
async (tx) =>
await provider.connection.sendRawTransaction(Buffer.from(tx), {
skipPreflight: true,
})
)
);
console.log("Sending", txids);
const success = await Promise.all(txids.map(async txid => {
const tx = await provider.connection.confirmTransaction(txid, "processed");
if(tx.value.err) {
const tx = await provider.connection.getTransaction(txid);
console.error(txid, tx!.meta!.logMessages?.join("\n"));
}
return !tx.value.err
}));

const success = await Promise.all(
txids.map(async (txid) => {
const tx = await confirmTransaction(provider, txid, "processed");
if (tx.value.err) {
const tx = await provider.connection.getTransaction(txid);
console.error(txid, tx!.meta!.logMessages?.join("\n"));
}
return !tx.value.err;
})
);

console.log("done", success.filter(s => !s).length, "failed", success.filter(s => s).length, "succeeded");
console.log(
"done",
success.filter((s) => !s).length,
"failed",
success.filter((s) => s).length,
"succeeded"
);
}

run()
1 change: 1 addition & 0 deletions packages/migration-service/yarn.deploy.lock
Original file line number Diff line number Diff line change
@@ -423,6 +423,7 @@ __metadata:
"@helium/helium-sub-daos-sdk": ^0.9.6
"@helium/lazy-distributor-sdk": ^0.9.6
"@helium/lazy-transactions-sdk": ^0.9.6
"@helium/spl-utils": ^0.9.6
"@helium/treasury-management-sdk": ^0.9.6
"@helium/voter-stake-registry-sdk": ^0.9.6
"@metaplex-foundation/mpl-token-metadata": ^2.10.0
40 changes: 38 additions & 2 deletions packages/spl-utils/src/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { AnchorProvider, Program, Provider } from "@coral-xyz/anchor";
import anchor, { AnchorProvider, Program, Provider } from "@coral-xyz/anchor";
import {
AddressLookupTableAccount,
Commitment,
ComputeBudgetProgram,
Connection,
Finality,
Keypair,
Message,
PublicKey,
RpcResponseAndContext,
SendOptions,
SignatureStatus,
Signer,
SimulatedTransactionResponse,
Transaction,
TransactionConfirmationStatus,
TransactionInstruction,
TransactionMessage,
TransactionSignature,
@@ -942,3 +942,39 @@ export async function batchParallelInstructionsWithPriorityFee(
maxSignatureBatch
);
}

export async function confirmTransaction(
provider: AnchorProvider,
signature: string,
confirmationStatus: TransactionConfirmationStatus = "finalized",
timeout: number = 15000,
pollingInterval: number = 500
): Promise<anchor.web3.RpcResponseAndContext<anchor.web3.SignatureResult>> {
const startTime = Date.now();

while (Date.now() - startTime < timeout) {
const statuses = await provider.connection.getSignatureStatuses([
signature,
]);

const status = statuses.value?.[0];

if (status?.confirmationStatus === confirmationStatus) {
return {
context: {
slot: status.slot || 0,
},
value: status,
};
}

if (status?.err) {
throw new Error("Transaction failed");
}

// Wait for the polling interval before checking again
await new Promise((resolve) => setTimeout(resolve, pollingInterval));
}

throw new Error("Transaction confirmation timed out");
}
6 changes: 4 additions & 2 deletions tests/helium-entity-manager.ts
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import {
createMintInstructions,
proofArgsAndAccounts,
sendInstructions,
confirmTransaction,
toBN,
} from "@helium/spl-utils";
import { AddGatewayV1 } from "@helium/transactions";
@@ -783,7 +784,7 @@ describe("helium-entity-manager", () => {
.signers([makerKeypair])
.transaction();
tx.recentBlockhash = (
await provider.connection.getRecentBlockhash()
await provider.connection.getLatestBlockhash()
).blockhash;
tx.feePayer = provider.wallet.publicKey;
tx.partialSign(makerKeypair);
@@ -803,7 +804,8 @@ describe("helium-entity-manager", () => {
const sig = await provider.connection.sendRawTransaction(
Buffer.from(transaction, "hex")
);
await provider.connection.confirmTransaction(sig);

await confirmTransaction(provider, sig);
});

it("issues a mobile hotspot", async () => {
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -1194,6 +1194,7 @@ __metadata:
"@helium/helium-sub-daos-sdk": ^0.9.6
"@helium/lazy-distributor-sdk": ^0.9.6
"@helium/lazy-transactions-sdk": ^0.9.6
"@helium/spl-utils": ^0.9.6
"@helium/treasury-management-sdk": ^0.9.6
"@helium/voter-stake-registry-sdk": ^0.9.6
"@metaplex-foundation/mpl-token-metadata": ^2.10.0