UNPKG

@exodus/solana-web3.js

Version:
91 lines (90 loc) 2.95 kB
/// <reference types="node" /> import { Buffer } from 'buffer'; import { Struct } from './utils/borsh-schema.js'; /** * Maximum length of derived pubkey seed */ export declare const MAX_SEED_LENGTH = 32; /** * Size of public key in bytes */ export declare const PUBLIC_KEY_LENGTH = 32; /** * Value to be converted into public key */ export declare type PublicKeyInitData = number | string | Uint8Array | Array<number> | PublicKeyData; /** * JSON object representation of PublicKey class */ export declare type PublicKeyData = {}; /** * A public key */ export declare class PublicKey extends Struct { /** * Create a new PublicKey object * @param value ed25519 public key as buffer or base-58 encoded string */ constructor(value: PublicKeyInitData); /** * Returns a unique PublicKey for tests and benchmarks using acounter */ static unique(): PublicKey; /** * Default public key value. (All zeros) */ static default: PublicKey; /** * Checks if two publicKeys are equal */ equals(publicKey: PublicKey): boolean; /** * Return the base-58 representation of the public key */ toBase58(): string; toJSON(): string; /** * Return the byte array representation of the public key */ toBytes(): Uint8Array; /** * Return the Buffer representation of the public key */ toBuffer(): Buffer; /** * Return the base-58 representation of the public key */ toString(): string; /** * Derive a public key from another key, a seed, and a program ID. * The program ID will also serve as the owner of the public key, giving * it permission to write data to the account. */ static createWithSeed(fromPublicKey: PublicKey, seed: string, programId: PublicKey): Promise<PublicKey>; /** * Derive a program address from seeds and a program ID. */ static createProgramAddressSync(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): PublicKey; /** * Async version of createProgramAddressSync * For backwards compatibility */ static createProgramAddress(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): Promise<PublicKey>; /** * Find a valid program address * * Valid program addresses must fall off the ed25519 curve. This function * iterates a nonce until it finds one that when combined with the seeds * results in a valid program address. */ static findProgramAddressSync(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): [PublicKey, number]; /** * Async version of findProgramAddressSync * For backwards compatibility */ static findProgramAddress(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): Promise<[PublicKey, number]>; /** * Check that a pubkey is on the ed25519 curve. */ static isOnCurve(pubkeyData: PublicKeyInitData): boolean; }