chore: add defs check

This commit is contained in:
Justin Starry 2021-02-08 09:13:06 +08:00 committed by Justin Starry
parent 4e6f914a9d
commit 6cd9c768ad
12 changed files with 361 additions and 36 deletions

View File

@ -9,6 +9,6 @@ cd token/js
npm install
npm run lint
npm run flow
npx tsc --esModuleInterop module.d.ts
npm run defs
npm run start-with-test-validator
PROGRAM_VERSION=2.0.4 npm run start-with-test-validator

View File

@ -53,4 +53,24 @@ module.exports = {
version: 'detect',
},
},
overrides: [
{
files: ['*.js'],
plugins: ['flowtype'],
extends: ['plugin:flowtype/recommended'],
rules: {
'flowtype/no-types-missing-file-annotation': 'off',
'flowtype/generic-spacing': [0],
},
},
{
files: ['*.d.ts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
},
},
],
};

View File

@ -1,4 +0,0 @@
declare module 'bn.js' {
// TODO: Fill in types
declare module.exports: any;
}

View File

@ -1,6 +0,0 @@
declare module 'bs58' {
declare module.exports: {
encode(input: Buffer): string;
decode(input: string): Buffer;
};
}

View File

@ -1,4 +0,0 @@
declare module 'buffer-layout' {
// TODO: Fill in types
declare module.exports: any;
}

View File

@ -1,10 +1,10 @@
// flow-typed signature: 65e18196703cbb222ea294226e99826d
// flow-typed version: <<STUB>>/mkdirp_v5.0.1/flow_v0.84.0
// flow-typed signature: 3b419b6cce77a4dadadb68a0d0f301cd
// flow-typed version: <<STUB>>/bn.js_v^5.1.0/flow_v0.142.0
/**
* This is an autogenerated libdef stub for:
*
* 'mkdirp'
* 'bn.js'
*
* Fill this stub out by replacing all the `any` types.
*
@ -13,7 +13,7 @@
* https://github.com/flowtype/flow-typed
*/
declare module 'mkdirp' {
declare module 'bn.js' {
declare module.exports: any;
}
@ -22,11 +22,11 @@ declare module 'mkdirp' {
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'mkdirp/lib/index' {
declare module 'bn.js/lib/bn' {
declare module.exports: any;
}
// Filename aliases
declare module 'mkdirp/lib/index.js' {
declare module.exports: $Exports<'mkdirp/lib/index'>;
declare module 'bn.js/lib/bn.js' {
declare module.exports: $Exports<'bn.js/lib/bn'>;
}

View File

@ -0,0 +1,53 @@
// flow-typed signature: a8fa25a70253f0b094eadea455a57eeb
// flow-typed version: <<STUB>>/buffer-layout_v^1.2.0/flow_v0.142.0
/**
* This is an autogenerated libdef stub for:
*
* 'buffer-layout'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'buffer-layout' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'buffer-layout/jsdoc/custom/local' {
declare module.exports: any;
}
declare module 'buffer-layout/lib/Layout' {
declare module.exports: any;
}
declare module 'buffer-layout/test/examples' {
declare module.exports: any;
}
declare module 'buffer-layout/test/LayoutTest' {
declare module.exports: any;
}
// Filename aliases
declare module 'buffer-layout/jsdoc/custom/local.js' {
declare module.exports: $Exports<'buffer-layout/jsdoc/custom/local'>;
}
declare module 'buffer-layout/lib/Layout.js' {
declare module.exports: $Exports<'buffer-layout/lib/Layout'>;
}
declare module 'buffer-layout/test/examples.js' {
declare module.exports: $Exports<'buffer-layout/test/examples'>;
}
declare module 'buffer-layout/test/LayoutTest.js' {
declare module.exports: $Exports<'buffer-layout/test/LayoutTest'>;
}

View File

@ -0,0 +1,33 @@
// flow-typed signature: 8dedcebf9a48fa95d40824e83a7eef7d
// flow-typed version: <<STUB>>/buffer_v6.0.1/flow_v0.130.0
/**
* This is an autogenerated libdef stub for:
*
* 'buffer'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'buffer' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
// Filename aliases
declare module 'buffer/index' {
declare module.exports: $Exports<'buffer'>;
}
declare module 'buffer/index.js' {
declare module.exports: $Exports<'buffer'>;
}

View File

@ -1,5 +1,5 @@
// flow-typed signature: ed29f42bf4f4916e4f3ba1f5e7343c9d
// flow-typed version: <<STUB>>/mz_v2.7.0/flow_v0.81.0
// flow-typed signature: 8c41c7830553f11284b1a8a5a831bccb
// flow-typed version: <<STUB>>/mz_v^2.7.0/flow_v0.142.0
/**
* This is an autogenerated libdef stub for:

View File

@ -2,14 +2,24 @@
* Flow Library definition for spl-token
*
* This file is manually maintained
*
*/
import BN from 'bn.js'; // eslint-disable-line
import {Buffer} from 'buffer';
import {Layout} from 'buffer-layout';
import {
Account,
Connection,
PublicKey,
TransactionInstruction,
} from '@solana/web3.js';
import type {TransactionSignature} from '@solana/web3.js';
declare module '@solana/spl-token' {
declare export var TOKEN_PROGRAM_ID;
declare export class u64 extends BN {
toBuffer(): Buffer;
static fromBuffer(buffer: Buffer): u64;
toBuffer(): typeof Buffer;
static fromBuffer(buffer: typeof Buffer): u64;
}
declare export type AuthorityType =
| 'MintTokens'
@ -17,7 +27,7 @@ declare module '@solana/spl-token' {
| 'AccountOwner'
| 'CloseAccount';
declare export var NATIVE_MINT: PublicKey;
declare export var MintLayout: Layout;
declare export var MintLayout: typeof Layout;
declare export type MintInfo = {|
mintAuthority: null | PublicKey,
supply: u64,
@ -25,7 +35,7 @@ declare module '@solana/spl-token' {
isInitialized: boolean,
freezeAuthority: null | PublicKey,
|};
declare export var AccountLayout: Layout;
declare export var AccountLayout: typeof Layout;
declare export type AccountInfo = {|
mint: PublicKey,
owner: PublicKey,

View File

@ -3040,6 +3040,17 @@
"secp256k1": "^4.0.2",
"superstruct": "^0.8.3",
"tweetnacl": "^1.0.0"
},
"dependencies": {
"buffer": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.1.tgz",
"integrity": "sha512-rVAXBwEcEoYtxnHSO5iWyhzV/O1WMtkUYWlfdLS7FjU4PnSJJHEfHXi/uHPI5EwltmOA794gN3bm3/pzuctWjQ==",
"requires": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
}
}
},
"@szmarczak/http-timer": {
@ -3127,6 +3138,12 @@
"integrity": "sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A==",
"dev": true
},
"@types/json-schema": {
"version": "7.0.7",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz",
"integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==",
"dev": true
},
"@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
@ -3177,6 +3194,175 @@
"@types/node": "*"
}
},
"@typescript-eslint/eslint-plugin": {
"version": "4.14.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.14.2.tgz",
"integrity": "sha512-uMGfG7GFYK/nYutK/iqYJv6K/Xuog/vrRRZX9aEP4Zv1jsYXuvFUMDFLhUnc8WFv3D2R5QhNQL3VYKmvLS5zsQ==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "4.14.2",
"@typescript-eslint/scope-manager": "4.14.2",
"debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1",
"lodash": "^4.17.15",
"regexpp": "^3.0.0",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"debug": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"dev": true,
"requires": {
"ms": "2.1.2"
}
},
"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
}
}
},
"@typescript-eslint/experimental-utils": {
"version": "4.14.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.14.2.tgz",
"integrity": "sha512-mV9pmET4C2y2WlyHmD+Iun8SAEqkLahHGBkGqDVslHkmoj3VnxnGP4ANlwuxxfq1BsKdl/MPieDbohCEQgKrwA==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/scope-manager": "4.14.2",
"@typescript-eslint/types": "4.14.2",
"@typescript-eslint/typescript-estree": "4.14.2",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
}
},
"@typescript-eslint/parser": {
"version": "4.14.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.14.2.tgz",
"integrity": "sha512-ipqSP6EuUsMu3E10EZIApOJgWSpcNXeKZaFeNKQyzqxnQl8eQCbV+TSNsl+s2GViX2d18m1rq3CWgnpOxDPgHg==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "4.14.2",
"@typescript-eslint/types": "4.14.2",
"@typescript-eslint/typescript-estree": "4.14.2",
"debug": "^4.1.1"
},
"dependencies": {
"debug": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"dev": true,
"requires": {
"ms": "2.1.2"
}
},
"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
}
}
},
"@typescript-eslint/scope-manager": {
"version": "4.14.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.14.2.tgz",
"integrity": "sha512-cuV9wMrzKm6yIuV48aTPfIeqErt5xceTheAgk70N1V4/2Ecj+fhl34iro/vIssJlb7XtzcaD07hWk7Jk0nKghg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.14.2",
"@typescript-eslint/visitor-keys": "4.14.2"
}
},
"@typescript-eslint/types": {
"version": "4.14.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.14.2.tgz",
"integrity": "sha512-LltxawRW6wXy4Gck6ZKlBD05tCHQUj4KLn4iR69IyRiDHX3d3NCAhO+ix5OR2Q+q9bjCrHE/HKt+riZkd1At8Q==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "4.14.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.2.tgz",
"integrity": "sha512-ESiFl8afXxt1dNj8ENEZT12p+jl9PqRur+Y19m0Z/SPikGL6rqq4e7Me60SU9a2M28uz48/8yct97VQYaGl0Vg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.14.2",
"@typescript-eslint/visitor-keys": "4.14.2",
"debug": "^4.1.1",
"globby": "^11.0.1",
"is-glob": "^4.0.1",
"lodash": "^4.17.15",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"debug": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"dev": true,
"requires": {
"ms": "2.1.2"
}
},
"globby": {
"version": "11.0.2",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.0.2.tgz",
"integrity": "sha512-2ZThXDvvV8fYFRVIxnrMQBipZQDr7MxKAmQK1vujaj9/7eF0efG7BPUKJ7jP7G5SLF37xKDXvO4S/KKLj/Z0og==",
"dev": true,
"requires": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.1.1",
"ignore": "^5.1.4",
"merge2": "^1.3.0",
"slash": "^3.0.0"
}
},
"ignore": {
"version": "5.1.8",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz",
"integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==",
"dev": true
},
"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
},
"slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"dev": true
}
}
},
"@typescript-eslint/visitor-keys": {
"version": "4.14.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.2.tgz",
"integrity": "sha512-KBB+xLBxnBdTENs/rUgeUKO0UkPBRs2vD09oMRRIkj5BEN8PX1ToXV532desXfpQnZsYTyLLviS7JrPhdL154w==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.14.2",
"eslint-visitor-keys": "^2.0.0"
},
"dependencies": {
"eslint-visitor-keys": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz",
"integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==",
"dev": true
}
}
},
"JSONStream": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
@ -4665,6 +4851,16 @@
"pkg-dir": "^2.0.0"
}
},
"eslint-plugin-flowtype": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-flowtype/-/eslint-plugin-flowtype-5.2.0.tgz",
"integrity": "sha512-z7ULdTxuhlRJcEe1MVljePXricuPOrsWfScRXFhNzVD5dmTHWjIF57AxD0e7AbEoLSbjSsaA5S+hCg43WvpXJQ==",
"dev": true,
"requires": {
"lodash": "^4.17.15",
"string-natural-compare": "^3.0.1"
}
},
"eslint-plugin-import": {
"version": "2.22.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz",
@ -5212,9 +5408,9 @@
"dev": true
},
"flow-bin": {
"version": "0.142.0",
"resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.142.0.tgz",
"integrity": "sha512-YgiapK/wrJjcgSgOWfoncbZ4vZrZWdHs+p7V9duI9zo4ehW2nM/VRrpSaWoZ+CWu3t+duGyAvupJvC6MM2l07w==",
"version": "0.144.0",
"resolved": "https://registry.npmjs.org/flow-bin/-/flow-bin-0.144.0.tgz",
"integrity": "sha512-+TeTukkfRjimaNhOHt8iQ/M33Fg8Afrm+iBHS19XzAz2fH4GwgroKCrAxDHnZoAUnmRv6jm/XngFxADlcqwYkw==",
"dev": true
},
"flow-typed": {
@ -5345,6 +5541,12 @@
"resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz",
"integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==",
"dev": true
},
"typescript": {
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz",
"integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==",
"dev": true
}
}
},
@ -7813,6 +8015,12 @@
"duplexer": "~0.1.1"
}
},
"string-natural-compare": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/string-natural-compare/-/string-natural-compare-3.0.1.tgz",
"integrity": "sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==",
"dev": true
},
"string-width": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
@ -8181,6 +8389,15 @@
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
},
"tsutils": {
"version": "3.20.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.20.0.tgz",
"integrity": "sha512-RYbuQuvkhuqVeXweWT3tJLKOEJ/UUw9GjNEZGWdrLLlM+611o1gwLHBpxoFJKKl25fLprp2eVthtKs5JOrNeXg==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
},
"tweetnacl": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
@ -8207,9 +8424,9 @@
"dev": true
},
"typescript": {
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz",
"integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz",
"integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==",
"dev": true
},
"typescript-compiler": {

View File

@ -37,6 +37,7 @@
"cluster:devnet": "cp cluster-devnet.env .env",
"cluster:testnet": "cp cluster-testnet.env .env",
"cluster:mainnet-beta": "cp cluster-mainnet-beta.env .env",
"defs": "set -ex; flow check-contents < module.flow.js; tsc --esModuleInterop module.d.ts",
"pretty": "prettier --check '{,cli*/**/}*.[jt]s'",
"pretty:fix": "prettier --write '{,cli*/**/}*.[jt]s'"
},
@ -44,6 +45,7 @@
"@babel/runtime": "^7.10.5",
"@solana/web3.js": "^0.91.0",
"bn.js": "^5.1.0",
"buffer": "6.0.1",
"buffer-layout": "^1.2.0",
"dotenv": "8.2.0",
"mkdirp": "1.0.4"
@ -59,16 +61,20 @@
"@rollup/plugin-babel": "^5.1.0",
"@rollup/plugin-commonjs": "^17.0.0",
"@types/bn.js": "^5.1.0",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"babel-eslint": "^10.1.0",
"eslint": "^7.4.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.0",
"flow-bin": "0.142.0",
"flow-bin": "^0.144.0",
"flow-typed": "^3.2.0",
"mz": "^2.7.0",
"prettier": "^2.0.5",
"rollup": "^2.23.0",
"rollup-plugin-copy": "^3.3.0",
"start-server-and-test": "^1.11.6",
"typescript": "^4.1.3",
"watch": "^1.0.2"
},
"engines": {