Copy config from parent dir

This commit is contained in:
Ethan Frey 2020-01-22 09:54:23 +01:00
parent 0fc62d4aa8
commit 1a4bb7fe2b
14 changed files with 199 additions and 35 deletions

9
.gitignore vendored
View File

@ -17,3 +17,12 @@ node_modules/
# Release dir
tmp/
# Build artifacts
build/
dist/
docs/
# Lock file?
yarn.lock
npm.lock

View File

@ -0,0 +1,12 @@
{
"suite": {
"displayNumber": true
},
"spec": {
"displayDuration": true
},
"summary": {
"displayPending": false,
"displayStacktrace": true
}
}

View File

@ -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");

View File

@ -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 <admin@iov.one>",
"description": "Transaction codec and client to communicate with any wasmd blockchain",
"author": "Ethan Frey <ethanfrey@users.noreply.github.com>",
"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"
}
}

View File

@ -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/**/*"]
}
}

View File

@ -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": []
}

21
types/address.d.ts vendored
View File

@ -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;

View File

@ -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;
}

View File

@ -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<Account | undefined>;
watchAccount(_account: AccountQuery): Stream<Account | undefined>;
getNonce(query: AddressQuery | PubkeyQuery): Promise<Nonce>;
getNonces(query: AddressQuery | PubkeyQuery, count: number): Promise<readonly Nonce[]>;
getNonces(
query: AddressQuery | PubkeyQuery,
count: number
): Promise<readonly Nonce[]>;
getBlockHeader(height: number): Promise<BlockHeader>;
watchBlockHeaders(): Stream<BlockHeader>;
getTx(id: TransactionId): Promise<ConfirmedAndSignedTransaction<UnsignedTransaction> | FailedTransaction>;
getTx(
id: TransactionId
): Promise<
ConfirmedAndSignedTransaction<UnsignedTransaction> | FailedTransaction
>;
postTx(tx: PostableBytes): Promise<PostTxResponse>;
searchTx(
query: TransactionQuery,
): Promise<readonly (ConfirmedTransaction<UnsignedTransaction> | FailedTransaction)[]>;
listenTx(_query: TransactionQuery): Stream<ConfirmedTransaction<UnsignedTransaction> | FailedTransaction>;
liveTx(_query: TransactionQuery): Stream<ConfirmedTransaction<UnsignedTransaction> | FailedTransaction>;
query: TransactionQuery
): Promise<
readonly (ConfirmedTransaction<UnsignedTransaction> | FailedTransaction)[]
>;
listenTx(
_query: TransactionQuery
): Stream<ConfirmedTransaction<UnsignedTransaction> | FailedTransaction>;
liveTx(
_query: TransactionQuery
): Stream<ConfirmedTransaction<UnsignedTransaction> | FailedTransaction>;
getFeeQuote(tx: UnsignedTransaction): Promise<Fee>;
withDefaultFee<T extends UnsignedTransaction>(tx: T): Promise<T>;
private parseAndPopulateTxResponse;

View File

@ -5,5 +5,5 @@ import { CosmosConnection } from "./cosmosconnection";
*/
export declare function createCosmosConnector(
url: string,
expectedChainId?: ChainId,
expectedChainId?: ChainId
): ChainConnector<CosmosConnection>;

20
types/decode.d.ts vendored
View File

@ -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<UnsignedTransaction>;

13
types/encode.d.ts vendored
View File

@ -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;

View File

@ -69,7 +69,10 @@ export declare class RestClient {
nodeInfo(): Promise<NodeInfoResponse>;
blocksLatest(): Promise<BlocksResponse>;
blocks(height: number): Promise<BlocksResponse>;
authAccounts(address: Address, height?: string): Promise<AuthAccountsResponse>;
authAccounts(
address: Address,
height?: string
): Promise<AuthAccountsResponse>;
txs(query: string): Promise<SearchTxsResponse>;
txsById(id: TransactionId): Promise<TxsResponse>;
postTx(tx: PostableBytes): Promise<PostTxsResponse>;

4
types/types.d.ts vendored
View File

@ -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;