Skip to content

Commit

Permalink
regen solita and fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
samwise2 committed Aug 29, 2023
1 parent c71ac65 commit c8864df
Show file tree
Hide file tree
Showing 37 changed files with 992 additions and 1,159 deletions.
63 changes: 26 additions & 37 deletions clients/js-solita/src/generated/accounts/TreeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type TreeConfigArgs = {
isDecompressable: DecompressableState;
};

export const treeConfigDiscriminator = [122, 245, 175, 248, 171, 34, 0, 207]
export const treeConfigDiscriminator = [122, 245, 175, 248, 171, 34, 0, 207];
/**
* Holds the data for the {@link TreeConfig} Account and provides de/serialization
* functionality for that data
Expand Down Expand Up @@ -60,11 +60,8 @@ export class TreeConfig implements TreeConfigArgs {
* Deserializes the {@link TreeConfig} from the data of the provided {@link web3.AccountInfo}.
* @returns a tuple of the account data and the offset up to which the buffer was read to obtain it.
*/
static fromAccountInfo(
accountInfo: web3.AccountInfo<Buffer>,
offset = 0
): [TreeConfig, number] {
return TreeConfig.deserialize(accountInfo.data, offset)
static fromAccountInfo(accountInfo: web3.AccountInfo<Buffer>, offset = 0): [TreeConfig, number] {
return TreeConfig.deserialize(accountInfo.data, offset);
}

/**
Expand All @@ -76,16 +73,13 @@ export class TreeConfig implements TreeConfigArgs {
static async fromAccountAddress(
connection: web3.Connection,
address: web3.PublicKey,
commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig
commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig,
): Promise<TreeConfig> {
const accountInfo = await connection.getAccountInfo(
address,
commitmentOrConfig
)
const accountInfo = await connection.getAccountInfo(address, commitmentOrConfig);
if (accountInfo == null) {
throw new Error(`Unable to find TreeConfig account at ${address}`)
throw new Error(`Unable to find TreeConfig account at ${address}`);
}
return TreeConfig.fromAccountInfo(accountInfo, 0)[0]
return TreeConfig.fromAccountInfo(accountInfo, 0)[0];
}

/**
Expand All @@ -95,19 +89,17 @@ export class TreeConfig implements TreeConfigArgs {
* @param programId - the program that owns the accounts we are filtering
*/
static gpaBuilder(
programId: web3.PublicKey = new web3.PublicKey(
'BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY'
)
programId: web3.PublicKey = new web3.PublicKey('BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY'),
) {
return beetSolana.GpaBuilder.fromStruct(programId, treeConfigBeet)
return beetSolana.GpaBuilder.fromStruct(programId, treeConfigBeet);
}

/**
* Deserializes the {@link TreeConfig} from the provided data Buffer.
* @returns a tuple of the account data and the offset up to which the buffer was read to obtain it.
*/
static deserialize(buf: Buffer, offset = 0): [TreeConfig, number] {
return treeConfigBeet.deserialize(buf, offset)
return treeConfigBeet.deserialize(buf, offset);
}

/**
Expand All @@ -118,15 +110,15 @@ export class TreeConfig implements TreeConfigArgs {
return treeConfigBeet.serialize({
accountDiscriminator: treeConfigDiscriminator,
...this,
})
});
}

/**
* Returns the byteSize of a {@link Buffer} holding the serialized data of
* {@link TreeConfig}
*/
static get byteSize() {
return treeConfigBeet.byteSize
return treeConfigBeet.byteSize;
}

/**
Expand All @@ -137,20 +129,17 @@ export class TreeConfig implements TreeConfigArgs {
*/
static async getMinimumBalanceForRentExemption(
connection: web3.Connection,
commitment?: web3.Commitment
commitment?: web3.Commitment,
): Promise<number> {
return connection.getMinimumBalanceForRentExemption(
TreeConfig.byteSize,
commitment
)
return connection.getMinimumBalanceForRentExemption(TreeConfig.byteSize, commitment);
}

/**
* Determines if the provided {@link Buffer} has the correct byte size to
* hold {@link TreeConfig} data.
*/
static hasCorrectByteSize(buf: Buffer, offset = 0) {
return buf.byteLength - offset === TreeConfig.byteSize
return buf.byteLength - offset === TreeConfig.byteSize;
}

/**
Expand All @@ -162,26 +151,26 @@ export class TreeConfig implements TreeConfigArgs {
treeCreator: this.treeCreator.toBase58(),
treeDelegate: this.treeDelegate.toBase58(),
totalMintCapacity: (() => {
const x = <{ toNumber: () => number }>this.totalMintCapacity
const x = <{ toNumber: () => number }>this.totalMintCapacity;
if (typeof x.toNumber === 'function') {
try {
return x.toNumber()
return x.toNumber();
} catch (_) {
return x
return x;
}
}
return x
return x;
})(),
numMinted: (() => {
const x = <{ toNumber: () => number }>this.numMinted
const x = <{ toNumber: () => number }>this.numMinted;
if (typeof x.toNumber === 'function') {
try {
return x.toNumber()
return x.toNumber();
} catch (_) {
return x
return x;
}
}
return x
return x;
})(),
isPublic: this.isPublic,
isDecompressable: 'DecompressableState.' + DecompressableState[this.isDecompressable],
Expand All @@ -196,7 +185,7 @@ export class TreeConfig implements TreeConfigArgs {
export const treeConfigBeet = new beet.BeetStruct<
TreeConfig,
TreeConfigArgs & {
accountDiscriminator: number[] /* size: 8 */
accountDiscriminator: number[] /* size: 8 */;
}
>(
[
Expand All @@ -209,5 +198,5 @@ export const treeConfigBeet = new beet.BeetStruct<
['isDecompressable', decompressableStateBeet],
],
TreeConfig.fromArgs,
'TreeConfig'
)
'TreeConfig',
);
69 changes: 29 additions & 40 deletions clients/js-solita/src/generated/accounts/Voucher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
* See: https://github.com/metaplex-foundation/solita
*/

