Small update to LeaseAccount.create

This commit is contained in:
Jackson Jessup 2022-12-02 09:55:45 -05:00
parent 46ea9568f1
commit cb75e26e17
1 changed files with 11 additions and 17 deletions

View File

@ -94,11 +94,11 @@ export class LeaseAccount extends Account<types.LeaseAccountData> {
program: SwitchboardProgram, program: SwitchboardProgram,
payer: PublicKey, payer: PublicKey,
params: { params: {
aggregatorAccount: AggregatorAccount;
queueAccount: QueueAccount;
loadAmount?: number; loadAmount?: number;
funderTokenAccount?: PublicKey; funderTokenAccount?: PublicKey;
funderAuthority?: Keypair; funderAuthority?: Keypair;
queuePubkey: PublicKey;
aggregatorPubkey: PublicKey;
withdrawAuthority?: PublicKey; withdrawAuthority?: PublicKey;
jobAuthorities: Array<PublicKey>; jobAuthorities: Array<PublicKey>;
} }
@ -131,8 +131,8 @@ export class LeaseAccount extends Account<types.LeaseAccountData> {
const [leaseAccount, leaseBump] = LeaseAccount.fromSeed( const [leaseAccount, leaseBump] = LeaseAccount.fromSeed(
program, program,
params.queuePubkey, params.queueAccount.publicKey,
params.aggregatorPubkey params.aggregatorAccount.publicKey
); );
const [escrow] = anchor.utils.publicKey.findProgramAddressSync( const [escrow] = anchor.utils.publicKey.findProgramAddressSync(
@ -169,8 +169,8 @@ export class LeaseAccount extends Account<types.LeaseAccountData> {
}, },
{ {
lease: leaseAccount.publicKey, lease: leaseAccount.publicKey,
queue: params.queuePubkey, queue: params.queueAccount.publicKey,
aggregator: params.aggregatorPubkey, aggregator: params.aggregatorAccount.publicKey,
payer: payer, payer: payer,
systemProgram: SystemProgram.programId, systemProgram: SystemProgram.programId,
tokenProgram: spl.TOKEN_PROGRAM_ID, tokenProgram: spl.TOKEN_PROGRAM_ID,
@ -189,12 +189,11 @@ export class LeaseAccount extends Account<types.LeaseAccountData> {
public static async create( public static async create(
program: SwitchboardProgram, program: SwitchboardProgram,
params: { params: {
loadAmount?: number;
mint: PublicKey;
funder?: PublicKey;
funderAuthority?: Keypair;
queueAccount: QueueAccount;
aggregatorAccount: AggregatorAccount; aggregatorAccount: AggregatorAccount;
queueAccount: QueueAccount;
loadAmount?: number;
funderTokenAccount?: PublicKey;
funderAuthority?: Keypair;
withdrawAuthority?: PublicKey; withdrawAuthority?: PublicKey;
jobAuthorities: Array<PublicKey>; jobAuthorities: Array<PublicKey>;
} }
@ -202,15 +201,10 @@ export class LeaseAccount extends Account<types.LeaseAccountData> {
const [leaseAccount, transaction] = await LeaseAccount.createInstructions( const [leaseAccount, transaction] = await LeaseAccount.createInstructions(
program, program,
program.walletPubkey, program.walletPubkey,
{ params
...params,
aggregatorPubkey: params.aggregatorAccount.publicKey,
queuePubkey: params.queueAccount.publicKey,
}
); );
const signature = await program.signAndSend(transaction); const signature = await program.signAndSend(transaction);
return [leaseAccount, signature]; return [leaseAccount, signature];
} }