2018-09-28 20:18:57 -07:00
|
|
|
/**
|
|
|
|
* Flow Library definition for @solana/web3.js
|
|
|
|
*
|
2020-02-03 21:36:35 +08:00
|
|
|
* This file is manually maintained
|
2018-09-28 20:18:57 -07:00
|
|
|
*
|
|
|
|
* Usage: add the following line under the [libs] section of your project's
|
|
|
|
* .flowconfig:
|
|
|
|
* [libs]
|
|
|
|
* node_modules/@solana/web3.js/module.flow.js
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-03-03 11:16:19 +08:00
|
|
|
import {Buffer} from 'buffer';
|
2020-01-29 14:29:18 +08:00
|
|
|
import * as BufferLayout from 'buffer-layout';
|
2018-10-16 13:51:04 -07:00
|
|
|
|
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 {
|
2020-02-13 08:25:22 +08:00
|
|
|
constructor(
|
|
|
|
value: number | string | Buffer | Uint8Array | Array<number>,
|
|
|
|
): PublicKey;
|
2020-04-04 21:35:08 +08:00
|
|
|
static isPublicKey(o: {}): boolean;
|
2020-03-16 17:44:12 +08:00
|
|
|
static createWithSeed(
|
|
|
|
fromPublicKey: PublicKey,
|
|
|
|
seed: string,
|
|
|
|
programId: PublicKey,
|
|
|
|
): Promise<PublicKey>;
|
2018-09-30 18:42:45 -07:00
|
|
|
equals(publickey: PublicKey): boolean;
|
|
|
|
toBase58(): string;
|
|
|
|
toBuffer(): Buffer;
|
2019-09-29 13:12:01 -04: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;
|
|
|
|
|
2018-09-28 20:18:57 -07:00
|
|
|
// === src/account.js ===
|
|
|
|
declare export class Account {
|
2020-02-13 08:25:22 +08:00
|
|
|
constructor(secretKey?: Buffer | Uint8Array | Array<number>): Account;
|
2018-09-28 20:18:57 -07:00
|
|
|
publicKey: PublicKey;
|
2018-09-30 18:42:45 -07:00
|
|
|
secretKey: Buffer;
|
2018-09-28 20:18:57 -07:00
|
|
|
}
|
|
|
|
|
2019-06-12 14:36:05 -07:00
|
|
|
// === src/fee-calculator.js ===
|
|
|
|
declare export type FeeCalculator = {
|
|
|
|
lamportsPerSignature: number,
|
|
|
|
};
|
|
|
|
|
2018-09-28 20:18:57 -07:00
|
|
|
// === src/budget-program.js ===
|
|
|
|
/* TODO */
|
|
|
|
|
|
|
|
// === src/connection.js ===
|
2020-03-23 22:19:32 +08:00
|
|
|
declare export type Context = {
|
|
|
|
slot: number,
|
|
|
|
};
|
|
|
|
|
2019-11-13 17:31:31 -05:00
|
|
|
declare export type RpcResponseAndContext<T> = {
|
2020-03-23 22:19:32 +08:00
|
|
|
context: Context,
|
2019-11-13 17:31:31 -05:00
|
|
|
value: T,
|
|
|
|
};
|
|
|
|
|
2019-11-11 13:01:10 -05:00
|
|
|
declare export type Commitment = 'max' | 'recent';
|
|
|
|
|
2020-04-06 17:56:26 +08:00
|
|
|
declare export type SignatureStatusConfig = {
|
|
|
|
searchTransactionHistory: boolean,
|
|
|
|
};
|
|
|
|
|
2020-03-23 23:01:12 +08:00
|
|
|
declare export type SignatureStatus = {
|
|
|
|
slot: number,
|
2020-04-04 21:35:08 +08:00
|
|
|
err: TransactionError | null,
|
2020-03-26 21:37:45 +08:00
|
|
|
confirmations: number | null,
|
2020-03-23 23:01:12 +08:00
|
|
|
};
|
|
|
|
|
2020-01-29 14:29:18 +08:00
|
|
|
declare export type BlockhashAndFeeCalculator = {
|
|
|
|
blockhash: Blockhash,
|
|
|
|
feeCalculator: FeeCalculator,
|
|
|
|
};
|
|
|
|
|
|
|
|
declare export type PublicKeyAndAccount = {
|
|
|
|
pubkey: PublicKey,
|
|
|
|
account: AccountInfo,
|
|
|
|
};
|
|
|
|
|
2018-09-28 21:45:04 -07:00
|
|
|
declare export type AccountInfo = {
|
2018-11-04 11:41:21 -08:00
|
|
|
executable: boolean,
|
2018-11-14 10:06:13 -08:00
|
|
|
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 12:21:08 -07:00
|
|
|
rentEpoch: number | null,
|
2018-11-04 11:41:21 -08:00
|
|
|
};
|
2018-09-28 20:18:57 -07:00
|
|
|
|
2019-04-23 09:53:26 -07:00
|
|
|
declare export type ContactInfo = {
|
2020-02-12 16:20:13 +08:00
|
|
|
pubkey: string,
|
2019-04-23 09:53:26 -07:00
|
|
|
gossip: string,
|
|
|
|
tpu: string | null,
|
|
|
|
rpc: string | null,
|
|
|
|
};
|
|
|
|
|
2020-04-22 11:12:59 +08:00
|
|
|
declare export type ConfirmedTransactionMeta = {
|
|
|
|
fee: number,
|
|
|
|
preBalances: Array<number>,
|
|
|
|
postBalances: Array<number>,
|
|
|
|
err: TransactionError | null,
|
|
|
|
};
|
|
|
|
|
2019-11-19 15:38:06 -07:00
|
|
|
declare export type ConfirmedBlock = {
|
|
|
|
blockhash: Blockhash,
|
|
|
|
previousBlockhash: Blockhash,
|
|
|
|
parentSlot: number,
|
2020-01-16 12:21:08 -07:00
|
|
|
transactions: Array<{
|
|
|
|
transaction: Transaction,
|
2020-04-22 11:12:59 +08:00
|
|
|
meta: ConfirmedTransactionMeta | null,
|
2020-01-16 12:21:08 -07:00
|
|
|
}>,
|
2019-11-19 15:38:06 -07:00
|
|
|
};
|
|
|
|
|
2020-04-21 15:40:44 +08:00
|
|
|
declare export type ConfirmedTransaction = {
|
|
|
|
slot: number,
|
|
|
|
transaction: Transaction,
|
2020-04-22 11:12:59 +08:00
|
|
|
meta: ConfirmedTransactionMeta | null,
|
2020-04-21 15:40:44 +08:00
|
|
|
};
|
|
|
|
|
2019-03-14 15:59:25 -07:00
|
|
|
declare export type KeyedAccountInfo = {
|
|
|
|
accountId: PublicKey,
|
|
|
|
accountInfo: AccountInfo,
|
|
|
|
};
|
|
|
|
|
2019-11-11 20:09:00 -05: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,
|
|
|
|
};
|
|
|
|
|
2019-11-25 11:04:35 -05:00
|
|
|
declare export type SlotInfo = {
|
|
|
|
parent: 'number',
|
|
|
|
slot: 'number',
|
|
|
|
root: 'number',
|
|
|
|
};
|
|
|
|
|
2020-03-23 22:19:32 +08:00
|
|
|
declare type AccountChangeCallback = (
|
|
|
|
accountInfo: AccountInfo,
|
|
|
|
context: Context,
|
|
|
|
) => void;
|
2019-03-19 12:54:47 -07:00
|
|
|
declare type ProgramAccountChangeCallback = (
|
|
|
|
keyedAccountInfo: KeyedAccountInfo,
|
2020-03-23 22:19:32 +08:00
|
|
|
context: Context,
|
2019-03-19 12:54:47 -07:00
|
|
|
) => void;
|
2019-11-25 11:04:35 -05:00
|
|
|
declare type SlotChangeCallback = (slotInfo: SlotInfo) => void;
|
2020-02-03 23:22:11 +08:00
|
|
|
declare type SignatureResultCallback = (
|
2020-04-04 21:35:08 +08:00
|
|
|
signatureResult: SignatureResult,
|
2020-03-23 22:19:32 +08:00
|
|
|
context: Context,
|
2020-02-03 23:22:11 +08:00
|
|
|
) => void;
|
2020-03-27 22:22:53 +08:00
|
|
|
declare type RootChangeCallback = (root: number) => void;
|
2018-10-26 21:37:39 -07:00
|
|
|
|
2020-04-04 21:35:08 +08:00
|
|
|
declare export type TransactionError = {};
|
|
|
|
declare export type SignatureResult = {|
|
|
|
|
err: TransactionError | null,
|
2019-04-10 14:40:49 -07:00
|
|
|
|};
|
2018-09-28 20:18:57 -07:00
|
|
|
|
2019-10-23 09:48:24 -04:00
|
|
|
declare export type Inflation = {
|
|
|
|
foundation: number,
|
2020-01-16 12:21:08 -07:00
|
|
|
foundationTerm: number,
|
2019-10-23 09:48:24 -04:00
|
|
|
initial: number,
|
|
|
|
storage: number,
|
|
|
|
taper: number,
|
|
|
|
terminal: number,
|
|
|
|
};
|
|
|
|
|
|
|
|
declare export type EpochSchedule = {
|
2020-01-16 12:21:08 -07:00
|
|
|
slotsPerEpoch: number,
|
|
|
|
leaderScheduleSlotOffset: number,
|
2019-10-23 09:48:24 -04:00
|
|
|
warmup: boolean,
|
2020-01-16 12:21:08 -07:00
|
|
|
firstNormalEpoch: number,
|
|
|
|
firstNormalSlot: number,
|
2019-10-23 09:48:24 -04:00
|
|
|
};
|
|
|
|
|
2020-01-29 14:29:18 +08:00
|
|
|
declare export type VoteAccountStatus = {
|
|
|
|
current: Array<VoteAccountInfo>,
|
|
|
|
delinquent: Array<VoteAccountInfo>,
|
|
|
|
};
|
|
|
|
|
2018-09-28 20:18:57 -07:00
|
|
|
declare export class Connection {
|
2019-11-11 13:01:10 -05:00
|
|
|
constructor(endpoint: string, commitment: ?Commitment): Connection;
|
2020-04-06 17:56:26 +08:00
|
|
|
commitment: ?Commitment;
|
2019-11-13 17:31:31 -05:00
|
|
|
getAccountInfoAndContext(
|
|
|
|
publicKey: PublicKey,
|
|
|
|
commitment: ?Commitment,
|
2020-04-05 16:18:45 +08:00
|
|
|
): Promise<RpcResponseAndContext<AccountInfo | null>>;
|
2019-11-11 13:01:10 -05:00
|
|
|
getAccountInfo(
|
|
|
|
publicKey: PublicKey,
|
|
|
|
commitment: ?Commitment,
|
2020-04-05 16:18:45 +08:00
|
|
|
): Promise<AccountInfo | null>;
|
2019-06-28 19:28:06 -06:00
|
|
|
getProgramAccounts(
|
|
|
|
programId: PublicKey,
|
2019-11-11 13:01:10 -05:00
|
|
|
commitment: ?Commitment,
|
2020-01-16 12:21:08 -07:00
|
|
|
): Promise<Array<PublicKeyAndAccount>>;
|
2019-11-13 17:31:31 -05:00
|
|
|
getBalanceAndContext(
|
|
|
|
publicKey: PublicKey,
|
|
|
|
commitment: ?Commitment,
|
|
|
|
): Promise<RpcResponseAndContext<number>>;
|
2019-11-11 13:01:10 -05:00
|
|
|
getBalance(publicKey: PublicKey, commitment: ?Commitment): Promise<number>;
|
2019-04-23 09:53:26 -07:00
|
|
|
getClusterNodes(): Promise<Array<ContactInfo>>;
|
2020-03-31 22:47:06 +08:00
|
|
|
getConfirmedBlock(slot: number): Promise<ConfirmedBlock>;
|
2020-04-21 15:40:44 +08:00
|
|
|
getConfirmedTransaction(
|
|
|
|
signature: TransactionSignature,
|
|
|
|
): Promise<ConfirmedTransaction | null>;
|
|
|
|
getConfirmedSignaturesForAddress(
|
|
|
|
address: PublicKey,
|
|
|
|
startSlot: number,
|
|
|
|
endSlot: number,
|
|
|
|
): Promise<Array<TransactionSignature>>;
|
2019-11-11 13:01:10 -05:00
|
|
|
getVoteAccounts(commitment: ?Commitment): Promise<VoteAccountStatus>;
|
2019-11-13 17:31:31 -05:00
|
|
|
confirmTransactionAndContext(
|
|
|
|
signature: TransactionSignature,
|
|
|
|
commitment: ?Commitment,
|
|
|
|
): Promise<RpcResponseAndContext<boolean>>;
|
2019-11-11 13:01:10 -05:00
|
|
|
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,
|
2020-04-06 17:56:26 +08:00
|
|
|
config: ?SignatureStatusConfig,
|
2020-03-26 21:37:45 +08:00
|
|
|
): Promise<RpcResponseAndContext<SignatureStatus | null>>;
|
2020-04-02 01:51:30 +08:00
|
|
|
getSignatureStatuses(
|
2020-03-23 23:01:12 +08:00
|
|
|
signatures: Array<TransactionSignature>,
|
2020-04-06 17:56:26 +08:00
|
|
|
config: ?SignatureStatusConfig,
|
2020-03-26 21:37:45 +08:00
|
|
|
): Promise<RpcResponseAndContext<Array<SignatureStatus | null>>>;
|
2019-11-11 13:01:10 -05:00
|
|
|
getTransactionCount(commitment: ?Commitment): Promise<number>;
|
|
|
|
getTotalSupply(commitment: ?Commitment): Promise<number>;
|
2019-11-11 20:09:00 -05:00
|
|
|
getVersion(): Promise<Version>;
|
2019-11-11 13:01:10 -05:00
|
|
|
getInflation(commitment: ?Commitment): Promise<Inflation>;
|
2019-10-23 09:48:24 -04:00
|
|
|
getEpochSchedule(): Promise<EpochSchedule>;
|
2019-11-13 17:31:31 -05:00
|
|
|
getRecentBlockhashAndContext(
|
|
|
|
commitment: ?Commitment,
|
2020-01-16 12:21:08 -07:00
|
|
|
): Promise<RpcResponseAndContext<BlockhashAndFeeCalculator>>;
|
2019-11-11 13:01:10 -05:00
|
|
|
getRecentBlockhash(
|
|
|
|
commitment: ?Commitment,
|
2020-01-16 12:21:08 -07:00
|
|
|
): Promise<BlockhashAndFeeCalculator>;
|
2018-11-04 11:41:21 -08:00
|
|
|
requestAirdrop(
|
|
|
|
to: PublicKey,
|
|
|
|
amount: number,
|
2019-11-11 13:01:10 -05:00
|
|
|
commitment: ?Commitment,
|
2018-11-04 11:41:21 -08:00
|
|
|
): Promise<TransactionSignature>;
|
|
|
|
sendTransaction(
|
|
|
|
transaction: Transaction,
|
2018-11-18 08:48:14 -08:00
|
|
|
...signers: Array<Account>
|
2018-11-04 11:41:21 -08:00
|
|
|
): Promise<TransactionSignature>;
|
2020-01-21 22:16:56 -07:00
|
|
|
sendEncodedTransaction(
|
|
|
|
encodedTransaction: string,
|
|
|
|
): Promise<TransactionSignature>;
|
2020-02-13 08:25:22 +08:00
|
|
|
sendRawTransaction(
|
|
|
|
wireTransaction: Buffer | Uint8Array | Array<number>,
|
|
|
|
): Promise<TransactionSignature>;
|
2018-11-04 11:41:21 -08:00
|
|
|
onAccountChange(
|
|
|
|
publickey: PublicKey,
|
|
|
|
callback: AccountChangeCallback,
|
|
|
|
): number;
|
2018-10-27 19:48:37 -07:00
|
|
|
removeAccountChangeListener(id: number): Promise<void>;
|
2019-03-08 17:02:39 -07:00
|
|
|
onProgramAccountChange(
|
|
|
|
programId: PublicKey,
|
|
|
|
callback: ProgramAccountChangeCallback,
|
|
|
|
): number;
|
|
|
|
removeProgramAccountChangeListener(id: number): Promise<void>;
|
2020-02-03 23:22:11 +08:00
|
|
|
onSlotChange(callback: SlotChangeCallback): number;
|
|
|
|
removeSlotChangeListener(id: number): Promise<void>;
|
|
|
|
onSignature(
|
|
|
|
signature: TransactionSignature,
|
|
|
|
callback: SignatureResultCallback,
|
|
|
|
): number;
|
|
|
|
removeSignatureListener(id: number): Promise<void>;
|
2020-03-27 22:22:53 +08:00
|
|
|
onRootChange(callback: RootChangeCallback): number;
|
|
|
|
removeRootChangeListener(id: number): Promise<void>;
|
2019-10-11 11:55:08 -06:00
|
|
|
validatorExit(): Promise<boolean>;
|
2020-01-03 11:30:16 -08:00
|
|
|
getMinimumBalanceForRentExemption(
|
|
|
|
dataLength: number,
|
|
|
|
commitment: ?Commitment,
|
|
|
|
): Promise<number>;
|
2020-04-05 22:10:20 +08:00
|
|
|
getNonce(
|
|
|
|
nonceAccount: PublicKey,
|
|
|
|
commitment: ?Commitment,
|
|
|
|
): Promise<NonceAccount>;
|
|
|
|
getNonceAndContext(
|
|
|
|
nonceAccount: PublicKey,
|
|
|
|
commitment: ?Commitment,
|
|
|
|
): Promise<RpcResponseAndContext<NonceAccount>>;
|
2018-09-28 20:18:57 -07:00
|
|
|
}
|
|
|
|
|
2020-03-05 09:44:56 -07:00
|
|
|
// === src/nonce-account.js ===
|
|
|
|
declare export class NonceAccount {
|
|
|
|
authorizedPubkey: PublicKey;
|
|
|
|
nonce: Blockhash;
|
|
|
|
feeCalculator: FeeCalculator;
|
|
|
|
}
|
|
|
|
|
2020-04-05 22:25:53 +08:00
|
|
|
declare export var NONCE_ACCOUNT_LENGTH: number;
|
|
|
|
|
2020-03-09 10:48:50 +08:00
|
|
|
// === src/validator-info.js ===
|
|
|
|
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 | Uint8Array | Array<number>,
|
|
|
|
): ValidatorInfo | null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// === 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;
|
|
|
|
|
|
|
|
// === src/vote-account.js ===
|
|
|
|
declare export var VOTE_PROGRAM_ID;
|
|
|
|
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 | Uint8Array | Array<number>,
|
|
|
|
): VoteAccount;
|
|
|
|
}
|
|
|
|
|
|
|
|
// === src/instruction.js ===
|
|
|
|
declare export type InstructionType = {|
|
|
|
|
index: number,
|
|
|
|
layout: typeof BufferLayout,
|
|
|
|
|};
|
|
|
|
|
2020-04-04 21:35:08 +08:00
|
|
|
declare export function encodeData(type: InstructionType, fields: {}): Buffer;
|
2020-03-09 10:48:50 +08:00
|
|
|
|
|
|
|
// === src/transaction.js ===
|
|
|
|
declare export type TransactionSignature = string;
|
|
|
|
|
|
|
|
declare type TransactionInstructionCtorFields = {|
|
|
|
|
keys: ?Array<{pubkey: PublicKey, isSigner: boolean, isWritable: boolean}>,
|
|
|
|
programId?: PublicKey,
|
|
|
|
data?: Buffer,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export class TransactionInstruction {
|
|
|
|
keys: Array<{pubkey: PublicKey, isSigner: boolean, isWritable: boolean}>;
|
|
|
|
programId: PublicKey;
|
|
|
|
data: Buffer;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
opts?: TransactionInstructionCtorFields,
|
|
|
|
): TransactionInstruction;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare type SignaturePubkeyPair = {|
|
|
|
|
signature: Buffer | null,
|
|
|
|
publicKey: PublicKey,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare type NonceInformation = {|
|
|
|
|
nonce: Blockhash,
|
|
|
|
nonceInstruction: TransactionInstruction,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare type TransactionCtorFields = {|
|
|
|
|
recentBlockhash?: Blockhash,
|
|
|
|
nonceInfo?: NonceInformation,
|
|
|
|
signatures?: Array<SignaturePubkeyPair>,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export class Transaction {
|
|
|
|
signatures: Array<SignaturePubkeyPair>;
|
|
|
|
signature: ?Buffer;
|
|
|
|
instructions: Array<TransactionInstruction>;
|
|
|
|
recentBlockhash: ?Blockhash;
|
|
|
|
nonceInfo: ?NonceInformation;
|
|
|
|
|
|
|
|
constructor(opts?: TransactionCtorFields): Transaction;
|
|
|
|
static from(buffer: Buffer | Uint8Array | Array<number>): Transaction;
|
|
|
|
add(
|
|
|
|
...items: Array<
|
|
|
|
Transaction | TransactionInstruction | TransactionInstructionCtorFields,
|
|
|
|
>
|
|
|
|
): Transaction;
|
|
|
|
sign(...signers: Array<Account>): void;
|
|
|
|
signPartial(...partialSigners: Array<PublicKey | Account>): void;
|
|
|
|
addSigner(signer: Account): void;
|
|
|
|
verifySignatures(): boolean;
|
|
|
|
serialize(): Buffer;
|
|
|
|
}
|
|
|
|
|
2019-12-23 11:46:49 -07:00
|
|
|
// === src/stake-program.js ===
|
2020-01-29 14:29:18 +08:00
|
|
|
declare export type StakeAuthorizationType = {|
|
|
|
|
index: number,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export class Authorized {
|
|
|
|
staker: PublicKey;
|
|
|
|
withdrawer: PublicKey;
|
|
|
|
constructor(staker: PublicKey, withdrawer: PublicKey): Authorized;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare export class Lockup {
|
|
|
|
unixTimestamp: number;
|
|
|
|
epoch: number;
|
|
|
|
custodian: PublicKey;
|
|
|
|
constructor(
|
|
|
|
unixTimestamp: number,
|
|
|
|
epoch: number,
|
|
|
|
custodian: PublicKey,
|
|
|
|
): Lockup;
|
|
|
|
}
|
|
|
|
|
2020-03-02 23:58:10 +08:00
|
|
|
declare export type CreateStakeAccountParams = {|
|
|
|
|
fromPubkey: PublicKey,
|
|
|
|
stakePubkey: PublicKey,
|
|
|
|
authorized: Authorized,
|
|
|
|
lockup: Lockup,
|
|
|
|
lamports: number,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type CreateStakeAccountWithSeedParams = {|
|
|
|
|
fromPubkey: PublicKey,
|
|
|
|
stakePubkey: PublicKey,
|
|
|
|
basePubkey: PublicKey,
|
|
|
|
seed: string,
|
|
|
|
authorized: Authorized,
|
|
|
|
lockup: Lockup,
|
|
|
|
lamports: number,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type InitializeStakeParams = {|
|
|
|
|
stakePubkey: PublicKey,
|
|
|
|
authorized: Authorized,
|
|
|
|
lockup: Lockup,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type DelegateStakeParams = {|
|
|
|
|
stakePubkey: PublicKey,
|
|
|
|
authorizedPubkey: PublicKey,
|
|
|
|
votePubkey: PublicKey,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type AuthorizeStakeParams = {|
|
|
|
|
stakePubkey: PublicKey,
|
|
|
|
authorizedPubkey: PublicKey,
|
|
|
|
newAuthorizedPubkey: PublicKey,
|
|
|
|
stakeAuthorizationType: StakeAuthorizationType,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type SplitStakeParams = {|
|
|
|
|
stakePubkey: PublicKey,
|
|
|
|
authorizedPubkey: PublicKey,
|
|
|
|
splitStakePubkey: PublicKey,
|
|
|
|
lamports: number,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type WithdrawStakeParams = {|
|
|
|
|
stakePubkey: PublicKey,
|
|
|
|
authorizedPubkey: PublicKey,
|
|
|
|
toPubkey: PublicKey,
|
|
|
|
lamports: number,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type DeactivateStakeParams = {|
|
|
|
|
stakePubkey: PublicKey,
|
|
|
|
authorizedPubkey: PublicKey,
|
|
|
|
|};
|
|
|
|
|
2019-12-23 11:46:49 -07:00
|
|
|
declare export class StakeProgram {
|
|
|
|
static programId: PublicKey;
|
|
|
|
static space: number;
|
2020-03-02 23:58:10 +08:00
|
|
|
static createAccount(params: CreateStakeAccountParams): Transaction;
|
2019-12-23 11:46:49 -07:00
|
|
|
static createAccountWithSeed(
|
2020-03-02 23:58:10 +08:00
|
|
|
params: CreateStakeAccountWithSeedParams,
|
2019-12-23 11:46:49 -07:00
|
|
|
): Transaction;
|
2020-03-02 23:58:10 +08:00
|
|
|
static delegate(params: DelegateStakeParams): Transaction;
|
|
|
|
static authorize(params: AuthorizeStakeParams): Transaction;
|
|
|
|
static split(params: SplitStakeParams): Transaction;
|
|
|
|
static withdraw(params: WithdrawStakeParams): Transaction;
|
|
|
|
static deactivate(params: DeactivateStakeParams): Transaction;
|
2019-12-23 11:46:49 -07:00
|
|
|
}
|
|
|
|
|
2020-02-28 18:43:10 +08:00
|
|
|
declare export type StakeInstructionType =
|
|
|
|
| 'Initialize'
|
|
|
|
| 'Authorize'
|
|
|
|
| 'Delegate'
|
|
|
|
| 'Split'
|
|
|
|
| 'Withdraw'
|
|
|
|
| 'Deactivate';
|
|
|
|
|
|
|
|
declare export var STAKE_INSTRUCTION_LAYOUTS: {
|
|
|
|
[StakeInstructionType]: InstructionType,
|
|
|
|
};
|
|
|
|
|
2020-03-02 23:58:10 +08:00
|
|
|
declare export class StakeInstruction {
|
|
|
|
static decodeInstructionType(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): StakeInstructionType;
|
|
|
|
static decodeInitialize(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): InitializeStakeParams;
|
|
|
|
static decodeDelegate(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): DelegateStakeParams;
|
|
|
|
static decodeAuthorize(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): AuthorizeStakeParams;
|
|
|
|
static decodeSplit(instruction: TransactionInstruction): SplitStakeParams;
|
|
|
|
static decodeWithdraw(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): WithdrawStakeParams;
|
|
|
|
static decodeDeactivate(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): DeactivateStakeParams;
|
2020-02-28 18:43:10 +08:00
|
|
|
}
|
|
|
|
|
2018-09-28 20:18:57 -07:00
|
|
|
// === src/system-program.js ===
|
2020-03-03 16:05:50 +08:00
|
|
|
declare export type CreateAccountParams = {|
|
|
|
|
fromPubkey: PublicKey,
|
|
|
|
newAccountPubkey: PublicKey,
|
|
|
|
lamports: number,
|
|
|
|
space: number,
|
|
|
|
programId: PublicKey,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type TransferParams = {|
|
|
|
|
fromPubkey: PublicKey,
|
|
|
|
toPubkey: PublicKey,
|
|
|
|
lamports: number,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type AssignParams = {|
|
|
|
|
fromPubkey: PublicKey,
|
|
|
|
programId: PublicKey,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type CreateAccountWithSeedParams = {|
|
|
|
|
fromPubkey: PublicKey,
|
|
|
|
newAccountPubkey: PublicKey,
|
|
|
|
basePubkey: PublicKey,
|
|
|
|
seed: string,
|
|
|
|
lamports: number,
|
|
|
|
space: number,
|
|
|
|
programId: PublicKey,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type CreateNonceAccountParams = {|
|
|
|
|
fromPubkey: PublicKey,
|
|
|
|
noncePubkey: PublicKey,
|
|
|
|
authorizedPubkey: PublicKey,
|
|
|
|
lamports: number,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type InitializeNonceParams = {|
|
|
|
|
noncePubkey: PublicKey,
|
|
|
|
authorizedPubkey: PublicKey,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type AdvanceNonceParams = {|
|
|
|
|
noncePubkey: PublicKey,
|
|
|
|
authorizedPubkey: PublicKey,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type WithdrawNonceParams = {|
|
|
|
|
noncePubkey: PublicKey,
|
|
|
|
authorizedPubkey: PublicKey,
|
|
|
|
toPubkey: PublicKey,
|
|
|
|
lamports: number,
|
|
|
|
|};
|
|
|
|
|
|
|
|
declare export type AuthorizeNonceParams = {|
|
|
|
|
noncePubkey: PublicKey,
|
|
|
|
authorizedPubkey: PublicKey,
|
|
|
|
newAuthorizedPubkey: PublicKey,
|
|
|
|
|};
|
|
|
|
|
2018-09-28 20:18:57 -07:00
|
|
|
declare export class SystemProgram {
|
|
|
|
static programId: PublicKey;
|
|
|
|
|
2020-03-03 16:05:50 +08:00
|
|
|
static createAccount(params: CreateAccountParams): Transaction;
|
|
|
|
static transfer(params: TransferParams): Transaction;
|
|
|
|
static assign(params: AssignParams): Transaction;
|
2019-12-09 19:50:01 -08:00
|
|
|
static createAccountWithSeed(
|
2020-03-03 16:05:50 +08:00
|
|
|
params: CreateAccountWithSeedParams,
|
2020-02-14 22:32:23 +08:00
|
|
|
): Transaction;
|
2020-03-03 16:05:50 +08:00
|
|
|
static createNonceAccount(params: CreateNonceAccountParams): Transaction;
|
|
|
|
static nonceAdvance(params: AdvanceNonceParams): TransactionInstruction;
|
|
|
|
static nonceWithdraw(params: WithdrawNonceParams): Transaction;
|
|
|
|
static nonceAuthorize(params: AuthorizeNonceParams): Transaction;
|
2018-09-28 20:18:57 -07:00
|
|
|
}
|
|
|
|
|
2020-02-28 18:43:10 +08:00
|
|
|
declare export type SystemInstructionType =
|
|
|
|
| 'Create'
|
|
|
|
| 'Assign'
|
|
|
|
| 'Transfer'
|
|
|
|
| 'CreateWithSeed'
|
|
|
|
| 'AdvanceNonceAccount'
|
|
|
|
| 'WithdrawNonceAccount'
|
|
|
|
| 'InitializeNonceAccount'
|
|
|
|
| 'AuthorizeNonceAccount';
|
|
|
|
|
|
|
|
declare export var SYSTEM_INSTRUCTION_LAYOUTS: {
|
|
|
|
[SystemInstructionType]: InstructionType,
|
|
|
|
};
|
|
|
|
|
2020-03-03 16:05:50 +08:00
|
|
|
declare export class SystemInstruction {
|
2020-03-09 10:48:50 +08:00
|
|
|
static decodeInstructionType(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): SystemInstructionType;
|
2020-03-03 16:05:50 +08:00
|
|
|
static decodeCreateAccount(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): CreateAccountParams;
|
|
|
|
static decodeTransfer(instruction: TransactionInstruction): TransferParams;
|
|
|
|
static decodeAssign(instruction: TransactionInstruction): AssignParams;
|
|
|
|
static decodeCreateWithSeed(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): CreateAccountWithSeedParams;
|
|
|
|
static decodeNonceInitialize(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): InitializeNonceParams;
|
|
|
|
static decodeNonceAdvance(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): AdvanceNonceParams;
|
|
|
|
static decodeNonceWithdraw(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): WithdrawNonceParams;
|
|
|
|
static decodeNonceAuthorize(
|
|
|
|
instruction: TransactionInstruction,
|
|
|
|
): AuthorizeNonceParams;
|
2020-02-12 10:06:34 +08:00
|
|
|
}
|
|
|
|
|
2018-10-17 09:35:24 -07:00
|
|
|
// === src/loader.js ===
|
|
|
|
declare export class Loader {
|
2019-10-22 16:10:21 -07:00
|
|
|
static getMinNumSignatures(dataLength: number): number;
|
2019-05-08 09:33:04 -07:00
|
|
|
static load(
|
|
|
|
connection: Connection,
|
|
|
|
payer: Account,
|
|
|
|
program: Account,
|
|
|
|
programId: PublicKey,
|
2020-02-13 08:25:22 +08:00
|
|
|
data: Buffer | Uint8Array | Array<number>,
|
2019-05-08 09:33:04 -07:00
|
|
|
): Promise<PublicKey>;
|
2018-10-17 09:35:24 -07:00
|
|
|
}
|
|
|
|
|
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,
|
2019-05-08 09:33:04 -07:00
|
|
|
payer: Account,
|
2020-04-15 21:26:19 +08:00
|
|
|
program: Account,
|
2020-02-13 08:25:22 +08:00
|
|
|
elfBytes: Buffer | Uint8Array | Array<number>,
|
2018-10-30 08:00:11 -07:00
|
|
|
): Promise<PublicKey>;
|
|
|
|
}
|
|
|
|
|
2018-10-22 22:30:48 -07:00
|
|
|
// === src/util/send-and-confirm-transaction.js ===
|
|
|
|
declare export function sendAndConfirmTransaction(
|
|
|
|
connection: Connection,
|
|
|
|
transaction: Transaction,
|
2018-11-18 08:48:14 -08:00
|
|
|
...signers: Array<Account>
|
2018-11-03 19:02:12 -07:00
|
|
|
): Promise<TransactionSignature>;
|
2018-11-28 11:56:50 -08:00
|
|
|
|
2019-11-11 13:01:10 -05:00
|
|
|
declare export function sendAndConfirmRecentTransaction(
|
|
|
|
connection: Connection,
|
|
|
|
transaction: Transaction,
|
|
|
|
...signers: Array<Account>
|
|
|
|
): Promise<TransactionSignature>;
|
|
|
|
|
2018-11-28 11:56:50 -08:00
|
|
|
// === src/util/send-and-confirm-raw-transaction.js ===
|
|
|
|
declare export function sendAndConfirmRawTransaction(
|
|
|
|
connection: Connection,
|
|
|
|
wireTransaction: Buffer,
|
2019-11-11 13:01:10 -05:00
|
|
|
commitment: ?Commitment,
|
2018-11-28 11:56:50 -08:00
|
|
|
): Promise<TransactionSignature>;
|
2018-12-19 19:28:28 -08:00
|
|
|
|
2020-03-30 20:27:09 +08:00
|
|
|
// === src/util/cluster.js ===
|
|
|
|
declare export type Cluster = 'devnet' | 'testnet' | 'mainnet-beta';
|
|
|
|
|
|
|
|
declare export function clusterApiUrl(
|
|
|
|
cluster?: Cluster,
|
2020-01-29 14:29:18 +08:00
|
|
|
tls?: boolean,
|
|
|
|
): string;
|
2019-10-19 11:36:06 -07:00
|
|
|
|
2020-03-30 20:27:09 +08:00
|
|
|
// === src/index.js ===
|
2019-12-30 11:36:12 -07:00
|
|
|
declare export var LAMPORTS_PER_SOL: number;
|
2018-09-28 20:18:57 -07:00
|
|
|
}
|