Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to make react native friendly #63

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 44 additions & 0 deletions .flowconfig
@@ -0,0 +1,44 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js

.*/react-native-fs/.*

<PROJECT_ROOT>/lib/.*.js.flow

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow
flow/

[options]
emoji=true

module.system=haste

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,6 +4,7 @@ coverage
.vscode

build
.idea/

lib/
contrib/boost*
Expand Down
127 changes: 127 additions & 0 deletions HostedMoneroAPIClient/BackgroundResponseParser.web.js
@@ -0,0 +1,127 @@
// Copyright (c) 2014-2018, MyMonero.com
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
"use strict"
//
// In the future this could implement web workers
const response_parser_utils = require('../hostAPI/response_parser_utils')
const monero_keyImage_cache_utils = require('../monero_utils/monero_keyImage_cache_utils')
const monero_utils_promise = require('../monero_utils/monero_utils')
//
class BackgroundResponseParser
{
constructor(options, context)
{
}
//
// Runtime - Accessors - Interface
//
Parsed_AddressInfo(
data,
address,
view_key__private,
spend_key__public,
spend_key__private,
fn //: (err?, returnValuesByKey?) -> Void
) {
monero_utils_promise.then(async function(monero_utils)
{
await response_parser_utils.Parsed_AddressInfo__keyImageManaged(
data,
address,
view_key__private,
spend_key__public,
spend_key__private,
monero_utils,
function(err, returnValuesByKey)
{
fn(err, returnValuesByKey)
}
)
})
}
Parsed_AddressTransactions(
data,
address,
view_key__private,
spend_key__public,
spend_key__private,
fn //: (err?, returnValuesByKey?) -> Void
) {
monero_utils_promise.then(function(monero_utils)
{
response_parser_utils.Parsed_AddressTransactions__keyImageManaged(
data,
address,
view_key__private,
spend_key__public,
spend_key__private,
monero_utils,
function(err, returnValuesByKey)
{
fn(err, returnValuesByKey)
}
)
})
}
Parsed_UnspentOuts(
data,
address,
view_key__private,
spend_key__public,
spend_key__private,
fn //: (err?, returnValuesByKey?) -> Void
) {
monero_utils_promise.then(function(monero_utils)
{
response_parser_utils.Parsed_UnspentOuts__keyImageManaged(
data,
address,
view_key__private,
spend_key__public,
spend_key__private,
monero_utils,
function(err, returnValuesByKey)
{
fn(err, returnValuesByKey)
}
)
})
}
//
DeleteManagedKeyImagesForWalletWith(
address,
fn // ((err) -> Void)?
) {
monero_keyImage_cache_utils.DeleteManagedKeyImagesForWalletWith(address)
if (fn) {
setImmediate(fn)
}
}
}
module.exports = BackgroundResponseParser
42 changes: 42 additions & 0 deletions HostedMoneroAPIClient/HostedMoneroAPIClient.Lite.js
@@ -0,0 +1,42 @@
// Copyright (c) 2014-2018, MyMonero.com
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"use strict"
//
const HostedMoneroAPIClient_Base = require('./HostedMoneroAPIClient_Base')
//
class HostedMoneroAPIClient extends HostedMoneroAPIClient_Base
{
//
// Lifecycle - Init
constructor(options, context)
{
super(options, context)
}
}
module.exports = HostedMoneroAPIClient