Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- PLEASE FILL OUT THE FOLLOWING MARKDOWN TEMPLATE -->
<!-- PR title alone should be sufficient to understand changes. -->

## Change Description
<!-- Describe your changes, their justification, AND their impact. Reference issues or pull requests where possible (use '#XX' or 'GH-XX' where XX is the issue or pull request number). -->


## API Changes
- [ ] API Changes
<!-- checked [x] = API changes; unchecked [ ] = no changes, ignore this section -->
<!-- If this PR introduces API changes, please describe the changes here. What will developers need to know before upgrading to this version? -->


## Documentation Additions
- [ ] Documentation Additions
<!-- checked [x] = Documentation changes; unchecked [ ] = no changes, ignore this section -->
<!-- Describe what must be added to the documentation after merge. -->
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,5 @@ Open a browser at `localhost:3000` to see a running instance of the example.
## Important

See LICENSE for copyright and license terms. Block.one makes its contribution on a voluntary basis as a member of the EOSIO community and is not responsible for ensuring the overall performance of the software or any related applications. We make no representation, warranty, guarantee or undertaking in respect of the software or any related documentation, whether expressed or implied, including but not limited to the warranties or merchantability, fitness for a particular purpose and noninfringement. In no event shall we be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or documentation or the use or other dealings in the software or documentation. Any test results or performance figures are indicative and will not reflect performance under all conditions. Any reference to any third party or third-party product, service or other resource is not an endorsement or recommendation by Block.one. We are not responsible, and disclaim any and all responsibility and liability, for your use of or reliance on any of these resources. Third-party resources may be updated, changed or terminated at any time, so the information here may be out of date or inaccurate.

Wallets and related components are complex software that require the highest levels of security. If incorrectly built or used, they may compromise users’ private keys and digital assets. Wallet applications and related components should undergo thorough security evaluations before being used. Only experienced developers should work with this software.
46 changes: 46 additions & 0 deletions __tests__/withUAL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react'
import { mount } from 'enzyme'

import { withUAL } from '../src/components/provider/withUAL'

const mockContext = 'testContext'
jest.mock('../src/components/provider/UALContext', () => ({
UALContext: {
Consumer: ({ children }) => children(mockContext),
}
}))

describe('withUAL', () => {
let wrappedComponent
let component
let name

beforeEach(() => {
component = (props) => {
return <h1>Hello, {props.name}</h1>;
}
name = 'testName'
const WrappedComponent = withUAL(component)
wrappedComponent = mount(<WrappedComponent name={name} />)
})

it('sets the props', () => {
expect(wrappedComponent.prop('name')).toBe(name)
})

it('renders the wrapped component', () => {
expect(wrappedComponent.find(component)).toHaveLength(1)
})

fit('passes the context as the prop ual to the wrapped component', () => {
expect(wrappedComponent.find(component).prop('ual')).toBe(mockContext)
})

it('passes the props to the wrapped component', () => {
expect(wrappedComponent.find(component).prop('name')).toBe(name)
})

it('renders the props in the wrapped component', () => {
expect(wrappedComponent.text()).toEqual(`Hello, ${name}`)
})
})
2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ Navigate to http://localhost:3000 to see the example application
## Important

See LICENSE for copyright and license terms. Block.one makes its contribution on a voluntary basis as a member of the EOSIO community and is not responsible for ensuring the overall performance of the software or any related applications. We make no representation, warranty, guarantee or undertaking in respect of the software or any related documentation, whether expressed or implied, including but not limited to the warranties or merchantability, fitness for a particular purpose and noninfringement. In no event shall we be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or documentation or the use or other dealings in the software or documentation. Any test results or performance figures are indicative and will not reflect performance under all conditions. Any reference to any third party or third-party product, service or other resource is not an endorsement or recommendation by Block.one. We are not responsible, and disclaim any and all responsibility and liability, for your use of or reliance on any of these resources. Third-party resources may be updated, changed or terminated at any time, so the information here may be out of date or inaccurate.

Wallets and related components are complex software that require the highest levels of security. If incorrectly built or used, they may compromise users’ private keys and digital assets. Wallet applications and related components should undergo thorough security evaluations before being used. Only experienced developers should work with this software.
6 changes: 3 additions & 3 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
"prop-types": "^15.6.2",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"ual-ledger": "^0.1.1",
"ual-lynx": "^0.1.0",
"ual-reactjs-renderer": "^0.1.0",
"ual-scatter": "^0.1.0",
"ual-ledger": "0.1.0"
"ual-reactjs-renderer": "^0.1.2",
"ual-scatter": "^0.1.1"
}
}
2 changes: 1 addition & 1 deletion examples/src/ButtonWebViewReact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class TransactionApp extends React.Component<TransactionProps, TransactionState>
super(props)
this.state = {
...defaultState,
rpc: new JsonRpc(`${EXAMPLE_ENV.RPC_PROTOCOL}://${EXAMPLE_ENV.RPC_HOST}`)
rpc: new JsonRpc(`${EXAMPLE_ENV.RPC_PROTOCOL}://${EXAMPLE_ENV.RPC_HOST}:${EXAMPLE_ENV.RPC_PORT}`)
}
this.updateAccountBalance = this.updateAccountBalance.bind(this)
this.updateAccountName = this.updateAccountName.bind(this)
Expand Down
62 changes: 21 additions & 41 deletions examples/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1235,11 +1235,6 @@
"@ledgerhq/errors" "^4.48.0"
events "^3.0.0"

