chore: migrate to typescript

This commit is contained in:
Justin Starry
2021-03-15 11:01:35 +08:00
committed by Justin Starry
parent 3eb9f7b3eb
commit f912c63b22
51 changed files with 948 additions and 980 deletions

View File

@@ -1,8 +1,3 @@
//@flow
/**
* @private
*/
const endpoint = {
http: {
devnet: 'http://devnet.solana.com',

View File

@@ -1,15 +1,13 @@
// @flow
export function promiseTimeout<T>(
promise: Promise<T>,
timeoutMs: number,
): Promise<T | null> {
let timeoutId: TimeoutID;
const timeoutPromise = new Promise(resolve => {
let timeoutId: ReturnType<typeof setTimeout>;
const timeoutPromise: Promise<null> = new Promise(resolve => {
timeoutId = setTimeout(() => resolve(null), timeoutMs);
});
return Promise.race([promise, timeoutPromise]).then(result => {
return Promise.race([promise, timeoutPromise]).then((result: T | null) => {
clearTimeout(timeoutId);
return result;
});

View File

@@ -1,5 +1,3 @@
// @flow
import {Connection} from '../connection';
import type {TransactionSignature} from '../transaction';
import type {ConfirmOptions} from '../connection';

View File

@@ -1,5 +1,3 @@
// @flow
import {Connection} from '../connection';
import {Transaction} from '../transaction';
import type {Account} from '../account';

View File

@@ -1,10 +1,8 @@
// @flow
export function decodeLength(bytes: Array<number>): number {
let len = 0;
let size = 0;
for (;;) {
let elem = bytes.shift();
let elem = bytes.shift() as number;
len |= (elem & 0x7f) << (size * 7);
size += 1;
if ((elem & 0x80) === 0) {

View File

@@ -1,5 +1,3 @@
// @flow
// zzz
export function sleep(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));

View File

@@ -1,5 +1,3 @@
// @flow
import {Buffer} from 'buffer';
export const toBuffer = (arr: Buffer | Uint8Array | Array<number>): Buffer => {