solana/web3.js/module.flow.js

312 lines
8.2 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 {
constructor(number: string | Buffer | Array<number>): PublicKey;
static isPublicKey(o: Object): boolean;
equals(publickey: PublicKey): boolean;
toBase58(): string;
toBuffer(): Buffer;
}
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 = {
lamportsPerSignature: number,
targetSignaturesPerSlot: number,
targetLamportsPerSignature: number,
};
// === src/budget-program.js ===
/* TODO */
// === src/connection.js ===
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,
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 KeyedAccountInfo = {
accountId: PublicKey,
accountInfo: AccountInfo,
};
2019-06-12 14:36:05 -07:00
declare export type VoteAccountInfo = {
votePubkey: string,
nodePubkey: string,
stake: number,
commission: 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;
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,
|};
declare export class Connection {
constructor(endpoint: string): Connection;
getAccountInfo(publicKey: PublicKey): Promise<AccountInfo>;
getBalance(publicKey: PublicKey): Promise<number>;
getClusterNodes(): Promise<Array<ContactInfo>>;
2019-06-12 14:36:05 -07:00
getEpochVoteAccounts(): Promise<Array<VoteAccountInfo>>;
confirmTransaction(signature: TransactionSignature): Promise<boolean>;
getSlotLeader(): Promise<string>;
2018-11-04 11:41:21 -08:00
getSignatureStatus(
signature: TransactionSignature,
2019-04-10 14:40:49 -07:00
): Promise<SignatureSuccess | TransactionError | null>;
getTransactionCount(): Promise<number>;
2019-06-12 14:36:05 -07:00
getRecentBlockhash(): Promise<[Blockhash, FeeCalculator]>;
2018-11-04 11:41:21 -08:00
requestAirdrop(
to: PublicKey,
amount: number,
): 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;
removeProgramAccountChangeListener(id: number): Promise<void>;
2019-04-24 15:22:50 -07:00
fullnodeExit(): Promise<boolean>;
}
// === 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;
}
// === 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, isDebitable: 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, isDebitable: boolean}>;
programId: PublicKey;
2019-03-14 13:27:47 -07:00
data: Buffer;
}
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(
2018-11-28 12:19:08 -08:00
...items: Array<Transaction | 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/token-program.js ===
2018-10-16 13:51:04 -07:00
declare export class TokenAmount extends BN {
toBuffer(): Buffer;
fromBuffer(buffer: Buffer): TokenAmount;
}
declare export type TokenInfo = {|
supply: TokenAmount,
decimals: number,
name: string,
symbol: string,
|};
declare export type TokenAccountInfo = {|
2018-11-04 11:41:21 -08:00
token: PublicKey,
owner: PublicKey,
amount: TokenAmount,
source: null | PublicKey,
originalAmount: TokenAmount,
|};
2018-10-16 13:51:04 -07:00
declare type TokenAndPublicKey = [Token, PublicKey];
declare export class Token {
programId: PublicKey;
2018-10-16 13:51:04 -07:00
token: PublicKey;
static createNewToken(
connection: Connection,
owner: Account,
supply: TokenAmount,
name: string,
symbol: string,
decimals: number,
programId?: PublicKey,
2018-10-16 13:51:04 -07:00
): Promise<TokenAndPublicKey>;
2018-11-04 11:41:21 -08:00
constructor(connection: Connection, token: PublicKey): Token;
newAccount(owner: Account, source?: PublicKey): Promise<PublicKey>;
2018-10-16 13:51:04 -07:00
tokenInfo(): Promise<TokenInfo>;
accountInfo(account: PublicKey): Promise<TokenAccountInfo>;
transfer(
owner: Account,
source: PublicKey,
destination: PublicKey,
amount: number | TokenAmount,
): Promise<TransactionSignature>;
2018-10-16 13:51:04 -07:00
approve(
owner: Account,
2018-10-20 18:21:25 -07:00
account: PublicKey,
2018-10-16 13:51:04 -07:00
delegate: PublicKey,
2018-11-04 11:41:21 -08:00
amount: number | TokenAmount,
2018-10-16 13:51:04 -07:00
): Promise<void>;
2018-10-18 22:28:37 -07:00
revoke(
2018-10-16 13:51:04 -07:00
owner: Account,
2018-10-20 18:21:25 -07:00
account: PublicKey,
2018-11-04 11:41:21 -08:00
delegate: PublicKey,
2018-10-16 13:51:04 -07:00
): Promise<void>;
2018-10-20 18:21:25 -07:00
setOwner(
owner: Account,
account: PublicKey,
2018-11-04 11:41:21 -08:00
newOwner: PublicKey,
2018-10-20 18:21:25 -07:00
): Promise<void>;
2018-10-24 14:58:55 -07:00
transferInstruction(
owner: PublicKey,
source: PublicKey,
destination: PublicKey,
amount: number | TokenAmount,
): Promise<TransactionInstruction>;
approveInstruction(
owner: PublicKey,
account: PublicKey,
delegate: PublicKey,
2018-11-04 11:41:21 -08:00
amount: number | TokenAmount,
2018-10-24 14:58:55 -07:00
): TransactionInstruction;
revokeInstruction(
owner: PublicKey,
account: PublicKey,
delegate: PublicKey,
): TransactionInstruction;
setOwnerInstruction(
owner: PublicKey,
account: PublicKey,
newOwner: PublicKey,
): TransactionInstruction;
2018-10-16 13:51:04 -07:00
}
2018-10-06 11:23:18 -07:00
// === src/loader.js ===
declare export class Loader {
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;
static load(
connection: Connection,
payer: Account,
2018-10-30 08:00:11 -07:00
elfBytes: Array<number>,
): Promise<PublicKey>;
}
// === src/native-loader.js ===
declare export class NativeLoader {
static programId: PublicKey;
static load(
connection: Connection,
payer: Account,
programName: string,
): Promise<PublicKey>;
}
// === src/util/send-and-confirm-transaction.js ===
declare export function sendAndConfirmTransaction(
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,
): Promise<TransactionSignature>;
2018-12-19 19:28:28 -08:00
// === src/util/testnet.js ===
declare export function testnetChannelEndpoint(channel?: string): string;
}