Skip to content

Commit

Permalink
wip: make it build and pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nhanphan committed Feb 22, 2024
1 parent 7086b94 commit 0d1752f
Show file tree
Hide file tree
Showing 89 changed files with 1,661 additions and 6,815 deletions.
5 changes: 3 additions & 2 deletions clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@
"@metaplex-foundation/umi": ">= 0.8.2 < 1"
},
"dependencies": {
"@metaplex-foundation/mpl-toolbox": "^0.9.0",
"@metaplex-foundation/mpl-asset": "^0.1.0",
"@metaplex-foundation/mpl-token-metadata": "3.0.0-alpha.27",
"@metaplex-foundation/mpl-toolbox": "^0.9.0",
"@noble/hashes": "^1.2.0",
"merkletreejs": "^0.3.9"
},
"devDependencies": {
"@ava/typescript": "^3.0.1",
"@identity.com/solana-gateway-ts": "^0.12.0",
"@metaplex-foundation/mpl-token-auth-rules": "^1.2.0",
"@metaplex-foundation/umi": "^0.8.2",
"@metaplex-foundation/umi-bundle-tests": "^0.8.2",
"@metaplex-foundation/umi-web3js-adapters": "^0.8.2",
"@metaplex-foundation/mpl-token-auth-rules": "^1.2.0",
"@solana/web3.js": "^1.73.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.46.1",
Expand Down
43 changes: 0 additions & 43 deletions clients/js/src/createCandyMachine.ts

This file was deleted.

26 changes: 2 additions & 24 deletions clients/js/src/createLutForCandyMachine.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
MetadataDelegateRole,
findCollectionAuthorityRecordPda,
findMasterEditionPda,
findMetadataDelegateRecordPda,
findMetadataPda,
getMplTokenMetadataProgramId,
} from '@metaplex-foundation/mpl-token-metadata';
import {
Expand All @@ -20,8 +15,8 @@ import {
TransactionBuilder,
uniquePublicKeys,
} from '@metaplex-foundation/umi';
import { getMplAssetProgramId } from '@metaplex-foundation/mpl-asset';
import {
AccountVersion,
fetchCandyMachine,
getMplCandyMachineCoreProgramId,
} from './generated';
Expand Down Expand Up @@ -55,33 +50,16 @@ export const getLutAddressesForCandyMachine = async (
const candyMachineAccount = await fetchCandyMachine(context, candyMachine);
const { mintAuthority, collectionMint } = candyMachineAccount;
collectionUpdateAuthority ??= context.identity.publicKey;
const [collectionAuthorityPda] = findCandyMachineAuthorityPda(context, {
candyMachine,
});
const [delegateRecordV1] = findCollectionAuthorityRecordPda(context, {
mint: collectionMint,
collectionAuthority: collectionAuthorityPda,
});
const [delegateRecordV2] = findMetadataDelegateRecordPda(context, {
mint: collectionMint,
delegateRole: MetadataDelegateRole.Collection,
updateAuthority: collectionUpdateAuthority,
delegate: collectionAuthorityPda,
});

return uniquePublicKeys([
candyMachine,
mintAuthority,
collectionMint,
findMetadataPda(context, { mint: collectionMint })[0],
findMasterEditionPda(context, { mint: collectionMint })[0],
collectionUpdateAuthority,
findCandyMachineAuthorityPda(context, { candyMachine })[0],
candyMachineAccount.version === AccountVersion.V1
? delegateRecordV1
: delegateRecordV2,
getSysvar('instructions'),
getSysvar('slotHashes'),
getMplAssetProgramId(context),
getSplTokenProgramId(context),
getSplAssociatedTokenProgramId(context),
getMplTokenMetadataProgramId(context),
Expand Down
4 changes: 3 additions & 1 deletion clients/js/src/defaultGuards/freezeSolPayment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ export const freezeSolPaymentGuardManifest: GuardManifest<
candyMachine: mintContext.candyMachine,
candyGuard: mintContext.candyGuard,
});

// TODO actually freeze asset
const [nftAta] = findAssociatedTokenPda(context, {
mint: mintContext.mint,
mint: mintContext.asset,
owner: mintContext.minter.publicKey,
});
return {
Expand Down
4 changes: 3 additions & 1 deletion clients/js/src/defaultGuards/freezeTokenPayment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ export const freezeTokenPaymentGuardManifest: GuardManifest<
candyMachine: mintContext.candyMachine,
candyGuard: mintContext.candyGuard,
});

// TODO actually freeze asset
const [nftAta] = findAssociatedTokenPda(context, {
mint: mintContext.mint,
mint: mintContext.asset,
owner: mintContext.minter.publicKey,
});
const [tokenAddress] = findAssociatedTokenPda(context, {
Expand Down
18 changes: 6 additions & 12 deletions clients/js/src/generated/accounts/candyMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
* @see https://github.com/metaplex-foundation/kinobi
*/

import {
TokenStandardArgs,
getTokenStandardSerializer,
} from '@metaplex-foundation/mpl-token-metadata';
import {
Account,
Context,
Expand Down Expand Up @@ -112,7 +108,6 @@ export function getCandyMachineGpaBuilder(
.registerFields<{
discriminator: Array<number>;
version: AccountVersionArgs;
tokenStandard: TokenStandardArgs;
features: Array<number>;
authority: PublicKey;
mintAuthority: PublicKey;
Expand All @@ -122,13 +117,12 @@ export function getCandyMachineGpaBuilder(
}>({
discriminator: [0, array(u8(), { size: 8 })],
version: [8, getAccountVersionSerializer()],
tokenStandard: [9, getTokenStandardSerializer()],
features: [null, array(u8(), { size: 6 })],
authority: [null, publicKeySerializer()],
mintAuthority: [null, publicKeySerializer()],
collectionMint: [null, publicKeySerializer()],
itemsRedeemed: [null, u64()],
data: [null, getCandyMachineDataSerializer()],
features: [9, array(u8(), { size: 6 })],
authority: [15, publicKeySerializer()],
mintAuthority: [47, publicKeySerializer()],
collectionMint: [79, publicKeySerializer()],
itemsRedeemed: [111, u64()],
data: [119, getCandyMachineDataSerializer()],
})
.deserializeUsing<CandyMachine>((account) =>
deserializeCandyMachine(account)
Expand Down
5 changes: 1 addition & 4 deletions clients/js/src/generated/instructions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
export * from './addConfigLines';
export * from './deleteCandyGuard';
export * from './deleteCandyMachine';
export * from './initializeCandyMachine';
export * from './initializeCandyMachineV2';
export * from './mintFromCandyMachine';
export * from './mintFromCandyMachineV2';
export * from './mintAssetFromCandyMachine';
export * from './setCandyGuardAuthority';
export * from './setCandyMachineAuthority';
export * from './setCollection';
export * from './setCollectionV2';
export * from './setMintAuthority';
export * from './setTokenStandard';
export * from './unwrap';
export * from './updateCandyMachine';
export * from './wrap';
Loading

0 comments on commit 0d1752f

Please sign in to comment.