solana.js: fix queue create signers
This commit is contained in:
parent
cf7b351fe0
commit
5c6d897099
|
@ -267,13 +267,7 @@ export class AggregatorAccount extends Account<types.AggregatorAccountData> {
|
|||
}
|
||||
|
||||
const jobs = await this.loadJobs(aggregator);
|
||||
const jobAuthorities = jobs.map(j => j.state.authority);
|
||||
// const jobAuthorities = Array.from(
|
||||
// jobs.reduce((set, job) => {
|
||||
// set.add(job.state.authority);
|
||||
// return set;
|
||||
// }, new Set<PublicKey>())
|
||||
// );
|
||||
const jobAuthorities = jobs.map(job => job.state.authority);
|
||||
|
||||
const [oldLeaseAccount] = LeaseAccount.fromSeed(
|
||||
this.program,
|
||||
|
|
|
@ -172,7 +172,7 @@ export class QueueAccount extends Account<types.OracleQueueAccountData> {
|
|||
payer,
|
||||
[
|
||||
SystemProgram.createAccount({
|
||||
fromPubkey: program.wallet.publicKey,
|
||||
fromPubkey: payer,
|
||||
newAccountPubkey: dataBuffer.publicKey,
|
||||
space: queueDataSize,
|
||||
lamports: await program.connection.getMinimumBalanceForRentExemption(
|
||||
|
|
|
@ -94,7 +94,7 @@ export class VrfAccount extends Account<types.VrfAccountData> {
|
|||
|
||||
const ixns = [
|
||||
spl.createAssociatedTokenAccountInstruction(
|
||||
program.wallet.payer.publicKey,
|
||||
payer,
|
||||
escrow,
|
||||
params.vrfKeypair.publicKey,
|
||||
program.mint.address
|
||||
|
@ -103,11 +103,10 @@ export class VrfAccount extends Account<types.VrfAccountData> {
|
|||
escrow,
|
||||
params.vrfKeypair.publicKey,
|
||||
spl.AuthorityType.AccountOwner,
|
||||
program.programState.publicKey,
|
||||
[program.wallet.payer, params.vrfKeypair]
|
||||
program.programState.publicKey
|
||||
),
|
||||
SystemProgram.createAccount({
|
||||
fromPubkey: program.wallet.payer.publicKey,
|
||||
fromPubkey: payer,
|
||||
newAccountPubkey: params.vrfKeypair.publicKey,
|
||||
space: size,
|
||||
lamports: await program.connection.getMinimumBalanceForRentExemption(
|
||||
|
|
|
@ -15,6 +15,10 @@ import { SwitchboardEvents } from './switchboardEvents';
|
|||
import { fromCode as fromSwitchboardCode } from './generated/errors/custom';
|
||||
import { fromCode as fromAnchorCode } from './generated/errors/anchor';
|
||||
|
||||
const DEVNET_GENESIS_HASH = 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG';
|
||||
|
||||
const MAINNET_GENESIS_HASH = '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d';
|
||||
|
||||
/**
|
||||
* Switchboard Devnet Program ID
|
||||
*/
|
||||
|
@ -177,6 +181,68 @@ export class SwitchboardProgram {
|
|||
return new SwitchboardProgram(program, cluster, mint);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create and initialize a {@linkcode SwitchboardProgram} connection object.
|
||||
*
|
||||
* @param provider - the anchor provider containing the rpc and wallet connection.
|
||||
*
|
||||
* @return the {@linkcode SwitchboardProgram} used to create and interact with Switchboard accounts.
|
||||
*
|
||||
* Basic usage example:
|
||||
*
|
||||
* ```ts
|
||||
* import * as anchor from "@project-serum/anchor";
|
||||
* import { Connection } from "@solana/web3.js";
|
||||
* import { AnchorWallet, SwitchboardProgram, TransactionObject } from '@switchboard-xyz/solana.js';
|
||||
*
|
||||
* const connection = new Connection("https://api.mainnet-beta.solana.com");
|
||||
* const provider = new anchor.AnchorProvider(
|
||||
connection,
|
||||
new AnchorWallet(payerKeypair ?? SwitchboardProgram._readOnlyKeypair),
|
||||
{ commitment: 'confirmed' }
|
||||
);
|
||||
* const program = await SwitchboardProgram.fromProvider(provider);
|
||||
*
|
||||
* const txn = new TransactionObject(program.walletPubkey, [], []);
|
||||
* const txnSignature = await program.signAndSend(txn);
|
||||
* ```
|
||||
*/
|
||||
static fromProvider = async (
|
||||
provider: anchor.AnchorProvider
|
||||
): Promise<SwitchboardProgram> => {
|
||||
const payer = (provider.wallet as AnchorWallet).payer;
|
||||
|
||||
// try mainnet program ID
|
||||
const mainnetAccountInfo = await provider.connection.getAccountInfo(
|
||||
SBV2_MAINNET_PID
|
||||
);
|
||||
if (mainnetAccountInfo && mainnetAccountInfo.executable) {
|
||||
return await SwitchboardProgram.load(
|
||||
'mainnet-beta',
|
||||
provider.connection,
|
||||
payer,
|
||||
SBV2_MAINNET_PID
|
||||
);
|
||||
}
|
||||
|
||||
// try devnet program ID
|
||||
const devnetAccountInfo = await provider.connection.getAccountInfo(
|
||||
SBV2_DEVNET_PID
|
||||
);
|
||||
if (devnetAccountInfo && devnetAccountInfo.executable) {
|
||||
return await SwitchboardProgram.load(
|
||||
'devnet',
|
||||
provider.connection,
|
||||
payer,
|
||||
SBV2_DEVNET_PID
|
||||
);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Failed to find the Switchboard program using the mainnet or devnet program ID`
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* The Switchboard Program ID for the currently connected cluster.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue