From 1a4bb7fe2bf0322440709986e90dd1f0252123b9 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 22 Jan 2020 09:54:23 +0100 Subject: [PATCH] Copy config from parent dir --- .gitignore | 9 +++++++ jasmine-spec-reporter.config.json | 12 +++++++++ jasmine-testrunner.js | 2 +- package.json | 40 +++++++++++++++++++++++++---- tsconfig.json | 29 ++++++++++++++++++--- tslint.json | 42 ++++++++++++++++++++++++++++++- types/address.d.ts | 21 ++++++++++++---- types/cosmoscodec.d.ts | 8 ++++-- types/cosmosconnection.d.ts | 27 ++++++++++++++------ types/cosmosconnector.d.ts | 2 +- types/decode.d.ts | 20 +++++++++++---- types/encode.d.ts | 13 ++++++++-- types/restclient.d.ts | 5 +++- types/types.d.ts | 4 ++- 14 files changed, 199 insertions(+), 35 deletions(-) create mode 100644 jasmine-spec-reporter.config.json diff --git a/.gitignore b/.gitignore index 07ca4b31..7a470402 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,12 @@ node_modules/ # Release dir tmp/ + +# Build artifacts +build/ +dist/ +docs/ + +# Lock file? +yarn.lock +npm.lock diff --git a/jasmine-spec-reporter.config.json b/jasmine-spec-reporter.config.json new file mode 100644 index 00000000..3a997556 --- /dev/null +++ b/jasmine-spec-reporter.config.json @@ -0,0 +1,12 @@ +{ + "suite": { + "displayNumber": true + }, + "spec": { + "displayDuration": true + }, + "summary": { + "displayPending": false, + "displayStacktrace": true + } +} diff --git a/jasmine-testrunner.js b/jasmine-testrunner.js index 9fada59b..55b2df29 100755 --- a/jasmine-testrunner.js +++ b/jasmine-testrunner.js @@ -1,7 +1,7 @@ #!/usr/bin/env node require("source-map-support").install(); -const defaultSpecReporterConfig = require("../../jasmine-spec-reporter.config.json"); +const defaultSpecReporterConfig = require("./jasmine-spec-reporter.config.json"); // setup Jasmine const Jasmine = require("jasmine"); diff --git a/package.json b/package.json index 6db02352..8ddeb511 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "@iov/cosmos", + "name": "cosm-js", "version": "2.0.0-alpha.7", - "description": "Transaction codec and client to communicate with the Cosmos Hub blockchain", - "author": "IOV SAS ", + "description": "Transaction codec and client to communicate with any wasmd blockchain", + "author": "Ethan Frey ", "license": "Apache-2.0", "main": "build/index.js", "types": "types/index.d.ts", @@ -15,7 +15,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/iov-one/iov-core/tree/master/packages/iov-cosmos" + "url": "https://github.com/confio/cosm-js" }, "publishConfig": { "access": "public" @@ -48,6 +48,36 @@ "xstream": "^11.11.0" }, "devDependencies": { - "@iov/keycontrol": "^2.0.0-alpha.7" + "@iov/keycontrol": "^2.0.0-alpha.7", + "@types/jasmine": "^3.3.7", + "@types/memdown": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^2.10.0", + "@typescript-eslint/parser": "^2.10.0", + "eslint": "^6.7.2", + "eslint-config-prettier": "^6.2.0", + "eslint-plugin-import": "^2.18.2", + "eslint-plugin-prettier": "^3.1.0", + "eslint-plugin-simple-import-sort": "^4.0.0", + "jasmine": "^3.3.1", + "jasmine-spec-reporter": "^4.2.1", + "karma": "^4.1.0", + "karma-chrome-launcher": "^2.2.0", + "karma-edge-launcher": "^0.4.2", + "karma-firefox-launcher": "^1.1.0", + "karma-jasmine": "^2", + "karma-jasmine-html-reporter": "^1.4", + "karma-safari-launcher": "^1.0.0", + "lerna": "^3.14.1", + "memdown": "^4.0.0", + "prettier": "^1.19.1", + "shx": "^0.3.2", + "source-map-support": "^0.5.6", + "tslint": "^5.19.0", + "tslint-config-prettier": "^1.13.0", + "tslint-immutable": "^5.5.2", + "typescript": "~3.7", + "webpack": "^4.12.0", + "webpack-cli": "^3.3.8" + } } diff --git a/tsconfig.json b/tsconfig.json index aaac1f7d..e1e7ec19 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,31 @@ { - "extends": "../../tsconfig.json", "compilerOptions": { "baseUrl": ".", - "outDir": "build", + "declaration": true, "declarationDir": "build/types", - "rootDir": "src" + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "module": "commonjs", + "moduleResolution": "node", + "newLine": "LF", + "noEmitOnError": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "noUnusedLocals": false, + "noUnusedParameters": false, + "outDir": "build", + "pretty": true, + "removeComments": false, + "resolveJsonModule": true, + "rootDir": "src", + "sourceMap": true, + "strict": true, + "target": "es6", + "lib": ["es6"], + "typeRoots": [ + "./custom_types", + "./node_modules/@types" + ] }, "include": ["src/**/*"] -} +} \ No newline at end of file diff --git a/tslint.json b/tslint.json index 0946f209..f1c4bad8 100644 --- a/tslint.json +++ b/tslint.json @@ -1,3 +1,43 @@ { - "extends": "../../tslint.json" + "defaultSeverity": "error", + "extends": ["tslint:latest", "tslint-immutable", "tslint-config-prettier"], + "jsRules": {}, + "rules": { + "array-type": [true, "array"], + "callable-types": false, + "comment-format": [true, "check-space"], + "curly": false, + "deprecation": true, + "interface-name": [true, "never-prefix"], + "max-classes-per-file": false, + "no-class": false, + "no-conditional-assignment": false, + "no-console": [true, "log"], + "no-delete": true, + "no-empty": false, + "no-empty-interface": false, + "no-expression-statement": false, + "no-floating-promises": true, + "no-if-statement": false, + "no-implicit-dependencies": false, + "no-let": false, + "no-loop-statement": false, + "no-method-signature": true, + "no-mixed-interface": false, + "no-object-mutation": true, + "no-parameter-reassignment": false, + "no-unnecessary-class": [true, "allow-static-only"], + "no-unnecessary-type-assertion": true, + "no-var-keyword": true, + "object-literal-shorthand": [true, "never"], + "object-literal-sort-keys": false, + "ordered-imports": false, + "prefer-const": true, + "promise-function-async": true, + "readonly-array": true, + "readonly-keyword": true, + "typedef": [true, "call-signature"], + "variable-name": [true, "check-format", "allow-leading-underscore"] + }, + "rulesDirectory": [] } diff --git a/types/address.d.ts b/types/address.d.ts index 776cb61d..c5cba906 100644 --- a/types/address.d.ts +++ b/types/address.d.ts @@ -1,12 +1,23 @@ import { Address, PubkeyBundle } from "@iov/bcp"; -export declare type CosmosAddressBech32Prefix = "cosmos" | "cosmosvalcons" | "cosmosvaloper"; -export declare type CosmosPubkeyBech32Prefix = "cosmospub" | "cosmosvalconspub" | "cosmosvaloperpub"; -export declare type CosmosBech32Prefix = CosmosAddressBech32Prefix | CosmosPubkeyBech32Prefix; +export declare type CosmosAddressBech32Prefix = + | "cosmos" + | "cosmosvalcons" + | "cosmosvaloper"; +export declare type CosmosPubkeyBech32Prefix = + | "cosmospub" + | "cosmosvalconspub" + | "cosmosvaloperpub"; +export declare type CosmosBech32Prefix = + | CosmosAddressBech32Prefix + | CosmosPubkeyBech32Prefix; export declare function decodeCosmosAddress( - address: Address, + address: Address ): { readonly prefix: CosmosAddressBech32Prefix; readonly data: Uint8Array; }; export declare function isValidAddress(address: string): boolean; -export declare function pubkeyToAddress(pubkey: PubkeyBundle, prefix: CosmosBech32Prefix): Address; +export declare function pubkeyToAddress( + pubkey: PubkeyBundle, + prefix: CosmosBech32Prefix +): Address; diff --git a/types/cosmoscodec.d.ts b/types/cosmoscodec.d.ts index 24ca7561..59482edc 100644 --- a/types/cosmoscodec.d.ts +++ b/types/cosmoscodec.d.ts @@ -8,13 +8,17 @@ import { SigningJob, TransactionId, TxCodec, - UnsignedTransaction, + UnsignedTransaction } from "@iov/bcp"; export declare class CosmosCodec implements TxCodec { bytesToSign(unsigned: UnsignedTransaction, nonce: Nonce): SigningJob; bytesToPost(signed: SignedTransaction): PostableBytes; identifier(signed: SignedTransaction): TransactionId; - parseBytes(bytes: PostableBytes, chainId: ChainId, nonce?: Nonce): SignedTransaction; + parseBytes( + bytes: PostableBytes, + chainId: ChainId, + nonce?: Nonce + ): SignedTransaction; identityToAddress(identity: Identity): Address; isValidAddress(address: string): boolean; } diff --git a/types/cosmosconnection.d.ts b/types/cosmosconnection.d.ts index 24ccface..94efb242 100644 --- a/types/cosmosconnection.d.ts +++ b/types/cosmosconnection.d.ts @@ -17,7 +17,7 @@ import { TokenTicker, TransactionId, TransactionQuery, - UnsignedTransaction, + UnsignedTransaction } from "@iov/bcp"; import { Stream } from "xstream"; export declare class CosmosConnection implements BlockchainConnection { @@ -37,16 +37,29 @@ export declare class CosmosConnection implements BlockchainConnection { getAccount(query: AccountQuery): Promise; watchAccount(_account: AccountQuery): Stream; getNonce(query: AddressQuery | PubkeyQuery): Promise; - getNonces(query: AddressQuery | PubkeyQuery, count: number): Promise; + getNonces( + query: AddressQuery | PubkeyQuery, + count: number + ): Promise; getBlockHeader(height: number): Promise; watchBlockHeaders(): Stream; - getTx(id: TransactionId): Promise | FailedTransaction>; + getTx( + id: TransactionId + ): Promise< + ConfirmedAndSignedTransaction | FailedTransaction + >; postTx(tx: PostableBytes): Promise; searchTx( - query: TransactionQuery, - ): Promise | FailedTransaction)[]>; - listenTx(_query: TransactionQuery): Stream | FailedTransaction>; - liveTx(_query: TransactionQuery): Stream | FailedTransaction>; + query: TransactionQuery + ): Promise< + readonly (ConfirmedTransaction | FailedTransaction)[] + >; + listenTx( + _query: TransactionQuery + ): Stream | FailedTransaction>; + liveTx( + _query: TransactionQuery + ): Stream | FailedTransaction>; getFeeQuote(tx: UnsignedTransaction): Promise; withDefaultFee(tx: T): Promise; private parseAndPopulateTxResponse; diff --git a/types/cosmosconnector.d.ts b/types/cosmosconnector.d.ts index db183826..6a18915d 100644 --- a/types/cosmosconnector.d.ts +++ b/types/cosmosconnector.d.ts @@ -5,5 +5,5 @@ import { CosmosConnection } from "./cosmosconnection"; */ export declare function createCosmosConnector( url: string, - expectedChainId?: ChainId, + expectedChainId?: ChainId ): ChainConnector; diff --git a/types/decode.d.ts b/types/decode.d.ts index b1442bf6..ac66c871 100644 --- a/types/decode.d.ts +++ b/types/decode.d.ts @@ -9,20 +9,30 @@ import { SendTransaction, SignatureBytes, SignedTransaction, - UnsignedTransaction, + UnsignedTransaction } from "@iov/bcp"; import amino from "@tendermint/amino-js"; import { TxsResponse } from "./restclient"; export declare function decodePubkey(pubkey: amino.PubKey): PubkeyBundle; export declare function decodeSignature(signature: string): SignatureBytes; -export declare function decodeFullSignature(signature: amino.StdSignature, nonce: number): FullSignature; +export declare function decodeFullSignature( + signature: amino.StdSignature, + nonce: number +): FullSignature; export declare function decodeAmount(amount: amino.Coin): Amount; -export declare function parseMsg(msg: amino.Msg, chainId: ChainId): SendTransaction; +export declare function parseMsg( + msg: amino.Msg, + chainId: ChainId +): SendTransaction; export declare function parseFee(fee: amino.StdFee): Fee; -export declare function parseTx(tx: amino.Tx, chainId: ChainId, nonce: Nonce): SignedTransaction; +export declare function parseTx( + tx: amino.Tx, + chainId: ChainId, + nonce: Nonce +): SignedTransaction; export declare function parseTxsResponse( chainId: ChainId, currentHeight: number, nonce: Nonce, - response: TxsResponse, + response: TxsResponse ): ConfirmedAndSignedTransaction; diff --git a/types/encode.d.ts b/types/encode.d.ts index 53e5e697..e5931aef 100644 --- a/types/encode.d.ts +++ b/types/encode.d.ts @@ -1,9 +1,18 @@ -import { Amount, Fee, FullSignature, PubkeyBundle, SignedTransaction, UnsignedTransaction } from "@iov/bcp"; +import { + Amount, + Fee, + FullSignature, + PubkeyBundle, + SignedTransaction, + UnsignedTransaction +} from "@iov/bcp"; import amino from "@tendermint/amino-js"; import { AminoTx } from "./types"; export declare function encodePubkey(pubkey: PubkeyBundle): amino.PubKey; export declare function encodeAmount(amount: Amount): amino.Coin; export declare function encodeFee(fee: Fee): amino.StdFee; -export declare function encodeFullSignature(fullSignature: FullSignature): amino.StdSignature; +export declare function encodeFullSignature( + fullSignature: FullSignature +): amino.StdSignature; export declare function buildUnsignedTx(tx: UnsignedTransaction): AminoTx; export declare function buildSignedTx(tx: SignedTransaction): AminoTx; diff --git a/types/restclient.d.ts b/types/restclient.d.ts index df1d9251..9097d2cb 100644 --- a/types/restclient.d.ts +++ b/types/restclient.d.ts @@ -69,7 +69,10 @@ export declare class RestClient { nodeInfo(): Promise; blocksLatest(): Promise; blocks(height: number): Promise; - authAccounts(address: Address, height?: string): Promise; + authAccounts( + address: Address, + height?: string + ): Promise; txs(query: string): Promise; txsById(id: TransactionId): Promise; postTx(tx: PostableBytes): Promise; diff --git a/types/types.d.ts b/types/types.d.ts index cb5a44a9..adcda576 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -2,4 +2,6 @@ import amino from "@tendermint/amino-js"; export declare type AminoTx = amino.Tx & { readonly value: amino.StdTx; }; -export declare function isAminoStdTx(txValue: amino.TxValue): txValue is amino.StdTx; +export declare function isAminoStdTx( + txValue: amino.TxValue +): txValue is amino.StdTx;