Skip to content

Commit

Permalink
Add additional addresses to LUT (#47)
Browse files Browse the repository at this point in the history
* Add additional addresses to LUT

* update test to include more addresses

* fix lint
  • Loading branch information
MarkSackerberg authored Jul 27, 2023
1 parent 817aa1a commit a1c99e1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
18 changes: 16 additions & 2 deletions clients/js/src/createLutForCandyMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import {
findMasterEditionPda,
findMetadataDelegateRecordPda,
findMetadataPda,
getMplTokenMetadataProgramId,
} from '@metaplex-foundation/mpl-token-metadata';
import { createLut, getSysvar } from '@metaplex-foundation/mpl-toolbox';
import {
createLut,
getSysvar,
getSplAssociatedTokenProgramId,
getSplTokenProgramId,
} from '@metaplex-foundation/mpl-toolbox';
import {
AddressLookupTableInput,
Context,
Expand All @@ -14,7 +20,11 @@ import {
TransactionBuilder,
uniquePublicKeys,
} from '@metaplex-foundation/umi';
import { AccountVersion, fetchCandyMachine } from './generated';
import {
AccountVersion,
fetchCandyMachine,
getMplCandyMachineCoreProgramId,
} from './generated';
import { findCandyMachineAuthorityPda } from './hooked';

export const createLutForCandyMachine = async (
Expand Down Expand Up @@ -72,5 +82,9 @@ export const getLutAddressesForCandyMachine = async (
: delegateRecordV2,
getSysvar('instructions'),
getSysvar('slotHashes'),
getSplTokenProgramId(context),
getSplAssociatedTokenProgramId(context),
getMplTokenMetadataProgramId(context),
getMplCandyMachineCoreProgramId(context),
]);
};
10 changes: 9 additions & 1 deletion clients/js/test/createLutForCandyMachine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import {
findMasterEditionPda,
findMetadataDelegateRecordPda,
findMetadataPda,
getMplTokenMetadataProgramId,
} from '@metaplex-foundation/mpl-token-metadata';
import {
getSplAssociatedTokenProgramId,
getSplTokenProgramId,
getSysvar,
setComputeUnitLimit,
} from '@metaplex-foundation/mpl-toolbox';
Expand All @@ -16,6 +19,7 @@ import {
createLutForCandyMachine,
findCandyGuardPda,
findCandyMachineAuthorityPda,
getMplCandyMachineCoreProgramId,
mintV2,
setMintAuthority,
} from '../src';
Expand Down Expand Up @@ -81,6 +85,10 @@ test('it can create a LUT for a candy machine v2', async (t) => {
})[0],
getSysvar('instructions'),
getSysvar('slotHashes'),
getSplTokenProgramId(umi),
getSplAssociatedTokenProgramId(umi),
getMplTokenMetadataProgramId(umi),
getMplCandyMachineCoreProgramId(umi),
].sort()
);

Expand All @@ -90,7 +98,7 @@ test('it can create a LUT for a candy machine v2', async (t) => {
builderWithoutLut.getTransactionSize(umi) -
builderWithLut.getTransactionSize(umi);
const expectedSizeDifference =
(32 - 1) * 9 + // Replaces keys with indexes for 9 out of 10 addresses (one is a Signer).
(32 - 1) * 13 + // Replaces keys with indexes for 13 out of 14 addresses (one is a Signer).
-32 + // Adds 32 bytes for the LUT address itself.
-2; // Adds 2 bytes for writable and readonly array sizes.
t.is(transactionSizeDifference, expectedSizeDifference);
Expand Down

0 comments on commit a1c99e1

Please sign in to comment.