"@types/jest@^23.3.1":
version "23.3.14"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-23.3.14.tgz#37daaf78069e7948520474c87b80092ea912520a"
integrity sha512-Q5hTcfdudEL2yOmluA1zaSyPbzWPmJ3XfSWeP3RyoYvS9hnje1ZyagrZOuQ6+1nQC1Gw+7gap3pLNL3xL6UBug==

"@types/[email protected]":
version "15.0.4"
resolved "https://registry.yarnpkg.com/@types/react/-/react-15.0.4.tgz#97aedbba00448a137331aa8450232124aeb8d426"
Expand Down Expand Up @@ -3532,7 +3527,7 @@ [email protected]:
bluebird "^3.5.2"
socket.io-client "^2.1.1"

[email protected], eosjs-ecc@^4.0.1:
[email protected]:
version "4.0.4"
resolved "https://registry.yarnpkg.com/eosjs-ecc/-/eosjs-ecc-4.0.4.tgz#431450f30a6f73088ff5d7ba1ebdfe967a5ca4ab"
integrity sha512-9wAYefts4TidHOu+eN9nAisZdWpUzlUimZrB63oP7+/s4xRNJEn2Vvep2ICRODpxpidbshM1L7WaSYW9oiV5gA==
Expand Down Expand Up @@ -3571,16 +3566,6 @@ [email protected], eosjs@^20.0.0:
eosjs-ecc "4.0.4"
text-encoding "0.7.0"

[email protected]:
version "20.0.0-beta2"
resolved "https://registry.yarnpkg.com/eosjs/-/eosjs-20.0.0-beta2.tgz#026255a13fefeb4d46a98b0c55de7b972de661c0"
integrity sha512-CtlM3Cy8Fh3sKik5h8of66Tj1zALlU48xQJB25HJ1DLUm58f9z2jPCZ0hfkOcCXMsRIxZu01NpPufN08qZjFnQ==
dependencies:
"@types/jest" "^23.3.1"
babel-polyfill "^6.26.0"
eosjs-ecc "^4.0.1"
text-encoding "^0.6.4"

errno@^0.1.3, errno@~0.1.7:
version "0.1.7"
resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.7.tgz#4684d71779ad39af177e3f007996f7c67c852618"
Expand Down Expand Up @@ -6850,18 +6835,18 @@ sax@^1.2.4:
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==

scatterjs-core@2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/scatterjs-core/-/scatterjs-core-2.5.0.tgz#e23d1d40bebeb861c4375a7427392b3cb795dca1"
integrity sha512-Senfn+cihffudC7/katFr5fs4QayOgHKjlgmBJM9cBnESA+JO2wWgJ72LY9LwyJNHnepe3smf0Xjgo4XUAn00Q==
scatterjs-core@2.7.17:
version "2.7.17"
resolved "https://registry.yarnpkg.com/scatterjs-core/-/scatterjs-core-2.7.17.tgz#f889e9d3bf1ba2003fc0411ad838fbfe42ed11fb"
integrity sha512-LKvg7nr2ViZgNyw7dzk5CbwDVz006PBFpJqKU1dx7fmMs9LmBov7gB60DFwLR9p3kirPWO2hon1TE/xe51pkFw==
dependencies:
create-hash "^1.2.0"
es6-promise "^4.2.4"
get-random-values "^1.2.0"
isomorphic-ws "^4.0.1"
ws "^6.1.0"

scatterjs-plugin-eosjs2@^1.2.0:
scatterjs-plugin-eosjs2@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/scatterjs-plugin-eosjs2/-/scatterjs-plugin-eosjs2-1.5.0.tgz#4e8e08859c82af7b9c0b275ea57c9739a373cc18"
integrity sha512-RIYGW+c4dH//jwcAflcnI2N+erzy2AHQwfqMr8CTMCRg2S8Drm/PWf/iDn1JHsjbyTv1+kIP335zWz7xP92iAQ==
Expand Down Expand Up @@ -7456,11 +7441,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.7.0.tgz#f895e836e45990624086601798ea98e8f36ee643"
integrity sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA==

text-encoding@^0.6.4:
version "0.6.4"
resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19"
integrity sha1-45mpgiV6J22uQou5KEXLcb3CbRk=

text-table@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
Expand Down Expand Up @@ -7605,10 +7585,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/u2f-api/-/u2f-api-0.2.7.tgz#17bf196b242f6bf72353d9858e6a7566cc192720"
integrity sha512-fqLNg8vpvLOD5J/z4B6wpPg4Lvowz1nJ9xdHcCzdUPKcFE/qNCceV2gNZxSJd5vhAZemHr/K/hbzVA0zxB5mkg==

