Skip to content

Commit

Permalink
Move processor implementation (#39)
Browse files Browse the repository at this point in the history
* Move processor implementation

* Fix truncated comment

* Update generated clients

* Fix test compilation

* Tweak processor methods visibility

* Remove duplicated functions

* Change instruction name (#40)

* Change instruction name

* Update instruction name enum

* Update generated code

* Add helpers

* Update generated clients

* Update test import

* Update generated clients

---------

Co-authored-by: febo <[email protected]>
  • Loading branch information
febo and febo authored Sep 27, 2023
1 parent 44c8f5e commit ecd1146
Show file tree
Hide file tree
Showing 50 changed files with 2,708 additions and 2,316 deletions.
13 changes: 11 additions & 2 deletions clients/js-solita/.solitarc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ module.exports = {
programDir,
rustbin: {
locked: true,
versionRangeFallback: "0.27.0",
versionRangeFallback: '0.27.0',
},
};
idlHook: (idl) => {
const instructions = idl.instructions.filter((ix) => {
return ix.name !== 'setDecompressableState';
});
const types = idl.types.filter((ty) => {
return ty.name !== 'InstructionName';
});
return { ...idl, instructions, types };
},
};
12 changes: 6 additions & 6 deletions clients/js-solita/src/generated/accounts/TreeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import * as web3 from '@solana/web3.js';
import * as beet from '@metaplex-foundation/beet';
import * as beetSolana from '@metaplex-foundation/beet-solana';
import { DecompressableState, decompressableStateBeet } from '../types/DecompressableState';
import { DecompressibleState, decompressibleStateBeet } from '../types/DecompressibleState';

/**
* Arguments used to create {@link TreeConfig}
Expand All @@ -21,7 +21,7 @@ export type TreeConfigArgs = {
totalMintCapacity: beet.bignum;
numMinted: beet.bignum;
isPublic: boolean;
isDecompressable: DecompressableState;
isDecompressible: DecompressibleState;
};

export const treeConfigDiscriminator = [122, 245, 175, 248, 171, 34, 0, 207];
Expand All @@ -39,7 +39,7 @@ export class TreeConfig implements TreeConfigArgs {
readonly totalMintCapacity: beet.bignum,
readonly numMinted: beet.bignum,
readonly isPublic: boolean,
readonly isDecompressable: DecompressableState,
readonly isDecompressible: DecompressibleState,
) {}

/**
Expand All @@ -52,7 +52,7 @@ export class TreeConfig implements TreeConfigArgs {
args.totalMintCapacity,
args.numMinted,
args.isPublic,
args.isDecompressable,
args.isDecompressible,
);
}

Expand Down Expand Up @@ -173,7 +173,7 @@ export class TreeConfig implements TreeConfigArgs {
return x;
})(),
isPublic: this.isPublic,
isDecompressable: 'DecompressableState.' + DecompressableState[this.isDecompressable],
isDecompressible: 'DecompressibleState.' + DecompressibleState[this.isDecompressible],
};
}
}
Expand All @@ -195,7 +195,7 @@ export const treeConfigBeet = new beet.BeetStruct<
['totalMintCapacity', beet.u64],
['numMinted', beet.u64],
['isPublic', beet.bool],
['isDecompressable', decompressableStateBeet],
['isDecompressible', decompressibleStateBeet],
],
TreeConfig.fromArgs,
'TreeConfig',
Expand Down
2 changes: 1 addition & 1 deletion clients/js-solita/src/generated/instructions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export * from './mintToCollectionV1';
export * from './mintV1';
export * from './redeem';
export * from './setAndVerifyCollection';
export * from './setDecompressableState';
export * from './setDecompressibleState';
export * from './setTreeDelegate';
export * from './transfer';
export * from './unverifyCollection';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,66 @@

import * as beet from '@metaplex-foundation/beet';
import * as web3 from '@solana/web3.js';
import { DecompressableState, decompressableStateBeet } from '../types/DecompressableState';
import { DecompressibleState, decompressibleStateBeet } from '../types/DecompressibleState';

/**
* @category Instructions
* @category SetDecompressableState
* @category SetDecompressibleState
* @category generated
*/
export type SetDecompressableStateInstructionArgs = {
decompressableState: DecompressableState;
export type SetDecompressibleStateInstructionArgs = {
decompressableState: DecompressibleState;
};
/**
* @category Instructions
* @category SetDecompressableState
* @category SetDecompressibleState
* @category generated
*/
export const setDecompressableStateStruct = new beet.BeetArgsStruct<
SetDecompressableStateInstructionArgs & {
export const setDecompressibleStateStruct = new beet.BeetArgsStruct<
SetDecompressibleStateInstructionArgs & {
instructionDiscriminator: number[] /* size: 8 */;
}
>(
[
['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)],
['decompressableState', decompressableStateBeet],
['decompressableState', decompressibleStateBeet],
],
'SetDecompressableStateInstructionArgs',
'SetDecompressibleStateInstructionArgs',
);
/**
* Accounts required by the _setDecompressableState_ instruction
* Accounts required by the _setDecompressibleState_ instruction
*
* @property [_writable_] treeAuthority
* @property [**signer**] treeCreator
* @category Instructions
* @category SetDecompressableState
* @category SetDecompressibleState
* @category generated
*/
export type SetDecompressableStateInstructionAccounts = {
export type SetDecompressibleStateInstructionAccounts = {
treeAuthority: web3.PublicKey;
treeCreator: web3.PublicKey;
anchorRemainingAccounts?: web3.AccountMeta[];
};

export const setDecompressableStateInstructionDiscriminator = [
18, 135, 238, 168, 246, 195, 61, 115,
];
export const setDecompressibleStateInstructionDiscriminator = [82, 104, 152, 6, 149, 111, 100, 13];

/**
* Creates a _SetDecompressableState_ instruction.
* Creates a _SetDecompressibleState_ instruction.
*
* @param accounts that will be accessed while the instruction is processed
* @param args to provide as instruction data to the program
*
* @category Instructions
* @category SetDecompressableState
* @category SetDecompressibleState
* @category generated
*/
export function createSetDecompressableStateInstruction(
accounts: SetDecompressableStateInstructionAccounts,
args: SetDecompressableStateInstructionArgs,
export function createSetDecompressibleStateInstruction(
accounts: SetDecompressibleStateInstructionAccounts,
args: SetDecompressibleStateInstructionArgs,
programId = new web3.PublicKey('BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY'),
) {
const [data] = setDecompressableStateStruct.serialize({
instructionDiscriminator: setDecompressableStateInstructionDiscriminator,
const [data] = setDecompressibleStateStruct.serialize({
instructionDiscriminator: setDecompressibleStateInstructionDiscriminator,
...args,
});
const keys: web3.AccountMeta[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as beet from '@metaplex-foundation/beet';
* @category enums
* @category generated
*/
export enum DecompressableState {
export enum DecompressibleState {
Enabled,
Disabled,
}
Expand All @@ -19,6 +19,6 @@ export enum DecompressableState {
* @category userTypes
* @category generated
*/
export const decompressableStateBeet = beet.fixedScalarEnum(
DecompressableState,
) as beet.FixedSizeBeet<DecompressableState, DecompressableState>;
export const decompressibleStateBeet = beet.fixedScalarEnum(
DecompressibleState,
) as beet.FixedSizeBeet<DecompressibleState, DecompressibleState>;
40 changes: 0 additions & 40 deletions clients/js-solita/src/generated/types/InstructionName.ts

This file was deleted.

3 changes: 1 addition & 2 deletions clients/js-solita/src/generated/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export * from './BubblegumEventType';
export * from './Collection';
export * from './Creator';
export * from './DecompressableState';
export * from './InstructionName';
export * from './DecompressibleState';
export * from './LeafSchema';
export * from './MetadataArgs';
export * from './TokenProgramVersion';
Expand Down
16 changes: 8 additions & 8 deletions clients/js/src/generated/accounts/treeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import {
u8,
} from '@metaplex-foundation/umi/serializers';
import {
DecompressableState,
DecompressableStateArgs,
getDecompressableStateSerializer,
DecompressibleState,
DecompressibleStateArgs,
getDecompressibleStateSerializer,
} from '../types';

export type TreeConfig = Account<TreeConfigAccountData>;
Expand All @@ -44,7 +44,7 @@ export type TreeConfigAccountData = {
totalMintCapacity: bigint;
numMinted: bigint;
isPublic: boolean;
isDecompressable: DecompressableState;
isDecompressible: DecompressibleState;
};

export type TreeConfigAccountDataArgs = {
Expand All @@ -53,7 +53,7 @@ export type TreeConfigAccountDataArgs = {
totalMintCapacity: number | bigint;
numMinted: number | bigint;
isPublic: boolean;
isDecompressable: DecompressableStateArgs;
isDecompressible: DecompressibleStateArgs;
};

export function getTreeConfigAccountDataSerializer(): Serializer<
Expand All @@ -69,7 +69,7 @@ export function getTreeConfigAccountDataSerializer(): Serializer<
['totalMintCapacity', u64()],
['numMinted', u64()],
['isPublic', bool()],
['isDecompressable', getDecompressableStateSerializer()],
['isDecompressible', getDecompressibleStateSerializer()],
],
{ description: 'TreeConfigAccountData' }
),
Expand Down Expand Up @@ -153,15 +153,15 @@ export function getTreeConfigGpaBuilder(
totalMintCapacity: number | bigint;
numMinted: number | bigint;
isPublic: boolean;
isDecompressable: DecompressableStateArgs;
isDecompressible: DecompressibleStateArgs;
}>({
discriminator: [0, array(u8(), { size: 8 })],
treeCreator: [8, publicKeySerializer()],
treeDelegate: [40, publicKeySerializer()],
totalMintCapacity: [72, u64()],
numMinted: [80, u64()],
isPublic: [88, bool()],
isDecompressable: [89, getDecompressableStateSerializer()],
isDecompressible: [89, getDecompressibleStateSerializer()],
})
.deserializeUsing<TreeConfig>((account) => deserializeTreeConfig(account))
.whereField('discriminator', [122, 245, 175, 248, 171, 34, 0, 207]);
Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/instructions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export * from './mintToCollectionV1';
export * from './mintV1';
export * from './redeem';
export * from './setAndVerifyCollection';
export * from './setDecompressableState';
export * from './setDecompressibleState';
export * from './setTreeDelegate';
export * from './transfer';
export * from './unverifyCollection';
Expand Down
Loading

0 comments on commit ecd1146

Please sign in to comment.