diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..18a9fc92 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,56 @@ +# Javascript Node CircleCI 2.0 configuration file. +# Check https://circleci.com/docs/2.0/language-javascript/ for more details +version: 2 + +references: + workspace: &workspace + ~/repo + + container_config: &container_config + docker: + - image: circleci/node:8.11.3 + working_directory: *workspace +jobs: + build: + <<: *container_config + steps: + - checkout + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + - v1-dependencies- + - run: sudo yarn global add yarn@1.7.0 greenkeeper-lockfile@1 + - run: yarn install + - run: yarn build + - run: greenkeeper-lockfile-update + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + - run: greenkeeper-lockfile-upload + test: + <<: *container_config + steps: + - checkout + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + - run: sudo apt-get -y update + - run: sudo apt-get -y install libgtk-3-0 libxss1 libgconf-2-4 libnss3 libasound2 + - run: sudo yarn global add yarn@1.7.0 + - run: yarn test + store_artifacts: + - path: artifacts + - destination: yarnpkg + +workflows: + version: 2 + build_test: + jobs: + - build + - test: + requires: + - build diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 87cd2336..726e313e 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,34 +1,42 @@ - - -Your issue may already be reported! -Please search on the [issue track](../) before creating one. - -## Expected Behavior +## Expected Behavior + + -## Current Behavior +## Current Behavior + -## Possible Solution - - -## Steps to Reproduce (for bugs) +## Steps to Reproduce (for bugs) 1. 2. 3. 4. -## Context + + + + +## Possible Solution + + + +## Additional context + + -## Your Environment -* Version used: -* Environment name and version (e.g. node.js 9.6.1, yarn 1.6.1, npm 5.6.0): +## Your Environment +* nOS Client version used: +* Environment name and version + * Node version: + * NPM version: + * Yarn version: * Operating System and version (desktop or mobile): diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..923f264c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,46 @@ +--- +name: Bug report +about: Create a report to help us improve the nOS Client + +--- + + +## Expected Behavior + + + + +## Current Behavior + + + + + +## Steps to Reproduce +1. +2. +3. +4. + + + + + +## Possible Solution + + + + + +## Additional context + + + + +## Your Environment +* nOS Client version used: +* Environment name and version + * Node version: + * NPM version: + * Yarn version: +* Operating System and version (desktop or mobile): diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..c7af178a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature request +about: Suggest an idea for the nOS Client + +--- + + +## Describe the solution you'd like and the expected behavior + + + + +## Is your feature request related to a problem? Please describe. + + + + +## Possible implementation / References + + + + +## Additional context diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index cf85761d..01c2c150 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,39 +1,44 @@ - - -## Description +## Description + + -## Motivation and Context - +## Motivation and Context + + -## How Has This Been Tested? - - + +## How Has This Been Tested? + + ## Screenshots (if appropriate): -## Types of changes + + +## Types of changes - [ ] Chore (tests, refactors, and fixes) - [ ] New feature (adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) -## Checklist: + + - -- [ ] My code follows the code style of this project. -- [ ] The commit message follows our guidelines +## Checklist: +- [ ] I have read the **[CONTRIBUTING](./CONTRIBUTING.md)** guidelines and confirm that my code follows the code style of this project. - [ ] Tests for the changes have been added (for bug fixes / features) - [ ] Docs have been added / updated (for bug fixes / features) -- [ ] I have read the **CONTRIBUTING** document. -## Closing issues + + +## Closing issues Fixes # diff --git a/.npmignore b/.npmignore index 5cdbb3a8..3651c7e1 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,3 @@ CODE_OF_CONDUCT.md .github/ +.circleci/ diff --git a/README.md b/README.md index c26f1b48..c20ee960 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,8 @@ npm i --save @nosplatform/api-functions yarn add @nosplatform/api-functions ``` + +## Usage in react +``` +import { injectNOS, nosProps } from "@nosplatform/api-functions/lib/react"; +``` diff --git a/es6/bindings.js b/es6/bindings.js index bd7de056..6aafba23 100644 --- a/es6/bindings.js +++ b/es6/bindings.js @@ -1,4 +1,4 @@ -import { useFallback, executor, exists, nos } from "./lib"; +import { executor } from "./lib"; // Wallet Actions diff --git a/es6/index.js b/es6/index.js index dd673c46..fea632bc 100644 --- a/es6/index.js +++ b/es6/index.js @@ -1,5 +1,5 @@ /** - * @nos/api-functions + * @nosplatform/api-functions * API bindings (with fallback) and types for nOS dApps * @author Jeroen Peeters */ @@ -14,7 +14,6 @@ import { testInvoke } from "./bindings"; import { exists } from "./lib"; -import * as reactNamespace from "./react"; export default { claimGas, @@ -26,5 +25,3 @@ export default { send, testInvoke }; - -export const react = reactNamespace; diff --git a/es6/lib.js b/es6/lib.js index aa1c9d12..27fd9a48 100644 --- a/es6/lib.js +++ b/es6/lib.js @@ -9,7 +9,7 @@ export const executor = (func, fallback, config) => exists ? nos[func](config) : useFallback(fallback, config); /** - * @function useFallback + * @function useFallback * @param {function} fallback checks if fallback function exists, otherwise return nothing * @param {object} args potential arguments that are passed along */ diff --git a/es6/react/index.js b/es6/react/index.js index dd864c59..b10b99d8 100644 --- a/es6/react/index.js +++ b/es6/react/index.js @@ -1,4 +1,4 @@ import nosProps from "./props"; -import { Consumer, injectNOS } from "./nosStore"; +import { injectNOS } from "./inject"; -export default { Consumer, injectNOS, nosProps }; +export { injectNOS, nosProps }; diff --git a/es6/react/inject.js b/es6/react/inject.js new file mode 100644 index 00000000..a73f9ffd --- /dev/null +++ b/es6/react/inject.js @@ -0,0 +1,9 @@ +import React from "react"; + +import nos from "../"; + +const injectNOS = Component => props => ( + +); + +export { injectNOS }; diff --git a/es6/react/nosStore.js b/es6/react/nosStore.js deleted file mode 100644 index f5c78f64..00000000 --- a/es6/react/nosStore.js +++ /dev/null @@ -1,31 +0,0 @@ -import React from "react"; - -import { - claimGas, - getAddress, - getBalance, - getStorage, - invoke, - send, - testInvoke -} from "./../bindings"; -import { exists } from "./../lib"; - -const nos = { - claimGas, - exists, - getAddress, - getBalance, - getStorage, - invoke, - send, - testInvoke -}; - -const { Provider, Consumer } = React.createContext(nos); - -const injectNOS = Component => props => ( - {context => } -); - -export { Consumer, injectNOS }; diff --git a/lib/index.js b/lib/index.js index 787a345f..03abefc1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,18 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.react = exports.default = void 0; +exports.default = void 0; var _bindings = require("./bindings"); var _lib = require("./lib"); -var reactNamespace = _interopRequireWildcard(require("./react")); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } - /** - * @nos/api-functions + * @nosplatform/api-functions * API bindings (with fallback) and types for nOS dApps * @author Jeroen Peeters */ @@ -28,6 +24,4 @@ var _default = { send: _bindings.send, testInvoke: _bindings.testInvoke }; -exports.default = _default; -var react = reactNamespace; -exports.react = react; \ No newline at end of file +exports.default = _default; \ No newline at end of file diff --git a/lib/lib.js b/lib/lib.js index f8eadc19..8df24c87 100644 --- a/lib/lib.js +++ b/lib/lib.js @@ -19,7 +19,7 @@ var executor = function executor(func, fallback, config) { return exists ? nos[func](config) : useFallback(fallback, config); }; /** - * @function useFallback + * @function useFallback * @param {function} fallback checks if fallback function exists, otherwise return nothing * @param {object} args potential arguments that are passed along */ diff --git a/lib/react/index.js b/lib/react/index.js index e9de734a..88720b3f 100644 --- a/lib/react/index.js +++ b/lib/react/index.js @@ -3,17 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = void 0; +Object.defineProperty(exports, "nosProps", { + enumerable: true, + get: function get() { + return _props.default; + } +}); +Object.defineProperty(exports, "injectNOS", { + enumerable: true, + get: function get() { + return _inject.injectNOS; + } +}); var _props = _interopRequireDefault(require("./props")); -var _nosStore = require("./nosStore"); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +var _inject = require("./inject"); -var _default = { - Consumer: _nosStore.Consumer, - injectNOS: _nosStore.injectNOS, - nosProps: _props.default -}; -exports.default = _default; \ No newline at end of file +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/lib/react/inject.js b/lib/react/inject.js new file mode 100644 index 00000000..11fa6c88 --- /dev/null +++ b/lib/react/inject.js @@ -0,0 +1,24 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.injectNOS = void 0; + +var _react = _interopRequireDefault(require("react")); + +var _ = _interopRequireDefault(require("../")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +var injectNOS = function injectNOS(Component) { + return function (props) { + return _react.default.createElement(Component, _extends({ + nos: _.default + }, props)); + }; +}; + +exports.injectNOS = injectNOS; \ No newline at end of file diff --git a/lib/react/nosStore.js b/lib/react/nosStore.js deleted file mode 100644 index a49d6f3c..00000000 --- a/lib/react/nosStore.js +++ /dev/null @@ -1,45 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.injectNOS = exports.Consumer = void 0; - -var _react = _interopRequireDefault(require("react")); - -var _bindings = require("./../bindings"); - -var _lib = require("./../lib"); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } - -var nos = { - claimGas: _bindings.claimGas, - exists: _lib.exists, - getAddress: _bindings.getAddress, - getBalance: _bindings.getBalance, - getStorage: _bindings.getStorage, - invoke: _bindings.invoke, - send: _bindings.send, - testInvoke: _bindings.testInvoke -}; - -var _React$createContext = _react.default.createContext(nos), - Provider = _React$createContext.Provider, - Consumer = _React$createContext.Consumer; - -exports.Consumer = Consumer; - -var injectNOS = function injectNOS(Component) { - return function (props) { - return _react.default.createElement(Consumer, null, function (context) { - return _react.default.createElement(Component, _extends({ - nos: context - }, props)); - }); - }; -}; - -exports.injectNOS = injectNOS; \ No newline at end of file diff --git a/package.json b/package.json index 29bd7b9c..d878b932 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nosplatform/api-functions", - "version": "0.2.2", + "version": "0.3.0", "description": "nOS API bindings and types", "main": "lib/index.js", "scripts": { @@ -32,14 +32,12 @@ "dependencies": { "prop-types": "15.6.1" }, - "peerDependencies": { - "react": ">=16.3.0" - }, "devDependencies": { "@babel/cli": "^7.0.0-beta.46", "@babel/core": "^7.0.0-beta.46", "@babel/preset-env": "^7.0.0-beta.46", "@babel/preset-react": "^7.0.0-beta.47", + "react": ">=16.3.0", "prettier": "^1.12.1" }, "prettier": {