solana/web3.js/module.flow.js

452 lines
12 KiB
JavaScript
Raw Normal View History

/**
* Flow Library definition for @solana/web3.js
*
* This file is manually generated from the contents of src/
*
* Usage: add the following line under the [libs] section of your project's
* .flowconfig:
* [libs]
* node_modules/@solana/web3.js/module.flow.js
*
*/
2018-10-16 13:51:04 -07:00
import BN from 'bn.js';
declare module '@solana/web3.js' {
2018-09-30 18:42:45 -07:00
// === src/publickey.js ===
declare export class PublicKey {
2019-09-29 10:12:01 -07:00
constructor(value: number | string | Buffer | Array<number>): PublicKey;
2018-09-30 18:42:45 -07:00
static isPublicKey(o: Object): boolean;
equals(publickey: PublicKey): boolean;
toBase58(): string;
toBuffer(): Buffer;
2019-09-29 10:12:01 -07:00
toString(): string;
2018-09-30 18:42:45 -07:00
}
2019-03-04 08:06:33 -08:00
// === src/blockhash.js ===
declare export type Blockhash = string;
// === src/account.js ===
declare export class Account {
constructor(secretKey: ?Buffer): Account;
publicKey: PublicKey;
2018-09-30 18:42:45 -07:00
secretKey: Buffer;
}
2019-06-12 14:36:05 -07:00
// === src/fee-calculator.js ===
declare export type FeeCalculator = {
burnPercent: number,
2019-06-12 14:36:05 -07:00
lamportsPerSignature: number,
maxLamportsPerSignature: number,
minLamportsPerSignature: number,
2019-06-12 14:36:05 -07:00
targetLamportsPerSignature: number,
targetSignaturesPerSlot: number,
2019-06-12 14:36:05 -07:00
};
// === src/budget-program.js ===
/* TODO */
// === src/connection.js ===
declare export type RpcResponseAndContext<T> = {
context: {
slot: number,
},
value: T,
};
declare export type Commitment = 'max' | 'recent';
2018-09-28 21:45:04 -07:00
declare export type AccountInfo = {
2018-11-04 11:41:21 -08:00
executable: boolean,
owner: PublicKey,
2019-03-05 17:52:13 -08:00
lamports: number,
2019-03-14 13:27:47 -07:00
data: Buffer,
2020-01-16 11:21:08 -08:00
rentEpoch: number | null,
2018-11-04 11:41:21 -08:00
};
declare export type ContactInfo = {
id: string,
gossip: string,
tpu: string | null,
rpc: string | null,
};
declare export type ConfirmedBlock = {
blockhash: Blockhash,
previousBlockhash: Blockhash,
parentSlot: number,
2020-01-16 11:21:08 -08:00
transactions: Array<{
transaction: Transaction,
meta: {
fee: number,
preBalances: Array<number>,
postBalances: Array<number>,
status: SignatureStatusResult,
},
}>,
};
declare export type KeyedAccountInfo = {
accountId: PublicKey,
accountInfo: AccountInfo,
};
2019-11-11 17:09:00 -08:00
declare export type Version = {
'solana-core': string,
};
2019-06-12 14:36:05 -07:00
declare export type VoteAccountInfo = {
votePubkey: string,
nodePubkey: string,
stake: number,
commission: number,
};
declare export type SlotInfo = {
parent: 'number',
slot: 'number',
root: 'number',
};
2018-10-26 21:37:39 -07:00
declare type AccountChangeCallback = (accountInfo: AccountInfo) => void;
2019-03-19 12:54:47 -07:00
declare type ProgramAccountChangeCallback = (
keyedAccountInfo: KeyedAccountInfo,
) => void;
declare type SlotChangeCallback = (slotInfo: SlotInfo) => void;
2018-10-26 21:37:39 -07:00
2019-04-10 14:40:49 -07:00
declare export type SignatureSuccess = {|
Ok: null,
|};
declare export type TransactionError = {|
Err: Object,
|};
2019-10-23 06:48:24 -07:00
declare export type Inflation = {
foundation: number,
2020-01-16 11:21:08 -08:00
foundationTerm: number,
2019-10-23 06:48:24 -07:00
initial: number,
storage: number,
taper: number,
terminal: number,
};
declare export type EpochSchedule = {
2020-01-16 11:21:08 -08:00
slotsPerEpoch: number,
leaderScheduleSlotOffset: number,
2019-10-23 06:48:24 -07:00
warmup: boolean,
2020-01-16 11:21:08 -08:00
firstNormalEpoch: number,
firstNormalSlot: number,
2019-10-23 06:48:24 -07:00
};
declare export class Connection {
constructor(endpoint: string, commitment: ?Commitment): Connection;
getAccountInfoAndContext(
publicKey: PublicKey,
commitment: ?Commitment,
): Promise<RpcResponseAndContext<AccountInfo>>;
getAccountInfo(
publicKey: PublicKey,
commitment: ?Commitment,
): Promise<AccountInfo>;
getProgramAccounts(
programId: PublicKey,
commitment: ?Commitment,
2020-01-16 11:21:08 -08:00
): Promise<Array<PublicKeyAndAccount>>;
getBalanceAndContext(
publicKey: PublicKey,
commitment: ?Commitment,
): Promise<RpcResponseAndContext<number>>;
getBalance(publicKey: PublicKey, commitment: ?Commitment): Promise<number>;
getClusterNodes(): Promise<Array<ContactInfo>>;
getConfirmedBlock(): Promise<ConfirmedBlock>;
getVoteAccounts(commitment: ?Commitment): Promise<VoteAccountStatus>;
confirmTransactionAndContext(
signature: TransactionSignature,
commitment: ?Commitment,
): Promise<RpcResponseAndContext<boolean>>;
confirmTransaction(
signature: TransactionSignature,
commitment: ?Commitment,
): Promise<boolean>;
getSlot(commitment: ?Commitment): Promise<number>;
getSlotLeader(commitment: ?Commitment): Promise<string>;
2018-11-04 11:41:21 -08:00
getSignatureStatus(
signature: TransactionSignature,
commitment: ?Commitment,
2019-04-10 14:40:49 -07:00
): Promise<SignatureSuccess | TransactionError | null>;
getTransactionCount(commitment: ?Commitment): Promise<number>;
getTotalSupply(commitment: ?Commitment): Promise<number>;
2019-11-11 17:09:00 -08:00
getVersion(): Promise<Version>;
getInflation(commitment: ?Commitment): Promise<Inflation>;
2019-10-23 06:48:24 -07:00
getEpochSchedule(): Promise<EpochSchedule>;
getRecentBlockhashAndContext(
commitment: ?Commitment,
2020-01-16 11:21:08 -08:00
): Promise<RpcResponseAndContext<BlockhashAndFeeCalculator>>;
getRecentBlockhash(
commitment: ?Commitment,
2020-01-16 11:21:08 -08:00
): Promise<BlockhashAndFeeCalculator>;
2018-11-04 11:41:21 -08:00
requestAirdrop(
to: PublicKey,
amount: number,
commitment: ?Commitment,
2018-11-04 11:41:21 -08:00
): Promise<TransactionSignature>;
sendTransaction(
transaction: Transaction,
...signers: Array<Account>
2018-11-04 11:41:21 -08:00
): Promise<TransactionSignature>;
sendRawTransaction(wireTransaction: Buffer): Promise<TransactionSignature>;
2018-11-04 11:41:21 -08:00
onAccountChange(
publickey: PublicKey,
callback: AccountChangeCallback,
): number;
removeAccountChangeListener(id: number): Promise<void>;
2019-03-08 16:02:39 -08:00
onProgramAccountChange(
programId: PublicKey,
callback: ProgramAccountChangeCallback,
): number;
onSlotChange(callback: SlotChangeCallback): number;
2019-03-08 16:02:39 -08:00
removeProgramAccountChangeListener(id: number): Promise<void>;
validatorExit(): Promise<boolean>;
getMinimumBalanceForRentExemption(
dataLength: number,
commitment: ?Commitment,
): Promise<number>;
}
// === src/stake-program.js ===
declare export class StakeProgram {
static programId: PublicKey;
static space: number;
static createAccount(
from: PublicKey,
stakeAccount: PublicKey,
authorized: Authorized,
lockup: Lockup,
lamports: number,
): Transaction;
static createAccountWithSeed(
from: PublicKey,
stakeAccount: PublicKey,
seed: string,
authorized: Authorized,
lockup: Lockup,
lamports: number,
): Transaction;
static delegate(
stakeAccount: PublicKey,
authorizedPubkey: PublicKey,
votePubkey: PublicKey,
): Transaction;
static authorize(
stakeAccount: PublicKey,
authorizedPubkey: PublicKey,
newAuthorized: PublicKey,
stakeAuthorizationType: StakeAuthorizationType,
): Transaction;
static redeemVoteCredits(
stakeAccount: PublicKey,
votePubkey: PublicKey,
): Transaction;
static split(
stakeAccount: PublicKey,
authorizedPubkey: PublicKey,
lamports: number,
splitStakePubkey: PublicKey,
): Transaction;
static withdraw(
stakeAccount: PublicKey,
withdrawerPubkey: PublicKey,
to: PublicKey,
lamports: number,
): Transaction;
static deactivate(
stakeAccount: PublicKey,
authorizedPubkey: PublicKey,
): Transaction;
}
// === src/system-program.js ===
declare export class SystemProgram {
static programId: PublicKey;
static createAccount(
from: PublicKey,
newAccount: PublicKey,
2019-03-05 17:52:13 -08:00
lamports: number,
space: number,
2018-11-04 11:41:21 -08:00
programId: PublicKey,
): Transaction;
static transfer(
from: PublicKey,
to: PublicKey,
amount: number,
): Transaction;
static assign(from: PublicKey, programId: PublicKey): Transaction;
static createAccountWithSeed(
from: PublicKey,
newAccount: PublicKey,
base: PublicKey,
seed: string,
lamports: number,
space: number,
programId: PublicKey,
): Transaction;
}
// === src/validator-info.js ===
2019-07-24 16:01:07 -07:00
declare export var VALIDATOR_INFO_KEY;
declare export type Info = {|
name: string,
website?: string,
details?: string,
keybaseUsername?: string,
|};
declare export class ValidatorInfo {
key: PublicKey;
info: Info;
constructor(key: PublicKey, info: Info): ValidatorInfo;
static fromConfigData(buffer: Buffer): ?ValidatorInfo;
}
// === src/sysvar.js ===
declare export var SYSVAR_CLOCK_PUBKEY;
declare export var SYSVAR_RENT_PUBKEY;
declare export var SYSVAR_REWARDS_PUBKEY;
declare export var SYSVAR_STAKE_HISTORY_PUBKEY;
2019-07-23 18:06:55 -07:00
// === src/vote-account.js ===
declare export var VOTE_PROGRAM_ID;
2019-07-23 18:06:55 -07:00
declare export type Lockout = {|
slot: number,
confirmationCount: number,
|};
declare export type EpochCredits = {|
epoch: number,
credits: number,
prevCredits: number,
|};
declare export class VoteAccount {
votes: Array<Lockout>;
nodePubkey: PublicKey;
authorizedVoterPubkey: PublicKey;
commission: number;
rootSlot: number | null;
epoch: number;
credits: number;
lastEpochCredits: number;
epochCredits: Array<EpochCredits>;
static fromAccountData(buffer: Buffer): VoteAccount;
}
// === src/instruction.js ===
declare export type InstructionType = {|
index: number,
layout: typeof BufferLayout,
|};
declare export function encodeData(
type: InstructionType,
fields: Object,
): Buffer;
// === src/transaction.js ===
2018-09-28 21:45:04 -07:00
declare export type TransactionSignature = string;
declare type TransactionInstructionCtorFields = {|
keys: ?Array<{pubkey: PublicKey, isSigner: boolean, isWritable: boolean}>,
2018-11-04 11:41:21 -08:00
programId?: PublicKey,
2019-03-14 13:27:47 -07:00
data?: Buffer,
|};
declare export class TransactionInstruction {
keys: Array<{pubkey: PublicKey, isSigner: boolean, isWritable: boolean}>;
programId: PublicKey;
2019-03-14 13:27:47 -07:00
data: Buffer;
constructor(
opts?: TransactionInstructionCtorFields,
): TransactionInstruction;
}
declare type SignaturePubkeyPair = {|
signature: Buffer | null,
publicKey: PublicKey,
|};
declare type TransactionCtorFields = {|
2019-03-04 08:06:33 -08:00
recentBlockhash?: Blockhash,
signatures?: Array<SignaturePubkeyPair>,
|};
declare export class Transaction {
2018-11-28 12:19:08 -08:00
signatures: Array<SignaturePubkeyPair>;
signature: ?Buffer;
instructions: Array<TransactionInstruction>;
2019-03-04 08:06:33 -08:00
recentBlockhash: ?Blockhash;
constructor(opts?: TransactionCtorFields): Transaction;
2018-11-04 11:41:21 -08:00
add(
...items: Array<
Transaction | TransactionInstruction | TransactionInstructionCtorFields,
>
2018-11-04 11:41:21 -08:00
): Transaction;
sign(...signers: Array<Account>): void;
signPartial(...partialSigners: Array<PublicKey | Account>): void;
addSigner(signer: Account): void;
serialize(): Buffer;
}
2018-10-06 11:23:18 -07:00
// === src/loader.js ===
declare export class Loader {
2019-10-22 16:10:21 -07:00
static getMinNumSignatures(dataLength: number): number;
static load(
connection: Connection,
payer: Account,
program: Account,
programId: PublicKey,
data: Array<number>,
): Promise<PublicKey>;
}
2018-10-30 08:00:11 -07:00
// === src/bpf-loader.js ===
declare export class BpfLoader {
static programId: PublicKey;
2019-10-22 16:10:21 -07:00
static getMinNumSignatures(dataLength: number): number;
2018-10-30 08:00:11 -07:00
static load(
connection: Connection,
payer: Account,
2018-10-30 08:00:11 -07:00
elfBytes: Array<number>,
): Promise<PublicKey>;
}
// === src/util/send-and-confirm-transaction.js ===
declare export function sendAndConfirmTransaction(
connection: Connection,
transaction: Transaction,
...signers: Array<Account>
): Promise<TransactionSignature>;
declare export function sendAndConfirmRecentTransaction(
connection: Connection,
transaction: Transaction,
...signers: Array<Account>
): Promise<TransactionSignature>;
// === src/util/send-and-confirm-raw-transaction.js ===
declare export function sendAndConfirmRawTransaction(
connection: Connection,
wireTransaction: Buffer,
commitment: ?Commitment,
): Promise<TransactionSignature>;
2018-12-19 19:28:28 -08:00
// === src/util/testnet.js ===
declare export function testnetChannelEndpoint(channel?: string): string;
declare export var LAMPORTS_PER_SOL: number;
}