2018-09-28 20:18:57 -07:00
|
|
|
/**
|
|
|
|
* 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';
|
|
|
|
|
2018-09-28 20:18:57 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-09-28 20:18:57 -07:00
|
|
|
// === src/account.js ===
|
|
|
|
declare export class Account {
|
|
|
|
constructor(secretKey: ?Buffer): Account;
|
|
|
|
publicKey: PublicKey;
|
2018-09-30 18:42:45 -07:00
|
|
|
secretKey: Buffer;
|
2018-09-28 20:18:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// === src/budget-program.js ===
|
|
|
|
/* TODO */
|
|
|
|
|
|
|
|
// === src/connection.js ===
|
2018-09-28 21:45:04 -07:00
|
|
|
declare export type AccountInfo = {
|
2018-10-17 09:35:24 -07:00
|
|
|
executable: boolean;
|
|
|
|
loaderProgramId: PublicKey,
|
2018-09-28 20:18:57 -07:00
|
|
|
programId: PublicKey,
|
2018-10-17 09:35:24 -07:00
|
|
|
tokens: number,
|
2018-09-28 22:51:52 -07:00
|
|
|
userdata: Buffer,
|
2018-09-28 20:18:57 -07:00
|
|
|
}
|
|
|
|
|
2018-10-23 13:10:08 -07:00
|
|
|
declare export type SignatureStatus = 'Confirmed'
|
|
|
|
| 'AccountInUse'
|
|
|
|
| 'SignatureNotFound'
|
|
|
|
| 'ProgramRuntimeError'
|
|
|
|
| 'GenericFailure';
|
2018-09-28 20:18:57 -07:00
|
|
|
|
|
|
|
declare export class Connection {
|
|
|
|
constructor(endpoint: string): Connection;
|
|
|
|
getBalance(publicKey: PublicKey): Promise<number>;
|
|
|
|
getAccountInfo(publicKey: PublicKey): Promise<AccountInfo>;
|
|
|
|
confirmTransaction(signature: TransactionSignature): Promise<boolean>;
|
|
|
|
getSignatureStatus(signature: TransactionSignature): Promise<SignatureStatus>;
|
|
|
|
getTransactionCount(): Promise<number>;
|
|
|
|
getLastId(): Promise<TransactionId>;
|
|
|
|
getFinality(): Promise<number>;
|
|
|
|
requestAirdrop(to: PublicKey, amount: number): Promise<TransactionSignature>;
|
|
|
|
sendTransaction(from: Account, transaction: Transaction): Promise<TransactionSignature>;
|
|
|
|
}
|
|
|
|
|
|
|
|
// === src/system-program.js ===
|
|
|
|
declare export class SystemProgram {
|
|
|
|
static programId: PublicKey;
|
|
|
|
|
|
|
|
static createAccount(
|
|
|
|
from: PublicKey,
|
|
|
|
newAccount: PublicKey,
|
|
|
|
tokens: number,
|
|
|
|
space: number,
|
|
|
|
programId: PublicKey
|
|
|
|
): Transaction;
|
|
|
|
static move(from: PublicKey, to: PublicKey, amount: number): Transaction;
|
|
|
|
static assign(from: PublicKey, programId: PublicKey): Transaction;
|
2018-10-18 14:29:57 -07:00
|
|
|
static spawn(programId: PublicKey): Transaction;
|
2018-09-28 20:18:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// === src/transaction.js ===
|
2018-09-28 21:45:04 -07:00
|
|
|
declare export type TransactionSignature = string;
|
|
|
|
declare export type TransactionId = string;
|
2018-09-28 20:18:57 -07:00
|
|
|
|
2018-10-23 15:17:43 -07:00
|
|
|
declare type TransactionInstructionCtorFields = {|
|
2018-09-28 20:18:57 -07:00
|
|
|
keys?: Array<PublicKey>;
|
|
|
|
programId?: PublicKey;
|
|
|
|
userdata?: Buffer;
|
|
|
|
|};
|
|
|
|
|
2018-10-23 15:17:43 -07:00
|
|
|
declare export class TransactionInstruction {
|
|
|
|
fee: number;
|
|
|
|
|
|
|
|
constructor(opts?: TransactionInstructionCtorFields): TransactionInstruction;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare type TransactionCtorFields = {|
|
|
|
|
fee?: number;
|
|
|
|
|};
|
2018-09-28 20:18:57 -07:00
|
|
|
|
|
|
|
declare export class Transaction {
|
|
|
|
signature: ?Buffer;
|
|
|
|
fee: number;
|
|
|
|
|
|
|
|
constructor(opts?: TransactionCtorFields): Transaction;
|
2018-10-24 14:58:55 -07:00
|
|
|
add(item: TransactionInstruction | TransactionInstructionCtorFields): Transaction;
|
2018-09-28 20:18:57 -07:00
|
|
|
sign(from: 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 = {|
|
|
|
|
token: PublicKey;
|
|
|
|
owner: PublicKey;
|
|
|
|
amount: TokenAmount;
|
|
|
|
source: null | PublicKey;
|
2018-10-18 08:27:03 -07:00
|
|
|
originalAmount: TokenAmount;
|
2018-10-16 13:51:04 -07:00
|
|
|
|}
|
|
|
|
declare type TokenAndPublicKey = [Token, PublicKey];
|
|
|
|
|
|
|
|
declare export class Token {
|
2018-10-18 09:28:21 -07:00
|
|
|
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,
|
2018-10-18 22:22:29 -07:00
|
|
|
programId?: PublicKey,
|
2018-10-16 13:51:04 -07:00
|
|
|
): Promise<TokenAndPublicKey>;
|
|
|
|
|
|
|
|
constructor(connection: Connection, token: PublicKey) : Token;
|
2018-10-18 23:12:14 -07:00
|
|
|
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<void>;
|
|
|
|
approve(
|
|
|
|
owner: Account,
|
2018-10-20 20:21:25 -05:00
|
|
|
account: PublicKey,
|
2018-10-16 13:51:04 -07:00
|
|
|
delegate: PublicKey,
|
|
|
|
amount: number | TokenAmount
|
|
|
|
): Promise<void>;
|
2018-10-18 22:28:37 -07:00
|
|
|
revoke(
|
2018-10-16 13:51:04 -07:00
|
|
|
owner: Account,
|
2018-10-20 20:21:25 -05:00
|
|
|
account: PublicKey,
|
2018-10-16 13:51:04 -07:00
|
|
|
delegate: PublicKey
|
|
|
|
): Promise<void>;
|
2018-10-20 20:21:25 -05:00
|
|
|
setOwner(
|
|
|
|
owner: Account,
|
|
|
|
account: PublicKey,
|
|
|
|
newOwner: PublicKey
|
|
|
|
): 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,
|
|
|
|
amount: number | TokenAmount
|
|
|
|
): 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
|
|
|
|
2018-10-17 09:35:24 -07:00
|
|
|
// === src/loader.js ===
|
|
|
|
declare export class Loader {
|
|
|
|
constructor(connection: Connection, programId: PublicKey) : Loader;
|
|
|
|
load(program: Account, offset: number, bytes: Array<number>): Promise<void>;
|
|
|
|
finalize(program: Account): Promise<void>;
|
|
|
|
}
|
|
|
|
|
|
|
|
// === src/native-loader.js ===
|
|
|
|
declare export class NativeLoader {
|
|
|
|
static programId: PublicKey;
|
|
|
|
static load(
|
|
|
|
connection: Connection,
|
|
|
|
owner: Account,
|
|
|
|
programName: string,
|
|
|
|
): Promise<PublicKey>;
|
|
|
|
}
|
2018-10-22 22:30:48 -07:00
|
|
|
|
|
|
|
// === src/util/send-and-confirm-transaction.js ===
|
|
|
|
declare export function sendAndConfirmTransaction(
|
|
|
|
connection: Connection,
|
|
|
|
from: Account,
|
|
|
|
transaction: Transaction,
|
|
|
|
runtimeErrorOk?: boolean,
|
|
|
|
): Promise<void>;
|
2018-09-28 20:18:57 -07:00
|
|
|
}
|