From e134639d6b22bbcec2dfa58b5a5af791e559716d Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 30 Nov 2017 20:22:02 +0100 Subject: [PATCH] Upgrade dependencies --- README.md | 5 ++-- package.json | 21 ++--------------- packages/api-format/package.json | 2 +- packages/api-format/src/util.js | 37 +++++++++++++++++++----------- packages/api-provider/package.json | 2 +- packages/api/package.json | 2 +- yarn.lock | 15 ++++++------ 7 files changed, 39 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 976719c7aba9..fe88ee2bf24f 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ ![ISC](https://img.shields.io/badge/license-ISC-lightgrey.svg) [![npm (scoped)](https://img.shields.io/npm/v/@polkadot/api.svg)](https://www.npmjs.com/package/@polkadot/api) [![Build Status](https://travis-ci.org/polkadot-js/api.svg?branch=master)](https://travis-ci.org/polkadot-js/api) +[![Maintainability](https://api.codeclimate.com/v1/badges/bdc230778ec91a5167b8/maintainability)](https://codeclimate.com/github/polkadot-js/api/maintainability) [![Coverage Status](https://coveralls.io/repos/github/polkadot-js/api/badge.svg?branch=master)](https://coveralls.io/github/polkadot-js/api?branch=master) [![Greenkeeper badge](https://badges.greenkeeper.io/polkadot-js/api.svg)](https://greenkeeper.io/) # @polkadot/client -This library provides a clean wrapper around all the methods exposed by a Polkadot network client. +This library provides a clean wrapper around all the methods exposed by a Polkadot network client. As part of the JsonRpc defintions, the [exposed methods are documented][packages/api-jsonrpc/docs/]. -It is split up into a number of internal packages - +The API is split up into a number of internal packages - - [@polkadot/api](packages/api/) The API library - [@polkadot/api-format](packages/api-format/) Input and output formatters diff --git a/package.json b/package.json index 653bbab4d170..c3928971f8df 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,6 @@ { - "name": "@polkadot/api-wrapper", "version": "0.5.5", - "description": "Non-published, see packages/", - "keywords": [], - "author": "Jaco Greeff ", - "license": "ISC", "private": true, - "engines": { - "node": ">=8.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/polkadot-js/api.git" - }, - "bugs": { - "url": "https://github.com/polkadot-js/api/issues" - }, - "homepage": "https://github.com/polkadot-js/api#readme", "workspaces": [ "packages/*" ], @@ -26,8 +10,7 @@ "test": "jest --coverage packages" }, "devDependencies": { - "@polkadot/dev": "^0.9.9", + "@polkadot/dev": "^0.10.1", "lerna": "^2.5.1" - }, - "dependencies": {} + } } diff --git a/packages/api-format/package.json b/packages/api-format/package.json index a81d6ce0605d..7f1beac535ff 100644 --- a/packages/api-format/package.json +++ b/packages/api-format/package.json @@ -33,7 +33,7 @@ "@polkadot/api-jsonrpc": "^0.5.5" }, "dependencies": { - "@polkadot/util": "^0.5.19", + "@polkadot/util": "^0.6.1", "babel-runtime": "^6.26.0" } } diff --git a/packages/api-format/src/util.js b/packages/api-format/src/util.js index 91d7fe46748c..68a662812142 100644 --- a/packages/api-format/src/util.js +++ b/packages/api-format/src/util.js @@ -8,11 +8,8 @@ const formatNoop = require('./noop'); const arrayTypeRegex = /\[\]$/; -function format (formatters: { [any]: FormatterFunction }, type: string, value: any): any { - const isArrayType: boolean = arrayTypeRegex.test(type); - const formatter: FormatterFunction = isArrayType - ? formatters[type.replace(arrayTypeRegex, '')] - : formatters[type]; +function formatSingleType (formatters: { [any]: FormatterFunction }, type: string, value: any): any { + const formatter: FormatterFunction = formatters[type]; if (isUndefined(formatter)) { console.warn(`Unable to find default formatter for '${type}', falling back to noop`); @@ -20,19 +17,31 @@ function format (formatters: { [any]: FormatterFunction }, type: string, value: return formatNoop(value); } - if (isArrayType && !Array.isArray(value)) { + try { + return formatter(value); + } catch (error) { + throw new Error(`Error formatting '${value}' as '${type}': ${error.message}`); + } +} + +function formatArrayType (formatters: { [any]: FormatterFunction }, type: string, value: any): any { + if (!Array.isArray(value)) { throw new Error(`Unable to format non-array '${value}' as '${type}'`); } - try { - if (isArrayType) { - return (value: Array).map((value) => formatter(value)); - } else { - return formatter(value); - } - } catch (error) { - throw new Error(`Error formatting '${value}' as '${type}'': ${error.message}`); + type = type.replace(arrayTypeRegex, ''); + + return (value: Array).map((value) => { + return formatSingleType(formatters, type, value); + }); +} + +function format (formatters: { [any]: FormatterFunction }, type: string, value: any): any { + if (arrayTypeRegex.test(type)) { + return formatArrayType(formatters, type, value); } + + return formatSingleType(formatters, type, value); } function formatArray (formatters: { [any]: FormatterFunction }, types: Array, values: Array): Array { diff --git a/packages/api-provider/package.json b/packages/api-provider/package.json index e63af7f3d650..7a61fbcafdcb 100644 --- a/packages/api-provider/package.json +++ b/packages/api-provider/package.json @@ -34,7 +34,7 @@ "nock": "^9.1.0" }, "dependencies": { - "@polkadot/util": "^0.5.19", + "@polkadot/util": "^0.6.1", "babel-runtime": "^6.26.0", "isomorphic-fetch": "^2.2.1" } diff --git a/packages/api/package.json b/packages/api/package.json index cea5ef05a9e1..1eb7de32d345 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -33,7 +33,7 @@ "@polkadot/api-format": "^0.5.5", "@polkadot/api-jsonrpc": "^0.5.5", "@polkadot/api-provider": "^0.5.5", - "@polkadot/util": "^0.5.19", + "@polkadot/util": "^0.6.1", "babel-runtime": "^6.26.0" } } diff --git a/yarn.lock b/yarn.lock index 596d90457817..c5dd8d248aee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -54,9 +54,9 @@ lodash "^4.2.0" to-fast-properties "^2.0.0" -"@polkadot/dev@^0.9.9": - version "0.9.9" - resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.9.9.tgz#b302ba6728a5068c7bffe069fd64290c227d317c" +"@polkadot/dev@^0.10.1": + version "0.10.1" + resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.10.1.tgz#4c57180413320f0194c340177725f8b8c0ecbffa" dependencies: babel-cli "^6.26.0" babel-core "^6.26.0" @@ -73,6 +73,7 @@ eslint "^4.11.0" eslint-config-semistandard "^11.0.0" eslint-config-standard "^10.2.1" + eslint-config-standard-jsx "^4.0.2" eslint-config-standard-react "^5.0.0" eslint-plugin-flowtype "^2.39.1" eslint-plugin-import "^2.8.0" @@ -89,9 +90,9 @@ stylelint "^8.2.0" stylelint-config-standard "^18.0.0" -"@polkadot/util@^0.5.19": - version "0.5.19" - resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.5.19.tgz#e34d917f3fd52b98c6a7633e534f26d182e7cb6f" +"@polkadot/util@^0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.6.1.tgz#d08fca12cbef5559f27bb0f51f72e71a3f11c824" dependencies: babel-runtime "^6.26.0" bn.js "^4.11.8" @@ -1882,7 +1883,7 @@ eslint-config-semistandard@^11.0.0: version "11.0.0" resolved "https://registry.yarnpkg.com/eslint-config-semistandard/-/eslint-config-semistandard-11.0.0.tgz#44eef7cfdfd47219e3a7b81b91b540e880bb2615" -eslint-config-standard-jsx@^4.0.0: +eslint-config-standard-jsx@^4.0.0, eslint-config-standard-jsx@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/eslint-config-standard-jsx/-/eslint-config-standard-jsx-4.0.2.tgz#009e53c4ddb1e9ee70b4650ffe63a7f39f8836e1"