import * as web3 from '@solana/web3.js'
import * as beet from '@metaplex-foundation/beet'
import * as beetSolana from '@metaplex-foundation/beet-solana'
import { LeafSchema, leafSchemaBeet } from '../types/LeafSchema'
import * as web3 from '@solana/web3.js';
import * as beet from '@metaplex-foundation/beet';
import * as beetSolana from '@metaplex-foundation/beet-solana';
import { LeafSchema, leafSchemaBeet } from '../types/LeafSchema';

/**
* Arguments used to create {@link Voucher}
* @category Accounts
* @category generated
*/
export type VoucherArgs = {
leafSchema: LeafSchema
index: number
merkleTree: web3.PublicKey
}
leafSchema: LeafSchema;
index: number;
merkleTree: web3.PublicKey;
};

export const voucherDiscriminator = [191, 204, 149, 234, 213, 165, 13, 65]
export const voucherDiscriminator = [191, 204, 149, 234, 213, 165, 13, 65];
/**
* Holds the data for the {@link Voucher} Account and provides de/serialization
* functionality for that data
Expand All @@ -33,25 +33,22 @@ export class Voucher implements VoucherArgs {
private constructor(
readonly leafSchema: LeafSchema,
readonly index: number,
readonly merkleTree: web3.PublicKey
readonly merkleTree: web3.PublicKey,
) {}

/**
* Creates a {@link Voucher} instance from the provided args.
*/
static fromArgs(args: VoucherArgs) {
return new Voucher(args.leafSchema, args.index, args.merkleTree)
return new Voucher(args.leafSchema, args.index, args.merkleTree);
}