[email protected].0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/ual-ledger/-/ual-ledger-0.1.0.tgz#666a678e68e95b62dc1eef641e6f1cd6e4c9dac2"
integrity sha512-fL2bSrejoLEGA0z/FeFneRHpSCQuXfl29xmTmR/daeThWC1TfNeW1FENts5CT6msk8md9JKQl9KtxhYShaN6Og==
ual-ledger@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ual-ledger/-/ual-ledger-0.1.1.tgz#b9800ca81174e34489b3f3826ccc2fe1a834a2af"
integrity sha512-o3bCGVtfi67VeTiMrkvSRfk8gWcV1cnMYVbKPykf38kAO74ou+LlOB9Q0hScSQWlH2nM0cheLSv71gHnBnydLA==
dependencies:
eosjs "20.0.0"
eosjs-ledger-signature-provider "0.1.1"
Expand All @@ -7624,10 +7604,10 @@ ual-lynx@^0.1.0:
eosjs "^20.0.0"
universal-authenticator-library "^0.1.0"

ual-reactjs-renderer@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/ual-reactjs-renderer/-/ual-reactjs-renderer-0.1.0.tgz#0c61e59d2af8e1695b5f16ec97fad505981f57f4"
integrity sha512-QwUuRFBvJZRpJ5nyZ43607OviKBaSh0OD4FERMB2il0UHM6B+EfTHreAVVl2T5gPn+EbFO0WoPkl9TKVWyPJlg==
ual-reactjs-renderer@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/ual-reactjs-renderer/-/ual-reactjs-renderer-0.1.2.tgz#4648208be772fbef9841128824a344e5a46dfdc4"
integrity sha512-xeHncHz07IQCraz1cvTDuxs9MMsUeXkFTBCQA4dHhyrBO/LRd+R0OnS2hOpycLI9pG4vkKZeVFZzKutlG/z/Xg==
dependencies:
i18next "^14.0.1"
i18next-browser-languagedetector "^2.2.4"
Expand All @@ -7639,15 +7619,15 @@ ual-reactjs-renderer@^0.1.0:
styled-components "^4.1.3"
universal-authenticator-library "^0.1.0"

ual-scatter@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/ual-scatter/-/ual-scatter-0.1.0.tgz#9a197aa27aad1d861a061a927620bda1077a4797"
integrity sha512-yXJ6shHN3NQmdcmCI0sZcrEOV4lyykQExfQaual1NpFqDKJnWI6EfKZrgsbtGaOTpQV9F4jK5Nsev8BY3/l3Zw==
ual-scatter@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ual-scatter/-/ual-scatter-0.1.1.tgz#f789ad786ee9fc2ba747029a182ed63587028b28"
integrity sha512-gcQrQdleQSYlPrZcxzU8DVJQReqLO2v1zoOpMspCMCdb0MZF2zIT2Gzp7udrbO1U+5s/no8YVzKnMtjCPEepzw==
dependencies:
eosjs "20.0.0-beta2"
eosjs "20.0.0"
eosjs-ecc "4.0.4"
scatterjs-core "2.5.0"
scatterjs-plugin-eosjs2 "^1.2.0"
scatterjs-core "2.7.17"
scatterjs-plugin-eosjs2 "^1.5.0"
universal-authenticator-library "0.1.0"

[email protected]:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ual-reactjs-renderer",
"version": "0.1.1",
"version": "0.1.2",
"main": "dist/index.js",
"author": {
"name": "block.one",
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/UALBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import i18n from '../../i18n'

import { UALContainer } from './UALContainer'
import { withUAL } from '../provider/UALContext'
import { withUAL } from '../provider/withUAL'
import { UALBoxParts } from './UALBoxParts'

import { box } from '../../styles/box'
Expand Down
15 changes: 0 additions & 15 deletions src/components/provider/UALContext.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
import React from 'react'

export const UALContext = React.createContext()
/**
* @type {function}
* @name withUAL
* @desc Function for making a component a consumer of the UAL context
*/
export const withUAL = WrappedComponent => props => {
const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component'
const WithUAL = props => (
<UALContext.Consumer>
{context => <WrappedComponent {...props} ual={context} />}
</UALContext.Consumer>
)
WithUAL.displayName = `withUAL(${displayName})`
return <WithUAL/>
}
19 changes: 19 additions & 0 deletions src/components/provider/withUAL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'

import { UALContext } from './UALContext'

/**
* @type {function}
* @name withUAL
* @desc Function for making a component a consumer of the UAL context
*/
export const withUAL = WrappedComponent => props => {
const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component'
const WithUAL = props => (
<UALContext.Consumer>
{ context => <WrappedComponent {...props} ual={context} /> }
</UALContext.Consumer>
)
WithUAL.displayName = `withUAL(${displayName})`
return <WithUAL {...props}/>
}
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { UALBox } from './components/modal/UALBox'
export { withUAL, UALContext } from './components/provider/UALContext'
export { UALContext } from './components/provider/UALContext'
export { withUAL } from './components/provider/withUAL'
export { UALProvider } from './components/provider/UALProvider'