edge-currency-monero 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +107 -0
- package/LICENSE +29 -0
- package/README.md +52 -0
- package/index.js +3 -0
- package/lib/miningFees.js +101 -0
- package/lib/react-native/edge-currency-monero.js +22487 -0
- package/lib/react-native/edge-currency-monero.js.map +1 -0
- package/lib/react-native-io.js +5 -0
- package/lib/utils.js +122 -0
- package/lib/xmrEngine.js +913 -0
- package/lib/xmrIndex.js +18 -0
- package/lib/xmrInfo.js +38 -0
- package/lib/xmrPlugin.js +301 -0
- package/lib/xmrTypes.js +92 -0
- package/package.json +84 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# edge-currency-monero
|
|
2
|
+
|
|
3
|
+
# 0.3.2 (2021-06-03)
|
|
4
|
+
|
|
5
|
+
- Remove icon URLs
|
|
6
|
+
|
|
7
|
+
# 0.3.1 (2021-05-25)
|
|
8
|
+
|
|
9
|
+
- Fix float amount precision
|
|
10
|
+
- Fix recorded native amount and fee
|
|
11
|
+
|
|
12
|
+
# 0.3.0 (2021-05-24)
|
|
13
|
+
|
|
14
|
+
- Import native code directly from react-native-mymonero-core. Before, this plugin relied on "magic" methods passed in via the global object.
|
|
15
|
+
|
|
16
|
+
# 0.2.10 (2021-04-12)
|
|
17
|
+
|
|
18
|
+
- Update image URL
|
|
19
|
+
|
|
20
|
+
# 0.2.9 (2021-01-17)
|
|
21
|
+
|
|
22
|
+
- Add additional logging and context for logs
|
|
23
|
+
- Upgrade to eslint-config-standard-kit v0.15.1
|
|
24
|
+
|
|
25
|
+
# 0.2.8 (2021-01-05)
|
|
26
|
+
|
|
27
|
+
- Update logging levels
|
|
28
|
+
- Add parseUri tests
|
|
29
|
+
|
|
30
|
+
# 0.2.7 (2020-12-08)
|
|
31
|
+
|
|
32
|
+
- Update Blockchair explorer URL to include partner ID
|
|
33
|
+
|
|
34
|
+
# 0.2.6 (2020-08-11)
|
|
35
|
+
|
|
36
|
+
- Export private view key via getDisplayPublicSeed()
|
|
37
|
+
- Update transaction explorer to Blockchair
|
|
38
|
+
|
|
39
|
+
# 0.2.5 (2020-06-03)
|
|
40
|
+
|
|
41
|
+
- Upgrade mymonero-core-js to export transaction private key
|
|
42
|
+
- Upgrade edge-core-js to v0.17.4
|
|
43
|
+
- Add `EdgeTransaction.txSecret` to capture transaction private key
|
|
44
|
+
- Improve logging
|
|
45
|
+
- Add makeMutex() to wrap makeSpend() to avoid entering it more than once at a time
|
|
46
|
+
|
|
47
|
+
# 0.2.4 (2019-08-08)
|
|
48
|
+
|
|
49
|
+
- Default `signedTx` property on EdgeTransaction to empty string
|
|
50
|
+
|
|
51
|
+
# 0.2.3 (2019-07-31)
|
|
52
|
+
|
|
53
|
+
- Pass an `apiKey` with every API request.
|
|
54
|
+
- Correctly handle the server-provided `fee_mask`.
|
|
55
|
+
|
|
56
|
+
# 0.2.2 (2019-03-27)
|
|
57
|
+
|
|
58
|
+
- Fix block explorer link.
|
|
59
|
+
|
|
60
|
+
# 0.2.1 (2019-03-07)
|
|
61
|
+
|
|
62
|
+
- Upgrade `mymonero-core-js` in preparation for the Monero v0.14.0 hard fork.
|
|
63
|
+
- Properly report failed broadcasts.
|
|
64
|
+
|
|
65
|
+
# 0.2.0 (2019-02-19)
|
|
66
|
+
|
|
67
|
+
- Upgrade to the edge-core-js v0.15.0 and adapt to breaking changes.
|
|
68
|
+
|
|
69
|
+
## 0.1.4 (2019-02-15)
|
|
70
|
+
|
|
71
|
+
- Update the readme file
|
|
72
|
+
- Upgrade to the edge-core-js v0.14.0 types
|
|
73
|
+
- Modernize the build system
|
|
74
|
+
|
|
75
|
+
## 0.1.3
|
|
76
|
+
|
|
77
|
+
- Fix notes and category metadata tagging
|
|
78
|
+
|
|
79
|
+
## 0.1.2
|
|
80
|
+
|
|
81
|
+
- Sanitize edgeTransaction returned from makeSpend to make it bridge compatible
|
|
82
|
+
|
|
83
|
+
## 0.1.1
|
|
84
|
+
|
|
85
|
+
- Use different blockexplorer
|
|
86
|
+
- Use new colored icon
|
|
87
|
+
|
|
88
|
+
## 0.1.0
|
|
89
|
+
|
|
90
|
+
- Implement new mymonero-core-js library with bulletproofs support
|
|
91
|
+
|
|
92
|
+
## 0.0.10
|
|
93
|
+
|
|
94
|
+
- No code changes. Only use renamed `EdgeApp/mymonero-core-js` repo
|
|
95
|
+
|
|
96
|
+
## 0.0.9
|
|
97
|
+
|
|
98
|
+
- Fix issue with `NoAmountSpecifiedError` error not being included in NPM version
|
|
99
|
+
|
|
100
|
+
## 0.0.8
|
|
101
|
+
|
|
102
|
+
- Add `NoAmountSpecifiedError`
|
|
103
|
+
|
|
104
|
+
## 0.0.5
|
|
105
|
+
|
|
106
|
+
- Specify requiredConfirmations = 10
|
|
107
|
+
- Use PendingFundsError when funds are unconfirmed
|
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017, Airbitz Inc (dba Edge)
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Edge Monero Currency Plugin
|
|
2
|
+
[![Build Status][travis-image]][travis-url] [![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url]
|
|
3
|
+
|
|
4
|
+
[](https://github.com/feross/standard)
|
|
5
|
+
|
|
6
|
+
Implements Monero send/receive functionality per the spec for crypto currency plugins for [edge-core-js](https://github.com/EdgeApp/edge-core-js)
|
|
7
|
+
|
|
8
|
+
## Installing
|
|
9
|
+
|
|
10
|
+
yarn add edge-currency-monero react-native-mymonero-core
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
import { moneroCurrencyPluginFactory } from `edge-currency-monero`
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Now you can pass `moneroCurrencyPluginFactory` to `edge-core-js`.
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
const context = makeEdgeContext({
|
|
20
|
+
apiKey: YOUR_API_KEY,
|
|
21
|
+
plugins: [ moneroCurrencyPluginFactory ]
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Contributing
|
|
26
|
+
|
|
27
|
+
You'll need to install Yarn 1.3.2 globally on your machine
|
|
28
|
+
|
|
29
|
+
To run a local version of this repo inside the full Edge Wallet app, clone this repo at the same level as `edge-react-gui`
|
|
30
|
+
|
|
31
|
+
git clone git@github.com:EdgeApp/edge-currency-monero.git`
|
|
32
|
+
cd edge-currency-monero
|
|
33
|
+
yarn
|
|
34
|
+
|
|
35
|
+
Run `npm run test` to run the unit tests.
|
|
36
|
+
|
|
37
|
+
To use the local cloned version of this repo, `cd edge-react-gui` and run
|
|
38
|
+
|
|
39
|
+
npm run updot edge-currency-monero
|
|
40
|
+
npm run postinstall
|
|
41
|
+
|
|
42
|
+
This will copy the necessary files from `edge-currency-monero` into the `edge-react-gui/node_modules/edge-currency-monero` replacing the npm installed version. This needs to be done after any modifications to `edge-currency-monero`
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
BSD 3
|
|
46
|
+
|
|
47
|
+
[npm-image]: https://badge.fury.io/js/edge-currency-ethereum.svg
|
|
48
|
+
[npm-url]: https://npmjs.org/package/edge-currency-ethereum
|
|
49
|
+
[travis-image]: https://travis-ci.org/Airbitz/edge-currency-ethereum.svg?branch=master
|
|
50
|
+
[travis-url]: https://travis-ci.org/Airbitz/edge-currency-ethereum
|
|
51
|
+
[daviddm-image]: https://david-dm.org/Airbitz/edge-currency-ethereum.svg?theme=shields.io
|
|
52
|
+
[daviddm-url]: https://david-dm.org/Airbitz/edge-currency-ethereum
|
package/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// /**
|
|
2
|
+
// * Created by paul on 8/26/17.
|
|
3
|
+
// *
|
|
4
|
+
// */
|
|
5
|
+
//
|
|
6
|
+
// import type { EthereumFees, EthereumFee, EthereumCalcedFees } from './xmrTypes.js'
|
|
7
|
+
// import type { EdgeSpendInfo } from 'edge-core-js'
|
|
8
|
+
// import { normalizeAddress } from './utils.js'
|
|
9
|
+
// import { bns } from 'biggystring'
|
|
10
|
+
//
|
|
11
|
+
// export const ES_FEE_LOW = 'low'
|
|
12
|
+
// export const ES_FEE_STANDARD = 'standard'
|
|
13
|
+
// export const ES_FEE_HIGH = 'high'
|
|
14
|
+
// export const ES_FEE_CUSTOM = 'custom'
|
|
15
|
+
//
|
|
16
|
+
// export function calcMiningFee (spendInfo: EdgeSpendInfo, networkFees: EthereumFees): EthereumCalcedFees {
|
|
17
|
+
// if (spendInfo.spendTargets && spendInfo.spendTargets.length && spendInfo.spendTargets[0].publicAddress) {
|
|
18
|
+
// const { customNetworkFee } = spendInfo || {}
|
|
19
|
+
// if (spendInfo.networkFeeOption === ES_FEE_CUSTOM && customNetworkFee) {
|
|
20
|
+
// const { gasLimit, gasPrice } = customNetworkFee
|
|
21
|
+
// const gasPriceGwei = bns.mul(gasPrice, '1000000000')
|
|
22
|
+
// if (gasLimit && bns.gt(gasLimit, '0') && gasPrice && bns.gt(gasPrice, '0')) {
|
|
23
|
+
// return { gasLimit, gasPrice: gasPriceGwei }
|
|
24
|
+
// }
|
|
25
|
+
// }
|
|
26
|
+
// const targetAddress = normalizeAddress(spendInfo.spendTargets[0].publicAddress)
|
|
27
|
+
// let networkFeeForGasPrice:EthereumFee = networkFees['default']
|
|
28
|
+
// let networkFeeForGasLimit:EthereumFee = networkFees['default']
|
|
29
|
+
//
|
|
30
|
+
// if (typeof networkFees[targetAddress] !== 'undefined') {
|
|
31
|
+
// networkFeeForGasLimit = networkFees[targetAddress]
|
|
32
|
+
// if (typeof networkFeeForGasLimit.gasPrice !== 'undefined') {
|
|
33
|
+
// networkFeeForGasPrice = networkFeeForGasLimit
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
|
+
//
|
|
37
|
+
// let useLimit = 'regularTransaction'
|
|
38
|
+
// if (spendInfo.currencyCode && spendInfo.currencyCode !== 'ETH') {
|
|
39
|
+
// useLimit = 'tokenTransaction'
|
|
40
|
+
// }
|
|
41
|
+
//
|
|
42
|
+
// let networkFeeOption = 'standard'
|
|
43
|
+
// if (typeof spendInfo.networkFeeOption === 'string') {
|
|
44
|
+
// networkFeeOption = spendInfo.networkFeeOption
|
|
45
|
+
// }
|
|
46
|
+
//
|
|
47
|
+
// const gasLimit = networkFeeForGasLimit.gasLimit[useLimit]
|
|
48
|
+
// let gasPrice = ''
|
|
49
|
+
// if (!spendInfo.spendTargets[0].nativeAmount) {
|
|
50
|
+
// throw new Error('ErrorInvalidNativeAmount')
|
|
51
|
+
// }
|
|
52
|
+
// let nativeAmount = spendInfo.spendTargets[0].nativeAmount
|
|
53
|
+
// if (useLimit === 'tokenTransaction') {
|
|
54
|
+
// // Small hack. Edgetimate the relative value of token to ethereum as 10%
|
|
55
|
+
// nativeAmount = bns.div(nativeAmount, '10')
|
|
56
|
+
// }
|
|
57
|
+
// if (!networkFeeForGasPrice.gasPrice) {
|
|
58
|
+
// throw new Error('ErrorInvalidGasPrice')
|
|
59
|
+
// }
|
|
60
|
+
// const gasPriceObj = networkFeeForGasPrice.gasPrice
|
|
61
|
+
// switch (networkFeeOption) {
|
|
62
|
+
// case ES_FEE_LOW:
|
|
63
|
+
// gasPrice = gasPriceObj.lowFee
|
|
64
|
+
// break
|
|
65
|
+
// case ES_FEE_STANDARD:
|
|
66
|
+
// if (bns.gte(nativeAmount, networkFeeForGasPrice.gasPrice.standardFeeHighAmount)) {
|
|
67
|
+
// gasPrice = gasPriceObj.standardFeeHigh
|
|
68
|
+
// break
|
|
69
|
+
// }
|
|
70
|
+
// if (bns.lte(nativeAmount, gasPriceObj.standardFeeLowAmount)) {
|
|
71
|
+
// if (!networkFeeForGasPrice.gasPrice) {
|
|
72
|
+
// throw new Error('ErrorInvalidGasPrice')
|
|
73
|
+
// }
|
|
74
|
+
// gasPrice = networkFeeForGasPrice.gasPrice.standardFeeLow
|
|
75
|
+
// break
|
|
76
|
+
// }
|
|
77
|
+
//
|
|
78
|
+
// // Scale the fee by the amount the user is sending scaled between standardFeeLowAmount and standardFeeHighAmount
|
|
79
|
+
// const lowHighAmountDiff = bns.sub(gasPriceObj.standardFeeHighAmount, gasPriceObj.standardFeeLowAmount)
|
|
80
|
+
// const lowHighFeeDiff = bns.sub(gasPriceObj.standardFeeHigh, gasPriceObj.standardFeeLow)
|
|
81
|
+
//
|
|
82
|
+
// // How much above the lowFeeAmount is the user sending
|
|
83
|
+
// const amountDiffFromLow = bns.sub(nativeAmount, gasPriceObj.standardFeeLowAmount)
|
|
84
|
+
//
|
|
85
|
+
// // Add this much to the low fee = (amountDiffFromLow * lowHighFeeDiff) / lowHighAmountDiff)
|
|
86
|
+
// const temp1 = bns.mul(amountDiffFromLow, lowHighFeeDiff)
|
|
87
|
+
// const addFeeToLow = bns.div(temp1, lowHighAmountDiff)
|
|
88
|
+
// gasPrice = bns.add(gasPriceObj.standardFeeLow, addFeeToLow)
|
|
89
|
+
// break
|
|
90
|
+
// case ES_FEE_HIGH:
|
|
91
|
+
// gasPrice = networkFeeForGasPrice.gasPrice.highFee
|
|
92
|
+
// break
|
|
93
|
+
// default:
|
|
94
|
+
// throw new Error(`Invalid networkFeeOption`)
|
|
95
|
+
// }
|
|
96
|
+
// const out: EthereumCalcedFees = { gasLimit, gasPrice }
|
|
97
|
+
// return out
|
|
98
|
+
// } else {
|
|
99
|
+
// throw new Error('ErrorInvalidSpendInfo')
|
|
100
|
+
// }
|
|
101
|
+
// }
|