Switch to tsc for transpilation
This commit is contained in:
parent
872eebb1a5
commit
a1d699b088
12
.babelrc
12
.babelrc
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"presets": [
|
||||
[ "@babel/preset-env", { "modules": "auto" } ]
|
||||
],
|
||||
"plugins": [
|
||||
"@babel/transform-runtime",
|
||||
["@babel/plugin-proposal-class-properties", { "loose": true }]
|
||||
],
|
||||
"ignore": [
|
||||
"**/*.test.js"
|
||||
]
|
||||
}
|
14
.eslintrc
14
.eslintrc
|
@ -1,11 +1,10 @@
|
|||
{
|
||||
"parser": "babel-eslint",
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"standard",
|
||||
"standard-react",
|
||||
"plugin:prettier/recommended",
|
||||
"prettier/standard",
|
||||
"prettier/react"
|
||||
"prettier/standard"
|
||||
],
|
||||
"env": {
|
||||
"node": true,
|
||||
|
@ -18,17 +17,8 @@
|
|||
"jsx": true
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"react": {
|
||||
"version": "16"
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"space-before-function-paren": 0,
|
||||
"react/prop-types": 0,
|
||||
"react/jsx-handler-names": 0,
|
||||
"react/jsx-fragments": 0,
|
||||
"react/no-unused-prop-types": 0,
|
||||
"import/export": 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
preset: 'ts-jest/presets/js-with-ts',
|
||||
testEnvironment: 'node',
|
||||
};
|
32
package.json
32
package.json
|
@ -10,54 +10,44 @@
|
|||
"node": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src --out-dir lib",
|
||||
"start": "babel src --out-dir lib --watch",
|
||||
"build": "tsc",
|
||||
"start": "tsc --watch",
|
||||
"clean": "rm -rf lib",
|
||||
"prepare": "run-s clean build",
|
||||
"test": "run-s test:unit test:lint test:build",
|
||||
"test:build": "run-s build",
|
||||
"test:lint": "eslint src",
|
||||
"test:unit": "cross-env CI=1 react-scripts test",
|
||||
"test:watch": "react-scripts test"
|
||||
"test:unit": "jest",
|
||||
"test:watch": "jest --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.10.5",
|
||||
"@babel/core": "^7.11.1",
|
||||
"@babel/plugin-proposal-class-properties": "^7.10.4",
|
||||
"@babel/plugin-transform-runtime": "^7.11.0",
|
||||
"@babel/preset-env": "^7.11.0",
|
||||
"@tsconfig/node12": "^1.0.7",
|
||||
"@types/jest": "^26.0.9",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint": "^7.6.0",
|
||||
"eslint-config-prettier": "^6.7.0",
|
||||
"eslint-config-standard": "^14.1.0",
|
||||
"eslint-config-standard-react": "^9.2.0",
|
||||
"eslint-plugin-import": "^2.18.2",
|
||||
"eslint-plugin-node": "^11.0.0",
|
||||
"eslint-plugin-prettier": "^3.1.1",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-react": "^7.17.0",
|
||||
"eslint-plugin-standard": "^4.0.1",
|
||||
"jest": "^26.4.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.0.4",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-scripts": "^3.4.1"
|
||||
"ts-jest": "^26.2.0",
|
||||
"typescript": "^3.9.7"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"jest": {
|
||||
"transformIgnorePatterns": [
|
||||
"^.+\\.cjs$"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
},
|
||||
"dependencies": {
|
||||
"@solana/web3.js": "^0.68",
|
||||
"@solana/web3.js": "^0.70.3",
|
||||
"bn.js": "^5.1.2",
|
||||
"buffer-layout": "^1.2.0"
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { blob, struct, u16, u32, u8, union } from 'buffer-layout';
|
||||
import { struct, u16, u32, u8, union } from 'buffer-layout';
|
||||
import {
|
||||
orderTypeLayout,
|
||||
publicKeyLayout,
|
||||
|
@ -6,7 +6,6 @@ import {
|
|||
u128,
|
||||
u64,
|
||||
VersionedLayout,
|
||||
zeros,
|
||||
} from './layout';
|
||||
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
||||
import { TOKEN_PROGRAM_ID } from './token-instructions';
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// @ts-nocheck
|
||||
|
||||
import { bits, Blob, Layout, u32, UInt } from 'buffer-layout';
|
||||
import { PublicKey } from '@solana/web3.js';
|
||||
import BN from 'bn.js';
|
||||
|
@ -138,6 +140,19 @@ export function orderTypeLayout(property) {
|
|||
return new EnumLayout({ limit: 0, ioc: 1, postOnly: 2 }, 4, property);
|
||||
}
|
||||
|
||||
const ACCOUNT_FLAGS_LAYOUT = new WideBits();
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('initialized');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('market');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('openOrders');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('requestQueue');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('eventQueue');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('bids');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('asks');
|
||||
|
||||
export function accountFlagsLayout(property = 'accountFlags') {
|
||||
return ACCOUNT_FLAGS_LAYOUT.replicate(property);
|
||||
}
|
||||
|
||||
export function setLayoutDecoder(layout, decoder) {
|
||||
const originalDecode = layout.decode;
|
||||
layout.decode = function decode(b, offset = 0) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { blob, seq, struct, u8 } from 'buffer-layout';
|
||||
import { publicKeyLayout, u128, u64, WideBits } from './layout';
|
||||
import { accountFlagsLayout, publicKeyLayout, u128, u64 } from './layout';
|
||||
import { SLAB_LAYOUT } from './slab';
|
||||
import { DEX_PROGRAM_ID, DexInstructions } from './instructions';
|
||||
import BN from 'bn.js';
|
||||
|
@ -10,21 +10,8 @@ import {
|
|||
Transaction,
|
||||
} from '@solana/web3.js';
|
||||
|
||||
const ACCOUNT_FLAGS_LAYOUT = new WideBits();
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('initialized');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('market');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('openOrders');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('requestQueue');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('eventQueue');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('bids');
|
||||
ACCOUNT_FLAGS_LAYOUT.addBoolean('asks');
|
||||
|
||||
export function accountFlags(property = 'accountFlags') {
|
||||
return ACCOUNT_FLAGS_LAYOUT.replicate(property);
|
||||
}
|
||||
|
||||
export const MARKET_STATE_LAYOUT = struct([
|
||||
accountFlags('accountFlags'),
|
||||
accountFlagsLayout('accountFlags'),
|
||||
|
||||
publicKeyLayout('ownAddress'),
|
||||
|
||||
|
@ -322,7 +309,7 @@ export class Market {
|
|||
}
|
||||
|
||||
export const OPEN_ORDERS_LAYOUT = struct([
|
||||
accountFlags('accountFlags'),
|
||||
accountFlagsLayout('accountFlags'),
|
||||
|
||||
publicKeyLayout('market'),
|
||||
publicKeyLayout('owner'),
|
||||
|
@ -420,7 +407,7 @@ export class OpenOrders {
|
|||
}
|
||||
|
||||
export const ORDERBOOK_LAYOUT = struct([
|
||||
accountFlags('accountFlags'),
|
||||
accountFlagsLayout('accountFlags'),
|
||||
SLAB_LAYOUT.replicate('slab'),
|
||||
]);
|
||||
|
||||
|
@ -445,7 +432,7 @@ export class Orderbook {
|
|||
for (const { key, quantity } of this.slab.items(descending)) {
|
||||
const price = getPriceFromKey(key);
|
||||
if (levels.length > 0 && levels[levels.length - 1][0].equals(price)) {
|
||||
levels[levels.length - 1].iadd(quantity);
|
||||
levels[levels.length - 1][1].iadd(quantity);
|
||||
} else if (levels.length === depth) {
|
||||
break;
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { accountFlags } from './market';
|
||||
import { accountFlagsLayout } from './layout';
|
||||
|
||||
describe('accountFlags', () => {
|
||||
const layout = accountFlags();
|
||||
const layout = accountFlagsLayout();
|
||||
it('parses', () => {
|
||||
const b = Buffer.from('0000000000000000', 'hex');
|
||||
expect(layout.getSpan(b)).toBe(8);
|
||||
|
|
|
@ -53,10 +53,10 @@ function encodeTokenInstructionData(instruction) {
|
|||
|
||||
export function initializeMint({
|
||||
mint,
|
||||
amount,
|
||||
amount = 0,
|
||||
decimals,
|
||||
initialAccount,
|
||||
mintOwner,
|
||||
initialAccount = null,
|
||||
mintOwner = null,
|
||||
}) {
|
||||
const keys = [{ pubkey: mint, isSigner: false, isWritable: true }];
|
||||
if (amount) {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"extends": "@tsconfig/node12/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./lib",
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["./src/**/*"],
|
||||
"exclude": ["./src/**/*.test.js", "node_modules", "**/node_modules"]
|
||||
}
|
Loading…
Reference in New Issue