From e03fa4b962268802db42a77cfe6b71424e74e9f9 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Mon, 3 Feb 2020 21:36:35 +0800 Subject: [PATCH] fix: add typescript type declaration to npm bundle --- web3.js/.eslintrc.js | 15 +- web3.js/module.d.ts | 479 ++++++++++++++++++++++++++++++++++++++ web3.js/module.flow.js | 2 +- web3.js/package-lock.json | 260 +++++++++++++++++++++ web3.js/package.json | 8 +- web3.js/rollup.config.js | 4 + 6 files changed, 764 insertions(+), 4 deletions(-) create mode 100644 web3.js/module.d.ts diff --git a/web3.js/.eslintrc.js b/web3.js/.eslintrc.js index 15685dd1d..ae1e91e10 100644 --- a/web3.js/.eslintrc.js +++ b/web3.js/.eslintrc.js @@ -1,5 +1,4 @@ module.exports = { - // eslint-disable-line import/no-commonjs env: { browser: true, es6: true, @@ -47,4 +46,18 @@ module.exports = { 'require-await': ['error'], semi: ['error', 'always'], }, + + // Used to lint the TypeScript type declaration file + overrides: [ + { + files: ['*.d.ts'], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + ], + }, + ], }; diff --git a/web3.js/module.d.ts b/web3.js/module.d.ts new file mode 100644 index 000000000..4c2fae5f2 --- /dev/null +++ b/web3.js/module.d.ts @@ -0,0 +1,479 @@ +declare module '@solana/web3.js' { + import * as BufferLayout from 'buffer-layout'; + + // === src/publickey.js === + export class PublicKey { + constructor(value: number | string | Buffer | Array); + static isPublicKey(o: object): boolean; + equals(publickey: PublicKey): boolean; + toBase58(): string; + toBuffer(): Buffer; + toString(): string; + } + + // === src/blockhash.js === + export type Blockhash = string; + + // === src/account.js === + export class Account { + constructor(secretKey?: Buffer); + publicKey: PublicKey; + secretKey: Buffer; + } + + // === src/fee-calculator.js === + export type FeeCalculator = { + burnPercent: number; + lamportsPerSignature: number; + maxLamportsPerSignature: number; + minLamportsPerSignature: number; + targetLamportsPerSignature: number; + targetSignaturesPerSlot: number; + }; + + // === src/budget-program.js === + + /* TODO */ + + // === src/connection.js === + export type RpcResponseAndContext = { + context: { + slot: number; + }; + value: T; + }; + + export type Commitment = 'max' | 'recent'; + + export type SignatureStatusResult = SignatureSuccess | TransactionError; + + export type BlockhashAndFeeCalculator = { + blockhash: Blockhash; + feeCalculator: FeeCalculator; + }; + + export type PublicKeyAndAccount = { + pubkey: PublicKey; + account: AccountInfo; + }; + + export type AccountInfo = { + executable: boolean; + owner: PublicKey; + lamports: number; + data: Buffer; + rentEpoch?: number; + }; + + export type ContactInfo = { + id: string; + gossip: string; + tpu?: string; + rpc?: string; + }; + + export type ConfirmedBlock = { + blockhash: Blockhash; + previousBlockhash: Blockhash; + parentSlot: number; + transactions: Array<{ + transaction: Transaction; + meta: { + fee: number; + preBalances: Array; + postBalances: Array; + status?: SignatureStatusResult; + }; + }>; + }; + + export type KeyedAccountInfo = { + accountId: PublicKey; + accountInfo: AccountInfo; + }; + + export type Version = { + 'solana-core': string; + }; + + export type VoteAccountInfo = { + votePubkey: string; + nodePubkey: string; + stake: number; + commission: number; + }; + + export type SlotInfo = { + parent: 'number'; + slot: 'number'; + root: 'number'; + }; + + export type AccountChangeCallback = (accountInfo: AccountInfo) => void; + export type ProgramAccountChangeCallback = ( + keyedAccountInfo: KeyedAccountInfo, + ) => void; + export type SlotChangeCallback = (slotInfo: SlotInfo) => void; + + export type SignatureSuccess = { + Ok: null; + }; + export type TransactionError = { + Err: object; + }; + + export type Inflation = { + foundation: number; + foundationTerm: number; + initial: number; + storage: number; + taper: number; + terminal: number; + }; + + export type EpochSchedule = { + slotsPerEpoch: number; + leaderScheduleSlotOffset: number; + warmup: boolean; + firstNormalEpoch: number; + firstNormalSlot: number; + }; + + export type VoteAccountStatus = { + current: Array; + delinquent: Array; + }; + + export class Connection { + constructor(endpoint: string, commitment?: Commitment); + getAccountInfoAndContext( + publicKey: PublicKey, + commitment?: Commitment, + ): Promise>; + getAccountInfo( + publicKey: PublicKey, + commitment?: Commitment, + ): Promise; + getProgramAccounts( + programId: PublicKey, + commitment?: Commitment, + ): Promise>; + getBalanceAndContext( + publicKey: PublicKey, + commitment?: Commitment, + ): Promise>; + getBalance(publicKey: PublicKey, commitment?: Commitment): Promise; + getClusterNodes(): Promise>; + getConfirmedBlock(): Promise; + getVoteAccounts(commitment?: Commitment): Promise; + confirmTransactionAndContext( + signature: TransactionSignature, + commitment?: Commitment, + ): Promise>; + confirmTransaction( + signature: TransactionSignature, + commitment?: Commitment, + ): Promise; + getSlot(commitment?: Commitment): Promise; + getSlotLeader(commitment?: Commitment): Promise; + getSignatureStatus( + signature: TransactionSignature, + commitment?: Commitment, + ): Promise; + getTransactionCount(commitment?: Commitment): Promise; + getTotalSupply(commitment?: Commitment): Promise; + getVersion(): Promise; + getInflation(commitment?: Commitment): Promise; + getEpochSchedule(): Promise; + getRecentBlockhashAndContext( + commitment?: Commitment, + ): Promise>; + getRecentBlockhash( + commitment?: Commitment, + ): Promise; + requestAirdrop( + to: PublicKey, + amount: number, + commitment?: Commitment, + ): Promise; + sendTransaction( + transaction: Transaction, + ...signers: Array + ): Promise; + sendEncodedTransaction( + encodedTransaction: string, + ): Promise; + sendRawTransaction(wireTransaction: Buffer): Promise; + onAccountChange( + publickey: PublicKey, + callback: AccountChangeCallback, + ): number; + removeAccountChangeListener(id: number): Promise; + onProgramAccountChange( + programId: PublicKey, + callback: ProgramAccountChangeCallback, + ): number; + onSlotChange(callback: SlotChangeCallback): number; + removeProgramAccountChangeListener(id: number): Promise; + validatorExit(): Promise; + getMinimumBalanceForRentExemption( + dataLength: number, + commitment?: Commitment, + ): Promise; + } + + // === src/stake-program.js === + export type StakeAuthorizationType = { + index: number; + }; + + export class Authorized { + staker: PublicKey; + withdrawer: PublicKey; + constructor(staker: PublicKey, withdrawer: PublicKey); + } + + export class Lockup { + unixTimestamp: number; + epoch: number; + custodian: PublicKey; + + constructor(unixTimestamp: number, epoch: number, custodian: PublicKey); + } + + 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 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 === + export class SystemProgram { + static programId: PublicKey; + + static createAccount( + from: PublicKey, + newAccount: PublicKey, + lamports: number, + space: number, + 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 === + export const VALIDATOR_INFO_KEY: PublicKey; + export type Info = { + name: string; + website?: string; + details?: string; + keybaseUsername?: string; + }; + + export class ValidatorInfo { + key: PublicKey; + info: Info; + + constructor(key: PublicKey, info: Info); + static fromConfigData(buffer: Buffer): ValidatorInfo | null | undefined; + } + + // === src/sysvar.js === + export const SYSVAR_CLOCK_PUBKEY: PublicKey; + export const SYSVAR_RENT_PUBKEY: PublicKey; + export const SYSVAR_REWARDS_PUBKEY: PublicKey; + export const SYSVAR_STAKE_HISTORY_PUBKEY: PublicKey; + + // === src/vote-account.js === + export const VOTE_PROGRAM_ID: PublicKey; + export type Lockout = { + slot: number; + confirmationCount: number; + }; + + export type EpochCredits = { + epoch: number; + credits: number; + prevCredits: number; + }; + + export class VoteAccount { + votes: Array; + nodePubkey: PublicKey; + authorizedVoterPubkey: PublicKey; + commission: number; + rootSlot?: number; + epoch: number; + credits: number; + lastEpochCredits: number; + epochCredits: Array; + static fromAccountData(buffer: Buffer): VoteAccount; + } + + // === src/instruction.js === + export type InstructionType = { + index: number; + layout: typeof BufferLayout; + }; + + export function encodeData( + type: InstructionType, + fields: Record, + ): Buffer; + + // === src/transaction.js === + export type TransactionSignature = string; + + export type TransactionInstructionCtorFields = { + keys?: Array<{pubkey: PublicKey; isSigner: boolean; isWritable: boolean}>; + programId?: PublicKey; + data?: Buffer; + }; + + export class TransactionInstruction { + keys: Array<{ + pubkey: PublicKey; + isSigner: boolean; + isWritable: boolean; + }>; + programId: PublicKey; + data: Buffer; + + constructor(opts?: TransactionInstructionCtorFields); + } + + export type SignaturePubkeyPair = { + signature?: Buffer; + publicKey: PublicKey; + }; + + export type TransactionCtorFields = { + recentBlockhash?: Blockhash; + signatures?: Array; + }; + + export class Transaction { + signatures: Array; + signature?: Buffer; + instructions: Array; + recentBlockhash?: Blockhash; + + constructor(opts?: TransactionCtorFields); + add( + ...items: Array< + Transaction | TransactionInstruction | TransactionInstructionCtorFields + > + ): Transaction; + sign(...signers: Array): void; + signPartial(...partialSigners: Array): void; + addSigner(signer: Account): void; + serialize(): Buffer; + } + + // === src/loader.js === + export class Loader { + static getMinNumSignatures(dataLength: number): number; + static load( + connection: Connection, + payer: Account, + program: Account, + programId: PublicKey, + data: Array, + ): Promise; + } + + // === src/bpf-loader.js === + export class BpfLoader { + static programId: PublicKey; + static getMinNumSignatures(dataLength: number): number; + static load( + connection: Connection, + payer: Account, + elfBytes: Array, + ): Promise; + } + + // === src/util/send-and-confirm-transaction.js === + export function sendAndConfirmTransaction( + connection: Connection, + transaction: Transaction, + ...signers: Array + ): Promise; + + export function sendAndConfirmRecentTransaction( + connection: Connection, + transaction: Transaction, + ...signers: Array + ): Promise; + + // === src/util/send-and-confirm-raw-transaction.js === + export function sendAndConfirmRawTransaction( + connection: Connection, + wireTransaction: Buffer, + commitment?: Commitment, + ): Promise; + + // === src/util/testnet.js === + export function testnetChannelEndpoint( + channel?: string, + tls?: boolean, + ): string; + + export const LAMPORTS_PER_SOL: number; +} diff --git a/web3.js/module.flow.js b/web3.js/module.flow.js index 5a86d6693..647eb9ff1 100644 --- a/web3.js/module.flow.js +++ b/web3.js/module.flow.js @@ -1,7 +1,7 @@ /** * Flow Library definition for @solana/web3.js * - * This file is manually generated from the contents of src/ + * This file is manually maintained * * Usage: add the following line under the [libs] section of your project's * .flowconfig: diff --git a/web3.js/package-lock.json b/web3.js/package-lock.json index fc6dd183d..9ca40b30b 100644 --- a/web3.js/package-lock.json +++ b/web3.js/package-lock.json @@ -5924,6 +5924,12 @@ "@types/node": "*" } }, + "@types/eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", + "dev": true + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -5939,6 +5945,26 @@ "@types/range-parser": "*" } }, + "@types/fs-extra": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.0.1.tgz", + "integrity": "sha512-J00cVDALmi/hJOYsunyT52Hva5TnJeKP5yd1r+mH/ZU0mbYZflR0Z5kw5kITtKTRYMhm1JMClOFYdHnQszEvqw==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/glob": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz", + "integrity": "sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w==", + "dev": true, + "requires": { + "@types/events": "*", + "@types/minimatch": "*", + "@types/node": "*" + } + }, "@types/istanbul-lib-coverage": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", @@ -6033,6 +6059,103 @@ "integrity": "sha512-wBlsw+8n21e6eTd4yVv8YD/E3xq0O6nNnJIquutAsFGE7EyMKz7W6RNT6BRu1SmdgmlCZ9tb0X+j+D6HGr8pZw==", "dev": true }, + "@typescript-eslint/eslint-plugin": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.18.0.tgz", + "integrity": "sha512-kuO8WQjV+RCZvAXVRJfXWiJ8iYEtfHlKgcqqqXg9uUkIolEHuUaMmm8/lcO4xwCOtaw6mY0gStn2Lg4/eUXXYQ==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "2.18.0", + "eslint-utils": "^1.4.3", + "functional-red-black-tree": "^1.0.1", + "regexpp": "^3.0.0", + "tsutils": "^3.17.1" + }, + "dependencies": { + "@typescript-eslint/experimental-utils": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.18.0.tgz", + "integrity": "sha512-J6MopKPHuJYmQUkANLip7g9I82ZLe1naCbxZZW3O2sIxTiq/9YYoOELEKY7oPg0hJ0V/AQ225h2z0Yp+RRMXhw==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "2.18.0", + "eslint-scope": "^5.0.0" + } + }, + "@typescript-eslint/typescript-estree": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.18.0.tgz", + "integrity": "sha512-gVHylf7FDb8VSi2ypFuEL3hOtoC4HkZZ5dOjXvVjoyKdRrvXAOPSzpNRnKMfaUUEiSLP8UF9j9X9EDLxC0lfZg==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "eslint-visitor-keys": "^1.1.0", + "glob": "^7.1.6", + "is-glob": "^4.0.1", + "lodash": "^4.17.15", + "semver": "^6.3.0", + "tsutils": "^3.17.1" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "eslint-utils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", + "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + }, + "eslint-visitor-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "regexpp": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.0.0.tgz", + "integrity": "sha512-Z+hNr7RAVWxznLPuA7DIh8UNX1j9CDrUQxskw9IrBE1Dxue2lyXT+shqEIeLUjrokxIP8CMy1WkjgG3rTsd5/g==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "@typescript-eslint/experimental-utils": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-1.13.0.tgz", @@ -6056,6 +6179,87 @@ } } }, + "@typescript-eslint/parser": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.18.0.tgz", + "integrity": "sha512-SJJPxFMEYEWkM6pGfcnjLU+NJIPo+Ko1QrCBL+i0+zV30ggLD90huEmMMhKLHBpESWy9lVEeWlQibweNQzyc+A==", + "dev": true, + "requires": { + "@types/eslint-visitor-keys": "^1.0.0", + "@typescript-eslint/experimental-utils": "2.18.0", + "@typescript-eslint/typescript-estree": "2.18.0", + "eslint-visitor-keys": "^1.1.0" + }, + "dependencies": { + "@typescript-eslint/experimental-utils": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.18.0.tgz", + "integrity": "sha512-J6MopKPHuJYmQUkANLip7g9I82ZLe1naCbxZZW3O2sIxTiq/9YYoOELEKY7oPg0hJ0V/AQ225h2z0Yp+RRMXhw==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "2.18.0", + "eslint-scope": "^5.0.0" + } + }, + "@typescript-eslint/typescript-estree": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.18.0.tgz", + "integrity": "sha512-gVHylf7FDb8VSi2ypFuEL3hOtoC4HkZZ5dOjXvVjoyKdRrvXAOPSzpNRnKMfaUUEiSLP8UF9j9X9EDLxC0lfZg==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "eslint-visitor-keys": "^1.1.0", + "glob": "^7.1.6", + "is-glob": "^4.0.1", + "lodash": "^4.17.15", + "semver": "^6.3.0", + "tsutils": "^3.17.1" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "eslint-visitor-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "@typescript-eslint/typescript-estree": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-1.13.0.tgz", @@ -7963,6 +8167,12 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, + "colorette": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.1.0.tgz", + "integrity": "sha512-6S062WDQUXi6hOfkO/sBPVwE5ASXY4G2+b4atvhJfSsuUUhIaUKlkjLe9692Ipyt5/a+IPF5aVTu3V5gvXq5cg==", + "dev": true + }, "colors": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", @@ -21301,6 +21511,47 @@ } } }, + "rollup-plugin-copy": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-copy/-/rollup-plugin-copy-3.3.0.tgz", + "integrity": "sha512-euDjCUSBXZa06nqnwCNADbkAcYDfzwowfZQkto9K/TFhiH+QG7I4PUsEMwM9tDgomGWJc//z7KLW8t+tZwxADA==", + "dev": true, + "requires": { + "@types/fs-extra": "^8.0.1", + "colorette": "^1.1.0", + "fs-extra": "^8.1.0", + "globby": "10.0.1", + "is-plain-object": "^3.0.0" + }, + "dependencies": { + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "graceful-fs": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", + "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", + "dev": true + }, + "is-plain-object": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-3.0.0.tgz", + "integrity": "sha512-tZIpofR+P05k8Aocp7UI/2UTa9lTJSebCXpFFoR9aibpokDj/uXBsJ8luUu0tTVYKkMU6URDUuOfJZ7koewXvg==", + "dev": true, + "requires": { + "isobject": "^4.0.0" + } + } + } + }, "rollup-plugin-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/rollup-plugin-json/-/rollup-plugin-json-4.0.0.tgz", @@ -23819,6 +24070,15 @@ "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", "dev": true }, + "tsutils": { + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", + "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/web3.js/package.json b/web3.js/package.json index 0fe95518f..d8b049e7d 100644 --- a/web3.js/package.json +++ b/web3.js/package.json @@ -21,6 +21,7 @@ }, "main": "lib/index.cjs.js", "module": "lib/index.esm.js", + "types": "lib/index.d.ts", "bin": { "solana-bpf-sdk-install": "bin/bpf-sdk-install.sh", "solana-localnet": "bin/localnet.sh" @@ -49,7 +50,7 @@ "flow": "set -ex; flow stop; flow-typed install jest@24; flow", "flow:stop": "flow stop", "flow:watch": "flow stop; watch 'flow' . --wait=1 --ignoreDirectoryPattern=/doc/", - "lint": "set -ex; npm run pretty; eslint .", + "lint": "set -ex; npm run pretty; eslint . --ext .js,.ts", "lint:fix": "npm run lint -- --fix", "lint:watch": "watch 'npm run lint:fix' . --wait=1 --ignoreDirectoryPattern=/doc/", "localnet:down": "bin/localnet.sh down", @@ -58,7 +59,7 @@ "localnet:update": "bin/localnet.sh update", "ok": "run-s lint flow test doc", "prepare": "run-s clean bpf-sdk:install bpf-sdk:remove-symlinks build", - "pretty": "prettier --write '{,{examples,src,test}/**/}*.js'", + "pretty": "prettier --write '{,{examples,src,test}/**/}*.{j,t}s'", "re": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git", "test": "npm run build:fixtures && cross-env NODE_ENV=test jest --useStderr", "test:cover": "npm run build:fixtures && cross-env NODE_ENV=test jest --coverage --useStderr", @@ -90,6 +91,8 @@ "@babel/preset-flow": "^7.0.0", "@commitlint/config-conventional": "^8.0.0", "@commitlint/travis-cli": "^8.0.0", + "@typescript-eslint/eslint-plugin": "^2.18.0", + "@typescript-eslint/parser": "^2.18.0", "acorn": "^7.0.0", "babel-eslint": "10.0.3", "babel-plugin-module-resolver": "3.2.0", @@ -117,6 +120,7 @@ "rollup": "1.15.2", "rollup-plugin-babel": "^4.3.2", "rollup-plugin-commonjs": "^10.0.0", + "rollup-plugin-copy": "^3.3.0", "rollup-plugin-json": "^4.0.0", "rollup-plugin-node-builtins": "^2.1.2", "rollup-plugin-node-globals": "^1.2.1", diff --git a/web3.js/rollup.config.js b/web3.js/rollup.config.js index 5d18f7936..4373053e0 100644 --- a/web3.js/rollup.config.js +++ b/web3.js/rollup.config.js @@ -1,6 +1,7 @@ import babel from 'rollup-plugin-babel'; import builtins from 'rollup-plugin-node-builtins'; import commonjs from 'rollup-plugin-commonjs'; +import copy from 'rollup-plugin-copy'; import globals from 'rollup-plugin-node-globals'; import json from 'rollup-plugin-json'; import nodeResolve from 'rollup-plugin-node-resolve'; @@ -22,6 +23,9 @@ function generateConfig(configType) { 'process.env.NODE_ENV': JSON.stringify(env), }), commonjs(), + copy({ + targets: [{src: 'module.d.ts', dest: 'lib', rename: 'index.d.ts'}], + }), ], };