/**
* Deserializes the {@link Voucher} from the data of the provided {@link web3.AccountInfo}.
* @returns a tuple of the account data and the offset up to which the buffer was read to obtain it.
*/
static fromAccountInfo(
accountInfo: web3.AccountInfo<Buffer>,
offset = 0
): [Voucher, number] {
return Voucher.deserialize(accountInfo.data, offset)
static fromAccountInfo(accountInfo: web3.AccountInfo<Buffer>, offset = 0): [Voucher, number] {
return Voucher.deserialize(accountInfo.data, offset);
}

/**
Expand All @@ -63,16 +60,13 @@ export class Voucher implements VoucherArgs {
static async fromAccountAddress(
connection: web3.Connection,
address: web3.PublicKey,
commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig
commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig,
): Promise<Voucher> {
const accountInfo = await connection.getAccountInfo(
address,
commitmentOrConfig
)
const accountInfo = await connection.getAccountInfo(address, commitmentOrConfig);
if (accountInfo == null) {
throw new Error(`Unable to find Voucher account at ${address}`)
throw new Error(`Unable to find Voucher account at ${address}`);
}
return Voucher.fromAccountInfo(accountInfo, 0)[0]
return Voucher.fromAccountInfo(accountInfo, 0)[0];
}

/**
Expand All @@ -82,19 +76,17 @@ export class Voucher implements VoucherArgs {
* @param programId - the program that owns the accounts we are filtering
*/
static gpaBuilder(
programId: web3.PublicKey = new web3.PublicKey(
'BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY'
)
programId: web3.PublicKey = new web3.PublicKey('BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY'),
) {
return beetSolana.GpaBuilder.fromStruct(programId, voucherBeet)
return beetSolana.GpaBuilder.fromStruct(programId, voucherBeet);
}

/**
* Deserializes the {@link Voucher} from the provided data Buffer.
* @returns a tuple of the account data and the offset up to which the buffer was read to obtain it.
*/
static deserialize(buf: Buffer, offset = 0): [Voucher, number] {
return voucherBeet.deserialize(buf, offset)
return voucherBeet.deserialize(buf, offset);
}

/**
Expand All @@ -105,7 +97,7 @@ export class Voucher implements VoucherArgs {
return voucherBeet.serialize({
accountDiscriminator: voucherDiscriminator,
...this,
})
});
}

/**
Expand All @@ -116,11 +108,11 @@ export class Voucher implements VoucherArgs {
* depends on them
*/
static byteSize(args: VoucherArgs) {
const instance = Voucher.fromArgs(args)
const instance = Voucher.fromArgs(args);
return voucherBeet.toFixedFromValue({
accountDiscriminator: voucherDiscriminator,
...instance,
}).byteSize
}).byteSize;
}

/**
Expand All @@ -134,12 +126,9 @@ export class Voucher implements VoucherArgs {
static async getMinimumBalanceForRentExemption(
args: VoucherArgs,
connection: web3.Connection,
commitment?: web3.Commitment
commitment?: web3.Commitment,
): Promise<number> {
return connection.getMinimumBalanceForRentExemption(
Voucher.byteSize(args),
commitment
)
return connection.getMinimumBalanceForRentExemption(Voucher.byteSize(args), commitment);
}

/**
Expand All @@ -151,7 +140,7 @@ export class Voucher implements VoucherArgs {
leafSchema: this.leafSchema.__kind,
index: this.index,
merkleTree: this.merkleTree.toBase58(),
}
};
}
}

Expand All @@ -162,7 +151,7 @@ export class Voucher implements VoucherArgs {
export const voucherBeet = new beet.FixableBeetStruct<
Voucher,
VoucherArgs & {
accountDiscriminator: number[] /* size: 8 */
accountDiscriminator: number[] /* size: 8 */;
}
>(
[
Expand All @@ -172,5 +161,5 @@ export const voucherBeet = new beet.FixableBeetStruct<
['merkleTree', beetSolana.publicKey],
],
Voucher.fromArgs,
'Voucher'
)
'Voucher',
);
10 changes: 5 additions & 5 deletions clients/js-solita/src/generated/accounts/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './TreeConfig'
export * from './Voucher'
export * from './TreeConfig';
export * from './Voucher';

import { TreeConfig } from './TreeConfig'
import { Voucher } from './Voucher'
import { TreeConfig } from './TreeConfig';
import { Voucher } from './Voucher';

export const accountProviders = { TreeConfig, Voucher }
export const accountProviders = { TreeConfig, Voucher };
Loading

0 comments on commit c8864df

Please sign in to comment.