Bugfix: extendInstruction should be 'wrap' not 'unwrap'

This commit is contained in:
Jackson Jessup 2022-12-12 10:45:24 -05:00
parent 682aee5182
commit 68f16bf7b6
2 changed files with 33 additions and 5 deletions

View File

@ -400,11 +400,9 @@ export class LeaseAccount extends Account<types.LeaseAccountData> {
const funderBalance = const funderBalance =
(await this.program.mint.getAssociatedBalance(funderAuthority)) ?? 0; (await this.program.mint.getAssociatedBalance(funderAuthority)) ?? 0;
if (funderBalance < params.loadAmount) { if (funderBalance < params.loadAmount) {
const wrapIxns = await this.program.mint.unwrapInstructions( const wrapIxns = await this.program.mint.wrapInstructions(payer, {
payer, amount: params.loadAmount,
params.loadAmount, });
params.funderAuthority
);
ixns.push(...wrapIxns.ixns); ixns.push(...wrapIxns.ixns);
signers.push(...wrapIxns.signers); signers.push(...wrapIxns.signers);
} }

View File

@ -0,0 +1,30 @@
import 'mocha';
import * as sbv2 from '../src';
import { setupTest, TestContext } from './utilts';
import { Keypair } from '@solana/web3.js';
describe('Lease Tests', () => {
let ctx: TestContext;
before(async () => {
ctx = await setupTest();
});
const aggregator = Keypair.generate();
const queue = Keypair.generate();
it('Creates a Lease', async () => {
const aggregatorAccount = new sbv2.AggregatorAccount(
ctx.program,
aggregator.publicKey
);
const queueAccount = new sbv2.QueueAccount(ctx.program, queue.publicKey);
const [leaseAccount] = await sbv2.LeaseAccount.create(ctx.program, {
aggregatorAccount,
queueAccount,
loadAmount: 0.01,
});
await leaseAccount.loadData();
});
});