generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renaming and switching to straight bytes.
- Loading branch information
1 parent
d58698d
commit 542444a
Showing
75 changed files
with
1,303 additions
and
1,526 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
CARGO_TERM_COLOR=always | ||
NODE_VERSION=16.x | ||
PROGRAMS=["mpl-json"] | ||
PROGRAMS=["mpl-inscription"] | ||
RUST_VERSION=1.70.0 | ||
SOLANA_VERSION=1.16.18 |
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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"rust-analyzer.linkedProjects": [ | ||
"./programs/mpl-json/Cargo.toml", | ||
"./programs/mpl-inscription/Cargo.toml", | ||
] | ||
} |
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
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
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
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
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
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
201 changes: 201 additions & 0 deletions
201
clients/js/src/generated/accounts/inscriptionMetadata.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,201 @@ | ||
/** | ||
* 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 { | ||
Account, | ||
Context, | ||
Option, | ||
OptionOrNullable, | ||
Pda, | ||
PublicKey, | ||
RpcAccount, | ||
RpcGetAccountOptions, | ||
RpcGetAccountsOptions, | ||
assertAccountExists, | ||
deserializeAccount, | ||
gpaBuilder, | ||
publicKey as toPublicKey, | ||
} from '@metaplex-foundation/umi'; | ||
import { | ||
Serializer, | ||
array, | ||
option, | ||
publicKey as publicKeySerializer, | ||
string, | ||
struct, | ||
u64, | ||
u8, | ||
} from '@metaplex-foundation/umi/serializers'; | ||
import { Key, KeyArgs, getKeySerializer } from '../types'; | ||
|
||
export type InscriptionMetadata = Account<InscriptionMetadataAccountData>; | ||
|
||
export type InscriptionMetadataAccountData = { | ||
key: Key; | ||
bump: number; | ||
inscriptionNumber: Option<bigint>; | ||
updateAuthorities: Array<PublicKey>; | ||
}; | ||
|
||
export type InscriptionMetadataAccountDataArgs = { | ||
key: KeyArgs; | ||
bump: number; | ||
inscriptionNumber: OptionOrNullable<number | bigint>; | ||
updateAuthorities: Array<PublicKey>; | ||
}; | ||
|
||
export function getInscriptionMetadataAccountDataSerializer(): Serializer< | ||
InscriptionMetadataAccountDataArgs, | ||
InscriptionMetadataAccountData | ||
> { | ||
return struct<InscriptionMetadataAccountData>( | ||
[ | ||
['key', getKeySerializer()], | ||
['bump', u8()], | ||
['inscriptionNumber', option(u64())], | ||
['updateAuthorities', array(publicKeySerializer())], | ||
], | ||
{ description: 'InscriptionMetadataAccountData' } | ||
) as Serializer< | ||
InscriptionMetadataAccountDataArgs, | ||
InscriptionMetadataAccountData | ||
>; | ||
} | ||
|
||
export function deserializeInscriptionMetadata( | ||
rawAccount: RpcAccount | ||
): InscriptionMetadata { | ||
return deserializeAccount( | ||
rawAccount, | ||
getInscriptionMetadataAccountDataSerializer() | ||
); | ||
} | ||
|
||
export async function fetchInscriptionMetadata( | ||
context: Pick<Context, 'rpc'>, | ||
publicKey: PublicKey | Pda, | ||
options?: RpcGetAccountOptions | ||
): Promise<InscriptionMetadata> { | ||
const maybeAccount = await context.rpc.getAccount( | ||
toPublicKey(publicKey, false), | ||
options | ||
); | ||
assertAccountExists(maybeAccount, 'InscriptionMetadata'); | ||
return deserializeInscriptionMetadata(maybeAccount); | ||
} | ||
|
||
export async function safeFetchInscriptionMetadata( | ||
context: Pick<Context, 'rpc'>, | ||
publicKey: PublicKey | Pda, | ||
options?: RpcGetAccountOptions | ||
): Promise<InscriptionMetadata | null> { | ||
const maybeAccount = await context.rpc.getAccount( | ||
toPublicKey(publicKey, false), | ||
options | ||
); | ||
return maybeAccount.exists | ||
? deserializeInscriptionMetadata(maybeAccount) | ||
: null; | ||
} | ||
|
||
export async function fetchAllInscriptionMetadata( | ||
context: Pick<Context, 'rpc'>, | ||
publicKeys: Array<PublicKey | Pda>, | ||
options?: RpcGetAccountsOptions | ||
): Promise<InscriptionMetadata[]> { | ||
const maybeAccounts = await context.rpc.getAccounts( | ||
publicKeys.map((key) => toPublicKey(key, false)), | ||
options | ||
); | ||
return maybeAccounts.map((maybeAccount) => { | ||
assertAccountExists(maybeAccount, 'InscriptionMetadata'); | ||
return deserializeInscriptionMetadata(maybeAccount); | ||
}); | ||
} | ||
|
||
export async function safeFetchAllInscriptionMetadata( | ||
context: Pick<Context, 'rpc'>, | ||
publicKeys: Array<PublicKey | Pda>, | ||
options?: RpcGetAccountsOptions | ||
): Promise<InscriptionMetadata[]> { | ||
const maybeAccounts = await context.rpc.getAccounts( | ||
publicKeys.map((key) => toPublicKey(key, false)), | ||
options | ||
); | ||
return maybeAccounts | ||
.filter((maybeAccount) => maybeAccount.exists) | ||
.map((maybeAccount) => | ||
deserializeInscriptionMetadata(maybeAccount as RpcAccount) | ||
); | ||
} | ||
|
||
export function getInscriptionMetadataGpaBuilder( | ||
context: Pick<Context, 'rpc' | 'programs'> | ||
) { | ||
const programId = context.programs.getPublicKey( | ||
'mplInscription', | ||
'JSoNoHBzUEFnjpZtcNcNzv5KLzo4tD5v4Z1pT9G4jJa' | ||
); | ||
return gpaBuilder(context, programId) | ||
.registerFields<{ | ||
key: KeyArgs; | ||
bump: number; | ||
inscriptionNumber: OptionOrNullable<number | bigint>; | ||
updateAuthorities: Array<PublicKey>; | ||
}>({ | ||
key: [0, getKeySerializer()], | ||
bump: [1, u8()], | ||
inscriptionNumber: [2, option(u64())], | ||
updateAuthorities: [null, array(publicKeySerializer())], | ||
}) | ||
.deserializeUsing<InscriptionMetadata>((account) => | ||
deserializeInscriptionMetadata(account) | ||
); | ||
} | ||
|
||
export function findInscriptionMetadataPda( | ||
context: Pick<Context, 'eddsa' | 'programs'>, | ||
seeds: { | ||
/** The address of the Inscription Account */ | ||
inscriptionAccount: PublicKey; | ||
} | ||
): Pda { | ||
const programId = context.programs.getPublicKey( | ||
'mplInscription', | ||
'JSoNoHBzUEFnjpZtcNcNzv5KLzo4tD5v4Z1pT9G4jJa' | ||
); | ||
return context.eddsa.findPda(programId, [ | ||
string({ size: 'variable' }).serialize('Inscription'), | ||
publicKeySerializer().serialize(programId), | ||
publicKeySerializer().serialize(seeds.inscriptionAccount), | ||
]); | ||
} | ||
|
||
export async function fetchInscriptionMetadataFromSeeds( | ||
context: Pick<Context, 'eddsa' | 'programs' | 'rpc'>, | ||
seeds: Parameters<typeof findInscriptionMetadataPda>[1], | ||
options?: RpcGetAccountOptions | ||
): Promise<InscriptionMetadata> { | ||
return fetchInscriptionMetadata( | ||
context, | ||
findInscriptionMetadataPda(context, seeds), | ||
options | ||
); | ||
} | ||
|
||
export async function safeFetchInscriptionMetadataFromSeeds( | ||
context: Pick<Context, 'eddsa' | 'programs' | 'rpc'>, | ||
seeds: Parameters<typeof findInscriptionMetadataPda>[1], | ||
options?: RpcGetAccountOptions | ||
): Promise<InscriptionMetadata | null> { | ||
return safeFetchInscriptionMetadata( | ||
context, | ||
findInscriptionMetadataPda(context, seeds), | ||
options | ||
); | ||
} |
Oops, something went wrong.