mirror of https://github.com/certusone/oyster.git
Added type keys and using a non grinded address for now to verify it works
This commit is contained in:
parent
90644ea681
commit
6ec255758d
|
@ -28,6 +28,9 @@ export const MAX_METADATA_LEN =
|
|||
|
||||
export const MAX_OWNER_LEN = 32 + 32;
|
||||
|
||||
export const METADATA_KEY = 0;
|
||||
export const NAME_SYMBOL_KEY = 1;
|
||||
|
||||
export function ensureSplAccount(
|
||||
instructions: TransactionInstruction[],
|
||||
cleanupInstructions: TransactionInstruction[],
|
||||
|
@ -218,6 +221,7 @@ class UpdateMetadataArgs {
|
|||
}
|
||||
|
||||
export class Metadata {
|
||||
key: number;
|
||||
updateAuthority?: PublicKey;
|
||||
mint: PublicKey;
|
||||
name: string;
|
||||
|
@ -232,6 +236,7 @@ export class Metadata {
|
|||
symbol: string;
|
||||
uri: string;
|
||||
}) {
|
||||
this.key = METADATA_KEY;
|
||||
this.updateAuthority =
|
||||
args.updateAuthority && new PublicKey(args.updateAuthority);
|
||||
this.mint = new PublicKey(args.mint);
|
||||
|
@ -242,10 +247,12 @@ export class Metadata {
|
|||
}
|
||||
|
||||
export class NameSymbolTuple {
|
||||
key: number;
|
||||
updateAuthority: PublicKey;
|
||||
metadata: PublicKey;
|
||||
|
||||
constructor(args: { updateAuthority: Buffer; metadata: Buffer }) {
|
||||
this.key = NAME_SYMBOL_KEY;
|
||||
this.updateAuthority = new PublicKey(args.updateAuthority);
|
||||
this.metadata = new PublicKey(args.metadata);
|
||||
}
|
||||
|
@ -281,6 +288,7 @@ export const SCHEMA = new Map<any, any>([
|
|||
{
|
||||
kind: 'struct',
|
||||
fields: [
|
||||
['key', 'u8'],
|
||||
['allow_duplicates', { kind: 'option', type: 'u8' }],
|
||||
['mint', [32]],
|
||||
['name', 'string'],
|
||||
|
@ -294,6 +302,7 @@ export const SCHEMA = new Map<any, any>([
|
|||
{
|
||||
kind: 'struct',
|
||||
fields: [
|
||||
['key', 'u8'],
|
||||
['update_authority', [32]],
|
||||
['metadata', [32]],
|
||||
],
|
||||
|
|
|
@ -19,7 +19,7 @@ export let BPF_UPGRADE_LOADER_ID = new PublicKey(
|
|||
'BPFLoaderUpgradeab1e11111111111111111111111',
|
||||
);
|
||||
export let METADATA_PROGRAM_ID = new PublicKey(
|
||||
'meta75ZHbozdG3sYzM6PdN7PNK6w9PgsAEEjVYKoAKr',
|
||||
'55tJbVhaDZTj7Fm5BUboKRJUD7SwZkMjvKzXfkU1HB7i',
|
||||
);
|
||||
|
||||
export const MEMO_ID = new PublicKey(
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
cache,
|
||||
MintParser,
|
||||
ParsedAccount,
|
||||
METADATA_KEY,
|
||||
} from '@oyster/common';
|
||||
import { MintInfo } from '@solana/spl-token';
|
||||
import BN from 'bn.js';
|
||||
|
@ -36,14 +37,12 @@ export function VinciAccountsProvider({ children = null as any }) {
|
|||
const extendedMetadataFetch = new Map<string, Promise<any>>();
|
||||
|
||||
metadataAccounts.forEach(meta => {
|
||||
try {
|
||||
if (meta.account.data[0] == METADATA_KEY) {
|
||||
const metadata = decodeMetadata(meta.account.data);
|
||||
console.log('metadata', metadata);
|
||||
if (isValidHttpUrl(metadata.uri)) {
|
||||
mintToMetadata.set(metadata.mint.toBase58(), metadata);
|
||||
}
|
||||
} catch {
|
||||
// ignore errors
|
||||
// add type as first byte for easier deserialization
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue