generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Spl Account Compression and Spl Noop to Umi library
- Loading branch information
1 parent
25200a5
commit e227b1c
Showing
30 changed files
with
2,539 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
*/ | ||
|
||
export * from './mplBubblegum'; | ||
export * from './splAccountCompression'; | ||
export * from './splNoop'; |
182 changes: 182 additions & 0 deletions
182
clients/js/src/generated/errors/splAccountCompression.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
/** | ||
* This code was AUTOGENERATED using the kinobi library. | ||
* Please DO NOT EDIT THIS FILE, instead use visitors | ||
* to add features, then rerun kinobi to update it. | ||
* | ||
* @see https://github.com/metaplex-foundation/kinobi | ||
*/ | ||
|
||
import { Program, ProgramError } from '@metaplex-foundation/umi'; | ||
|
||
type ProgramErrorConstructor = new ( | ||
program: Program, | ||
cause?: Error | ||
) => ProgramError; | ||
const codeToErrorMap: Map<number, ProgramErrorConstructor> = new Map(); | ||
const nameToErrorMap: Map<string, ProgramErrorConstructor> = new Map(); | ||
|
||
/** IncorrectLeafLength: Incorrect leaf length. Expected vec of 32 bytes */ | ||
export class IncorrectLeafLengthError extends ProgramError { | ||
readonly name: string = 'IncorrectLeafLength'; | ||
|
||
readonly code: number = 0x1770; // 6000 | ||
|
||
constructor(program: Program, cause?: Error) { | ||
super('Incorrect leaf length. Expected vec of 32 bytes', program, cause); | ||
} | ||
} | ||
codeToErrorMap.set(0x1770, IncorrectLeafLengthError); | ||
nameToErrorMap.set('IncorrectLeafLength', IncorrectLeafLengthError); | ||
|
||
/** ConcurrentMerkleTreeError: Concurrent merkle tree error */ | ||
export class ConcurrentMerkleTreeErrorError extends ProgramError { | ||
readonly name: string = 'ConcurrentMerkleTreeError'; | ||
|
||
readonly code: number = 0x1771; // 6001 | ||
|
||
constructor(program: Program, cause?: Error) { | ||
super('Concurrent merkle tree error', program, cause); | ||
} | ||
} | ||
codeToErrorMap.set(0x1771, ConcurrentMerkleTreeErrorError); | ||
nameToErrorMap.set('ConcurrentMerkleTreeError', ConcurrentMerkleTreeErrorError); | ||
|
||
/** ZeroCopyError: Issue zero copying concurrent merkle tree data */ | ||
export class ZeroCopyErrorError extends ProgramError { | ||
readonly name: string = 'ZeroCopyError'; | ||
|
||
readonly code: number = 0x1772; // 6002 | ||
|
||
constructor(program: Program, cause?: Error) { | ||
super('Issue zero copying concurrent merkle tree data', program, cause); | ||
} | ||
} | ||
codeToErrorMap.set(0x1772, ZeroCopyErrorError); | ||
nameToErrorMap.set('ZeroCopyError', ZeroCopyErrorError); | ||
|
||
/** ConcurrentMerkleTreeConstantsError: An unsupported max depth or max buffer size constant was provided */ | ||
export class ConcurrentMerkleTreeConstantsErrorError extends ProgramError { | ||
readonly name: string = 'ConcurrentMerkleTreeConstantsError'; | ||
|
||
readonly code: number = 0x1773; // 6003 | ||
|
||
constructor(program: Program, cause?: Error) { | ||
super( | ||
'An unsupported max depth or max buffer size constant was provided', | ||
program, | ||
cause | ||
); | ||
} | ||
} | ||
codeToErrorMap.set(0x1773, ConcurrentMerkleTreeConstantsErrorError); | ||
nameToErrorMap.set( | ||
'ConcurrentMerkleTreeConstantsError', | ||
ConcurrentMerkleTreeConstantsErrorError | ||
); | ||
|
||
/** CanopyLengthMismatch: Expected a different byte length for the merkle tree canopy */ | ||
export class CanopyLengthMismatchError extends ProgramError { | ||
readonly name: string = 'CanopyLengthMismatch'; | ||
|
||
readonly code: number = 0x1774; // 6004 | ||
|
||
constructor(program: Program, cause?: Error) { | ||
super( | ||
'Expected a different byte length for the merkle tree canopy', | ||
program, | ||
cause | ||
); | ||
} | ||
} | ||
codeToErrorMap.set(0x1774, CanopyLengthMismatchError); | ||
nameToErrorMap.set('CanopyLengthMismatch', CanopyLengthMismatchError); | ||
|
||
/** IncorrectAuthority: Provided authority does not match expected tree authority */ | ||
export class IncorrectAuthorityError extends ProgramError { | ||
readonly name: string = 'IncorrectAuthority'; | ||
|
||
readonly code: number = 0x1775; // 6005 | ||
|
||
constructor(program: Program, cause?: Error) { | ||
super( | ||
'Provided authority does not match expected tree authority', | ||
program, | ||
cause | ||
); | ||
} | ||
} | ||
codeToErrorMap.set(0x1775, IncorrectAuthorityError); | ||
nameToErrorMap.set('IncorrectAuthority', IncorrectAuthorityError); | ||
|
||
/** IncorrectAccountOwner: Account is owned by a different program, expected it to be owned by this program */ | ||
export class IncorrectAccountOwnerError extends ProgramError { | ||
readonly name: string = 'IncorrectAccountOwner'; | ||
|
||
readonly code: number = 0x1776; // 6006 | ||
|
||
constructor(program: Program, cause?: Error) { | ||
super( | ||
'Account is owned by a different program, expected it to be owned by this program', | ||
program, | ||
cause | ||
); | ||
} | ||
} | ||
codeToErrorMap.set(0x1776, IncorrectAccountOwnerError); | ||
nameToErrorMap.set('IncorrectAccountOwner', IncorrectAccountOwnerError); | ||
|
||
/** IncorrectAccountType: Account provided has incorrect account type */ | ||
export class IncorrectAccountTypeError extends ProgramError { | ||
readonly name: string = 'IncorrectAccountType'; | ||
|
||
readonly code: number = 0x1777; // 6007 | ||
|
||
constructor(program: Program, cause?: Error) { | ||
super('Account provided has incorrect account type', program, cause); | ||
} | ||
} | ||
codeToErrorMap.set(0x1777, IncorrectAccountTypeError); | ||
nameToErrorMap.set('IncorrectAccountType', IncorrectAccountTypeError); | ||
|
||
/** LeafIndexOutOfBounds: Leaf index of concurrent merkle tree is out of bounds */ | ||
export class LeafIndexOutOfBoundsError extends ProgramError { | ||
readonly name: string = 'LeafIndexOutOfBounds'; | ||
|
||
readonly code: number = 0x1778; // 6008 | ||
|
||
constructor(program: Program, cause?: Error) { | ||
super( | ||
'Leaf index of concurrent merkle tree is out of bounds', | ||
program, | ||
cause | ||
); | ||
} | ||
} | ||
codeToErrorMap.set(0x1778, LeafIndexOutOfBoundsError); | ||
nameToErrorMap.set('LeafIndexOutOfBounds', LeafIndexOutOfBoundsError); | ||
|
||
/** | ||
* Attempts to resolve a custom program error from the provided error code. | ||
* @category Errors | ||
*/ | ||
export function getSplAccountCompressionErrorFromCode( | ||
code: number, | ||
program: Program, | ||
cause?: Error | ||
): ProgramError | null { | ||
const constructor = codeToErrorMap.get(code); | ||
return constructor ? new constructor(program, cause) : null; | ||
} | ||
|
||
/** | ||
* Attempts to resolve a custom program error from the provided error name, i.e. 'Unauthorized'. | ||
* @category Errors | ||
*/ | ||
export function getSplAccountCompressionErrorFromName( | ||
name: string, | ||
program: Program, | ||
cause?: Error | ||
): ProgramError | null { | ||
const constructor = nameToErrorMap.get(name); | ||
return constructor ? new constructor(program, cause) : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* This code was AUTOGENERATED using the kinobi library. | ||
* Please DO NOT EDIT THIS FILE, instead use visitors | ||
* to add features, then rerun kinobi to update it. | ||
* | ||
* @see https://github.com/metaplex-foundation/kinobi | ||
*/ | ||
|
||
import { Program, ProgramError } from '@metaplex-foundation/umi'; | ||
|
||
type ProgramErrorConstructor = new ( | ||
program: Program, | ||
cause?: Error | ||
) => ProgramError; | ||
const codeToErrorMap: Map<number, ProgramErrorConstructor> = new Map(); | ||
const nameToErrorMap: Map<string, ProgramErrorConstructor> = new Map(); | ||
|
||
/** | ||
* Attempts to resolve a custom program error from the provided error code. | ||
* @category Errors | ||
*/ | ||
export function getSplNoopErrorFromCode( | ||
code: number, | ||
program: Program, | ||
cause?: Error | ||
): ProgramError | null { | ||
const constructor = codeToErrorMap.get(code); | ||
return constructor ? new constructor(program, cause) : null; | ||
} | ||
|
||
/** | ||
* Attempts to resolve a custom program error from the provided error name, i.e. 'Unauthorized'. | ||
* @category Errors | ||
*/ | ||
export function getSplNoopErrorFromName( | ||
name: string, | ||
program: Program, | ||
cause?: Error | ||
): ProgramError | null { | ||
const constructor = nameToErrorMap.get(name); | ||
return constructor ? new constructor(program, cause) : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/** | ||
* This code was AUTOGENERATED using the kinobi library. | ||
* Please DO NOT EDIT THIS FILE, instead use visitors | ||
* to add features, then rerun kinobi to update it. | ||
* | ||
* @see https://github.com/metaplex-foundation/kinobi | ||
*/ | ||
|
||
import { | ||
AccountMeta, | ||
Context, | ||
PublicKey, | ||
Serializer, | ||
Signer, | ||
TransactionBuilder, | ||
mapSerializer, | ||
transactionBuilder, | ||
} from '@metaplex-foundation/umi'; | ||
import { addObjectProperty, isWritable } from '../shared'; | ||
|
||
// Accounts. | ||
export type AppendInstructionAccounts = { | ||
merkleTree: PublicKey; | ||
authority?: Signer; | ||
noop: PublicKey; | ||
}; | ||
|
||
// Data. | ||
export type AppendInstructionData = { | ||
discriminator: Array<number>; | ||
leaf: Uint8Array; | ||
}; | ||
|
||
export type AppendInstructionDataArgs = { leaf: Uint8Array }; | ||
|
||
export function getAppendInstructionDataSerializer( | ||
context: Pick<Context, 'serializer'> | ||
): Serializer<AppendInstructionDataArgs, AppendInstructionData> { | ||
const s = context.serializer; | ||
return mapSerializer<AppendInstructionDataArgs, any, AppendInstructionData>( | ||
s.struct<AppendInstructionData>( | ||
[ | ||
['discriminator', s.array(s.u8(), { size: 8 })], | ||
['leaf', s.bytes({ size: 32 })], | ||
], | ||
{ description: 'AppendInstructionData' } | ||
), | ||
(value) => ({ | ||
...value, | ||
discriminator: [149, 120, 18, 222, 236, 225, 88, 203], | ||
}) | ||
) as Serializer<AppendInstructionDataArgs, AppendInstructionData>; | ||
} | ||
|
||
// Args. | ||
export type AppendInstructionArgs = AppendInstructionDataArgs; | ||
|
||
// Instruction. | ||
export function append( | ||
context: Pick<Context, 'serializer' | 'programs' | 'identity'>, | ||
input: AppendInstructionAccounts & AppendInstructionArgs | ||
): TransactionBuilder { | ||
const signers: Signer[] = []; | ||
const keys: AccountMeta[] = []; | ||
|
||
// Program ID. | ||
const programId = { | ||
...context.programs.getPublicKey( | ||
'splAccountCompression', | ||
'cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK' | ||
), | ||
isWritable: false, | ||
}; | ||
|
||
// Resolved inputs. | ||
const resolvingAccounts = {}; | ||
const resolvingArgs = {}; | ||
addObjectProperty( | ||
resolvingAccounts, | ||
'authority', | ||
input.authority ?? context.identity | ||
); | ||
const resolvedAccounts = { ...input, ...resolvingAccounts }; | ||
const resolvedArgs = { ...input, ...resolvingArgs }; | ||
|
||
// Merkle Tree. | ||
keys.push({ | ||
pubkey: resolvedAccounts.merkleTree, | ||
isSigner: false, | ||
isWritable: isWritable(resolvedAccounts.merkleTree, true), | ||
}); | ||
|
||
// Authority. | ||
signers.push(resolvedAccounts.authority); | ||
keys.push({ | ||
pubkey: resolvedAccounts.authority.publicKey, | ||
isSigner: true, | ||
isWritable: isWritable(resolvedAccounts.authority, false), | ||
}); | ||
|
||
// Noop. | ||
keys.push({ | ||
pubkey: resolvedAccounts.noop, | ||
isSigner: false, | ||
isWritable: isWritable(resolvedAccounts.noop, false), | ||
}); | ||
|
||
// Data. | ||
const data = | ||
getAppendInstructionDataSerializer(context).serialize(resolvedArgs); | ||
|
||
// Bytes Created On Chain. | ||
const bytesCreatedOnChain = 0; | ||
|
||
return transactionBuilder([ | ||
{ instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, | ||
]); | ||
} |
Oops, something went wrong.