From 010f060060877656b65501e02d3195b574f077f9 Mon Sep 17 00:00:00 2001 From: Matt Huggins Date: Sun, 9 Sep 2018 08:50:21 -0500 Subject: [PATCH 1/9] feat(assets): added injectAssets HOC + fallback, and refactored internals --- es6/assets.js | 10 +++++++++ es6/{lib.js => executor.js} | 17 ++++++++------ es6/index.js | 23 +++---------------- es6/{bindings.js => nos.js} | 28 ++++++++++++++++------- es6/react/index.js | 4 ++-- es6/react/inject.js | 10 +++++---- es6/react/props.js | 19 ++++++++-------- lib/assets.js | 17 ++++++++++++++ lib/{lib.js => executor.js} | 22 ++++++++----------- lib/index.js | 34 +++++++++++++--------------- lib/{bindings.js => nos.js} | 44 ++++++++++++++++++------------------- lib/react/index.js | 6 +++++ lib/react/inject.js | 22 ++++++++++++++----- lib/react/props.js | 22 ++++++++----------- 14 files changed, 154 insertions(+), 124 deletions(-) create mode 100644 es6/assets.js rename es6/{lib.js => executor.js} (53%) rename es6/{bindings.js => nos.js} (64%) create mode 100644 lib/assets.js rename lib/{lib.js => executor.js} (80%) rename lib/{bindings.js => nos.js} (67%) diff --git a/es6/assets.js b/es6/assets.js new file mode 100644 index 00000000..c0b5a9b5 --- /dev/null +++ b/es6/assets.js @@ -0,0 +1,10 @@ +/** @const {boolean} exists check whether assets constant is defined */ +const exists = !!window.NOS && !!window.NOS.ASSETS; + +/** @const {object} assets bind assets constant to variable */ +const assets = exists ? window.NOS.ASSETS : { + NEO: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b', + GAS: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7' +}; + +export default assets; diff --git a/es6/lib.js b/es6/executor.js similarity index 53% rename from es6/lib.js rename to es6/executor.js index 27fd9a48..e4c39368 100644 --- a/es6/lib.js +++ b/es6/executor.js @@ -1,16 +1,19 @@ /** @const {boolean} exists check whether nOS is defined */ -export const exists = !!window.NOS && !!window.NOS.V1; +const exists = !!window.NOS && !!window.NOS.V1; /** @const {object} nos bind nOS api to variable */ -export const nos = exists ? window.NOS.V1 : undefined; - -/** @function executor executes the nOS API function */ -export const executor = (func, fallback, config) => - exists ? nos[func](config) : useFallback(fallback, config); +const nos = exists ? window.NOS.V1 : undefined; /** * @function useFallback * @param {function} fallback checks if fallback function exists, otherwise return nothing * @param {object} args potential arguments that are passed along */ -export const useFallback = (fallback, args) => fallback ? fallback(args) : undefined; +const useFallback = (fallback, args) => fallback ? fallback(args) : undefined; + +/** @function executor executes the nOS API function */ +const executor = (func, fallback, config) => ( + exists ? nos[func](config) : useFallback(fallback, config) +); + +export default executor; diff --git a/es6/index.js b/es6/index.js index fea632bc..03f02d6d 100644 --- a/es6/index.js +++ b/es6/index.js @@ -4,24 +4,7 @@ * @author Jeroen Peeters */ -import { - claimGas, - getAddress, - getBalance, - getStorage, - invoke, - send, - testInvoke -} from "./bindings"; -import { exists } from "./lib"; +import assets from "./assets"; +import nos from "./nos"; -export default { - claimGas, - exists, - getAddress, - getBalance, - getStorage, - invoke, - send, - testInvoke -}; +export { assets, nos }; diff --git a/es6/bindings.js b/es6/nos.js similarity index 64% rename from es6/bindings.js rename to es6/nos.js index 6aafba23..952d20d0 100644 --- a/es6/bindings.js +++ b/es6/nos.js @@ -1,4 +1,4 @@ -import { executor } from "./lib"; +import executor from "./executor"; // Wallet Actions @@ -6,27 +6,27 @@ import { executor } from "./lib"; * @function getAddress * @param {function} fallback fallback function if outside of nOS browser */ -export const getAddress = fallback => executor('getAddress', fallback); +const getAddress = fallback => executor('getAddress', fallback); /** * @function getBalance * @param {object} config All possible arguments and flags are passed as childs of this object * @param {function} fallback fallback function if outside of nOS browser */ -export const getBalance = (config, fallback) => executor('getBalance', fallback, config); +const getBalance = (config, fallback) => executor('getBalance', fallback, config); /** * @function claimGas * @param {function} fallback fallback function if outside of nOS browser */ -export const claimGas = fallback => executor('claimGas', fallback); +const claimGas = fallback => executor('claimGas', fallback); /** * @function send * @param {object} config All possible arguments and flags are passed as childs of this object * @param {function} fallback fallback function if outside of nOS browser */ -export const send = (config, fallback) => executor('send', fallback, config); +const send = (config, fallback) => executor('send', fallback, config); // Smart Contract Actions @@ -35,18 +35,30 @@ export const send = (config, fallback) => executor('send', fallback, config); * @param {object} config All possible arguments and flags are passed as childs of this object * @param {function} fallback fallback function if outside of nOS browser */ -export const testInvoke = (config, fallback) => executor('testInvoke', fallback, config); +const testInvoke = (config, fallback) => executor('testInvoke', fallback, config); /** * @function invoke * @param {object} config All possible arguments and flags are passed as childs of this object * @param {function} fallback fallback function if outside of nOS browser */ -export const invoke = (config, fallback) => executor('invoke', fallback, config); +const invoke = (config, fallback) => executor('invoke', fallback, config); /** * @function getStorage * @param {object} config All possible arguments and flags are passed as childs of this object * @param {function} fallback fallback function if outside of nOS browser */ -export const getStorage = (config, fallback) => executor('getStorage', fallback, config); +const getStorage = (config, fallback) => executor('getStorage', fallback, config); + +const nos = { + claimGas, + getAddress, + getBalance, + getStorage, + invoke, + send, + testInvoke +}; + +export default nos; diff --git a/es6/react/index.js b/es6/react/index.js index b10b99d8..8368611b 100644 --- a/es6/react/index.js +++ b/es6/react/index.js @@ -1,4 +1,4 @@ import nosProps from "./props"; -import { injectNOS } from "./inject"; +import { injectNOS, injectAssets } from "./inject"; -export { injectNOS, nosProps }; +export { injectNOS, injectAssets, nosProps }; diff --git a/es6/react/inject.js b/es6/react/inject.js index a73f9ffd..b65b6959 100644 --- a/es6/react/inject.js +++ b/es6/react/inject.js @@ -1,9 +1,11 @@ import React from "react"; -import nos from "../"; +import { nos, assets } from "../"; -const injectNOS = Component => props => ( - +export const injectNOS = Component => props => ( + ); -export { injectNOS }; +export const injectAssets = Component => props => ( + +); diff --git a/es6/react/props.js b/es6/react/props.js index 8fbc4203..8f310bca 100644 --- a/es6/react/props.js +++ b/es6/react/props.js @@ -1,14 +1,13 @@ -import PropTypes from "prop-types"; +import { func, shape } from "prop-types"; -const nosProps = PropTypes.shape({ - exists: PropTypes.bool.isRequired, - getAddress: PropTypes.func.isRequired, - getBalance: PropTypes.func.isRequired, - claimGas: PropTypes.func.isRequired, - send: PropTypes.func.isRequired, - testInvoke: PropTypes.func.isRequired, - invoke: PropTypes.func.isRequired, - getStorage: PropTypes.func.isRequired +const nosProps = shape({ + getAddress: func.isRequired, + getBalance: func.isRequired, + claimGas: func.isRequired, + send: func.isRequired, + testInvoke: func.isRequired, + invoke: func.isRequired, + getStorage: func.isRequired }); export default nosProps; diff --git a/lib/assets.js b/lib/assets.js new file mode 100644 index 00000000..4932760f --- /dev/null +++ b/lib/assets.js @@ -0,0 +1,17 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +/** @const {boolean} exists check whether assets constant is defined */ +var exists = !!window.NOS && !!window.NOS.ASSETS; +/** @const {object} assets bind assets constant to variable */ + +var assets = exists ? window.NOS.ASSETS : { + NEO: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b', + GAS: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7' +}; +var _default = assets; +exports.default = _default; \ No newline at end of file diff --git a/lib/lib.js b/lib/executor.js similarity index 80% rename from lib/lib.js rename to lib/executor.js index 8df24c87..699c422d 100644 --- a/lib/lib.js +++ b/lib/executor.js @@ -3,32 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.useFallback = exports.executor = exports.nos = exports.exists = void 0; +exports.default = void 0; /** @const {boolean} exists check whether nOS is defined */ var exists = !!window.NOS && !!window.NOS.V1; /** @const {object} nos bind nOS api to variable */ -exports.exists = exists; var nos = exists ? window.NOS.V1 : undefined; -/** @function executor executes the nOS API function */ - -exports.nos = nos; - -var executor = function executor(func, fallback, config) { - return exists ? nos[func](config) : useFallback(fallback, config); -}; /** * @function useFallback * @param {function} fallback checks if fallback function exists, otherwise return nothing * @param {object} args potential arguments that are passed along */ - -exports.executor = executor; - var useFallback = function useFallback(fallback, args) { return fallback ? fallback(args) : undefined; }; +/** @function executor executes the nOS API function */ + + +var executor = function executor(func, fallback, config) { + return exists ? nos[func](config) : useFallback(fallback, config); +}; -exports.useFallback = useFallback; \ No newline at end of file +var _default = executor; +exports.default = _default; \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index 03abefc1..f91bdffc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,25 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = void 0; +Object.defineProperty(exports, "assets", { + enumerable: true, + get: function get() { + return _assets.default; + } +}); +Object.defineProperty(exports, "nos", { + enumerable: true, + get: function get() { + return _nos.default; + } +}); -var _bindings = require("./bindings"); +var _assets = _interopRequireDefault(require("./assets")); -var _lib = require("./lib"); +var _nos = _interopRequireDefault(require("./nos")); -/** - * @nosplatform/api-functions - * API bindings (with fallback) and types for nOS dApps - * @author Jeroen Peeters - */ -var _default = { - claimGas: _bindings.claimGas, - exists: _lib.exists, - getAddress: _bindings.getAddress, - getBalance: _bindings.getBalance, - getStorage: _bindings.getStorage, - invoke: _bindings.invoke, - send: _bindings.send, - testInvoke: _bindings.testInvoke -}; -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/bindings.js b/lib/nos.js similarity index 67% rename from lib/bindings.js rename to lib/nos.js index 35614dd9..53857772 100644 --- a/lib/bindings.js +++ b/lib/nos.js @@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.getStorage = exports.invoke = exports.testInvoke = exports.send = exports.claimGas = exports.getBalance = exports.getAddress = void 0; +exports.default = void 0; -var _lib = require("./lib"); +var _executor = _interopRequireDefault(require("./executor")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // Wallet Actions @@ -14,7 +16,7 @@ var _lib = require("./lib"); * @param {function} fallback fallback function if outside of nOS browser */ var getAddress = function getAddress(fallback) { - return (0, _lib.executor)('getAddress', fallback); + return (0, _executor.default)('getAddress', fallback); }; /** * @function getBalance @@ -23,10 +25,8 @@ var getAddress = function getAddress(fallback) { */ -exports.getAddress = getAddress; - var getBalance = function getBalance(config, fallback) { - return (0, _lib.executor)('getBalance', fallback, config); + return (0, _executor.default)('getBalance', fallback, config); }; /** * @function claimGas @@ -34,10 +34,8 @@ var getBalance = function getBalance(config, fallback) { */ -exports.getBalance = getBalance; - var claimGas = function claimGas(fallback) { - return (0, _lib.executor)('claimGas', fallback); + return (0, _executor.default)('claimGas', fallback); }; /** * @function send @@ -46,10 +44,8 @@ var claimGas = function claimGas(fallback) { */ -exports.claimGas = claimGas; - var send = function send(config, fallback) { - return (0, _lib.executor)('send', fallback, config); + return (0, _executor.default)('send', fallback, config); }; // Smart Contract Actions /** @@ -59,10 +55,8 @@ var send = function send(config, fallback) { */ -exports.send = send; - var testInvoke = function testInvoke(config, fallback) { - return (0, _lib.executor)('testInvoke', fallback, config); + return (0, _executor.default)('testInvoke', fallback, config); }; /** * @function invoke @@ -71,10 +65,8 @@ var testInvoke = function testInvoke(config, fallback) { */ -exports.testInvoke = testInvoke; - var invoke = function invoke(config, fallback) { - return (0, _lib.executor)('invoke', fallback, config); + return (0, _executor.default)('invoke', fallback, config); }; /** * @function getStorage @@ -83,10 +75,18 @@ var invoke = function invoke(config, fallback) { */ -exports.invoke = invoke; - var getStorage = function getStorage(config, fallback) { - return (0, _lib.executor)('getStorage', fallback, config); + return (0, _executor.default)('getStorage', fallback, config); }; -exports.getStorage = getStorage; \ No newline at end of file +var nos = { + claimGas: claimGas, + getAddress: getAddress, + getBalance: getBalance, + getStorage: getStorage, + invoke: invoke, + send: send, + testInvoke: testInvoke +}; +var _default = nos; +exports.default = _default; \ No newline at end of file diff --git a/lib/react/index.js b/lib/react/index.js index 88720b3f..9a862d7d 100644 --- a/lib/react/index.js +++ b/lib/react/index.js @@ -15,6 +15,12 @@ Object.defineProperty(exports, "injectNOS", { return _inject.injectNOS; } }); +Object.defineProperty(exports, "injectAssets", { + enumerable: true, + get: function get() { + return _inject.injectAssets; + } +}); var _props = _interopRequireDefault(require("./props")); diff --git a/lib/react/inject.js b/lib/react/inject.js index 11fa6c88..20591b43 100644 --- a/lib/react/inject.js +++ b/lib/react/inject.js @@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.injectNOS = void 0; +exports.injectAssets = exports.injectNOS = void 0; var _react = _interopRequireDefault(require("react")); -var _ = _interopRequireDefault(require("../")); +var _ = require("../"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -15,10 +15,20 @@ function _extends() { _extends = Object.assign || function (target) { for (var i var injectNOS = function injectNOS(Component) { return function (props) { - return _react.default.createElement(Component, _extends({ - nos: _.default - }, props)); + return _react.default.createElement(Component, _extends({}, props, { + nos: _.nos + })); }; }; -exports.injectNOS = injectNOS; \ No newline at end of file +exports.injectNOS = injectNOS; + +var injectAssets = function injectAssets(Component) { + return function (props) { + return _react.default.createElement(Component, _extends({}, props, { + assets: _.assets + })); + }; +}; + +exports.injectAssets = injectAssets; \ No newline at end of file diff --git a/lib/react/props.js b/lib/react/props.js index 27344b7d..7ec470c3 100644 --- a/lib/react/props.js +++ b/lib/react/props.js @@ -5,20 +5,16 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -var _propTypes = _interopRequireDefault(require("prop-types")); +var _propTypes = require("prop-types"); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var nosProps = _propTypes.default.shape({ - exists: _propTypes.default.bool.isRequired, - getAddress: _propTypes.default.func.isRequired, - getBalance: _propTypes.default.func.isRequired, - claimGas: _propTypes.default.func.isRequired, - send: _propTypes.default.func.isRequired, - testInvoke: _propTypes.default.func.isRequired, - invoke: _propTypes.default.func.isRequired, - getStorage: _propTypes.default.func.isRequired +var nosProps = (0, _propTypes.shape)({ + getAddress: _propTypes.func.isRequired, + getBalance: _propTypes.func.isRequired, + claimGas: _propTypes.func.isRequired, + send: _propTypes.func.isRequired, + testInvoke: _propTypes.func.isRequired, + invoke: _propTypes.func.isRequired, + getStorage: _propTypes.func.isRequired }); - var _default = nosProps; exports.default = _default; \ No newline at end of file From 4420141d416b1e55b8811efc0970545debd40e2d Mon Sep 17 00:00:00 2001 From: Matt Huggins Date: Sun, 9 Sep 2018 08:50:52 -0500 Subject: [PATCH 2/9] chore(package): update dependencies --- package.json | 6 ++-- yarn.lock | 96 ++++++++++++++++------------------------------------ 2 files changed, 32 insertions(+), 70 deletions(-) diff --git a/package.json b/package.json index d878b932..fc2b7246 100644 --- a/package.json +++ b/package.json @@ -30,15 +30,15 @@ }, "homepage": "https://github.com/nos/api-functions#readme", "dependencies": { - "prop-types": "15.6.1" + "prop-types": "15.6.2" }, "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": "^1.12.1", + "react": ">=16.3.0" }, "prettier": { "printWidth": 100 diff --git a/yarn.lock b/yarn.lock index fb26e49b..d6d0cb84 100644 --- a/yarn.lock +++ b/yarn.lock @@ -629,10 +629,6 @@ array-unique@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" -asap@~2.0.3: - version "2.0.6" - resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" - async-each@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" @@ -732,10 +728,6 @@ convert-source-map@^1.1.0: version "1.5.1" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.1.tgz#b8278097b9bc229365de5c62cf5fcaed8b5599e5" -core-js@^1.0.0: - version "1.2.7" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" - core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -768,12 +760,6 @@ electron-to-chromium@^1.3.42: version "1.3.42" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.42.tgz#95c33bf01d0cc405556aec899fe61fd4d76ea0f9" -encoding@^0.1.11: - version "0.1.12" - resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" - dependencies: - iconv-lite "~0.4.13" - escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -800,18 +786,6 @@ extglob@^0.3.1: dependencies: is-extglob "^1.0.0" -fbjs@^0.8.16: - version "0.8.16" - resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db" - dependencies: - core-js "^1.0.0" - isomorphic-fetch "^2.1.1" - loose-envify "^1.0.0" - object-assign "^4.1.0" - promise "^7.1.1" - setimmediate "^1.0.5" - ua-parser-js "^0.7.9" - filename-regex@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" @@ -910,7 +884,7 @@ has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" -iconv-lite@^0.4.4, iconv-lite@~0.4.13: +iconv-lite@^0.4.4: version "0.4.21" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.21.tgz#c47f8733d02171189ebc4a400f3218d348094798" dependencies: @@ -1007,10 +981,6 @@ is-primitive@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" -is-stream@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - isarray@1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -1021,17 +991,14 @@ isobject@^2.0.0: dependencies: isarray "1.0.0" -isomorphic-fetch@^2.1.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" - dependencies: - node-fetch "^1.0.1" - whatwg-fetch ">=0.10.0" - js-tokens@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" +"js-tokens@^3.0.0 || ^4.0.0": + version "4.0.0" + resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + jsesc@^2.5.1: version "2.5.1" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.1.tgz#e421a2a8e20d6b0819df28908f782526b96dd1fe" @@ -1066,6 +1033,12 @@ loose-envify@^1.0.0, loose-envify@^1.3.1: dependencies: js-tokens "^3.0.0" +loose-envify@^1.1.0: + version "1.4.0" + resolved "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" + dependencies: + js-tokens "^3.0.0 || ^4.0.0" + micromatch@^2.1.5, micromatch@^2.3.11: version "2.3.11" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" @@ -1133,13 +1106,6 @@ needle@^2.2.0: iconv-lite "^0.4.4" sax "^1.2.4" -node-fetch@^1.0.1: - version "1.7.3" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" - dependencies: - encoding "^0.1.11" - is-stream "^1.0.1" - node-pre-gyp@^0.9.0: version "0.9.1" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.9.1.tgz#f11c07516dd92f87199dbc7e1838eab7cd56c9e0" @@ -1265,17 +1231,10 @@ process-nextick-args@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" -promise@^7.1.1: - version "7.3.1" - resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" - dependencies: - asap "~2.0.3" - -prop-types@15.6.1: - version "15.6.1" - resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca" +prop-types@15.6.2, prop-types@^15.6.2: + version "15.6.2" + resolved "https://registry.npmjs.org/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102" dependencies: - fbjs "^0.8.16" loose-envify "^1.3.1" object-assign "^4.1.1" @@ -1295,6 +1254,15 @@ rc@^1.1.7: minimist "^1.2.0" strip-json-comments "~2.0.1" +react@>=16.3.0: + version "16.5.0" + resolved "https://registry.npmjs.org/react/-/react-16.5.0.tgz#f2c1e754bf9751a549d9c6d9aca41905beb56575" + dependencies: + loose-envify "^1.1.0" + object-assign "^4.1.1" + prop-types "^15.6.2" + schedule "^0.3.0" + readable-stream@^2.0.2, readable-stream@^2.0.6: version "2.3.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" @@ -1395,6 +1363,12 @@ sax@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" +schedule@^0.3.0: + version "0.3.0" + resolved "https://registry.npmjs.org/schedule/-/schedule-0.3.0.tgz#1be2ab2fc2e768536269ce7326efb478d6c045e8" + dependencies: + object-assign "^4.1.1" + semver@^5.3.0, semver@^5.4.1: version "5.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" @@ -1407,10 +1381,6 @@ set-immediate-shim@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" -setimmediate@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - signal-exit@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" @@ -1473,10 +1443,6 @@ trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" -ua-parser-js@^0.7.9: - version "0.7.17" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac" - unicode-canonical-property-names-ecmascript@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.3.tgz#f6119f417467593c0086357c85546b6ad5abc583" @@ -1500,10 +1466,6 @@ util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" -whatwg-fetch@>=0.10.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" - wide-align@^1.1.0: version "1.1.2" resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" From 40b1effc3419917ebfe7cee8666042fcf2f24262 Mon Sep 17 00:00:00 2001 From: Matt Huggins Date: Sun, 9 Sep 2018 08:51:05 -0500 Subject: [PATCH 3/9] chore(package): separate clean script --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index fc2b7246..35f5fdf5 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build": "rm -rf lib && ./node_modules/.bin/babel es6 -d lib" + "clean": "rm -rf lib", + "build": "yarn run clean && ./node_modules/.bin/babel es6 -d lib" }, "repository": { "type": "git", From e79a4cdc00b64fabedf798bceeee964a40228030 Mon Sep 17 00:00:00 2001 From: Matt Huggins Date: Sun, 9 Sep 2018 09:02:28 -0500 Subject: [PATCH 4/9] feat(assets): updated readme --- README.md | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c20ee960..26adbb72 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,47 @@ yarn add @nosplatform/api-functions ``` ## Usage in react +Wrap your component with the higher-order components to provide fallbacks when running outside the +context of the [nOS client](https://github.com/nos/client). Specify `propTypes` provided by this +package. + +```js +import React from 'react'; +import { compose } from 'recompose'; +import { injectNOS, injectAssets, nosProps } from "@nosplatform/api-functions/lib/react"; + +class ShowBalance extends React.Component { + static propTypes = { + nos: nosProps.isRequired + } + + render() { + return ( + + ); + } + + async handleClick = () => { + const { nos, assets } = this.props; + const balance = await nos.getBalance({ asset: assets.NEO }); + console.log('NEO Balance:', balance); + } +}; + +export default compose( + injectNOS, + injectAssets +)(ShowBalance); ``` -import { injectNOS, nosProps } from "@nosplatform/api-functions/lib/react"; + +In addition to automatically providing the NOS API function as a prop to your React component, the +api-functions package also provides the opportunity to specify a fallback implementation. This is +especially useful for building in the context of another browser if not wanting to use the nOS +client for any reason. + +```js +const balance = await nos.getBalance({ asset: assets.NEO }, () => '23'); +console.log('NEO Balance:', balance); // NEO Balance: 23 ``` From 26a5f265adad79f31c0b4e27582408db1a25450a Mon Sep 17 00:00:00 2001 From: Matt Huggins Date: Sun, 9 Sep 2018 09:04:33 -0500 Subject: [PATCH 5/9] feat(assets): added assetProps shape --- es6/react/index.js | 4 ++-- es6/react/props.js | 6 +++--- lib/react/index.js | 14 +++++++++----- lib/react/props.js | 7 ++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/es6/react/index.js b/es6/react/index.js index 8368611b..90fbee3b 100644 --- a/es6/react/index.js +++ b/es6/react/index.js @@ -1,4 +1,4 @@ -import nosProps from "./props"; +import { nosProps, assetProps } from "./props"; import { injectNOS, injectAssets } from "./inject"; -export { injectNOS, injectAssets, nosProps }; +export { injectNOS, injectAssets, nosProps, assetProps }; diff --git a/es6/react/props.js b/es6/react/props.js index 8f310bca..3b9d9896 100644 --- a/es6/react/props.js +++ b/es6/react/props.js @@ -1,6 +1,6 @@ -import { func, shape } from "prop-types"; +import { func, string, shape, objectOf } from "prop-types"; -const nosProps = shape({ +export const nosProps = shape({ getAddress: func.isRequired, getBalance: func.isRequired, claimGas: func.isRequired, @@ -10,4 +10,4 @@ const nosProps = shape({ getStorage: func.isRequired }); -export default nosProps; +export const assetProps = objectOf(string); diff --git a/lib/react/index.js b/lib/react/index.js index 9a862d7d..ff903182 100644 --- a/lib/react/index.js +++ b/lib/react/index.js @@ -6,7 +6,13 @@ Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "nosProps", { enumerable: true, get: function get() { - return _props.default; + return _props.nosProps; + } +}); +Object.defineProperty(exports, "assetProps", { + enumerable: true, + get: function get() { + return _props.assetProps; } }); Object.defineProperty(exports, "injectNOS", { @@ -22,8 +28,6 @@ Object.defineProperty(exports, "injectAssets", { } }); -var _props = _interopRequireDefault(require("./props")); - -var _inject = require("./inject"); +var _props = require("./props"); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file +var _inject = require("./inject"); \ No newline at end of file diff --git a/lib/react/props.js b/lib/react/props.js index 7ec470c3..2af09ec9 100644 --- a/lib/react/props.js +++ b/lib/react/props.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = void 0; +exports.assetProps = exports.nosProps = void 0; var _propTypes = require("prop-types"); @@ -16,5 +16,6 @@ var nosProps = (0, _propTypes.shape)({ invoke: _propTypes.func.isRequired, getStorage: _propTypes.func.isRequired }); -var _default = nosProps; -exports.default = _default; \ No newline at end of file +exports.nosProps = nosProps; +var assetProps = (0, _propTypes.objectOf)(_propTypes.string); +exports.assetProps = assetProps; \ No newline at end of file From 072aa9af2d95ca2abb519b8c0ed9122dbab8217b Mon Sep 17 00:00:00 2001 From: Matt Huggins Date: Sun, 9 Sep 2018 09:05:06 -0500 Subject: [PATCH 6/9] feat(assets): updated readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 26adbb72..5c010762 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,12 @@ package. ```js import React from 'react'; import { compose } from 'recompose'; -import { injectNOS, injectAssets, nosProps } from "@nosplatform/api-functions/lib/react"; +import { injectNOS, injectAssets, nosProps, assetProps } from "@nosplatform/api-functions/lib/react"; class ShowBalance extends React.Component { static propTypes = { - nos: nosProps.isRequired + nos: nosProps.isRequired, + assets: assetProps.isRequired } render() { From a336554e5496317d80c4f5fd2573074a9fe36362 Mon Sep 17 00:00:00 2001 From: Matt Huggins Date: Tue, 11 Sep 2018 19:55:06 -0500 Subject: [PATCH 7/9] feat(nos): export exists --- es6/assets.js | 3 +-- es6/executor.js | 3 +-- es6/exists.js | 4 ++++ es6/nos.js | 2 ++ es6/react/props.js | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 es6/exists.js diff --git a/es6/assets.js b/es6/assets.js index c0b5a9b5..e5b06cf3 100644 --- a/es6/assets.js +++ b/es6/assets.js @@ -1,5 +1,4 @@ -/** @const {boolean} exists check whether assets constant is defined */ -const exists = !!window.NOS && !!window.NOS.ASSETS; +import exists from "./exists"; /** @const {object} assets bind assets constant to variable */ const assets = exists ? window.NOS.ASSETS : { diff --git a/es6/executor.js b/es6/executor.js index e4c39368..d8e3433c 100644 --- a/es6/executor.js +++ b/es6/executor.js @@ -1,5 +1,4 @@ -/** @const {boolean} exists check whether nOS is defined */ -const exists = !!window.NOS && !!window.NOS.V1; +import exists from "./exists"; /** @const {object} nos bind nOS api to variable */ const nos = exists ? window.NOS.V1 : undefined; diff --git a/es6/exists.js b/es6/exists.js new file mode 100644 index 00000000..38745541 --- /dev/null +++ b/es6/exists.js @@ -0,0 +1,4 @@ +/** @const {boolean} exists check whether nOS is defined */ +const exists = !!window.NOS; + +export default exists; diff --git a/es6/nos.js b/es6/nos.js index 952d20d0..de3794d2 100644 --- a/es6/nos.js +++ b/es6/nos.js @@ -1,3 +1,4 @@ +import exists from "./exists"; import executor from "./executor"; // Wallet Actions @@ -53,6 +54,7 @@ const getStorage = (config, fallback) => executor('getStorage', fallback, config const nos = { claimGas, + exists, getAddress, getBalance, getStorage, diff --git a/es6/react/props.js b/es6/react/props.js index 3b9d9896..82e7d600 100644 --- a/es6/react/props.js +++ b/es6/react/props.js @@ -1,6 +1,7 @@ import { func, string, shape, objectOf } from "prop-types"; export const nosProps = shape({ + exists: bool.isRequired, getAddress: func.isRequired, getBalance: func.isRequired, claimGas: func.isRequired, From 369d6427267380093b7ef8a358bf13324418e9fd Mon Sep 17 00:00:00 2001 From: Jeroen Peeters Date: Fri, 14 Sep 2018 08:59:08 +0200 Subject: [PATCH 8/9] feat: getLastBlock --- lib/assets.js | 9 +++++---- lib/executor.js | 11 ++++++----- lib/exists.js | 11 +++++++++++ lib/nos.js | 28 +++++++++++++++++++++------- lib/react/props.js | 2 ++ package.json | 2 +- {es6 => src}/assets.js | 0 {es6 => src}/executor.js | 0 {es6 => src}/exists.js | 0 {es6 => src}/index.js | 0 {es6 => src}/nos.js | 22 +++++++++++++++------- {es6 => src}/react/index.js | 0 {es6 => src}/react/inject.js | 0 {es6 => src}/react/props.js | 1 + 14 files changed, 62 insertions(+), 24 deletions(-) create mode 100644 lib/exists.js rename {es6 => src}/assets.js (100%) rename {es6 => src}/executor.js (100%) rename {es6 => src}/exists.js (100%) rename {es6 => src}/index.js (100%) rename {es6 => src}/nos.js (67%) rename {es6 => src}/react/index.js (100%) rename {es6 => src}/react/inject.js (100%) rename {es6 => src}/react/props.js (91%) diff --git a/lib/assets.js b/lib/assets.js index 4932760f..ca2a5c06 100644 --- a/lib/assets.js +++ b/lib/assets.js @@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -/** @const {boolean} exists check whether assets constant is defined */ -var exists = !!window.NOS && !!window.NOS.ASSETS; -/** @const {object} assets bind assets constant to variable */ +var _exists = _interopRequireDefault(require("./exists")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var assets = exists ? window.NOS.ASSETS : { +/** @const {object} assets bind assets constant to variable */ +var assets = _exists.default ? window.NOS.ASSETS : { NEO: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b', GAS: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7' }; diff --git a/lib/executor.js b/lib/executor.js index 699c422d..bf10d74c 100644 --- a/lib/executor.js +++ b/lib/executor.js @@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -/** @const {boolean} exists check whether nOS is defined */ -var exists = !!window.NOS && !!window.NOS.V1; -/** @const {object} nos bind nOS api to variable */ +var _exists = _interopRequireDefault(require("./exists")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var nos = exists ? window.NOS.V1 : undefined; +/** @const {object} nos bind nOS api to variable */ +var nos = _exists.default ? window.NOS.V1 : undefined; /** * @function useFallback * @param {function} fallback checks if fallback function exists, otherwise return nothing @@ -23,7 +24,7 @@ var useFallback = function useFallback(fallback, args) { var executor = function executor(func, fallback, config) { - return exists ? nos[func](config) : useFallback(fallback, config); + return _exists.default ? nos[func](config) : useFallback(fallback, config); }; var _default = executor; diff --git a/lib/exists.js b/lib/exists.js new file mode 100644 index 00000000..f71ab6ec --- /dev/null +++ b/lib/exists.js @@ -0,0 +1,11 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +/** @const {boolean} exists check whether nOS is defined */ +var exists = !!window.NOS; +var _default = exists; +exports.default = _default; \ No newline at end of file diff --git a/lib/nos.js b/lib/nos.js index 53857772..39c1be98 100644 --- a/lib/nos.js +++ b/lib/nos.js @@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; +var _exists = _interopRequireDefault(require("./exists")); + var _executor = _interopRequireDefault(require("./executor")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -16,7 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @param {function} fallback fallback function if outside of nOS browser */ var getAddress = function getAddress(fallback) { - return (0, _executor.default)('getAddress', fallback); + return (0, _executor.default)("getAddress", fallback); }; /** * @function getBalance @@ -26,7 +28,17 @@ var getAddress = function getAddress(fallback) { var getBalance = function getBalance(config, fallback) { - return (0, _executor.default)('getBalance', fallback, config); + return (0, _executor.default)("getBalance", fallback, config); +}; +/** + * @function getLastBlock + * @param {object} config All possible arguments and flags are passed as childs of this object + * @param {function} fallback fallback function if outside of nOS browser + */ + + +var getLastBlock = function getLastBlock(config, fallback) { + return (0, _executor.default)("getLastBlock", fallback, config); }; /** * @function claimGas @@ -35,7 +47,7 @@ var getBalance = function getBalance(config, fallback) { var claimGas = function claimGas(fallback) { - return (0, _executor.default)('claimGas', fallback); + return (0, _executor.default)("claimGas", fallback); }; /** * @function send @@ -45,7 +57,7 @@ var claimGas = function claimGas(fallback) { var send = function send(config, fallback) { - return (0, _executor.default)('send', fallback, config); + return (0, _executor.default)("send", fallback, config); }; // Smart Contract Actions /** @@ -56,7 +68,7 @@ var send = function send(config, fallback) { var testInvoke = function testInvoke(config, fallback) { - return (0, _executor.default)('testInvoke', fallback, config); + return (0, _executor.default)("testInvoke", fallback, config); }; /** * @function invoke @@ -66,7 +78,7 @@ var testInvoke = function testInvoke(config, fallback) { var invoke = function invoke(config, fallback) { - return (0, _executor.default)('invoke', fallback, config); + return (0, _executor.default)("invoke", fallback, config); }; /** * @function getStorage @@ -76,13 +88,15 @@ var invoke = function invoke(config, fallback) { var getStorage = function getStorage(config, fallback) { - return (0, _executor.default)('getStorage', fallback, config); + return (0, _executor.default)("getStorage", fallback, config); }; var nos = { claimGas: claimGas, + exists: _exists.default, getAddress: getAddress, getBalance: getBalance, + getLastBlock: getLastBlock, getStorage: getStorage, invoke: invoke, send: send, diff --git a/lib/react/props.js b/lib/react/props.js index 2af09ec9..1cdfcd23 100644 --- a/lib/react/props.js +++ b/lib/react/props.js @@ -8,8 +8,10 @@ exports.assetProps = exports.nosProps = void 0; var _propTypes = require("prop-types"); var nosProps = (0, _propTypes.shape)({ + exists: bool.isRequired, getAddress: _propTypes.func.isRequired, getBalance: _propTypes.func.isRequired, + getLastBlock: _propTypes.func.isRequired, claimGas: _propTypes.func.isRequired, send: _propTypes.func.isRequired, testInvoke: _propTypes.func.isRequired, diff --git a/package.json b/package.json index 35f5fdf5..eb8259b7 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "clean": "rm -rf lib", - "build": "yarn run clean && ./node_modules/.bin/babel es6 -d lib" + "build": "yarn run clean && ./node_modules/.bin/babel src -d lib" }, "repository": { "type": "git", diff --git a/es6/assets.js b/src/assets.js similarity index 100% rename from es6/assets.js rename to src/assets.js diff --git a/es6/executor.js b/src/executor.js similarity index 100% rename from es6/executor.js rename to src/executor.js diff --git a/es6/exists.js b/src/exists.js similarity index 100% rename from es6/exists.js rename to src/exists.js diff --git a/es6/index.js b/src/index.js similarity index 100% rename from es6/index.js rename to src/index.js diff --git a/es6/nos.js b/src/nos.js similarity index 67% rename from es6/nos.js rename to src/nos.js index de3794d2..6b0ca958 100644 --- a/es6/nos.js +++ b/src/nos.js @@ -7,27 +7,34 @@ import executor from "./executor"; * @function getAddress * @param {function} fallback fallback function if outside of nOS browser */ -const getAddress = fallback => executor('getAddress', fallback); +const getAddress = fallback => executor("getAddress", fallback); /** * @function getBalance * @param {object} config All possible arguments and flags are passed as childs of this object * @param {function} fallback fallback function if outside of nOS browser */ -const getBalance = (config, fallback) => executor('getBalance', fallback, config); +const getBalance = (config, fallback) => executor("getBalance", fallback, config); + +/** + * @function getLastBlock + * @param {object} config All possible arguments and flags are passed as childs of this object + * @param {function} fallback fallback function if outside of nOS browser + */ +const getLastBlock = (config, fallback) => executor("getLastBlock", fallback, config); /** * @function claimGas * @param {function} fallback fallback function if outside of nOS browser */ -const claimGas = fallback => executor('claimGas', fallback); +const claimGas = fallback => executor("claimGas", fallback); /** * @function send * @param {object} config All possible arguments and flags are passed as childs of this object * @param {function} fallback fallback function if outside of nOS browser */ -const send = (config, fallback) => executor('send', fallback, config); +const send = (config, fallback) => executor("send", fallback, config); // Smart Contract Actions @@ -36,27 +43,28 @@ const send = (config, fallback) => executor('send', fallback, config); * @param {object} config All possible arguments and flags are passed as childs of this object * @param {function} fallback fallback function if outside of nOS browser */ -const testInvoke = (config, fallback) => executor('testInvoke', fallback, config); +const testInvoke = (config, fallback) => executor("testInvoke", fallback, config); /** * @function invoke * @param {object} config All possible arguments and flags are passed as childs of this object * @param {function} fallback fallback function if outside of nOS browser */ -const invoke = (config, fallback) => executor('invoke', fallback, config); +const invoke = (config, fallback) => executor("invoke", fallback, config); /** * @function getStorage * @param {object} config All possible arguments and flags are passed as childs of this object * @param {function} fallback fallback function if outside of nOS browser */ -const getStorage = (config, fallback) => executor('getStorage', fallback, config); +const getStorage = (config, fallback) => executor("getStorage", fallback, config); const nos = { claimGas, exists, getAddress, getBalance, + getLastBlock, getStorage, invoke, send, diff --git a/es6/react/index.js b/src/react/index.js similarity index 100% rename from es6/react/index.js rename to src/react/index.js diff --git a/es6/react/inject.js b/src/react/inject.js similarity index 100% rename from es6/react/inject.js rename to src/react/inject.js diff --git a/es6/react/props.js b/src/react/props.js similarity index 91% rename from es6/react/props.js rename to src/react/props.js index 82e7d600..65d83482 100644 --- a/es6/react/props.js +++ b/src/react/props.js @@ -4,6 +4,7 @@ export const nosProps = shape({ exists: bool.isRequired, getAddress: func.isRequired, getBalance: func.isRequired, + getLastBlock: func.isRequired, claimGas: func.isRequired, send: func.isRequired, testInvoke: func.isRequired, From e33d9e32a77c63d87e63283f7a679ba232d124b8 Mon Sep 17 00:00:00 2001 From: Jeroen Peeters Date: Fri, 14 Sep 2018 09:00:37 +0200 Subject: [PATCH 9/9] chore(app): v0.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eb8259b7..653f7c27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nosplatform/api-functions", - "version": "0.3.0", + "version": "0.4.0", "description": "nOS API bindings and types", "main": "lib/index.js", "scripts": {